From d223fcaba3660e8c4d61c9136311064898e23ae9 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 19 Mar 2011 18:28:10 +0000 Subject: The rest of libbu++ is corrected as far as the now Bu::String toUpper/toLower semantics go as well as switching everything to the new string formatting code. --- src/minimacro.h | 8 ++------ src/tests/cache.cpp | 19 ++++++------------- src/tests/fastcgi.cpp | 8 ++++---- src/tests/fstrformat.cpp | 19 ------------------- src/tests/heap.cpp | 3 +-- src/unit/string.unit | 14 ++++++++++++++ support/findcaseshift.sh | 3 +++ 7 files changed, 30 insertions(+), 44 deletions(-) delete mode 100644 src/tests/fstrformat.cpp create mode 100755 support/findcaseshift.sh diff --git a/src/minimacro.h b/src/minimacro.h index 582e1b0..b6c7c13 100644 --- a/src/minimacro.h +++ b/src/minimacro.h @@ -105,9 +105,7 @@ namespace Bu virtual Bu::String call( const Bu::String &sIn, StrList & ) { - Bu::String sOut( sIn ); - sOut.toUpper(); - return sOut; + return sIn.toUpper(); } }; @@ -119,9 +117,7 @@ namespace Bu virtual Bu::String call( const Bu::String &sIn, StrList & ) { - Bu::String sOut( sIn ); - sOut.toLower(); - return sOut; + return sIn.toLower(); } }; diff --git a/src/tests/cache.cpp b/src/tests/cache.cpp index 243012d..e9dbd86 100644 --- a/src/tests/cache.cpp +++ b/src/tests/cache.cpp @@ -105,9 +105,7 @@ public: Bu::File f( sFile, Bu::File::Write|Bu::File::Create|Bu::File::Truncate ); - Bu::String s; - s.format("%d", num ); - f.write( s ); + f.write( Bu::String("%1").arg( num ) ); } virtual void sync( Bob *, const long & ) @@ -126,16 +124,14 @@ public: virtual Bob *load( const long &key ) { TRACE( key ); - Bu::String sDest; - sDest.format("bobcache/%d", key ); + Bu::String sDest = Bu::String("bobcache/%1").arg( key ); return new Bob( readNum( sDest ) ); } virtual void unload( Bob *pObj, const long &key ) { TRACE( pObj, key ); - Bu::String sDest; - sDest.format("bobcache/%d", key ); + Bu::String sDest = Bu::String("bobcache/%1").arg( key ); writeNum( sDest, pObj->getInt() ); delete pObj; } @@ -144,8 +140,7 @@ public: { TRACE( rSrc ); long id = ++cLastId; - Bu::String sDest; - sDest.format("bobcache/%d", id ); + Bu::String sDest = Bu::String("bobcache/%1").arg( id ); writeNum( sDest, rSrc->getInt() ); return id; } @@ -153,8 +148,7 @@ public: virtual void destroy( Bob *pObj, const long &key ) { TRACE( pObj, key ); - Bu::String sDest; - sDest.format("bobcache/%d", key ); + Bu::String sDest = Bu::String("bobcache/%1").arg( key ); if( !access( sDest.getStr(), F_OK ) ) unlink( sDest.getStr() ); delete pObj; @@ -163,8 +157,7 @@ public: virtual void destroy( const long &key ) { TRACE( pObj, key ); - Bu::String sDest; - sDest.format("bobcache/%d", key ); + Bu::String sDest = Bu::String("bobcache/%1").arg( key ); if( !access( sDest.getStr(), F_OK ) ) unlink( sDest.getStr() ); } diff --git a/src/tests/fastcgi.cpp b/src/tests/fastcgi.cpp index 7ca4ebc..7447a6f 100644 --- a/src/tests/fastcgi.cpp +++ b/src/tests/fastcgi.cpp @@ -43,17 +43,17 @@ public: sOut += getcwd( buf, 2048 ); sOut += ""; sOut += "

Stdin:

"; - sOut.formatAppend("%d bytes
", sStdIn.getSize() );
+		sOut += Bu::String("%1 bytes
").arg( sStdIn.getSize() );
 		Bu::String sL, sR;
 		for( Bu::String::const_iterator i = sStdIn.begin();
 			i; i++ )
 		{
-			sL.formatAppend("%02X ",
-				(unsigned int)((unsigned char)*i) );
+			sL += Bu::String("%1").arg(
+					(unsigned int)((unsigned char)*i), Bu::Fmt::hex().width(2).fill('0') );
 			if( *i < 27 )
 				sR += ". ";
 			else
-				sR.formatAppend("&#%d; ",
+				sR += Bu::String("&#%1; ").arg(
 					(unsigned int)((unsigned char)*i) );
 			if( sL.getSize()/3 == 8 )
 			{
diff --git a/src/tests/fstrformat.cpp b/src/tests/fstrformat.cpp
deleted file mode 100644
index a911a8f..0000000
--- a/src/tests/fstrformat.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
- *
- * This file is part of the libbu++ library and is released under the
- * terms of the license contained in the file LICENSE.
- */
-
-#include "bu/string.h"
-#include 
-
-int main()
-{
-	Bu::String s;
-
-	s.format("%d, %f, \'%s\'", 144, 12.5, "bob" );
-
-	printf("test:  %s\n", s.getStr() );
-}
-
diff --git a/src/tests/heap.cpp b/src/tests/heap.cpp
index 14da55a..520a57f 100644
--- a/src/tests/heap.cpp
+++ b/src/tests/heap.cpp
@@ -41,8 +41,7 @@ typedef struct num
 void printHeap( Bu::Heap &h, int j )
 {
 //	return;
-	Bu::String sFName;
-	sFName.format("graph-step-%02d.dot", j );
+	Bu::String sFName = Bu::String("graph-step-%1.dot").arg( j, Bu::Fmt().width(2).fill('0') );
 	Bu::File fOut( sFName, Bu::File::WriteNew );
 	Bu::Formatter f( fOut );
 	f << "Graph step: " << j << ", total size: " << h.getSize() << f.nl;
diff --git a/src/unit/string.unit b/src/unit/string.unit
index d38aa54..8f65c70 100644
--- a/src/unit/string.unit
+++ b/src/unit/string.unit
@@ -407,6 +407,20 @@ suite String
 		unitTest( m1 == m2 );
 		unitTest( m1 == "\x03\xF0\x9C\xA4\xF5\x8A\xC8\xCA\x0E" );
 	}
+
+	test toUpper1
+	{
+		Bu::String s1("HeLlO ThErE, HoW ArE YoU DoInG?");
+		unitTest( s1.toUpper() == "HELLO THERE, HOW ARE YOU DOING?" );
+		unitTest( s1 == "HeLlO ThErE, HoW ArE YoU DoInG?" );
+	}
+
+	test toLower1
+	{
+		Bu::String s1("HeLlO ThErE, HoW ArE YoU DoInG?");
+		unitTest( s1.toLower() == "hello there, how are you doing?" );
+		unitTest( s1 == "HeLlO ThErE, HoW ArE YoU DoInG?" );
+	}
 }
 // 03F09CA4F58AC8CA0E80F0D9D409D0A60700A192270004BC3A99E91D0001034F544603362E35013103313130019CA4F58AC8CA0E0002830800002C4200008AC200EBF7D9D4090127BB010000E3
 // 
diff --git a/support/findcaseshift.sh b/support/findcaseshift.sh
new file mode 100755
index 0000000..75646ae
--- /dev/null
+++ b/support/findcaseshift.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+grep 'to\(Lower\|Upper\)' -o $(find -iname *.cpp) $(find -iname *.h) 2>&1 | grep -v '.svn' | sort | uniq
-- 
cgit v1.2.3