GEOS
Classes | Typedefs | Functions | Variables
geos::xmlWrapper Namespace Reference

Classes

struct  xmlAttributePos
 
struct  xmlNodePos
 
class  xmlDocument
 

Typedefs

using xmlResult = pugi::xml_parse_result
 Alias for the type of the result from an xml parse attempt.
 
using xmlNode = pugi::xml_node
 
using xmlAttribute = pugi::xml_attribute
 
using xmlNodeType = pugi::xml_node_type
 Alias for the type variant of an xml node.
 

Functions

string buildMultipleInputXML (string_array const &inputFileList, string const &outputDir={})
 Function to handle multiple input xml files. More...
 
bool isFileMetadataAttribute (string const &name)
 
String to variable parsing.

These functions take in value and parse that string based on the type of target. The function implementation should provide sufficient error checking in the case that value is formatted incorrectly for the type specified in target.

void validateString (string const &value, Regex const &regex)
 
void processInputException (std::exception const &ex, string const &targetAttributeName, xmlWrapper::xmlNode const &targetNode, xmlWrapper::xmlNodePos const &nodePos)
 Helper method to process an exception that has been thrown during xml parsing. More...
 
template<typename T >
std::enable_if_t< traits::CanStreamInto< std::istringstream, T > > stringToInputVariable (T &target, string const &value, Regex const &regex)
 Parse a string and fill a variable with the value(s) in the string. More...
 
template<typename T , int SIZE>
void stringToInputVariable (Tensor< T, SIZE > &target, string const &value, Regex const &regex)
 Parse a string and fill a R1Tensor with the value(s) in the string. More...
 
template<typename T , int NDIM, typename PERMUTATION >
std::enable_if_t< traits::CanStreamInto< std::istringstream, T > > stringToInputVariable (Array< T, NDIM, PERMUTATION > &array, string const &value, Regex const &regex)
 Parse a string and fill an Array with the value(s) in the string. More...
 
Attribute extraction from XML nodes.
template<typename T , typename U >
std::enable_if_t< !internal::canParseVariable< T >, bool > readAttributeAsType (T &, string const &name, Regex const &, xmlNode const &, U const &)
 Extract attribute in an xml tree, and translate its value into a typed variable. This SFINAE implementation is used if the value is not parsable. More...
 
template<typename T , typename T_DEF = T>
std::enable_if_t< internal::canParseVariable< T >, bool > readAttributeAsType (T &rval, string const &name, Regex const &regex, xmlNode const &targetNode, T_DEF const &defVal)
 Extract attribute in an xml tree, and translate its value into a typed variable. More...
 
template<typename T >
std::enable_if_t< internal::canParseVariable< T >, bool > readAttributeAsType (T &rval, string const &name, Regex const &regex, xmlNode const &targetNode, bool const required)
 Extract attribute in an xml tree, and translate its value into a typed variable. More...
 
template<typename T >
std::enable_if_t< !dataRepository::DefaultValue< T >::has_default_value, bool > readAttributeAsType (T &rval, string const &name, Regex const &regex, xmlNode const &targetNode, dataRepository::DefaultValue< T > const &)
 Extract attribute in an xml tree, and translate its value into a typed variable. More...
 
template<typename T >
std::enable_if_t< dataRepository::DefaultValue< T >::has_default_value, bool > readAttributeAsType (T &rval, string const &name, Regex const &regex, xmlNode const &targetNode, dataRepository::DefaultValue< T > const &defVal)
 Extract attribute in an xml tree, and translate its value into a typed variable. More...
 

Variables

constexpr char const filePathString [] = "__filePath__"
 constexpr variable to hold name for inserting the file path into the xml file. More...
 
constexpr char const charOffsetString [] = "__charOffset__"
 constexpr variable to hold node character offset from the start of the xml file. More...
 
constexpr char const includedListTag [] = "Included"
 XML tag name for included sections.
 
constexpr char const includedFileTag [] = "File"
 XML tag name for included files.
 

Detailed Description

Wraps/provides facilities to process entries from an xml file into the appropriate data types. xmlWrapper provides some aliases that will wrap the underlying xml package being used to extract data from the xml file, and a set of functions that facilitate the parsing of string data from the xml into the variables that will hold those values in the code.

Typedef Documentation

◆ xmlAttribute

using geos::xmlWrapper::xmlAttribute = typedef pugi::xml_attribute

Alias for the type of an xml attribute. An xmlAttribute behave as a pointer object: passing it by value to a function which modify it will modify the original xmlAttribute object.

Definition at line 64 of file xmlWrapper.hpp.

◆ xmlNode

using geos::xmlWrapper::xmlNode = typedef pugi::xml_node

