diff options
Diffstat (limited to 'src/string.h')
-rw-r--r-- | src/string.h | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/src/string.h b/src/string.h index 3ac161b..2874e37 100644 --- a/src/string.h +++ b/src/string.h | |||
@@ -117,6 +117,13 @@ namespace Bu | |||
117 | iPos = i.iPos; | 117 | iPos = i.iPos; |
118 | return *this; | 118 | return *this; |
119 | } | 119 | } |
120 | |||
121 | const_iterator &operator=( const iterator &i ) | ||
122 | { | ||
123 | pChunk = i.pChunk; | ||
124 | iPos = i.iPos; | ||
125 | return *this; | ||
126 | } | ||
120 | 127 | ||
121 | const_iterator &operator++() | 128 | const_iterator &operator++() |
122 | { | 129 | { |
@@ -203,7 +210,8 @@ namespace Bu | |||
203 | if( *a != *b ) | 210 | if( *a != *b ) |
204 | return false; | 211 | return false; |
205 | } | 212 | } |
206 | 213 | if( (bool)a != (bool)b ) | |
214 | return false; | ||
207 | return true; | 215 | return true; |
208 | } | 216 | } |
209 | 217 | ||
@@ -213,14 +221,11 @@ namespace Bu | |||
213 | const_iterator b = c; | 221 | const_iterator b = c; |
214 | if( a == b ) | 222 | if( a == b ) |
215 | return true; | 223 | return true; |
216 | int j; | 224 | for(int j = 0; j < nLen; a++, b++, j++ ) |
217 | for( j = 0; a && b && j < nLen; a++, b++, j++ ) | ||
218 | { | 225 | { |
219 | if( *a != *b ) | 226 | if( !a || !b || *a != *b ) |
220 | return false; | 227 | return false; |
221 | } | 228 | } |
222 | if( j < nLen ) | ||
223 | return false; | ||
224 | return true; | 229 | return true; |
225 | } | 230 | } |
226 | 231 | ||
@@ -256,7 +261,7 @@ namespace Bu | |||
256 | bool compare( const String &s ) const | 261 | bool compare( const String &s ) const |
257 | { | 262 | { |
258 | if( !pChunk ) return false; | 263 | if( !pChunk ) return false; |
259 | return compare( s.begin(), s.getSize() ); | 264 | return compare( s.begin() ); |
260 | } | 265 | } |
261 | 266 | ||
262 | bool compare( const String &s, int nLen ) const | 267 | bool compare( const String &s, int nLen ) const |
@@ -442,10 +447,10 @@ namespace Bu | |||
442 | return pChunk != NULL; | 447 | return pChunk != NULL; |
443 | } | 448 | } |
444 | 449 | ||
445 | bool compare( const iterator &c ) const | 450 | bool compare( const const_iterator &c ) const |
446 | { | 451 | { |
447 | iterator a = *this; | 452 | const_iterator a( *this ); |
448 | iterator b = c; | 453 | const_iterator b = c; |
449 | if( a == b ) | 454 | if( a == b ) |
450 | return true; | 455 | return true; |
451 | for(; a && b; a++, b++ ) | 456 | for(; a && b; a++, b++ ) |
@@ -453,23 +458,22 @@ namespace Bu | |||
453 | if( *a != *b ) | 458 | if( *a != *b ) |
454 | return false; | 459 | return false; |
455 | } | 460 | } |
461 | if( (bool)a != (bool)b ) | ||
462 | return false; | ||
456 | return true; | 463 | return true; |
457 | } | 464 | } |
458 | 465 | ||
459 | bool compare( const iterator &c, int nLen ) const | 466 | bool compare( const const_iterator &c, int nLen ) const |
460 | { | 467 | { |
461 | iterator a = *this; | 468 | const_iterator a( *this ); |
462 | iterator b = c; | 469 | const_iterator b = c; |
463 | if( a == b ) | 470 | if( a == b ) |
464 | return true; | 471 | return true; |
465 | int j; | 472 | for(int j = 0; j < nLen; a++, b++, j++ ) |
466 | for( j = 0; a && b && j < nLen; a++, b++, j++ ) | ||
467 | { | 473 | { |
468 | if( *a != *b ) | 474 | if( !a || !b || *a != *b ) |
469 | return false; | 475 | return false; |
470 | } | 476 | } |
471 | if( j < nLen ) | ||
472 | return false; | ||
473 | return true; | 477 | return true; |
474 | } | 478 | } |
475 | 479 | ||
@@ -505,7 +509,7 @@ namespace Bu | |||
505 | bool compare( const String &s ) const | 509 | bool compare( const String &s ) const |
506 | { | 510 | { |
507 | if( !pChunk ) return false; | 511 | if( !pChunk ) return false; |
508 | return compare( s.begin(), s.getSize() ); | 512 | return compare( s.begin() ); |
509 | } | 513 | } |
510 | 514 | ||
511 | bool compare( const String &s, int nLen ) const | 515 | bool compare( const String &s, int nLen ) const |
@@ -924,8 +928,9 @@ namespace Bu | |||
924 | */ | 928 | */ |
925 | void trimFront( long nAmnt ); | 929 | void trimFront( long nAmnt ); |
926 | 930 | ||
927 | // void trimBack( char c ); | ||
928 | void trimBack( long iAmnt ); | 931 | void trimBack( long iAmnt ); |
932 | |||
933 | Bu::String trimWhitespace() const; | ||
929 | 934 | ||
930 | iterator begin(); | 935 | iterator begin(); |
931 | 936 | ||