summaryrefslogtreecommitdiff
path: root/src/utils.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-01 01:47:54 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-01 01:47:54 -0400
commitcac7d02dd8fa595722faace8aa84be54b49e554b (patch)
treebf0a061d5331cb27eae79b4bc93f879612288d0f /src/utils.h
parent307a93318029837f1a72e1b6cb5a8000531c875f (diff)
downloadfork-ledger-cac7d02dd8fa595722faace8aa84be54b49e554b.tar.gz
fork-ledger-cac7d02dd8fa595722faace8aa84be54b49e554b.tar.bz2
fork-ledger-cac7d02dd8fa595722faace8aa84be54b49e554b.zip
Added a streaming object for outputting XML strings (convenience wrapper).
Diffstat (limited to 'src/utils.h')
-rw-r--r--src/utils.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h
index 319d6126..39a8dc0e 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -548,6 +548,30 @@ inline void xml_print(std::ostream& out,
out << str;
}
+struct xml_str
+{
+ const string& str;
+ const std::size_t depth;
+
+ xml_str(const string& _str, const std::size_t _depth)
+ : str(_str), depth(_depth) {
+ TRACE_CTOR(xml_str, "const string&, const std::size_t");
+ }
+ xml_str(const xml_str& other)
+ : str(other.str), depth(other.depth) {
+ TRACE_CTOR(xml_str, "copy");
+ }
+ ~xml_str() throw() {
+ TRACE_DTOR(xml_str);
+ }
+};
+
+inline std::ostream& operator<<(std::ostream& out, const xml_str& obj) {
+ xml_space(out, obj.depth);
+ out << obj.str;
+ return out;
+}
+
#define READ_INTO(str, targ, size, var, cond) { \
char * _p = targ; \
var = str.peek(); \