Alias for the type of an xml node. An xmlNode behave as a pointer object: passing it by value to a function which modify it will modify the original xmlNode object.

Definition at line 59 of file xmlWrapper.hpp.

Function Documentation

◆ buildMultipleInputXML()

string geos::xmlWrapper::buildMultipleInputXML ( string_array const &  inputFileList,
string const &  outputDir = {} 
)

Function to handle multiple input xml files.

Parameters
inputFileListthe list of input xml files
outputDirthe output directory to place the composite input file in
Returns
inputFilePath the input xml file name

This function checks for multiple xml files, and will build a new input xml file with an included block if neccesary

◆ isFileMetadataAttribute()

bool geos::xmlWrapper::isFileMetadataAttribute ( string const &  name)
Returns
true if the attribute with the specified name declares metadata relative to the xml
Parameters
namethe name of an attribute

◆ processInputException()

void geos::xmlWrapper::processInputException ( std::exception const &  ex,
string const &  targetAttributeName,
xmlWrapper::xmlNode const &  targetNode,
xmlWrapper::xmlNodePos const &  nodePos 
)

Helper method to process an exception that has been thrown during xml parsing.

Parameters
exThe caught exception.
targetAttributeNameThe name of the attribute in which an input exception occured.
targetNodeThe node from which this Group is interpreted.
nodePosthe target node position.
Exceptions
AnInputError with the node & attribut info, including the nearest xml line possible.

◆ readAttributeAsType() [1/5]

template<typename T , typename U >
std::enable_if_t< !internal::canParseVariable< T >, bool > geos::xmlWrapper::readAttributeAsType ( T &  ,
string const &  name,
Regex const &  ,
xmlNode const &  ,
U const &   
)

Extract attribute in an xml tree, and translate its value into a typed variable. This SFINAE implementation is used if the value is not parsable.

Template Parameters
Tthe type of variable fill with xml attribute.
Utype of the default value for rval
Parameters
[in]namethe name of the xml attribute to process
Returns
false
Exceptions
AnInputError if the string value could not be validated by the type regex or parsed to the destination type. In the context of xml parsing, use processInputException to format this error with the proper xml line.

Definition at line 446 of file xmlWrapper.hpp.

◆ readAttributeAsType() [2/5]

template<typename T >
std::enable_if_t< internal::canParseVariable< T >, bool > geos::xmlWrapper::readAttributeAsType ( T &  rval,
string const &  name,
Regex const &  regex,
xmlNode const &  targetNode,
bool const  required 
)

Extract attribute in an xml tree, and translate its value into a typed variable.

Template Parameters
Tthe type of variable fill with xml attribute.
Parameters
[out]rvalthe variable to fill with value
[in]namethe name of the xml attribute to process
[in]regexthe regular expression used for validating the string value.
[in]targetNodethe xml node that should contain the attribute
[in]requiredwhether or not the value is required
Returns
boolean value indicating whether the value was successfully read from XML.
Exceptions
AnInputError if the string value could not be validated by the type regex or parsed to the destination type. In the context of xml parsing, use processInputException to format this error with the proper xml line.

Definition at line 501 of file xmlWrapper.hpp.

◆ readAttributeAsType() [3/5]

template<typename T >
std::enable_if_t< !dataRepository::DefaultValue< T >::has_default_value, bool > geos::xmlWrapper::readAttributeAsType ( T &  rval,
string const &  name,
Regex const &  regex,
xmlNode const &  targetNode,
dataRepository::DefaultValue< T > const &   
)

Extract attribute in an xml tree, and translate its value into a typed variable.

Template Parameters
Tthe type of variable fill with xml attribute.
Parameters
[out]rvalthe variable to fill with value
[in]namethe name of the xml attribute to process
[in]regexthe regular expression used for validating the string value.
[in]targetNodethe xml node that should contain the attribute
Returns
boolean value indicating whether the value was successfully read from XML.
Exceptions
AnInputError if the string value could not be validated by the type regex or parsed to the destination type. In the context of xml parsing, use processInputException to format this error with the proper xml line.

Definition at line 532 of file xmlWrapper.hpp.

◆ readAttributeAsType() [4/5]

template<typename T >
std::enable_if_t< dataRepository::DefaultValue< T >::has_default_value, bool > geos::xmlWrapper::readAttributeAsType ( T &  rval,
string const &  name,
Regex const &  regex,
xmlNode const &  targetNode,
dataRepository::DefaultValue< T > const &  defVal 
)

Extract attribute in an xml tree, and translate its value into a typed variable.

