From 46542b4d64565fcf46a4d92f63e1bcd4e4b9ccd8 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 10 Sep 2012 20:27:39 +0000 Subject: Changed Fmt to use lower case by default and added more helpers. --- src/stable/fmt.h | 6 ++++-- src/stable/formatter.cpp | 12 ++++++++++++ src/tests/print.cpp | 17 ++++++++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/stable/fmt.h b/src/stable/fmt.h index 15d8efc..bcc5240 100644 --- a/src/stable/fmt.h +++ b/src/stable/fmt.h @@ -17,7 +17,7 @@ namespace Bu uRadix( 10 ), uAlign( Right ), bPlus( false ), - bCaps( true ), + bCaps( false ), bTokenize( true ) { } @@ -47,7 +47,7 @@ namespace Bu { } - static Fmt hex( unsigned int uWidth=0, bool bCaps=true ) + static Fmt hex( unsigned int uWidth=0, bool bCaps=false ) { return Fmt( uWidth, 16, Right, false, bCaps, '0' ); } @@ -73,6 +73,8 @@ namespace Bu Fmt &align( Alignment eAlign ); Fmt &plus( bool bPlus=true ); Fmt &caps( bool bCaps=true ); + Fmt &upper(); + Fmt &lower(); Fmt &tokenize( bool bTokenize=true ); Fmt &left(); diff --git a/src/stable/formatter.cpp b/src/stable/formatter.cpp index 2f3c382..a04f7a6 100644 --- a/src/stable/formatter.cpp +++ b/src/stable/formatter.cpp @@ -294,6 +294,18 @@ Bu::Fmt &Bu::Fmt::caps( bool bCaps ) return *this; } +Bu::Fmt &Bu::Fmt::upper() +{ + this->bCaps = true; + return *this; +} + +Bu::Fmt &Bu::Fmt::lower() +{ + this->bCaps = false; + return *this; +} + Bu::Fmt &Bu::Fmt::tokenize( bool bTokenize ) { this->bTokenize = bTokenize; diff --git a/src/tests/print.cpp b/src/tests/print.cpp index 0f9be6b..c6fe053 100644 --- a/src/tests/print.cpp +++ b/src/tests/print.cpp @@ -1,16 +1,31 @@ #include +int upper() +{ + static int iVal = 1; + return iVal++; +} + int main() { Bu::print("hello there %1!\n").arg("Bob"); Bu::println("This is %1 crazy, like %2 times over!"). - arg("totally").arg( 47.2 ); + arg("totally").arg( 47.2 ).end(); Bu::println("This is unsubstituted?"); Bu::serr << "This is error text." << Bu::serr.nl; Bu::println( Bu::serr, "This is also error text?"); + Bu::println("This is %{1}000 - %{1}.").arg( 34, Bu::Fmt().width(10).fill('0') ); + + Bu::String s = Bu::String("hello %1").arg("bob %1").end().toLower().arg("yo"); + + Bu::println( s ); + Bu::println("Hello %%1"); + + Bu::println("Nums: %1, %2, %3, %4, %5, %6").arg( upper() ).arg( upper() ).arg( upper() ).arg( upper() ).arg( upper() ).arg( upper() ); + return 0; } -- cgit v1.2.3