diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2012-09-05 21:10:05 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2012-09-05 21:10:05 +0000 |
| commit | 912207fe0fa25d21837ced09dcd689c68e449ef7 (patch) | |
| tree | 47f7ebb10e813987b9989ce70efc62cdbe451da8 /src/stable | |
| parent | e5f2e1ce7faeb8fb4609f7291e77d5b682685057 (diff) | |
| download | libbu++-912207fe0fa25d21837ced09dcd689c68e449ef7.tar.gz libbu++-912207fe0fa25d21837ced09dcd689c68e449ef7.tar.bz2 libbu++-912207fe0fa25d21837ced09dcd689c68e449ef7.tar.xz libbu++-912207fe0fa25d21837ced09dcd689c68e449ef7.zip | |
Added extra formatting argument indexing method to Bu::String::FormatProxy.
You can now use %{3} so that arguments can be followed by a digit.
Diffstat (limited to 'src/stable')
| -rw-r--r-- | src/stable/string.cpp | 24 | ||||
| -rw-r--r-- | src/stable/string.h | 1 |
2 files changed, 23 insertions, 2 deletions
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 | |||
| 1269 | else | 1269 | else |
| 1270 | { | 1270 | { |
| 1271 | String sNum; | 1271 | String sNum; |
| 1272 | while( s && *s >= '0' && *s <= '9' ) | 1272 | if( *s == '{' ) |
| 1273 | { | 1273 | { |
| 1274 | sNum += *s; | ||
| 1275 | s++; | 1274 | s++; |
| 1275 | while( s && *s >= '0' && *s <= '9' ) | ||
| 1276 | { | ||
| 1277 | sNum += *s; | ||
| 1278 | s++; | ||
| 1279 | } | ||
| 1280 | if( !s || *s != '}' ) | ||
| 1281 | { | ||
| 1282 | delete[] aArg; | ||
| 1283 | throw Bu::ExceptionBase( | ||
| 1284 | "Argument started with a '{' but terminated " | ||
| 1285 | "with a '%c' instead of '}'.", *s ); | ||
| 1286 | } | ||
| 1287 | s++; | ||
| 1288 | } | ||
| 1289 | else | ||
| 1290 | { | ||
| 1291 | while( s && *s >= '0' && *s <= '9' ) | ||
| 1292 | { | ||
| 1293 | sNum += *s; | ||
| 1294 | s++; | ||
| 1295 | } | ||
| 1276 | } | 1296 | } |
| 1277 | int iIndex = strtol( sNum.getStr(), 0, 10 )-1; | 1297 | int iIndex = strtol( sNum.getStr(), 0, 10 )-1; |
| 1278 | if( iIndex < 0 || iIndex >= iCount ) | 1298 | 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 | |||
| 950 | class FormatProxyEndAction | 950 | class FormatProxyEndAction |
| 951 | { | 951 | { |
| 952 | public: | 952 | public: |
| 953 | virtual ~FormatProxyEndAction() { }; | ||
| 953 | virtual void operator()( const Bu::String &sFinal )=0; | 954 | virtual void operator()( const Bu::String &sFinal )=0; |
| 954 | }; | 955 | }; |
| 955 | 956 | ||