Template Parameters
Tthe type of variable fill with xml attribute.
Parameters
[out]rvalthe variable to fill with value
[in]namethe name of the xml attribute to process
[in]regexthe regular expression used for validating the string value.
[in]targetNodethe xml node that should contain the attribute
[in]defValdefault value of rval (or entries of rval, if it is an array)
Returns
boolean value indicating whether the value was successfully read from XML.
Exceptions
AnInputError if the string value could not be validated by the type regex or parsed to the destination type. In the context of xml parsing, use processInputException to format this error with the proper xml line.

Definition at line 555 of file xmlWrapper.hpp.

◆ readAttributeAsType() [5/5]

template<typename T , typename T_DEF = T>
std::enable_if_t< internal::canParseVariable< T >, bool > geos::xmlWrapper::readAttributeAsType ( T &  rval,
string const &  name,
Regex const &  regex,
xmlNode const &  targetNode,
T_DEF const &  defVal 
)

Extract attribute in an xml tree, and translate its value into a typed variable.

Template Parameters
Tthe type of variable fill with xml attribute.
T_DEFtype of the default value for rval
Parameters
[out]rvalthe variable to fill with value
[in]namethe name of the xml attribute to process
[in]regexthe regular expression used for validating the string value.
[in]targetNodethe xml node that should contain the attribute
[in]defValdefault value of rval (or entries of rval, if it is an array)
Returns
true
Exceptions
AnInputError if the string value could not be validated by the type regex or parsed to the destination type. In the context of xml parsing, use processInputException to format this error with the proper xml line.

Definition at line 466 of file xmlWrapper.hpp.

◆ stringToInputVariable() [1/3]

template<typename T , int NDIM, typename PERMUTATION >
std::enable_if_t< traits::CanStreamInto< std::istringstream, T > > geos::xmlWrapper::stringToInputVariable ( Array< T, NDIM, PERMUTATION > &  array,
string const &  value,
Regex const &  regex 
)

Parse a string and fill an Array with the value(s) in the string.

Template Parameters
Tdata type of the array
NDIMnumber of dimensions of the array
PERMUTATIONthe permutation of the array
Parameters
[out]arraythe array to read values into
[in]valuethe string that contains the data to be parsed into target
[in]regexthe regular expression used for validating the string value.
Exceptions
AnInputError if the string value could not be validated by the type regex or parsed to the destination type. In the context of xml parsing, use processInputException to format this error with the proper xml line.
Returns

Definition at line 389 of file xmlWrapper.hpp.

◆ stringToInputVariable() [2/3]

template<typename T >
std::enable_if_t< traits::CanStreamInto< std::istringstream, T > > geos::xmlWrapper::stringToInputVariable ( T &  target,
string const &  value,
Regex const &  regex 
)

Parse a string and fill a variable with the value(s) in the string.

Template Parameters
Tthe type of variable fill with string value
Parameters
[out]targetthe object to read values into
[in]valuethe string that contains the data to be parsed into target
[in]regexthe regular expression used for validating the string value.
Exceptions
AnInputError if the string value could not be validated by the type regex or parsed to the destination type. In the context of xml parsing, use processInputException to format this error with the proper xml line.
Returns

Definition at line 351 of file xmlWrapper.hpp.

◆ stringToInputVariable() [3/3]

template<typename T , int SIZE>
void geos::xmlWrapper::stringToInputVariable ( Tensor< T, SIZE > &  target,
string const &  value,
Regex const &  regex 
)

Parse a string and fill a R1Tensor with the value(s) in the string.

Parameters
[out]targetthe object to read values into
[in]valuethe string that contains the data to be parsed into target
[in]regexthe regular expression used for validating the string value.
Exceptions
AnInputError if the string value could not be validated by the type regex or parsed to the destination type. In the context of xml parsing, use processInputException to format this error with the proper xml line.

◆ validateString()

void geos::xmlWrapper::validateString ( string const &  value,
Regex const &  regex 
)
Exceptions
AnInputError if the string value could not be validated with the provided regular expression. In the context of xml parsing, use processInputException to format this error with the proper xml line.
Parameters
valueThe string to validate
regexThe regular expression used for validating the string value.

Variable Documentation

◆ charOffsetString

constexpr char const geos::xmlWrapper::charOffsetString[] = "__charOffset__"
constexpr

constexpr variable to hold node character offset from the start of the xml file.

This is used because we would like the option to hold the offset in the xml structure. The name is uglified with underscores to avoid collisions with real attribute names.

Definition at line 284 of file xmlWrapper.hpp.

◆ filePathString

constexpr char const geos::xmlWrapper::filePathString[] = "__filePath__"
constexpr

constexpr variable to hold name for inserting the file path into the xml file.

This is used because we would like the option to hold the file path in the xml structure. The name is uglified with underscores to avoid collisions with real attribute names.

Definition at line 276 of file xmlWrapper.hpp.