98 std::multimap<std::string, XNode*> m_children_by_name;
104 void SetName(
const std::string& sName) { m_sName = sName; }
105 [[nodiscard]]
auto GetName()
const ->
const std::string& {
return m_sName; }
107 static const std::string TEXT_ATTRIBUTE;
109 void GetTextValue(T& out)
const
111 GetAttrValue(TEXT_ATTRIBUTE, out);
115 [[nodiscard]]
auto GetAttr(
const std::string& sAttrName)
const
117 auto GetAttr(
const std::string& sAttrName) ->
XNodeValue*;
119 auto GetAttrValue(
const std::string& sName, T& out)
const ->
bool
122 if (pAttr ==
nullptr) {
125 pAttr->GetValue(out);
128 auto PushAttrValue(lua_State* L,
const std::string& sName)
const -> bool;
130 auto GetChildrenBegin() -> XNodes::iterator {
return m_childs.begin(); }
131 [[nodiscard]]
auto GetChildrenBegin()
const -> XNodes::const_iterator
133 return m_childs.begin();
135 auto GetChildrenEnd() -> XNodes::iterator {
return m_childs.end(); }
136 [[nodiscard]]
auto GetChildrenEnd()
const -> XNodes::const_iterator
138 return m_childs.end();
140 [[nodiscard]]
auto ChildrenEmpty()
const ->
bool
142 return m_childs.empty();
146 [[nodiscard]]
auto GetChild(
const std::string& sName)
const ->
const XNode*;
147 auto GetChild(
const std::string& sName) ->
XNode*;
149 auto GetChildValue(
const std::string& sName, T& out)
const ->
bool
151 const XNode* pChild = GetChild(sName);
152 if (pChild ==
nullptr) {
155 pChild->GetTextValue(out);
158 auto PushChildValue(lua_State* L,
const std::string& sName)
const -> bool;
162 auto AppendChild(
const std::string& sName, T value) ->
XNode*
164 XNode* p = AppendChild(sName);
165 p->AppendAttr(XNode::TEXT_ATTRIBUTE, value);
168 auto AppendChild(
const std::string& sName) ->
XNode*
170 auto* p =
new XNode(sName);
171 return AppendChild(p);
174 auto RemoveChild(
XNode* node,
bool bDelete =
true) -> bool;
175 void RemoveChildFromByName(
XNode* node);
176 void RenameChildInByName(
XNode* node);
178 auto AppendAttrFrom(
const std::string& sName,
181 auto AppendAttr(
const std::string& sName) ->
XNodeValue*;
183 auto AppendAttr(
const std::string& sName, T value) ->
XNodeValue*
186 pVal->SetValue(value);
189 auto RemoveAttr(
const std::string& sName) -> bool;
192 explicit XNode(
const std::string& sName);
200 auto operator=(
const XNode& cpy) ->
XNode& =
delete;