summaryrefslogtreecommitdiff
path: root/src/core/XML.hpp
diff options
context:
space:
mode:
authorBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-01-09 15:25:13 +0100
committerBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-01-09 15:25:13 +0100
commit302565043bed0dc68bbe5e86ab94d94b15e43424 (patch)
treec4664672d3eaea90f5f4df5ffd59d3417959a491 /src/core/XML.hpp
parent4b8f07b478015196de3db8dbaf91e176cdc4a6f0 (diff)
Added RTTI information for XML classes, made children vector of XML elements private and added name printout to Manager debug graphviz function.
Diffstat (limited to 'src/core/XML.hpp')
-rw-r--r--src/core/XML.hpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/core/XML.hpp b/src/core/XML.hpp
index b4b803d..25c8dae 100644
--- a/src/core/XML.hpp
+++ b/src/core/XML.hpp
@@ -45,6 +45,7 @@
#include <ostream>
#include <vector>
+#include <core/common/Rtti.hpp>
#include <core/managed/Managed.hpp>
#include <core/managed/ManagedContainer.hpp>
@@ -101,19 +102,22 @@ public:
* Additionally it might have other Nodes as children.
*/
class Element : public Node {
+private:
+ ManagedVector<Node> children;
+
public:
const std::string name;
std::map<std::string, std::string> attributes;
- ManagedVector<Node> children;
Element(Manager &mgr, Handle<Element> parent, std::string name)
- : Node(mgr, parent), name(std::move(name))
+ : Node(mgr, parent), children(this), name(std::move(name))
{
}
Element(Manager &mgr, Handle<Element> parent, std::string name,
std::map<std::string, std::string> attributes)
: Node(mgr, parent),
+ children(this),
name(std::move(name)),
attributes(std::move(attributes))
{
@@ -127,6 +131,15 @@ public:
*
*/
void doSerialize(std::ostream &out, unsigned int tabdepth) override;
+
+ const ManagedVector<Node> &getChildren() const { return children; }
+
+ void addChild(Handle<Node> child) { children.push_back(child); }
+
+ void addChildren(std::vector<Handle<Node>> c)
+ {
+ children.insert(children.end(), c.begin(), c.end());
+ }
};
class Text : public Node {
@@ -145,5 +158,11 @@ public:
void doSerialize(std::ostream &out, unsigned int tabdepth) override;
};
}
+
+namespace RttiTypes {
+extern const Rtti<xml::Node> XMLNode;
+extern const Rtti<xml::Element> XMLElement;
+extern const Rtti<xml::Text> XMLText;
+}
}
#endif