summaryrefslogtreecommitdiff
path: root/src/utils.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-11-09 03:42:06 -0500
committerJohn Wiegley <johnw@newartisans.com>2009-11-09 03:42:35 -0500
commit6cdb79e2a611d99fa6e13dd224a92dc8badaf2ac (patch)
tree967464fc8bda9543a108d83d3fc96ecdffb4e04c /src/utils.h
parent2c80227339538154ad0869e746f52db805325589 (diff)
downloadfork-ledger-6cdb79e2a611d99fa6e13dd224a92dc8badaf2ac.tar.gz
fork-ledger-6cdb79e2a611d99fa6e13dd224a92dc8badaf2ac.tar.bz2
fork-ledger-6cdb79e2a611d99fa6e13dd224a92dc8badaf2ac.zip
XML reporting now works via the "xml" command
Diffstat (limited to 'src/utils.h')
-rw-r--r--src/utils.h21
1 files changed, 16 insertions, 5 deletions
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 << "</" << tag << '>';
+ if (! leave_open)
+ out << "</" << tag << '>';
+ }
+
+ 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) {