aboutsummaryrefslogtreecommitdiff
path: root/src/string.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/string.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/string.cpp b/src/string.cpp
index 5834da1..edc45f9 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -443,7 +443,7 @@ Bu::String Bu::String::replace( const Bu::String &fnd,
443 const_iterator o = begin(); 443 const_iterator o = begin();
444 while( true ) 444 while( true )
445 { 445 {
446 const_iterator i = o.find( fnd ); 446 const_iterator i = o.find( fnd, fnd.getSize() );
447 if( !i ) 447 if( !i )
448 { 448 {
449 out.append( o ); 449 out.append( o );
@@ -994,7 +994,7 @@ Bu::String::const_iterator Bu::String::find( const String &rStr,
994 if( !iStart ) iStart = begin(); 994 if( !iStart ) iStart = begin();
995 for( ; iStart; iStart++ ) 995 for( ; iStart; iStart++ )
996 { 996 {
997 if( iStart.compare( rStr, rStr.getSize() ) ) 997 if( iStart.compare( rStr ) )
998 return iStart; 998 return iStart;
999 } 999 }
1000 return end(); 1000 return end();
@@ -1133,6 +1133,36 @@ void Bu::String::trimBack( long iAmnt )
1133 core->nLength -= iAmnt; 1133 core->nLength -= iAmnt;
1134} 1134}
1135 1135
1136Bu::String Bu::String::trimWhitespace() const
1137{
1138 if( core->nLength == 0 )
1139 return "";
1140 const_iterator i = begin();
1141 for( ; i && (*i == ' ' || *i == '\t' || *i == '\n' || *i == '\r'); i++ ) { }
1142 if( !i )
1143 return "";
1144
1145 const_iterator e = i;
1146 for( ; e; e++ )
1147 {
1148 if( *e == ' ' || *e == '\t' || *e == '\n' || *e == '\r' )
1149 {
1150 const_iterator t = e;
1151 for( ; t && (*t == ' ' || *t == '\t' || *t == '\n' || *t == '\r'); t++ ) { }
1152 if( t )
1153 {
1154 e = t;
1155 }
1156 else
1157 {
1158 break;
1159 }
1160 }
1161 }
1162
1163 return Bu::String( i, e );
1164}
1165
1136Bu::String::iterator Bu::String::begin() 1166Bu::String::iterator Bu::String::begin()
1137{ 1167{
1138 if( core->nLength == 0 ) 1168 if( core->nLength == 0 )