|
SuperTuxKart
|
utility class used to parse XML files More...
#include <xml_node.hpp>

Public Member Functions | |
| LEAK_CHECK () | |
| XMLNode (io::IXMLReader *xml) | |
| XMLNode (const std::string &filename) | |
| Reads a XML file and convert it into a XMLNode tree. More... | |
| ~XMLNode () | |
| Destructor. | |
| const std::string & | getName () const |
| const XMLNode * | getNode (const std::string &name) const |
| Returns the node with the given name. More... | |
| const void | getNodes (const std::string &s, std::vector< XMLNode * > &out) const |
| Returns all nodes with the given name. More... | |
| const XMLNode * | getNode (unsigned int i) const |
| Returns the i.th node. More... | |
| unsigned int | getNumNodes () const |
| int | get (const std::string &attribute, std::string *value) const |
| If 'attribute' was defined, set 'value' to the value of the attribute and return 1, otherwise return 0 and do not change value. More... | |
| int | get (const std::string &attribute, core::stringw *value) const |
| int | getAndDecode (const std::string &attribute, core::stringw *value) const |
| int | get (const std::string &attribute, int32_t *value) const |
| int | get (const std::string &attribute, uint16_t *value) const |
| int | get (const std::string &attribute, uint32_t *value) const |
| int | get (const std::string &attribute, int64_t *value) const |
| int | get (const std::string &attribute, uint64_t *value) const |
| int | get (const std::string &attribute, float *value) const |
| int | get (const std::string &attribute, double *value) const |
| int | get (const std::string &attribute, bool *value) const |
| int | get (const std::string &attribute, Vec3 *value) const |
| int | get (const std::string &attribute, core::vector2df *value) const |
| int | get (const std::string &attribute, core::vector3df *value) const |
| int | get (const std::string &attribute, video::SColorf *value) const |
| int | get (const std::string &attribute, video::SColor *value) const |
| int | get (const std::string &attribute, std::vector< std::string > *value) const |
| If 'attribute' was defined, split the value of the attribute by spaces, set value to this vector array and return the number of elements. More... | |
| int | get (const std::string &attribute, std::vector< float > *value) const |
| If 'attribute' was defined, split the value of the attribute by spaces, set value to this vector array and return the number of elements. More... | |
| int | get (const std::string &attribute, std::vector< int > *value) const |
| If 'attribute' was defined, split the value of the attribute by spaces, set value to this vector array and return the number of elements. More... | |
| int | get (const std::string &attribute, InterpolationArray *value) const |
| Reads an InterpolatioARray. More... | |
| int | get (core::vector3df *value) const |
| Interprets the attributes 'x', 'y', 'z' or 'h', 'p', 'r' as a 3d vector and set the corresponding elements of value. More... | |
| int | getXYZ (core::vector3df *value) const |
| Interprets the attributes 'x', 'y', 'z' as a 3d vector and set the corresponding elements of value. More... | |
| int | getXYZ (Vec3 *vaslue) const |
| Interprets the attributes 'x', 'y', 'z' as a 3d vector and set the corresponding elements of value. More... | |
| int | getHPR (core::vector3df *value) const |
| Interprets the attributes 'h', 'p', 'r' as a 3d vector and set the corresponding elements of value. More... | |
| int | getHPR (Vec3 *value) const |
| Interprets the attributes 'h', 'p', 'r' as a 3d vector and set the corresponding elements of value. More... | |
| bool | hasChildNamed (const char *name) const |
| const std::string & | getFilename () const |
Static Public Member Functions | |
| static bool | hasX (int b) |
| Handy functions to test the bit pattern returned by get(vector3df*). | |
| static bool | hasY (int b) |
| static bool | hasZ (int b) |
| static bool | hasH (int b) |
| static bool | hasP (int b) |
| static bool | hasR (int b) |
Private Member Functions | |
| void | readXML (io::IXMLReader *xml) |
| Stores all attributes, and reads in all children. More... | |
Private Attributes | |
| std::string | m_name |
| Name of this element. | |
| std::map< std::string, core::stringw > | m_attributes |
| List of all attributes. | |
| std::vector< XMLNode * > | m_nodes |
| List of all sub nodes. | |
| std::string | m_file_name |
utility class used to parse XML files
| XMLNode::XMLNode | ( | const std::string & | filename | ) |
Reads a XML file and convert it into a XMLNode tree.
| runtime_error | if the file is not found |
| filename | Name of the XML file to read. |
| int XMLNode::get | ( | const std::string & | attribute, |
| InterpolationArray * | value | ||
| ) | const |
Reads an InterpolatioARray.
The values must be specified as: x0:y0 x1:y1 x2:y2 ... and the X values must be sorted. The function will abort (exit) with an error message in case of incorrectly formed x:y pairs.
| attribute | Name of the attribute. |
| value | The InterpolationArray. |
| int XMLNode::get | ( | const std::string & | attribute, |
| std::string * | value | ||
| ) | const |
If 'attribute' was defined, set 'value' to the value of the attribute and return 1, otherwise return 0 and do not change value.
| attribute | Name of the attribute. |
| value | Value of the attribute. |
| int XMLNode::get | ( | const std::string & | attribute, |
| std::vector< float > * | value | ||
| ) | const |
If 'attribute' was defined, split the value of the attribute by spaces, set value to this vector array and return the number of elements.
Otherwise return 0 and do not change value.
| attribute | Name of the attribute. |
| value | Value of the attribute. |
| int XMLNode::get | ( | const std::string & | attribute, |
| std::vector< int > * | value | ||
| ) | const |
If 'attribute' was defined, split the value of the attribute by spaces, set value to this vector array and return the number of elements.
Otherwise return 0 and do not change value.
| attribute | Name of the attribute. |
| value | Value of the attribute. |
| int XMLNode::get | ( | const std::string & | attribute, |
| std::vector< std::string > * | value | ||
| ) | const |
If 'attribute' was defined, split the value of the attribute by spaces, set value to this vector array and return the number of elements.
Otherwise return 0 and do not change value.
| attribute | Name of the attribute. |
| value | Value of the attribute. |
| int XMLNode::get | ( | core::vector3df * | value | ) | const |
Interprets the attributes 'x', 'y', 'z' or 'h', 'p', 'r' as a 3d vector and set the corresponding elements of value.
Not all values need to be defined as attributes (and the correspnding elements of the vector will not be changed). It returns a bit field for each defined value, i.e. if x and y are defined, 3 is returned.
| value | Vector to return the values in. |
| int XMLNode::getHPR | ( | core::vector3df * | value | ) | const |
Interprets the attributes 'h', 'p', 'r' as a 3d vector and set the corresponding elements of value.
Not all values need to be defined as attributes (and the correspnding elements of the vector will not be changed). It returns a bit field for each defined value, i.e. if x and y are defined, 3 is returned.
| value | Vector to return the values in. |
| int XMLNode::getHPR | ( | Vec3 * | value | ) | const |
Interprets the attributes 'h', 'p', 'r' as a 3d vector and set the corresponding elements of value.
Not all values need to be defined as attributes (and the correspnding elements of the vector will not be changed). It returns a bit field for each defined value, i.e. if x and y are defined, 3 is returned.
| value | Vector to return the values in. |
| const XMLNode * XMLNode::getNode | ( | const std::string & | s | ) | const |
Returns the node with the given name.
| s | Name of the node to return. |
| const XMLNode * XMLNode::getNode | ( | unsigned int | i | ) | const |
Returns the i.th node.
| i | Number of node to return. |
| const void XMLNode::getNodes | ( | const std::string & | s, |
| std::vector< XMLNode * > & | out | ||
| ) | const |
Returns all nodes with the given name.
| s | Name of the nodes to return. |
| s | Vector that will be filled with output values. |
| int XMLNode::getXYZ | ( | core::vector3df * | value | ) | const |
Interprets the attributes 'x', 'y', 'z' as a 3d vector and set the corresponding elements of value.
Not all values need to be defined as attributes (and the correspnding elements of the vector will not be changed). It returns a bit field for each defined value, i.e. if x and y are defined, 3 is returned.
| value | Vector to return the values in. |
| int XMLNode::getXYZ | ( | Vec3 * | value | ) | const |
Interprets the attributes 'x', 'y', 'z' as a 3d vector and set the corresponding elements of value.
Not all values need to be defined as attributes (and the correspnding elements of the vector will not be changed). It returns a bit field for each defined value, i.e. if x and y are defined, 3 is returned.
| value | Vector to return the values in. |
|
private |
Stores all attributes, and reads in all children.
| xml | The XML reader. |
Read all children elements.