aboutsummaryrefslogtreecommitdiff
path: root/src/xml/XmlNode.cpp
blob: f4b43ea656b6e951a65959c0aa492083092de701 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "cru/xml/XmlNode.hpp"

namespace cru::xml {
void XmlElementNode::AddAttribute(String key, String value) {
  attributes_[std::move(key)] = std::move(value);
}

void XmlElementNode::AddChild(XmlNode* child) {
  assert(child->GetParent() == nullptr);
  children_.push_back(child);
  child->parent_ = this;
}

XmlNode* XmlElementNode::Clone() const {
  XmlElementNode* node = new XmlElementNode(tag_, attributes_);

  for (auto child : children_) {
    node->AddChild(child->Clone());
  }

  return node;
}
}  // namespace cru::xml