diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-03-31 14:23:55 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-03-31 14:23:55 +0000 |
commit | db45c881d98f2288aa26960e5eae6070f792b82a (patch) | |
tree | 21c3a259c7dcb9312d12acfaef2e76fd910d4de1 /src | |
parent | 85315f2cc85a0c44055cd94c1b7de8cfe11b46e1 (diff) | |
download | libbu++-db45c881d98f2288aa26960e5eae6070f792b82a.tar.gz libbu++-db45c881d98f2288aa26960e5eae6070f792b82a.tar.bz2 libbu++-db45c881d98f2288aa26960e5eae6070f792b82a.tar.xz libbu++-db45c881d98f2288aa26960e5eae6070f792b82a.zip |
Removed the bool cast operator from FBasicString. It turns out it was causing
way, way, way more problems than it solved. A number of libbu++ tests were
inacurate because of it, there were problems in several other programs, and
there may be more that have problems we haven't found yet because of this.
This will most likely cause complitaion errors, especially in places we didn't
expect, where strings were being stored into or passed as integers and the like.
In cases where you were just testing a string, just call the "isSet()" function,
which is functionally equivellent to the old bool cast operator.
Diffstat (limited to '')
-rw-r--r-- | src/csvreader.cpp | 3 | ||||
-rw-r--r-- | src/fbasicstring.h | 5 | ||||
-rw-r--r-- | src/formatter.cpp | 2 | ||||
-rw-r--r-- | src/formatter.h | 4 | ||||
-rw-r--r-- | src/optparser.cpp | 14 | ||||
-rw-r--r-- | src/tafwriter.cpp | 2 | ||||
-rw-r--r-- | src/tests/fstrstd.cpp | 2 | ||||
-rw-r--r-- | src/tools/myriad.cpp | 4 | ||||
-rw-r--r-- | src/unit/fstring.unit | 2 | ||||
-rw-r--r-- | src/unit/hash.unit | 8 |
10 files changed, 25 insertions, 21 deletions
diff --git a/src/csvreader.cpp b/src/csvreader.cpp index b045773..c63fe06 100644 --- a/src/csvreader.cpp +++ b/src/csvreader.cpp | |||
@@ -71,6 +71,9 @@ Bu::FString Bu::CsvReader::decodeExcel( Bu::FString::iterator &i ) | |||
71 | 71 | ||
72 | for(; i && (*i == ' ' || *i == '\t'); i++ ) { } | 72 | for(; i && (*i == ' ' || *i == '\t'); i++ ) { } |
73 | 73 | ||
74 | if( !i ) | ||
75 | return sRet; | ||
76 | |||
74 | if( *i == '\"' ) | 77 | if( *i == '\"' ) |
75 | { | 78 | { |
76 | for( i++ ; i; i++ ) | 79 | for( i++ ; i; i++ ) |
diff --git a/src/fbasicstring.h b/src/fbasicstring.h index 4907d61..e965de8 100644 --- a/src/fbasicstring.h +++ b/src/fbasicstring.h | |||
@@ -335,7 +335,7 @@ namespace Bu | |||
335 | if( !pChunk ) return false; | 335 | if( !pChunk ) return false; |
336 | return pChunk->pData[iPos] != c; | 336 | return pChunk->pData[iPos] != c; |
337 | } | 337 | } |
338 | 338 | ||
339 | operator bool() const | 339 | operator bool() const |
340 | { | 340 | { |
341 | return pChunk != NULL; | 341 | return pChunk != NULL; |
@@ -1598,11 +1598,12 @@ namespace Bu | |||
1598 | return pFirst->pData; | 1598 | return pFirst->pData; |
1599 | } | 1599 | } |
1600 | */ | 1600 | */ |
1601 | 1601 | /* | |
1602 | operator bool() const | 1602 | operator bool() const |
1603 | { | 1603 | { |
1604 | return (core->pFirst != NULL); | 1604 | return (core->pFirst != NULL); |
1605 | } | 1605 | } |
1606 | */ | ||
1606 | 1607 | ||
1607 | bool isSet() const | 1608 | bool isSet() const |
1608 | { | 1609 | { |
diff --git a/src/formatter.cpp b/src/formatter.cpp index 7ebe256..3e0f41e 100644 --- a/src/formatter.cpp +++ b/src/formatter.cpp | |||
@@ -459,7 +459,7 @@ Bu::Formatter &Bu::operator>>( Bu::Formatter &f, long double &flt ) | |||
459 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, bool &b ) | 459 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, bool &b ) |
460 | { | 460 | { |
461 | Bu::FString sStr = f.readToken(); | 461 | Bu::FString sStr = f.readToken(); |
462 | if( !sStr ) | 462 | if( !sStr.isSet() ) |
463 | return f; | 463 | return f; |
464 | char c = *sStr.begin(); | 464 | char c = *sStr.begin(); |
465 | if( c == 'y' || c == 'Y' || c == 't' || c == 'T' ) | 465 | if( c == 'y' || c == 'Y' || c == 't' || c == 'T' ) |
diff --git a/src/formatter.h b/src/formatter.h index ec84be5..47592ad 100644 --- a/src/formatter.h +++ b/src/formatter.h | |||
@@ -204,7 +204,7 @@ namespace Bu | |||
204 | template<typename type> | 204 | template<typename type> |
205 | void iparse( type &i, const Bu::FString &sBuf ) | 205 | void iparse( type &i, const Bu::FString &sBuf ) |
206 | { | 206 | { |
207 | if( !sBuf ) | 207 | if( !sBuf.isSet() ) |
208 | return; | 208 | return; |
209 | if( sBuf[0] != '+' && sBuf[0] != '-' && | 209 | if( sBuf[0] != '+' && sBuf[0] != '-' && |
210 | (sBuf[0] < '0' && sBuf[0] > '9') ) | 210 | (sBuf[0] < '0' && sBuf[0] > '9') ) |
@@ -230,7 +230,7 @@ namespace Bu | |||
230 | template<typename type> | 230 | template<typename type> |
231 | void uparse( type &i, const Bu::FString &sBuf ) | 231 | void uparse( type &i, const Bu::FString &sBuf ) |
232 | { | 232 | { |
233 | if( !sBuf ) | 233 | if( !sBuf.isSet() ) |
234 | return; | 234 | return; |
235 | if( sBuf[0] != '+' && | 235 | if( sBuf[0] != '+' && |
236 | (sBuf[0] < '0' && sBuf[0] > '9') ) | 236 | (sBuf[0] < '0' && sBuf[0] > '9') ) |
diff --git a/src/optparser.cpp b/src/optparser.cpp index bbac9d5..53efe92 100644 --- a/src/optparser.cpp +++ b/src/optparser.cpp | |||
@@ -53,7 +53,7 @@ void Bu::OptParser::parse( int argc, char **argv ) | |||
53 | { | 53 | { |
54 | Bu::StrArray aParams( iCount ); | 54 | Bu::StrArray aParams( iCount ); |
55 | aParams.append( sOpt ); | 55 | aParams.append( sOpt ); |
56 | if( sExtraParam ) | 56 | if( sExtraParam.isSet() ) |
57 | { | 57 | { |
58 | aParams.append( argv[j]+iEPos+1 ); | 58 | aParams.append( argv[j]+iEPos+1 ); |
59 | } | 59 | } |
@@ -65,11 +65,11 @@ void Bu::OptParser::parse( int argc, char **argv ) | |||
65 | } | 65 | } |
66 | else if( pOpt->pProxy ) | 66 | else if( pOpt->pProxy ) |
67 | { | 67 | { |
68 | if( pOpt->sOverride ) | 68 | if( pOpt->sOverride.isSet() ) |
69 | { | 69 | { |
70 | pOpt->pProxy->setValue( pOpt->sOverride ); | 70 | pOpt->pProxy->setValue( pOpt->sOverride ); |
71 | } | 71 | } |
72 | else if( sExtraParam ) | 72 | else if( sExtraParam.isSet() ) |
73 | { | 73 | { |
74 | pOpt->pProxy->setValue( sExtraParam ); | 74 | pOpt->pProxy->setValue( sExtraParam ); |
75 | } | 75 | } |
@@ -117,7 +117,7 @@ void Bu::OptParser::parse( int argc, char **argv ) | |||
117 | } | 117 | } |
118 | else if( pOpt->pProxy ) | 118 | else if( pOpt->pProxy ) |
119 | { | 119 | { |
120 | if( pOpt->sOverride ) | 120 | if( pOpt->sOverride.isSet() ) |
121 | { | 121 | { |
122 | pOpt->pProxy->setValue( pOpt->sOverride ); | 122 | pOpt->pProxy->setValue( pOpt->sOverride ); |
123 | } | 123 | } |
@@ -172,7 +172,7 @@ void Bu::OptParser::addOption( const Option &opt ) | |||
172 | lOption.append( opt ); | 172 | lOption.append( opt ); |
173 | if( opt.cOpt != '\0' ) | 173 | if( opt.cOpt != '\0' ) |
174 | hsOption.insert( opt.cOpt, &lOption.last() ); | 174 | hsOption.insert( opt.cOpt, &lOption.last() ); |
175 | if( opt.sOpt ) | 175 | if( opt.sOpt.isSet() ) |
176 | hlOption.insert( opt.sOpt, &lOption.last() ); | 176 | hlOption.insert( opt.sOpt, &lOption.last() ); |
177 | } | 177 | } |
178 | 178 | ||
@@ -226,7 +226,7 @@ int Bu::OptParser::optHelp( StrArray /*aParams*/ ) | |||
226 | if( (*i).cOpt != '\0' ) | 226 | if( (*i).cOpt != '\0' ) |
227 | bHasShort = true; | 227 | bHasShort = true; |
228 | int lOptSize = (*i).sOpt.getSize() + (*i).sHelpDefault.getSize(); | 228 | int lOptSize = (*i).sOpt.getSize() + (*i).sHelpDefault.getSize(); |
229 | if( (*i).sOpt && iMaxWidth < lOptSize ) | 229 | if( (*i).sOpt.isSet() && iMaxWidth < lOptSize ) |
230 | iMaxWidth = lOptSize; | 230 | iMaxWidth = lOptSize; |
231 | } | 231 | } |
232 | int iIndent = 4; | 232 | int iIndent = 4; |
@@ -260,7 +260,7 @@ int Bu::OptParser::optHelp( StrArray /*aParams*/ ) | |||
260 | } | 260 | } |
261 | if( iMaxWidth > 0 ) | 261 | if( iMaxWidth > 0 ) |
262 | { | 262 | { |
263 | if( (*i).sOpt ) | 263 | if( (*i).sOpt.isSet() ) |
264 | { | 264 | { |
265 | sio << "--" << Fmt(iMaxWidth, Fmt::Left) | 265 | sio << "--" << Fmt(iMaxWidth, Fmt::Left) |
266 | << (*i).sOpt + (*i).sHelpDefault; | 266 | << (*i).sOpt + (*i).sHelpDefault; |
diff --git a/src/tafwriter.cpp b/src/tafwriter.cpp index 7564e74..215cb68 100644 --- a/src/tafwriter.cpp +++ b/src/tafwriter.cpp | |||
@@ -28,7 +28,7 @@ void Bu::TafWriter::writeGroup( const Bu::TafGroup *pRoot ) | |||
28 | { | 28 | { |
29 | ident(); | 29 | ident(); |
30 | sOut.write("{", 1 ); | 30 | sOut.write("{", 1 ); |
31 | if( pRoot->getName() ) | 31 | if( pRoot->getName().isSet() ) |
32 | writeString( pRoot->getName() ); | 32 | writeString( pRoot->getName() ); |
33 | sOut.write(":\n", 2 ); | 33 | sOut.write(":\n", 2 ); |
34 | iDepth++; | 34 | iDepth++; |
diff --git a/src/tests/fstrstd.cpp b/src/tests/fstrstd.cpp index 5999ecd..86d7c5c 100644 --- a/src/tests/fstrstd.cpp +++ b/src/tests/fstrstd.cpp | |||
@@ -12,5 +12,5 @@ int main() | |||
12 | { | 12 | { |
13 | Bu::FString s("Hey there, dude.\n"); | 13 | Bu::FString s("Hey there, dude.\n"); |
14 | 14 | ||
15 | std::cout << s << 5; | 15 | // std::cout << s << 5; |
16 | } | 16 | } |
diff --git a/src/tools/myriad.cpp b/src/tools/myriad.cpp index 4147579..b3067d2 100644 --- a/src/tools/myriad.cpp +++ b/src/tools/myriad.cpp | |||
@@ -75,7 +75,7 @@ int main( int argc, char *argv[] ) | |||
75 | switch( opts.eMode ) | 75 | switch( opts.eMode ) |
76 | { | 76 | { |
77 | case modeCreate: | 77 | case modeCreate: |
78 | if( !opts.sOutput ) | 78 | if( !opts.sOutput.isSet() ) |
79 | { | 79 | { |
80 | sio << "Please specify an output file to create a stream for." | 80 | sio << "Please specify an output file to create a stream for." |
81 | << sio.nl; | 81 | << sio.nl; |
@@ -90,7 +90,7 @@ int main( int argc, char *argv[] ) | |||
90 | break; | 90 | break; |
91 | 91 | ||
92 | case modeInfo: | 92 | case modeInfo: |
93 | if( !opts.sInput ) | 93 | if( !opts.sInput.isSet() ) |
94 | { | 94 | { |
95 | sio << "Please specify an input file to display info about." | 95 | sio << "Please specify an input file to display info about." |
96 | << sio.nl; | 96 | << sio.nl; |
diff --git a/src/unit/fstring.unit b/src/unit/fstring.unit index fe41ae9..8aaae93 100644 --- a/src/unit/fstring.unit +++ b/src/unit/fstring.unit | |||
@@ -74,7 +74,7 @@ | |||
74 | unitTest( a == "ab" ); | 74 | unitTest( a == "ab" ); |
75 | a += "cdefghijklmnop"; | 75 | a += "cdefghijklmnop"; |
76 | a.remove( 5, 1 ); | 76 | a.remove( 5, 1 ); |
77 | unitTest( a = "abcdeghijklmnop" ); | 77 | unitTest( a == "abcdeghijklmnop" ); |
78 | } | 78 | } |
79 | 79 | ||
80 | {%add1} | 80 | {%add1} |
diff --git a/src/unit/hash.unit b/src/unit/hash.unit index 9edc61e..c0a10e3 100644 --- a/src/unit/hash.unit +++ b/src/unit/hash.unit | |||
@@ -45,13 +45,13 @@ typedef Bu::Hash<int, Bu::FString> IntStrHash; | |||
45 | unitTest( h["Hi"].getValue() == "Yo" ); | 45 | unitTest( h["Hi"].getValue() == "Yo" ); |
46 | 46 | ||
47 | StrStrHash h2(h); | 47 | StrStrHash h2(h); |
48 | unitTest( h2["Hi"].getValue() = "Yo" ); | 48 | unitTest( h2["Hi"].getValue() == "Yo" ); |
49 | unitTest( h2["Bye"].getValue() = "Later" ); | 49 | unitTest( h2["Bye"].getValue() == "Later" ); |
50 | 50 | ||
51 | StrStrHash h3; | 51 | StrStrHash h3; |
52 | h3 = h; | 52 | h3 = h; |
53 | unitTest( h3["Hi"].getValue() = "Yo" ); | 53 | unitTest( h3["Hi"].getValue() == "Yo" ); |
54 | unitTest( h3["Bye"].getValue() = "Later" ); | 54 | unitTest( h3["Bye"].getValue() == "Later" ); |
55 | } | 55 | } |
56 | 56 | ||
57 | {%insert3} | 57 | {%insert3} |