Added STR() utility function

This commit is contained in:
John Wiegley 2012-02-29 22:11:55 -06:00
parent eac84f5e21
commit 8013e09129
3 changed files with 12 additions and 3 deletions

View file

@ -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) {

View file

@ -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

View file

@ -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)