SuperTuxKart
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
XMLNode Class Reference

utility class used to parse XML files More...

#include <xml_node.hpp>

Inheritance diagram for XMLNode:
Inheritance graph
[legend]

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.
 
 ~XMLNode ()
 Destructor.
 
const std::string & getName () const
 
const XMLNodegetNode (const std::string &name) const
 Returns the node with the given name.
 
const void getNodes (const std::string &s, std::vector< XMLNode * > &out) const
 Returns all nodes with the given name.
 
const XMLNodegetNode (unsigned int i) const
 Returns the i.th node.
 
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.
 
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.
 
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.
 
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.
 
int get (const std::string &attribute, InterpolationArray *value) const
 Reads an InterpolatioARray.
 
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.
 
int getXYZ (core::vector3df *value) const
 Interprets the attributes 'x', 'y', 'z' as a 3d vector and set the corresponding elements of value.
 
int getXYZ (Vec3 *vaslue) const
 Interprets the attributes 'x', 'y', 'z' as a 3d vector and set the corresponding elements of value.
 
int getHPR (core::vector3df *value) const
 Interprets the attributes 'h', 'p', 'r' as a 3d vector and set the corresponding elements of value.
 
int getHPR (Vec3 *value) const
 Interprets the attributes 'h', 'p', 'r' as a 3d vector and set the corresponding elements of value.
 
bool hasChildNamed (const char *name) 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.
 

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
 

Detailed Description

utility class used to parse XML files

Constructor & Destructor Documentation

◆ XMLNode()

XMLNode::XMLNode ( const std::string &  filename)

Reads a XML file and convert it into a XMLNode tree.

Exceptions
runtime_errorif the file is not found
Parameters
filenameName of the XML file to read.

Member Function Documentation

◆ get() [1/6]

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.

Parameters
attributeName of the attribute.
valueThe InterpolationArray.
Returns
0 in case of an error, !=0 otherwise

◆ get() [2/6]

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.

Parameters
attributeName of the attribute.
valueValue of the attribute.

◆ get() [3/6]

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.

Parameters
attributeName of the attribute.
valueValue of the attribute.

◆ get() [4/6]

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.

Parameters
attributeName of the attribute.
valueValue of the attribute.

◆ get() [5/6]

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.

Parameters
attributeName of the attribute.
valueValue of the attribute.

◆ get() [6/6]

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.

Parameters
valueVector to return the values in.

◆ getHPR() [1/2]

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.

Parameters
valueVector to return the values in.

◆ getHPR() [2/2]

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.

Parameters
valueVector to return the values in.

◆ getNode() [1/2]

const XMLNode * XMLNode::getNode ( const std::string &  s) const

Returns the node with the given name.

Parameters
sName of the node to return.

◆ getNode() [2/2]

const XMLNode * XMLNode::getNode ( unsigned int  i) const

Returns the i.th node.

Parameters
iNumber of node to return.

◆ getNodes()

const void XMLNode::getNodes ( const std::string &  s,
std::vector< XMLNode * > &  out 
) const

Returns all nodes with the given name.

Parameters
sName of the nodes to return.
sVector that will be filled with output values.

◆ getXYZ() [1/2]

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.

Parameters
valueVector to return the values in.

◆ getXYZ() [2/2]

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.

Parameters
valueVector to return the values in.

◆ readXML()

void XMLNode::readXML ( io::IXMLReader *  xml)
private

Stores all attributes, and reads in all children.

Parameters
xmlThe XML reader.

Read all children elements.


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