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 { namespace ledger {
straccstream _accum;
std::ostringstream _accum_buffer;
std::streamsize straccbuf::xsputn(const char * s, std::streamsize num) std::streamsize straccbuf::xsputn(const char * s, std::streamsize num)
{ {
if (index == 0) { if (index == 0) {

View file

@ -83,6 +83,14 @@ public:
#define ACCUM(obj) (static_cast<const straccstream&>(obj).str()) #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 } // namespace ledger
#endif // _ACCUM_H #endif // _ACCUM_H

View file

@ -67,10 +67,8 @@ void draft_t::xact_template_t::dump(std::ostream& out) const
<< std::endl; << std::endl;
} else { } else {
foreach (const post_template_t& post, posts) { foreach (const post_template_t& post, posts) {
straccstream accum;
out << std::endl out << std::endl
<< ACCUM(accum << _("[Posting \"%1\"]") << STR(_("[Posting \"%1\"]") << (post.from ? _("from") : _("to")))
<< (post.from ? _("from") : _("to")))
<< std::endl; << std::endl;
if (post.account_mask) if (post.account_mask)