aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-09-10 20:27:39 +0000
committerMike Buland <eichlan@xagasoft.com>2012-09-10 20:27:39 +0000
commit46542b4d64565fcf46a4d92f63e1bcd4e4b9ccd8 (patch)
tree7e6267ade384d860a7689355126e58f1f1c0b442 /src
parent17829dc5722c5811912dd7dc8806d79cf562893a (diff)
downloadlibbu++-46542b4d64565fcf46a4d92f63e1bcd4e4b9ccd8.tar.gz
libbu++-46542b4d64565fcf46a4d92f63e1bcd4e4b9ccd8.tar.bz2
libbu++-46542b4d64565fcf46a4d92f63e1bcd4e4b9ccd8.tar.xz
libbu++-46542b4d64565fcf46a4d92f63e1bcd4e4b9ccd8.zip
Changed Fmt to use lower case by default and added more helpers.
Diffstat (limited to '')
-rw-r--r--src/stable/fmt.h6
-rw-r--r--src/stable/formatter.cpp12
-rw-r--r--src/tests/print.cpp17
3 files changed, 32 insertions, 3 deletions
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
17 uRadix( 10 ), 17 uRadix( 10 ),
18 uAlign( Right ), 18 uAlign( Right ),
19 bPlus( false ), 19 bPlus( false ),
20 bCaps( true ), 20 bCaps( false ),
21 bTokenize( true ) 21 bTokenize( true )
22 { 22 {
23 } 23 }
@@ -47,7 +47,7 @@ namespace Bu
47 { 47 {
48 } 48 }
49 49
50 static Fmt hex( unsigned int uWidth=0, bool bCaps=true ) 50 static Fmt hex( unsigned int uWidth=0, bool bCaps=false )
51 { 51 {
52 return Fmt( uWidth, 16, Right, false, bCaps, '0' ); 52 return Fmt( uWidth, 16, Right, false, bCaps, '0' );
53 } 53 }
@@ -73,6 +73,8 @@ namespace Bu
73 Fmt &align( Alignment eAlign ); 73 Fmt &align( Alignment eAlign );
74 Fmt &plus( bool bPlus=true ); 74 Fmt &plus( bool bPlus=true );
75 Fmt &caps( bool bCaps=true ); 75 Fmt &caps( bool bCaps=true );
76 Fmt &upper();
77 Fmt &lower();
76 Fmt &tokenize( bool bTokenize=true ); 78 Fmt &tokenize( bool bTokenize=true );
77 79
78 Fmt &left(); 80 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 )
294 return *this; 294 return *this;
295} 295}
296 296
297Bu::Fmt &Bu::Fmt::upper()
298{
299 this->bCaps = true;
300 return *this;
301}
302
303Bu::Fmt &Bu::Fmt::lower()
304{
305 this->bCaps = false;
306 return *this;
307}
308
297Bu::Fmt &Bu::Fmt::tokenize( bool bTokenize ) 309Bu::Fmt &Bu::Fmt::tokenize( bool bTokenize )
298{ 310{
299 this->bTokenize = bTokenize; 311 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 @@
1#include <bu/sio.h> 1#include <bu/sio.h>
2 2
3int upper()
4{
5 static int iVal = 1;
6 return iVal++;
7}
8
3int main() 9int main()
4{ 10{
5 Bu::print("hello there %1!\n").arg("Bob"); 11 Bu::print("hello there %1!\n").arg("Bob");
6 12
7 Bu::println("This is %1 crazy, like %2 times over!"). 13 Bu::println("This is %1 crazy, like %2 times over!").
8 arg("totally").arg( 47.2 ); 14 arg("totally").arg( 47.2 ).end();
9 Bu::println("This is unsubstituted?"); 15 Bu::println("This is unsubstituted?");
10 16
11 Bu::serr << "This is error text." << Bu::serr.nl; 17 Bu::serr << "This is error text." << Bu::serr.nl;
12 Bu::println( Bu::serr, "This is also error text?"); 18 Bu::println( Bu::serr, "This is also error text?");
13 19
20 Bu::println("This is %{1}000 - %{1}.").arg( 34, Bu::Fmt().width(10).fill('0') );
21
22 Bu::String s = Bu::String("hello %1").arg("bob %1").end().toLower().arg("yo");
23
24 Bu::println( s );
25 Bu::println("Hello %%1");
26
27 Bu::println("Nums: %1, %2, %3, %4, %5, %6").arg( upper() ).arg( upper() ).arg( upper() ).arg( upper() ).arg( upper() ).arg( upper() );
28
14 return 0; 29 return 0;
15} 30}
16 31