![]() |
Parasol Planning Library (PPL)
|
#include <XMLNode.h>
Public Member Functions | |
| template<> | |
| size_t | Read (const std::string &_name, const bool _req, const size_t &_default, const size_t &_min, const size_t &_max, const std::string &_desc) |
Metadata Accessors | |
| const std::string & | Name () const |
| Get the XMLNode name. More... | |
| const std::string & | Filename () const |
| Get the XML filename. More... | |
| std::string | GetPath () const |
| Get the directory path containing the XML file. More... | |
Content Accessors | |
| std::string | GetText () const |
| Get the text between opening and closing tags. More... | |
Attribute Parsing | |
| template<typename T > | |
| 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. More... | |
| 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. More... | |
| iterator | end () |
| Get an iterator to this node's last child. More... | |
Construction | |
| XMLNode (const std::string &_filename, const std::string &_desiredNode) | |
| XMLNode (const std::string &_filename, std::shared_ptr< tinyxml2::XMLDocument > doc, const std::string &_desiredNode) | |
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.
| typedef std::vector<XMLNode>::iterator XMLNode::iterator |
| XMLNode::XMLNode | ( | const std::string & | _filename, |
| const std::string & | _desiredNode | ||
| ) |
Construct an XML node object from an XML file.
| _filename | XML Filename |
| _desiredNode | Desired XML Node to make root of tree |
Will throw ParseException when _desiredNode cannot be found or _filename is poorly formed input
| XMLNode::XMLNode | ( | const std::string & | _filename, |
| std::shared_ptr< tinyxml2::XMLDocument > | doc, | ||
| const std::string & | _desiredNode | ||
| ) |
Construct an XML node object from an XML document.
| _filename | XML Filename (used for error messages) |
| _desiredNode | Desired XML Node to make root of tree |
Will throw ParseException when _desiredNode cannot be found or doc is not valid
| XMLNode::iterator XMLNode::begin | ( | ) |
Get an iterator to this node's first child.
| XMLNode::iterator XMLNode::end | ( | ) |
Get an iterator to this node's last child.
| const std::string & XMLNode::Filename | ( | ) | const |
Get the XML filename.
| std::string XMLNode::GetPath | ( | ) | const |
Get the directory path containing the XML file.
| std::string XMLNode::GetText | ( | ) | const |
Get the text between opening and closing tags.
| void XMLNode::Ignore | ( | ) |
Ignore unrequested node/attribute errors for this node.
| const std::string & XMLNode::Name | ( | ) | const |
Get the XMLNode name.
| bool XMLNode::Read | ( | const std::string & | _name, |
| const bool | _req, | ||
| const bool | _default, | ||
| const std::string & | _desc | ||
| ) |
Read XML boolean attribute
| _name | Name of attribute |
| _req | Is attribute required |
| _default | Default value of attribute |
| _desc | Description 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.
| std::string XMLNode::Read | ( | const std::string & | _name, |
| const bool | _req, | ||
| const char * | _default, | ||
| const std::string & | _desc | ||
| ) |
Read XML string attribute
Calls string version of function to avoid confusion with bool -> const char* conversion in compile.
| size_t XMLNode::Read | ( | const std::string & | _name, |
| const bool | _req, | ||
| const size_t & | _default, | ||
| const size_t & | _min, | ||
| const size_t & | _max, | ||
| const std::string & | _desc | ||
| ) |
| std::string XMLNode::Read | ( | const std::string & | _name, |
| const bool | _req, | ||
| const std::string & | _default, | ||
| const std::string & | _desc | ||
| ) |
Read XML string attribute
| _name | Name of attribute |
| _req | Is attribute required |
| _default | Default value of attribute |
| _desc | Description 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.
| 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.
| T | Type of attribute |
| _name | Name of attribute |
| _req | Is attribute required |
| _default | Default value of attribute |
| _min | Minimum value of attribute |
| _max | Maximum value of attribute |
| _desc | Description 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.
| void XMLNode::WarnAll | ( | const bool | _warningsAsErrors = false | ) |
Report warnings for XML tree rooted at this node
| _warningsAsErrors | True 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:
| std::string XMLNode::Where | ( | ) | const |
Generate string describing where the node is
To be used with PMPLExceptions, specifically ParseException. Gives string with filename, row (line number), and column of XMLNode.