tools/navgenproj/XmlNode.h Source File
Go to the documentation of this file.
26 explicit XmlNode(TiXmlNode* node) : m_node(node) {}
29 XmlNode FirstChild()
const {
return XmlNode(TiXml::FirstChild(m_node)); }
30 XmlNode NextSibling()
const {
return XmlNode(TiXml::NextSibling(m_node)); }
32 bool IsValid()
const {
return m_node !=
nullptr; }
33 operator bool()
const {
return m_node !=
nullptr; }
35 bool IsElement()
const {
return TiXml::IsElement(m_node); }
37 bool HasName(
const char* name)
const {
return m_node ? TiXml::HasName(m_node, name) : false; }
39 const char* GetName()
const {
return m_node ? TiXml::GetName(m_node) : nullptr; }
41 bool HasValue()
const {
return TiXml::HasValue(m_node); }
43 bool HasValue(
const char* name)
const {
return TiXml::HasValue(m_node, name); }
45 const char* GetValue()
const {
return TiXml::GetValue(m_node); }
47 void CreateValue(XmlNode node,
const char* value) { TiXml::CreateValue(node.m_node, value); }
49 XmlNode CreateChild(
const char* name) {
return XmlNode(TiXml::CreateChild(m_node, name)); }
51 XmlNode GetChild(
const char* name) {
return m_node ? XmlNode(TiXml::GetChild(m_node, name)) : XmlNode(nullptr); }
54 bool ReadNode(T& value) {
return m_node ? Read(*
this, value) : false; }
56 template<
typename T,
typename U>
57 bool ReadNode(T& value,
const U& enumNames) {
return m_node ? Read(*
this, value, enumNames) : false; }
60 void WriteNode(
const T& value) { Write(*
this, value); }
62 template<
typename T,
typename U>
63 void WriteNode(
const T& value,
const U& enumNames) { Write(*
this, value, enumNames); }
66 bool ReadChild(
const char* name, T& value) {
return GetChild(name).ReadNode(value); }
68 template<
typename T,
typename U>
69 bool ReadChild(
const char* name, T& value,
const U& enumNames) {
return GetChild(name).ReadNode(value, enumNames); }
72 void WriteChild(
const char* name,
const T& value) { CreateChild(name).WriteNode(value); }
74 template<
typename T,
typename U>
75 void WriteChild(
const char* name,
const T& value,
const U& enumNames) { CreateChild(name).WriteNode(value, enumNames); }
82 #define KY_READ_CHILD_VALUE(child_, name_, value_) \
84 if (child_.HasName(name_)) \
86 if (Kaim::Read(child_, value_) == false) \
88 KY_LOG_ERROR(("[NavGenProj] Read <%s> FAILED", name_)); \
96 #define KY_READ_CHILD_ENUM(child_, name_, value_, enumNames_) \
98 if (child_.HasName(name_)) \
100 if (Kaim::Read(child_, value_, enumNames_) == false) \
102 KY_LOG_ERROR(("[NavGenProj] Read <%s> FAILED", name_)); \
109 #define KY_READ_CHILD_FUNC(child_, name_, func_) \
111 if (child_.HasName(name_)) \
113 if ((func_) == false) \
115 KY_LOG_ERROR(("[NavGenProj] Read <%s> FAILED", name_)); \
126 XmlDoc(
const char* path) { m_doc = TiXml::CreateDoc(path); }
127 XmlNode Root() {
return XmlNode((TiXmlNode*)m_doc); }
128 bool Load() {
return TiXml::LoadDoc(m_doc); }
129 bool Save() {
return TiXml::SaveDoc(m_doc); }
130 ~XmlDoc() { TiXml::DestroyDoc(m_doc); }
132 TiXmlDocument* m_doc;
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17