PPL API Reference
Overview Core Algorithm Abstractions Utilities Parallel Methods
Modules Class Hierarchy Classes Functions
Todo List Bug List Dead Code
List of all members
XMLNode Class Reference

Public Member Functions

Metadata Accessors
const std::string & Name () const
 Get the XMLNode name.
 
const std::string & Filename () const
 Get the XML filename.
 
std::string GetPath () const
 Get the directory path containing the XML file.
 
Content Accessors
std::string GetText () const
 Get the text between opening and closing tags.
 
Attribute Parsing
template<typename T >
Read (const std::string &_name, const bool _req, const T &_default, const T &_min, const T &_max, const std::string &_desc)
 
bool Read (const std::string &_name, const bool _req, const bool _default, const std::string &_desc)
 
std::string Read (const std::string &_name, const bool _req, const char *_default, const std::string &_desc)
 
std::string Read (const std::string &_name, const bool _req, const std::string &_default, const std::string &_desc)
 
Parsing Flow
void Ignore ()
 Ignore unrequested node/attribute errors for this node.
 
void WarnAll (const bool _warningsAsErrors=false)
 
std::string Where () const
 

Iteration

typedef std::vector< XMLNode >::iterator iterator
 
iterator begin ()
 Get an iterator to this node's first child.
 
iterator end ()
 Get an iterator to this node's last child.
 

Construction

 XMLNode (const std::string &_filename, const std::string &_desiredNode)
 

Detailed Description

Wrapper class for XML parsing with TinyXML.

This is a wrapper class for XML handling with TinyXML. It is read only and supports trivial XML parsing.

Constructor & Destructor Documentation

◆ XMLNode()

XMLNode::XMLNode ( const std::string &  _filename,
const std::string &  _desiredNode 
)

Construct an XML node object from an XML file.

Parameters
_filenameXML Filename
_desiredNodeDesired XML Node to make root of tree

Will throw ParseException when _desiredNode cannot be found or _filename is poorly formed input

Member Function Documentation

◆ Read() [1/4]

template<typename T >
T XMLNode::Read ( const std::string &  _name,
const bool  _req,
const T &  _default,
const T &  _min,
const T &  _max,
const std::string &  _desc 
)

Read XML attribute.

Template Parameters
TType of attribute
Parameters
_nameName of attribute
_reqIs attribute required
_defaultDefault value of attribute
_minMinimum value of attribute
_maxMaximum value of attribute
_descDescription of attribute
Returns
Value of attribute

Reads XML attribute value with _name. If _req is specified and no attribute is given, _default is returned, otherwise input value is required to be in the range [_min, _max]. Otherwise, an error is reported and _desc is shown to the user.

◆ Read() [2/4]

bool XMLNode::Read ( const std::string &  _name,
const bool  _req,
const bool  _default,
const std::string &  _desc 
)

Read XML boolean attribute

Parameters
_nameName of attribute
_reqIs attribute required
_defaultDefault value of attribute
_descDescription of attribute
Returns
Value of attribute

Reads XML attribute value with _name. If _req is specified and no attribute is given, _default is returned. Otherwise, an error is reported and _desc is shown to the user.

◆ Read() [3/4]

std::string XMLNode::Read ( const std::string &  _name,
const bool  _req,
const char *  _default,
const std::string &  _desc 
)

Read XML string attribute

Returns
Value of attribute

Calls string version of function to avoid confusion with bool -> const char* conversion in compile.

◆ Read() [4/4]

std::string XMLNode::Read ( const std::string &  _name,
const bool  _req,
const std::string &  _default,
const std::string &  _desc 
)

Read XML string attribute

Parameters
_nameName of attribute
_reqIs attribute required
_defaultDefault value of attribute
_descDescription of attribute
Returns
Value of attribute

Reads XML attribute value with _name. If _req is specified and no attribute is given, _default is returned. Otherwise, an error is reported and _desc is shown to the user.

◆ WarnAll()

void XMLNode::WarnAll ( const bool  _warningsAsErrors = false)

Report warnings for XML tree rooted at this node

Parameters
_warningsAsErrorsTrue will throw exceptions for warnings

To be called after parsing phase. This will report warnings throughout entire XML document. Should only be called on root XML node. Warnings to be reported:

  • unknown/unparsed nodes
  • unrequested attribues

◆ Where()

std::string XMLNode::Where ( ) const

Generate string describing where the node is

Returns
String representing where node is

To be used with PMPLExceptions, specifically ParseException. Gives string with filename, row (line number), and column of XMLNode.


The documentation for this class was generated from the following files: