Assimp v5.2.2 (January 2022)
The Asset-Importer-Lib API documentation.
Assimp::TXmlParser< TNodeType > Class Template Reference

The Xml-Parser class. More...

#include <XmlParser.h>

Public Member Functions

void clear ()
 Will clear the parsed xml-file. More...
 
TNodeType * findNode (const std::string &name)
 Will search for a child-node by its name. More...
 
pugi::xml_document * getDocument () const
 Will return the document pointer, is nullptr if no xml-file was parsed. More...
 
TNodeType getRootNode ()
 Will return the root node, non-const version. More...
 
const TNodeType getRootNode () const
 Will return the root node, const version. More...
 
bool hasNode (const std::string &name)
 Will return true, if the node is a child-node. More...
 
bool hasRoot () const
 Will return true if a root node is there. More...
 
bool parse (IOStream *stream)
 Will parse an xml-file from a given stream. More...
 
 TXmlParser ()
 The default class constructor. More...
 
 ~TXmlParser ()
 The class destructor. More...
 

Static Public Member Functions

static bool getBoolAttribute (XmlNode &xmlNode, const char *name, bool &val)
 Will try to get a bool attribute value. More...
 
static bool getDoubleAttribute (XmlNode &xmlNode, const char *name, double &val)
 Will try to get a double attribute value. More...
 
static bool getFloatAttribute (XmlNode &xmlNode, const char *name, float &val)
 Will try to get a float attribute value. More...
 
static bool getIntAttribute (XmlNode &xmlNode, const char *name, int &val)
 Will try to get an int attribute value. More...
 
static bool getRealAttribute (XmlNode &xmlNode, const char *name, ai_real &val)
 Will try to get a real attribute value. More...
 
static bool getStdStrAttribute (XmlNode &xmlNode, const char *name, std::string &val)
 Will try to get a std::string attribute value. More...
 
static bool getUIntAttribute (XmlNode &xmlNode, const char *name, unsigned int &val)
 Will try to get an unsigned int attribute value. More...
 
static bool getValueAsBool (XmlNode &node, bool &v)
 Will try to get the value of the node as an bool. More...
 
static bool getValueAsFloat (XmlNode &node, ai_real &v)
 Will try to get the value of the node as a float. More...
 
static bool getValueAsInt (XmlNode &node, int &v)
 Will try to get the value of the node as an integer. More...
 
static bool getValueAsString (XmlNode &node, std::string &text)
 Will try to get the value of the node as a string. More...
 
static bool hasAttribute (XmlNode &xmlNode, const char *name)
 Will check if an attribute is part of the XmlNode. More...
 
static bool hasNode (XmlNode &node, const char *name)
 Will check if a node with the given name is in. More...
 

Detailed Description

template<class TNodeType>
class Assimp::TXmlParser< TNodeType >

The Xml-Parser class.

Use this parser if you have to import any kind of xml-format.

An example:

if (theParser.parse(fileStream)) {
auto node = theParser.getRootNode();
for ( auto currentNode : node.children()) {
// Will loop over all children
}
}
The Xml-Parser class.
Definition: XmlParser.h:99
const TNodeType getRootNode() const
Will return the root node, const version.
Definition: XmlParser.h:321
bool parse(IOStream *stream)
Will parse an xml-file from a given stream.
Definition: XmlParser.h:284
Template Parameters
TNodeType

Constructor & Destructor Documentation

◆ TXmlParser()

template<class TNodeType >
Assimp::TXmlParser< TNodeType >::TXmlParser
inline

The default class constructor.

◆ ~TXmlParser()

template<class TNodeType >
Assimp::TXmlParser< TNodeType >::~TXmlParser
inline

The class destructor.

Member Function Documentation

◆ clear()

template<class TNodeType >
void Assimp::TXmlParser< TNodeType >::clear
inline

Will clear the parsed xml-file.

◆ findNode()

template<class TNodeType >
TNodeType * Assimp::TXmlParser< TNodeType >::findNode ( const std::string &  name)
inline

Will search for a child-node by its name.

Parameters
name[in] The name of the child-node.
Returns
The node instance or nullptr, if nothing was found.

◆ getBoolAttribute()

template<class TNodeType >
bool Assimp::TXmlParser< TNodeType >::getBoolAttribute ( XmlNode xmlNode,
const char *  name,
bool &  val 
)
inlinestatic

Will try to get a bool attribute value.

Parameters
xmlNode[in] The node to search in.
name[in] The attribute name to look for.
val[out] The bool value from the attribute.
Returns
true, if the node contains an attribute with the given name and if the value is a bool.

◆ getDocument()

template<class TNodeType >
pugi::xml_document * Assimp::TXmlParser< TNodeType >::getDocument

Will return the document pointer, is nullptr if no xml-file was parsed.

Returns
The pointer showing to the document.

◆ getDoubleAttribute()

template<class TNodeType >
bool Assimp::TXmlParser< TNodeType >::getDoubleAttribute ( XmlNode xmlNode,
const char *  name,
double &  val 
)
inlinestatic

Will try to get a double attribute value.

Parameters
xmlNode[in] The node to search in.
name[in] The attribute name to look for.
val[out] The double value from the attribute.
Returns
true, if the node contains an attribute with the given name and if the value is a double.

◆ getFloatAttribute()

