summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-02-29 22:11:55 -0600
committerJohn Wiegley <johnw@newartisans.com>2012-02-29 22:11:55 -0600
commit8013e091292628b3e631fea07342c31f1c36966b (patch)
tree6e3e804c4fba3a416dfa79a890f25381032b8552 /src
parenteac84f5e2184cabad709fbb165d58d0b17f791d0 (diff)
downloadfork-ledger-8013e091292628b3e631fea07342c31f1c36966b.tar.gz
fork-ledger-8013e091292628b3e631fea07342c31f1c36966b.tar.bz2
fork-ledger-8013e091292628b3e631fea07342c31f1c36966b.zip
Added STR() utility function
Diffstat (limited to 'src')
-rw-r--r--src/accum.cc3
-rw-r--r--src/accum.h8
-rw-r--r--src/draft.cc4
3 files changed, 12 insertions, 3 deletions
diff --git a/src/accum.cc b/src/accum.cc
index 8f3d5185..0187995e 100644
--- a/src/accum.cc
+++ b/src/accum.cc
@@ -35,6 +35,9 @@
namespace ledger {
+straccstream _accum;
+std::ostringstream _accum_buffer;
+
std::streamsize straccbuf::xsputn(const char * s, std::streamsize num)
{
if (index == 0) {
diff --git a/src/accum.h b/src/accum.h
index 236a7714..411bcbe6 100644
--- a/src/accum.h
+++ b/src/accum.h
@@ -83,6 +83,14 @@ public:
#define ACCUM(obj) (static_cast<const straccstream&>(obj).str())
+extern straccstream _accum;
+extern std::ostringstream _accum_buffer;
+
+#define STR(msg) \
+ ((_accum_buffer << ACCUM(_accum << msg)), \
+ _accum.clear(), \
+ _accum_buffer.str())
+
} // namespace ledger
#endif // _ACCUM_H
diff --git a/src/draft.cc b/src/draft.cc
index 2b8b45f7..9f9ec6e8 100644
--- a/src/draft.cc
+++ b/src/draft.cc
@@ -67,10 +67,8 @@ void draft_t::xact_template_t::dump(std::ostream& out) const
<< std::endl;
} else {
foreach (const post_template_t& post, posts) {
- straccstream accum;
out << std::endl
- << ACCUM(accum << _("[Posting \"%1\"]")
- << (post.from ? _("from") : _("to")))
+ << STR(_("[Posting \"%1\"]") << (post.from ? _("from") : _("to")))
<< std::endl;
if (post.account_mask)