From e5f2e1ce7faeb8fb4609f7291e77d5b682685057 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 5 Sep 2012 20:44:55 +0000 Subject: This'll make *everything* rebuild. String formatters now support the end() call, which will force substitution and return a string. They now also support ending actions, which let us do great stuff like printing stuff out after formatting finished...and other stuff. --- src/stable/string.h | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'src/stable/string.h') diff --git a/src/stable/string.h b/src/stable/string.h index 82b903b..c92a704 100644 --- a/src/stable/string.h +++ b/src/stable/string.h @@ -946,12 +946,21 @@ namespace Bu void flatten() const; bool isFlat() const; + public: + class FormatProxyEndAction + { + public: + virtual void operator()( const Bu::String &sFinal )=0; + }; + class FormatProxy { + friend class Bu::String; + private: + FormatProxy( const String &rFmt, FormatProxyEndAction *pAct=NULL ); + public: - FormatProxy( const String &rFmt ); virtual ~FormatProxy(); - template FormatProxy &arg( const T &x ) { @@ -968,7 +977,8 @@ namespace Bu return *this; } - operator String() const; + String end() const; + operator String() const { return end(); } private: const String &rFmt; @@ -993,20 +1003,32 @@ namespace Bu }; typedef Bu::List ArgList; ArgList lArgs; + FormatProxyEndAction *pAct; + mutable bool bOpen; }; public: template - FormatProxy arg( const ArgType &x ) + FormatProxy arg( const ArgType &x ) const { return FormatProxy( *this ).arg( x ); } template - FormatProxy arg( const ArgType &x, const Bu::Fmt &f ) + FormatProxy arg( const ArgType &x, const Bu::Fmt &f ) const { return FormatProxy( *this ).arg( x, f ); } + + FormatProxy format() const + { + return FormatProxy( *this ); + } + + FormatProxy format( FormatProxyEndAction *pEndAction ) const + { + return FormatProxy( *this, pEndAction ); + } }; template String operator+( const T *pLeft, const String &rRight ) -- cgit v1.2.3