diff options
author | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2015-01-06 22:38:49 +0100 |
---|---|---|
committer | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2015-01-06 22:38:49 +0100 |
commit | fd8ce97afb16e17102ec8f109103ed334ad0e939 (patch) | |
tree | be609366b106940252c36bdfb3f02e677e9c3e3a /src/core/XML.cpp | |
parent | 0778a9446dc3475b887d20515165a4dc63ed0cd0 (diff) |
added XML classes including Serialization functions and added a test for it. I tried not to include Managed.hpp to prevent further overhead but I failed miserably.
Diffstat (limited to 'src/core/XML.cpp')
-rw-r--r-- | src/core/XML.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/core/XML.cpp b/src/core/XML.cpp new file mode 100644 index 0000000..ad69ba1 --- /dev/null +++ b/src/core/XML.cpp @@ -0,0 +1,34 @@ + +#include "XML.hpp" + +namespace ousia { +namespace xml { + +void Element::serialize(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->serialize(out, tabdepth + 1); + } + for (unsigned int t = 0; t < tabdepth; t++) { + out << '\t'; + } + out << "</" << name << ">\n"; +} + +void Text::serialize(std::ostream& out, unsigned int tabdepth) +{ + for (unsigned int t = 0; t < tabdepth; t++) { + out << '\t'; + } + out << text << '\n'; +} +} +} |