summaryrefslogtreecommitdiff
path: root/src/utils.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-10-25 05:13:21 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-11-09 02:17:26 -0500
commit2c80227339538154ad0869e746f52db805325589 (patch)
tree091188e3ad5c8cc41e3f94285969ef9849a97ac4 /src/utils.h
parent7411c74d6d5bea42cb9fa5b6b0ed90480c954a03 (diff)
downloadfork-ledger-2c80227339538154ad0869e746f52db805325589.tar.gz
fork-ledger-2c80227339538154ad0869e746f52db805325589.tar.bz2
fork-ledger-2c80227339538154ad0869e746f52db805325589.zip
Added basic foundation for XML reporting
Diffstat (limited to 'src/utils.h')
-rw-r--r--src/utils.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h
index 48435844..6bd67146 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -646,6 +646,40 @@ inline string to_hex(uint_least32_t * message_digest, const int len = 1)
return buf.str();
}
+class push_xml
+{
+ std::ostream& out;
+ string tag;
+public:
+ push_xml(std::ostream& _out, const string& _tag) : out(_out), tag(_tag) {
+ out << '<' << tag << '>';
+ }
+ ~push_xml() {
+ out << "</" << tag << '>';
+ }
+
+ string guard(const string& str) {
+ std::ostringstream buf;
+ foreach (const char& ch, str) {
+ switch (ch) {
+ case '<':
+ buf << "&lt;";
+ break;
+ case '>':
+ buf << "&gt;";
+ break;
+ case '&':
+ buf << "&amp;";
+ break;
+ default:
+ buf << ch;
+ break;
+ }
+ }
+ return buf.str();
+ }
+};
+
extern const string version;
} // namespace ledger