template<class TNodeType >
bool Assimp::TXmlParser< TNodeType >::getFloatAttribute ( XmlNode xmlNode,
const char *  name,
float &  val 
)
inlinestatic

Will try to get a float attribute value.

Parameters
xmlNode[in] The node to search in.
name[in] The attribute name to look for.
val[out] The float value from the attribute.
Returns
true, if the node contains an attribute with the given name and if the value is a float.

◆ getIntAttribute()

template<class TNodeType >
bool Assimp::TXmlParser< TNodeType >::getIntAttribute ( XmlNode xmlNode,
const char *  name,
int &  val 
)
inlinestatic

Will try to get an int attribute value.

Parameters
xmlNode[in] The node to search in.
name[in] The attribute name to look for.
val[out] The int value from the attribute.
Returns
true, if the node contains an attribute with the given name and if the value is an int.

◆ getRealAttribute()

template<class TNodeType >
bool Assimp::TXmlParser< TNodeType >::getRealAttribute ( XmlNode xmlNode,
const char *  name,
ai_real val 
)
inlinestatic

Will try to get a real attribute value.

Parameters
xmlNode[in] The node to search in.
name[in] The attribute name to look for.
val[out] The real value from the attribute.
Returns
true, if the node contains an attribute with the given name and if the value is a real.

◆ getRootNode() [1/2]

template<class TNodeType >
TNodeType Assimp::TXmlParser< TNodeType >::getRootNode

Will return the root node, non-const version.

Returns
The root node.

◆ getRootNode() [2/2]

template<class TNodeType >
const TNodeType Assimp::TXmlParser< TNodeType >::getRootNode

Will return the root node, const version.

Returns
The root node.

◆ getStdStrAttribute()

template<class TNodeType >
bool Assimp::TXmlParser< TNodeType >::getStdStrAttribute ( XmlNode xmlNode,
const char *  name,
std::string &  val 
)
inlinestatic

Will try to get a std::string attribute value.

Parameters
xmlNode[in] The node to search in.
name[in] The attribute name to look for.
val[out] The std::string value from the attribute.
Returns
true, if the node contains an attribute with the given name and if the value is a std::string.

◆ getUIntAttribute()

template<class TNodeType >
bool Assimp::TXmlParser< TNodeType >::getUIntAttribute ( XmlNode xmlNode,
const char *  name,
unsigned int &  val 
)
inlinestatic

Will try to get an unsigned int attribute value.

Parameters
xmlNode[in] The node to search in.
name[in] The attribute name to look for.
val[out] The unsigned int value from the attribute.
Returns
true, if the node contains an attribute with the given name and if the value is an unsigned int.

◆ getValueAsBool()

template<class TNodeType >
bool Assimp::TXmlParser< TNodeType >::getValueAsBool ( XmlNode node,
bool &  v 
)
inlinestatic

Will try to get the value of the node as an bool.

Parameters
node[in] The node to search in.
text[out] The value as a bool.
Returns
true, if the value can be read out.

◆ getValueAsFloat()

template<class TNodeType >
bool Assimp::TXmlParser< TNodeType >::getValueAsFloat ( XmlNode node,
ai_real v 
)
inlinestatic

Will try to get the value of the node as a float.

Parameters
node[in] The node to search in.
text[out] The value as a float.
Returns
true, if the value can be read out.

◆ getValueAsInt()

template<class TNodeType >
bool Assimp::TXmlParser< TNodeType >::getValueAsInt ( XmlNode node,
int &  v 
)
inlinestatic

Will try to get the value of the node as an integer.

Parameters
node[in] The node to search in.
text[out] The value as a int.
Returns
true, if the value can be read out.

◆ getValueAsString()

template<class TNodeType >
bool Assimp::TXmlParser< TNodeType >::getValueAsString ( XmlNode node,
std::string &  text 
)
inlinestatic

Will try to get the value of the node as a string.

Parameters
node[in] The node to search in.
text[out] The value as a text.
Returns
true, if the value can be read out.

◆ hasAttribute()

template<class TNodeType >
bool Assimp::TXmlParser< TNodeType >::hasAttribute ( XmlNode xmlNode,
const char *  name 
)
inlinestatic

Will check if an attribute is part of the XmlNode.

Parameters
xmlNode[in] The node to search in.
name[in} The attribute name to look for.
Returns
true, if the was found, false if not.

◆ hasNode() [1/2]

template<class TNodeType >
bool Assimp::TXmlParser< TNodeType >::hasNode ( const std::string &  name)

Will return true, if the node is a child-node.

Parameters
name[in] The name of the child node to look for.
Returns
true, if the node is a child-node or false if not.

◆ hasNode() [2/2]

template<class TNodeType >
bool Assimp::TXmlParser< TNodeType >::hasNode ( XmlNode node,
const char *  name 
)
inlinestatic

Will check if a node with the given name is in.

Parameters
node[in] The node to look in.
name[in] The name of the child-node.
Returns
true, if node was found, false if not.

◆ hasRoot()

template<class TNodeType >
bool Assimp::TXmlParser< TNodeType >::hasRoot

Will return true if a root node is there.

Returns
true in case of an existing root.

◆ parse()

template<class TNodeType >
bool Assimp::TXmlParser< TNodeType >::parse ( IOStream stream)

Will parse an xml-file from a given stream.

Parameters
streamThe input stream.
Returns
true, if the parsing was successful, false if not.

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