From 912207fe0fa25d21837ced09dcd689c68e449ef7 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 5 Sep 2012 21:10:05 +0000 Subject: Added extra formatting argument indexing method to Bu::String::FormatProxy. You can now use %{3} so that arguments can be followed by a digit. --- src/stable/string.cpp | 24 ++++++++++++++++++++++-- src/stable/string.h | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'src/stable') diff --git a/src/stable/string.cpp b/src/stable/string.cpp index d1f76aa..dd484fd 100644 --- a/src/stable/string.cpp +++ b/src/stable/string.cpp @@ -1269,10 +1269,30 @@ Bu::String Bu::String::FormatProxy::end() const else { String sNum; - while( s && *s >= '0' && *s <= '9' ) + if( *s == '{' ) { - sNum += *s; s++; + while( s && *s >= '0' && *s <= '9' ) + { + sNum += *s; + s++; + } + if( !s || *s != '}' ) + { + delete[] aArg; + throw Bu::ExceptionBase( + "Argument started with a '{' but terminated " + "with a '%c' instead of '}'.", *s ); + } + s++; + } + else + { + while( s && *s >= '0' && *s <= '9' ) + { + sNum += *s; + s++; + } } int iIndex = strtol( sNum.getStr(), 0, 10 )-1; if( iIndex < 0 || iIndex >= iCount ) diff --git a/src/stable/string.h b/src/stable/string.h index c92a704..197821d 100644 --- a/src/stable/string.h +++ b/src/stable/string.h @@ -950,6 +950,7 @@ namespace Bu class FormatProxyEndAction { public: + virtual ~FormatProxyEndAction() { }; virtual void operator()( const Bu::String &sFinal )=0; }; -- cgit v1.2.3