|
|
|
@ -99,32 +99,165 @@ template <class TNodeType>
|
|
|
|
|
class TXmlParser {
|
|
|
|
|
public:
|
|
|
|
|
/// @brief The default class constructor.
|
|
|
|
|
TXmlParser() :
|
|
|
|
|
mDoc(nullptr),
|
|
|
|
|
mData() {
|
|
|
|
|
// empty
|
|
|
|
|
}
|
|
|
|
|
TXmlParser();
|
|
|
|
|
|
|
|
|
|
/// @brief The class destructor.
|
|
|
|
|
~TXmlParser() {
|
|
|
|
|
clear();
|
|
|
|
|
}
|
|
|
|
|
~TXmlParser();
|
|
|
|
|
|
|
|
|
|
/// @brief Will clear the parsed xml-file.
|
|
|
|
|
void clear() {
|
|
|
|
|
if (mData.empty()) {
|
|
|
|
|
mDoc = nullptr;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
mData.clear();
|
|
|
|
|
delete mDoc;
|
|
|
|
|
mDoc = nullptr;
|
|
|
|
|
}
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
|
|
/// @brief Will search for a child-node by its name
|
|
|
|
|
/// @param name [in] The name of the child-node.
|
|
|
|
|
/// @return The node instance or nullptr, if nothing was found.
|
|
|
|
|
TNodeType *findNode(const std::string &name) {
|
|
|
|
|
TNodeType *findNode(const std::string &name);
|
|
|
|
|
|
|
|
|
|
/// @brief Will return true, if the node is a child-node.
|
|
|
|
|
/// @param name [in] The name of the child node to look for.
|
|
|
|
|
/// @return true, if the node is a child-node or false if not.
|
|
|
|
|
bool hasNode(const std::string &name);
|
|
|
|
|
|
|
|
|
|
/// @brief Will parse an xml-file from a given stream.
|
|
|
|
|
/// @param stream The input stream.
|
|
|
|
|
/// @return true, if the parsing was successful, false if not.
|
|
|
|
|
bool parse(IOStream *stream);
|
|
|
|
|
|
|
|
|
|
/// @brief Will return true if a root node is there.
|
|
|
|
|
/// @return true in case of an existing root.
|
|
|
|
|
bool hasRoot() const;
|
|
|
|
|
|
|
|
|
|
/// @brief Will return the document pointer, is nullptr if no xml-file was parsed.
|
|
|
|
|
/// @return The pointer showing to the document.
|
|
|
|
|
pugi::xml_document *getDocument() const;
|
|
|
|
|
|
|
|
|
|
/// @brief Will return the root node, const version.
|
|
|
|
|
/// @return The root node.
|
|
|
|
|
const TNodeType getRootNode() const;
|
|
|
|
|
|
|
|
|
|
/// @brief Will return the root node, non-const version.
|
|
|
|
|
/// @return The root node.
|
|
|
|
|
TNodeType getRootNode();
|
|
|
|
|
|
|
|
|
|
/// @brief Will check if a node with the given name is in.
|
|
|
|
|
/// @param node [in] The node to look in.
|
|
|
|
|
/// @param name [in] The name of the child-node.
|
|
|
|
|
/// @return true, if node was found, false if not.
|
|
|
|
|
static inline bool hasNode(XmlNode &node, const char *name);
|
|
|
|
|
|
|
|
|
|
/// @brief Will check if an attribute is part of the XmlNode.
|
|
|
|
|
/// @param xmlNode [in] The node to search in.
|
|
|
|
|
/// @param name [in} The attribute name to look for.
|
|
|
|
|
/// @return true, if the was found, false if not.
|
|
|
|
|
static inline bool hasAttribute(XmlNode &xmlNode, const char *name);
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get an unsigned int attribute value.
|
|
|
|
|
/// @param xmlNode [in] The node to search in.
|
|
|
|
|
/// @param name [in] The attribute name to look for.
|
|
|
|
|
/// @param val [out] The unsigned int value from the attribute.
|
|
|
|
|
/// @return true, if the node contains an attribute with the given name and if the value is an unsigned int.
|
|
|
|
|
static inline bool getUIntAttribute(XmlNode &xmlNode, const char *name, unsigned int &val);
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get an int attribute value.
|
|
|
|
|
/// @param xmlNode [in] The node to search in.
|
|
|
|
|
/// @param name [in] The attribute name to look for.
|
|
|
|
|
/// @param val [out] The int value from the attribute.
|
|
|
|
|
/// @return true, if the node contains an attribute with the given name and if the value is an int.
|
|
|
|
|
static inline bool getIntAttribute(XmlNode &xmlNode, const char *name, int &val);
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get a real attribute value.
|
|
|
|
|
/// @param xmlNode [in] The node to search in.
|
|
|
|
|
/// @param name [in] The attribute name to look for.
|
|
|
|
|
/// @param val [out] The real value from the attribute.
|
|
|
|
|
/// @return true, if the node contains an attribute with the given name and if the value is a real.
|
|
|
|
|
static inline bool getRealAttribute(XmlNode &xmlNode, const char *name, ai_real &val);
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get a float attribute value.
|
|
|
|
|
/// @param xmlNode [in] The node to search in.
|
|
|
|
|
/// @param name [in] The attribute name to look for.
|
|
|
|
|
/// @param val [out] The float value from the attribute.
|
|
|
|
|
/// @return true, if the node contains an attribute with the given name and if the value is a float.
|
|
|
|
|
static inline bool getFloatAttribute(XmlNode &xmlNode, const char *name, float &val);
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get a double attribute value.
|
|
|
|
|
/// @param xmlNode [in] The node to search in.
|
|
|
|
|
/// @param name [in] The attribute name to look for.
|
|
|
|
|
/// @param val [out] The double value from the attribute.
|
|
|
|
|
/// @return true, if the node contains an attribute with the given name and if the value is a double.
|
|
|
|
|
static inline bool getDoubleAttribute(XmlNode &xmlNode, const char *name, double &val);
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get a std::string attribute value.
|
|
|
|
|
/// @param xmlNode [in] The node to search in.
|
|
|
|
|
/// @param name [in] The attribute name to look for.
|
|
|
|
|
/// @param val [out] The std::string value from the attribute.
|
|
|
|
|
/// @return true, if the node contains an attribute with the given name and if the value is a std::string.
|
|
|
|
|
static inline bool getStdStrAttribute(XmlNode &xmlNode, const char *name, std::string &val);
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get a bool attribute value.
|
|
|
|
|
/// @param xmlNode [in] The node to search in.
|
|
|
|
|
/// @param name [in] The attribute name to look for.
|
|
|
|
|
/// @param val [out] The bool value from the attribute.
|
|
|
|
|
/// @return true, if the node contains an attribute with the given name and if the value is a bool.
|
|
|
|
|
static inline bool getBoolAttribute(XmlNode &xmlNode, const char *name, bool &val);
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get the value of the node as a string.
|
|
|
|
|
/// @param node [in] The node to search in.
|
|
|
|
|
/// @param text [out] The value as a text.
|
|
|
|
|
/// @return true, if the value can be read out.
|
|
|
|
|
static inline bool getValueAsString(XmlNode &node, std::string &text);
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get the value of the node as a float.
|
|
|
|
|
/// @param node [in] The node to search in.
|
|
|
|
|
/// @param text [out] The value as a float.
|
|
|
|
|
/// @return true, if the value can be read out.
|
|
|
|
|
static inline bool getValueAsFloat(XmlNode &node, ai_real &v);
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get the value of the node as an integer.
|
|
|
|
|
/// @param node [in] The node to search in.
|
|
|
|
|
/// @param text [out] The value as a int.
|
|
|
|
|
/// @return true, if the value can be read out.
|
|
|
|
|
static inline bool getValueAsInt(XmlNode &node, int &v);
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get the value of the node as an bool.
|
|
|
|
|
/// @param node [in] The node to search in.
|
|
|
|
|
/// @param text [out] The value as a bool.
|
|
|
|
|
/// @return true, if the value can be read out.
|
|
|
|
|
static inline bool getValueAsBool(XmlNode &node, bool &v);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
pugi::xml_document *mDoc;
|
|
|
|
|
TNodeType mCurrent;
|
|
|
|
|
std::vector<char> mData;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
inline TXmlParser<TNodeType>::TXmlParser() :
|
|
|
|
|
mDoc(nullptr),
|
|
|
|
|
mData() {
|
|
|
|
|
// empty
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
inline TXmlParser<TNodeType>::~TXmlParser() {
|
|
|
|
|
clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
inline void TXmlParser<TNodeType>::clear() {
|
|
|
|
|
if (mData.empty()) {
|
|
|
|
|
if (mDoc) {
|
|
|
|
|
delete mDoc;
|
|
|
|
|
}
|
|
|
|
|
mDoc = nullptr;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mData.clear();
|
|
|
|
|
delete mDoc;
|
|
|
|
|
mDoc = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
inline TNodeType *TXmlParser<TNodeType>::findNode(const std::string &name) {
|
|
|
|
|
if (name.empty()) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
@ -140,19 +273,19 @@ public:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return &mCurrent;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @brief Will return true, if the node is a child-node.
|
|
|
|
|
/// @param name [in] The name of the child node to look for.
|
|
|
|
|
/// @return true, if the node is a child-node or false if not.
|
|
|
|
|
bool hasNode(const std::string &name) {
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
bool TXmlParser<TNodeType>::hasNode(const std::string &name) {
|
|
|
|
|
return nullptr != findNode(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
bool TXmlParser<TNodeType>::parse(IOStream *stream) {
|
|
|
|
|
if (hasRoot()) {
|
|
|
|
|
clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @brief Will parse an xml-file from a given stream.
|
|
|
|
|
/// @param stream The input stream.
|
|
|
|
|
/// @return true, if the parsing was successful, false if not.
|
|
|
|
|
bool parse(IOStream *stream) {
|
|
|
|
|
if (nullptr == stream) {
|
|
|
|
|
ASSIMP_LOG_DEBUG("Stream is nullptr.");
|
|
|
|
|
return false;
|
|
|
|
@ -172,63 +305,51 @@ public:
|
|
|
|
|
ASSIMP_LOG_DEBUG("Error while parse xml.", std::string(parse_result.description()), " @ ", parse_result.offset);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @brief Will return truem if a root node is there.
|
|
|
|
|
/// @return true in case of an existing root.
|
|
|
|
|
bool hasRoot() const {
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
bool TXmlParser<TNodeType>::hasRoot() const {
|
|
|
|
|
return nullptr != mDoc;
|
|
|
|
|
}
|
|
|
|
|
/// @brief Will return the document pointer, is nullptr if no xml-file was parsed.
|
|
|
|
|
/// @return The pointer showing to the document.
|
|
|
|
|
pugi::xml_document *getDocument() const {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
pugi::xml_document *TXmlParser<TNodeType>::getDocument() const {
|
|
|
|
|
return mDoc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @brief Will return the root node, const version.
|
|
|
|
|
/// @return The root node.
|
|
|
|
|
const TNodeType getRootNode() const {
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
const TNodeType TXmlParser<TNodeType>::getRootNode() const {
|
|
|
|
|
static pugi::xml_node none;
|
|
|
|
|
if (nullptr == mDoc) {
|
|
|
|
|
return none;
|
|
|
|
|
}
|
|
|
|
|
return mDoc->root();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @brief Will return the root node, non-const version.
|
|
|
|
|
/// @return The root node.
|
|
|
|
|
TNodeType getRootNode() {
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
TNodeType TXmlParser<TNodeType>::getRootNode() {
|
|
|
|
|
static pugi::xml_node none;
|
|
|
|
|
if (nullptr == mDoc) {
|
|
|
|
|
return none;
|
|
|
|
|
}
|
|
|
|
|
return mDoc->root();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @brief Will check if a node with the given name is in.
|
|
|
|
|
/// @param node [in] The node to look in.
|
|
|
|
|
/// @param name [in] The name of the child-node.
|
|
|
|
|
/// @return true, if node was found, false if not.
|
|
|
|
|
static inline bool hasNode(XmlNode &node, const char *name) {
|
|
|
|
|
return mDoc->root();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
inline bool TXmlParser<TNodeType>::hasNode(XmlNode &node, const char *name) {
|
|
|
|
|
pugi::xml_node child = node.find_child(find_node_by_name_predicate(name));
|
|
|
|
|
return !child.empty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @brief Will check if an attribute is part of the XmlNode.
|
|
|
|
|
/// @param xmlNode [in] The node to search in.
|
|
|
|
|
/// @param name [in} The attribute name to look for.
|
|
|
|
|
/// @return true, if the was found, false if not.
|
|
|
|
|
static inline bool hasAttribute(XmlNode &xmlNode, const char *name) {
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
inline bool TXmlParser<TNodeType>::hasAttribute(XmlNode &xmlNode, const char *name) {
|
|
|
|
|
pugi::xml_attribute attr = xmlNode.attribute(name);
|
|
|
|
|
return !attr.empty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get an unsigned int attribute value.
|
|
|
|
|
/// @param xmlNode [in] The node to search in.
|
|
|
|
|
/// @param name [in] The attribute name to look for.
|
|
|
|
|
/// @param val [out] The unsigned int value from the attribute.
|
|
|
|
|
/// @return true, if the node contains an attribute with the given name and if the value is an unsigned int.
|
|
|
|
|
static inline bool getUIntAttribute(XmlNode &xmlNode, const char *name, unsigned int &val) {
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
inline bool TXmlParser<TNodeType>::getUIntAttribute(XmlNode &xmlNode, const char *name, unsigned int &val) {
|
|
|
|
|
pugi::xml_attribute attr = xmlNode.attribute(name);
|
|
|
|
|
if (attr.empty()) {
|
|
|
|
|
return false;
|
|
|
|
@ -236,14 +357,10 @@ public:
|
|
|
|
|
|
|
|
|
|
val = attr.as_uint();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get an int attribute value.
|
|
|
|
|
/// @param xmlNode [in] The node to search in.
|
|
|
|
|
/// @param name [in] The attribute name to look for.
|
|
|
|
|
/// @param val [out] The int value from the attribute.
|
|
|
|
|
/// @return true, if the node contains an attribute with the given name and if the value is an int.
|
|
|
|
|
static inline bool getIntAttribute(XmlNode &xmlNode, const char *name, int &val) {
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
inline bool TXmlParser<TNodeType>::getIntAttribute(XmlNode &xmlNode, const char *name, int &val) {
|
|
|
|
|
pugi::xml_attribute attr = xmlNode.attribute(name);
|
|
|
|
|
if (attr.empty()) {
|
|
|
|
|
return false;
|
|
|
|
@ -251,14 +368,10 @@ public:
|
|
|
|
|
|
|
|
|
|
val = attr.as_int();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get a real attribute value.
|
|
|
|
|
/// @param xmlNode [in] The node to search in.
|
|
|
|
|
/// @param name [in] The attribute name to look for.
|
|
|
|
|
/// @param val [out] The real value from the attribute.
|
|
|
|
|
/// @return true, if the node contains an attribute with the given name and if the value is a real.
|
|
|
|
|
static inline bool getRealAttribute(XmlNode &xmlNode, const char *name, ai_real &val) {
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
inline bool TXmlParser<TNodeType>::getRealAttribute(XmlNode &xmlNode, const char *name, ai_real &val) {
|
|
|
|
|
pugi::xml_attribute attr = xmlNode.attribute(name);
|
|
|
|
|
if (attr.empty()) {
|
|
|
|
|
return false;
|
|
|
|
@ -269,73 +382,58 @@ public:
|
|
|
|
|
val = attr.as_float();
|
|
|
|
|
#endif
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get a float attribute value.
|
|
|
|
|
/// @param xmlNode [in] The node to search in.
|
|
|
|
|
/// @param name [in] The attribute name to look for.
|
|
|
|
|
/// @param val [out] The float value from the attribute.
|
|
|
|
|
/// @return true, if the node contains an attribute with the given name and if the value is a float.
|
|
|
|
|
static inline bool getFloatAttribute(XmlNode &xmlNode, const char *name, float &val) {
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
inline bool TXmlParser<TNodeType>::getFloatAttribute(XmlNode &xmlNode, const char *name, float &val) {
|
|
|
|
|
pugi::xml_attribute attr = xmlNode.attribute(name);
|
|
|
|
|
if (attr.empty()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val = attr.as_float();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get a double attribute value.
|
|
|
|
|
/// @param xmlNode [in] The node to search in.
|
|
|
|
|
/// @param name [in] The attribute name to look for.
|
|
|
|
|
/// @param val [out] The double value from the attribute.
|
|
|
|
|
/// @return true, if the node contains an attribute with the given name and if the value is a double.
|
|
|
|
|
static inline bool getDoubleAttribute(XmlNode &xmlNode, const char *name, double &val) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
inline bool TXmlParser<TNodeType>::getDoubleAttribute(XmlNode &xmlNode, const char *name, double &val) {
|
|
|
|
|
pugi::xml_attribute attr = xmlNode.attribute(name);
|
|
|
|
|
if (attr.empty()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val = attr.as_double();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get a std::string attribute value.
|
|
|
|
|
/// @param xmlNode [in] The node to search in.
|
|
|
|
|
/// @param name [in] The attribute name to look for.
|
|
|
|
|
/// @param val [out] The std::string value from the attribute.
|
|
|
|
|
/// @return true, if the node contains an attribute with the given name and if the value is a std::string.
|
|
|
|
|
static inline bool getStdStrAttribute(XmlNode &xmlNode, const char *name, std::string &val) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
inline bool TXmlParser<TNodeType>::getStdStrAttribute(XmlNode &xmlNode, const char *name, std::string &val) {
|
|
|
|
|
pugi::xml_attribute attr = xmlNode.attribute(name);
|
|
|
|
|
if (attr.empty()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val = attr.as_string();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get a bool attribute value.
|
|
|
|
|
/// @param xmlNode [in] The node to search in.
|
|
|
|
|
/// @param name [in] The attribute name to look for.
|
|
|
|
|
/// @param val [out] The bool value from the attribute.
|
|
|
|
|
/// @return true, if the node contains an attribute with the given name and if the value is a bool.
|
|
|
|
|
static inline bool getBoolAttribute(XmlNode &xmlNode, const char *name, bool &val) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
inline bool TXmlParser<TNodeType>::getBoolAttribute(XmlNode &xmlNode, const char *name, bool &val) {
|
|
|
|
|
pugi::xml_attribute attr = xmlNode.attribute(name);
|
|
|
|
|
if (attr.empty()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val = attr.as_bool();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get the value of the node as a string.
|
|
|
|
|
/// @param node [in] The node to search in.
|
|
|
|
|
/// @param text [out] The value as a text.
|
|
|
|
|
/// @return true, if the value can be read out.
|
|
|
|
|
static inline bool getValueAsString(XmlNode &node, std::string &text) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
inline bool TXmlParser<TNodeType>::getValueAsString(XmlNode &node, std::string &text) {
|
|
|
|
|
text = std::string();
|
|
|
|
|
if (node.empty()) {
|
|
|
|
|
return false;
|
|
|
|
@ -344,13 +442,10 @@ public:
|
|
|
|
|
text = node.text().as_string();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get the value of the node as a float.
|
|
|
|
|
/// @param node [in] The node to search in.
|
|
|
|
|
/// @param text [out] The value as a float.
|
|
|
|
|
/// @return true, if the value can be read out.
|
|
|
|
|
static inline bool getValueAsFloat(XmlNode &node, ai_real &v) {
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
inline bool TXmlParser<TNodeType>::getValueAsFloat(XmlNode &node, ai_real &v) {
|
|
|
|
|
if (node.empty()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -358,13 +453,10 @@ public:
|
|
|
|
|
v = node.text().as_float();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get the value of the node as an integer.
|
|
|
|
|
/// @param node [in] The node to search in.
|
|
|
|
|
/// @param text [out] The value as a int.
|
|
|
|
|
/// @return true, if the value can be read out.
|
|
|
|
|
static inline bool getValueAsInt(XmlNode &node, int &v) {
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
inline bool TXmlParser<TNodeType>::getValueAsInt(XmlNode &node, int &v) {
|
|
|
|
|
if (node.empty()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -372,14 +464,10 @@ public:
|
|
|
|
|
v = node.text().as_int();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @brief Will try to get the value of the node as an bool.
|
|
|
|
|
/// @param node [in] The node to search in.
|
|
|
|
|
/// @param text [out] The value as a bool.
|
|
|
|
|
/// @return true, if the value can be read out.
|
|
|
|
|
static inline bool getValueAsBool(XmlNode& node, bool& v)
|
|
|
|
|
{
|
|
|
|
|
template <class TNodeType>
|
|
|
|
|
inline bool TXmlParser<TNodeType>::getValueAsBool(XmlNode &node, bool &v) {
|
|
|
|
|
if (node.empty()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -387,13 +475,7 @@ public:
|
|
|
|
|
v = node.text().as_bool();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
pugi::xml_document *mDoc;
|
|
|
|
|
TNodeType mCurrent;
|
|
|
|
|
std::vector<char> mData;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using XmlParser = TXmlParser<pugi::xml_node>;
|
|
|
|
|
|
|
|
|
|