SENSEI
A frame work for generic in situ analytics
sensei::XMLUtils Namespace Reference

a collection of functions for parsing XML. More...

Functions

SENSEI_EXPORT int RequireAttribute (const pugi::xml_node &node, const char *attributeName)
 check that an attribute of the passed in name exists return of 0 indicates that it does. More...
 
SENSEI_EXPORT int RequireChild (const pugi::xml_node &node, const char *childName)
 check that a child element of the passed in name exists return of 0 indicates that it does. More...
 
SENSEI_EXPORT int Parse (MPI_Comm comm, const std::string &filename, pugi::xml_document &doc)
 Parallel collective read, parse, and distribute the XML file. More...
 
template<typename num_t >
int ParseNumeric (const pugi::xml_node &node, std::vector< num_t > &numData)
 parse text data in the node of unknown length, return in the vector. More...
 
template<typename num_t , unsigned long n>
int ParseNumeric (const pugi::xml_node &node, std::array< num_t, n > &numData)
 parse text data in the node of specific length More...
 
int ParseNameValuePairs (const pugi::xml_node &node, std::vector< std::string > &names, std::vector< std::string > &values)
 process a sequence of "name = value" pairs in a node's text. More...
 
int ParseList (pugi::xml_node node, std::vector< std::string > &listOut)
 process a list in a node's text. More...
 

Detailed Description

a collection of functions for parsing XML.

Function Documentation

◆ Parse()

SENSEI_EXPORT int sensei::XMLUtils::Parse ( MPI_Comm  comm,
const std::string &  filename,
pugi::xml_document &  doc 
)

Parallel collective read, parse, and distribute the XML file.

Rank 0 does the I/O and parse and will broadcast to the other ranks in the communicator. return of 0 indicates success.

◆ ParseList()

int sensei::XMLUtils::ParseList ( pugi::xml_node  node,
std::vector< std::string > &  listOut 
)

process a list in a node's text.

List elements should be space or comma delimited. Give the following XML

<some_elem>
list1, list2, ... , listN
</some_elem>

extract list1 ... listN and return as a vector of strings. returns the number of elements found or < 0 on error.

◆ ParseNameValuePairs()

int sensei::XMLUtils::ParseNameValuePairs ( const pugi::xml_node &  node,
std::vector< std::string > &  names,
std::vector< std::string > &  values 
)

process a sequence of "name = value" pairs in a node's text.

◆ ParseNumeric() [1/2]

template<typename num_t >
int sensei::XMLUtils::ParseNumeric ( const pugi::xml_node &  node,
std::vector< num_t > &  numData 
)

parse text data in the node of unknown length, return in the vector.

return 0 if successful

◆ ParseNumeric() [2/2]

template<typename num_t , unsigned long n>
int sensei::XMLUtils::ParseNumeric ( const pugi::xml_node &  node,
std::array< num_t, n > &  numData 
)

parse text data in the node of specific length

◆ RequireAttribute()

SENSEI_EXPORT int sensei::XMLUtils::RequireAttribute ( const pugi::xml_node &  node,
const char *  attributeName 
)

check that an attribute of the passed in name exists return of 0 indicates that it does.

if not non-zero value is returned and an error message is sent to stderr.

◆ RequireChild()

SENSEI_EXPORT int sensei::XMLUtils::RequireChild ( const pugi::xml_node &  node,
const char *  childName 
)

check that a child element of the passed in name exists return of 0 indicates that it does.

if not non-zero value is returned and an error message is sent to stderr.