From 6cdb79e2a611d99fa6e13dd224a92dc8badaf2ac Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 9 Nov 2009 03:42:06 -0500 Subject: XML reporting now works via the "xml" command --- src/utils.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/utils.h') diff --git a/src/utils.h b/src/utils.h index 6bd67146..bfdee0b2 100644 --- a/src/utils.h +++ b/src/utils.h @@ -649,16 +649,27 @@ inline string to_hex(uint_least32_t * message_digest, const int len = 1) class push_xml { std::ostream& out; - string tag; + string tag; + bool leave_open; + public: - push_xml(std::ostream& _out, const string& _tag) : out(_out), tag(_tag) { - out << '<' << tag << '>'; + push_xml(std::ostream& _out, const string& _tag, bool has_attrs = false, + bool _leave_open = false) + : out(_out), tag(_tag), leave_open(_leave_open) { + out << '<' << tag; + if (! has_attrs) + out << '>'; } ~push_xml() { - out << "'; + if (! leave_open) + out << "'; + } + + void close_attrs() { + out << '>'; } - string guard(const string& str) { + static string guard(const string& str) { std::ostringstream buf; foreach (const char& ch, str) { switch (ch) { -- cgit v1.2.3