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

Static Public Member Functions

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

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
}
}
Definition Exceptional.h:121
Template Parameters
TNodeType

Constructor & Destructor Documentation

◆ TXmlParser()

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

The default class constructor.

◆ ~TXmlParser()

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
[in]nameThe 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
[in]xmlNodeThe node to search in.
[in]nameThe attribute name to look for.
[out]valThe 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 ( ) const

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
[in]xmlNodeThe node to search in.
[in]nameThe attribute name to look for.
[out]valThe 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
[in]xmlNodeThe node to search in.
[in]nameThe attribute name to look for.
[out]valThe 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
[in]xmlNodeThe node to search in.
[in]nameThe attribute name to look for.
[out]valThe 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
[in]xmlNodeThe node to search in.
[in]nameThe attribute name to look for.
[out]valThe 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 ( ) const

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
[in]xmlNodeThe node to search in.
[in]nameThe attribute name to look for.
[out]valThe 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
[in]xmlNodeThe node to search in.
[in]nameThe attribute name to look for.
[out]valThe 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
[in]nodeThe node to search in.
[out]vThe value as a bool.
Returns
true, if the value can be read out.

◆ getValueAsFloat()

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

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

Parameters
[in]nodeThe node to search in.
[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
[in]nodeThe node to search in.
[out]iThe value as a int.
Returns
true, if the value can be read out.

◆ getValueAsReal()

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

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

Parameters
[in]nodeThe node to search in.
[out]vThe value as a ai_real.
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
[in]nodeThe node to search in.
[out]textThe 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
[in]xmlNodeThe node to search in.
[in]nameThe 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
[in]nameThe 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
[in]nodeThe node to look in.
[in]nameThe name of the child-node.
Returns
true, if node was found, false if not.

◆ hasRoot()

template<class TNodeType >
bool Assimp::TXmlParser< TNodeType >::hasRoot ( ) const

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
[in]streamThe input stream.
Returns
true, if the parsing was successful, false if not.

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