From 2c80227339538154ad0869e746f52db805325589 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 25 Oct 2009 05:13:21 -0400 Subject: Added basic foundation for XML reporting --- src/utils.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/utils.h') 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 << "'; + } + + string guard(const string& str) { + std::ostringstream buf; + foreach (const char& ch, str) { + switch (ch) { + case '<': + buf << "<"; + break; + case '>': + buf << ">"; + break; + case '&': + buf << "&"; + break; + default: + buf << ch; + break; + } + } + return buf.str(); + } +}; + extern const string version; } // namespace ledger -- cgit v1.2.3