summaryrefslogtreecommitdiff
path: root/src/core/XML.cpp
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-08 19:41:54 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-08 19:41:54 +0100
commitb6197efcf5b97ddcaae99425748b2f2e74bde3c3 (patch)
treed2ccb792ad81f4e7a4594a037c35c20c4f82c6a1 /src/core/XML.cpp
parentf0abafd4367b3b5c58dffdab69edce1d867942cb (diff)
parent33b92b72ed160f22dc627e841d5f84de4ebc0c6c (diff)
Merge branch 'master' of somweyr.de:ousia
Diffstat (limited to 'src/core/XML.cpp')
-rw-r--r--src/core/XML.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/core/XML.cpp b/src/core/XML.cpp
new file mode 100644
index 0000000..038cb86
--- /dev/null
+++ b/src/core/XML.cpp
@@ -0,0 +1,39 @@
+
+#include "XML.hpp"
+
+namespace ousia {
+namespace xml {
+
+void Node::serialize(std::ostream& out){
+ out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ doSerialize(out, 0);
+}
+
+void Element::doSerialize(std::ostream& out, unsigned int tabdepth)
+{
+ for (unsigned int t = 0; t < tabdepth; t++) {
+ out << '\t';
+ }
+ out << '<' << name;
+ for (auto &a : attributes) {
+ out << ' ' << a.first << "=\"" << a.second << '\"';
+ }
+ out << ">\n";
+ for (auto &n : children) {
+ n->doSerialize(out, tabdepth + 1);
+ }
+ for (unsigned int t = 0; t < tabdepth; t++) {
+ out << '\t';
+ }
+ out << "</" << name << ">\n";
+}
+
+void Text::doSerialize(std::ostream& out, unsigned int tabdepth)
+{
+ for (unsigned int t = 0; t < tabdepth; t++) {
+ out << '\t';
+ }
+ out << text << '\n';
+}
+}
+}