diff options
author | John Wiegley <johnw@newartisans.com> | 2009-10-27 22:26:13 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-10-27 22:26:13 -0400 |
commit | 58fb65421829de49a3b27800ce54e093d45f0f41 (patch) | |
tree | 18fb188d4bfb45677ec0a660f0b6cd5019601621 /src/format.h | |
parent | 3c30f74931bbe94484da82481eb9d3b788347907 (diff) | |
parent | 6c9cf1237e1e813c2d56ed51a38cc0685614e8e0 (diff) | |
download | ledger-58fb65421829de49a3b27800ce54e093d45f0f41.tar.gz ledger-58fb65421829de49a3b27800ce54e093d45f0f41.tar.bz2 ledger-58fb65421829de49a3b27800ce54e093d45f0f41.zip |
Merge branch 'next'
Diffstat (limited to 'src/format.h')
-rw-r--r-- | src/format.h | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/format.h b/src/format.h index bc513f71..8b2a7965 100644 --- a/src/format.h +++ b/src/format.h @@ -61,7 +61,7 @@ DECLARE_EXCEPTION(format_error, std::runtime_error); */ class format_t : public noncopyable { - struct element_t : public supports_flags<>, public noncopyable + struct element_t : public supports_flags<> { #define ELEMENT_ALIGN_LEFT 0x01 @@ -82,6 +82,21 @@ class format_t : public noncopyable ~element_t() throw() { TRACE_DTOR(element_t); } + element_t(const element_t& elem) : supports_flags<>() { + *this = elem; + } + + element_t& operator=(const element_t& elem) { + if (this != &elem) { + supports_flags<>::operator=(elem); + type = elem.type; + min_width = elem.min_width; + max_width = elem.max_width; + chars = elem.chars; + expr = elem.expr; + } + return *this; + } friend inline void mark_red(std::ostream& out, const element_t * elem) { out.setf(std::ios::left); @@ -114,7 +129,8 @@ public: static bool default_style_changed; private: - static element_t * parse_elements(const string& fmt); + static element_t * parse_elements(const string& fmt, + const optional<format_t&>& tmpl); public: format_t() { @@ -128,8 +144,8 @@ public: TRACE_DTOR(format_t); } - void parse(const string& _format) { - elements.reset(parse_elements(_format)); + void parse(const string& _format, const optional<format_t&>& tmpl = none) { + elements.reset(parse_elements(_format, tmpl)); format_string = _format; } |