summaryrefslogtreecommitdiff
path: root/src/core/XML.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/XML.cpp')
-rw-r--r--src/core/XML.cpp34
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';
+}
+}
+}