diff options
| author | Li Jin <dragon-fly@qq.com> | 2022-11-15 17:23:46 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2022-11-15 17:52:09 +0800 |
| commit | 94f8330613877b3582d32bd11abd83a97b4399ad (patch) | |
| tree | 5359de314be1ebde17f8d1e48632a97d18f9e50f /src/3rdParty/efsw/String.cpp | |
| parent | 60f8f00a022ac08701792b2897b72d8c99b50f52 (diff) | |
| download | yuescript-94f8330613877b3582d32bd11abd83a97b4399ad.tar.gz yuescript-94f8330613877b3582d32bd11abd83a97b4399ad.tar.bz2 yuescript-94f8330613877b3582d32bd11abd83a97b4399ad.zip | |
adding -w option to Yuescript tool.
Diffstat (limited to 'src/3rdParty/efsw/String.cpp')
| -rwxr-xr-x | src/3rdParty/efsw/String.cpp | 669 |
1 files changed, 669 insertions, 0 deletions
diff --git a/src/3rdParty/efsw/String.cpp b/src/3rdParty/efsw/String.cpp new file mode 100755 index 0000000..8c9a3cc --- /dev/null +++ b/src/3rdParty/efsw/String.cpp | |||
| @@ -0,0 +1,669 @@ | |||
| 1 | #include <efsw/String.hpp> | ||
| 2 | #include <efsw/Utf.hpp> | ||
| 3 | #include <iterator> | ||
| 4 | |||
| 5 | namespace efsw { | ||
| 6 | |||
| 7 | const std::size_t String::InvalidPos = StringType::npos; | ||
| 8 | |||
| 9 | std::vector<std::string> String::split( const std::string& str, const char& splitchar, | ||
| 10 | const bool& pushEmptyString ) { | ||
| 11 | std::vector<std::string> tmp; | ||
| 12 | std::string tmpstr; | ||
| 13 | |||
| 14 | for ( size_t i = 0; i < str.size(); i++ ) { | ||
| 15 | if ( str[i] == splitchar ) { | ||
| 16 | if ( pushEmptyString || tmpstr.size() ) { | ||
| 17 | tmp.push_back( tmpstr ); | ||
| 18 | tmpstr = ""; | ||
| 19 | } | ||
| 20 | } else { | ||
| 21 | tmpstr += str[i]; | ||
| 22 | } | ||
| 23 | } | ||
| 24 | |||
| 25 | if ( tmpstr.size() ) { | ||
| 26 | tmp.push_back( tmpstr ); | ||
| 27 | } | ||
| 28 | |||
| 29 | return tmp; | ||
| 30 | } | ||
| 31 | |||
| 32 | std::vector<String> String::split( const String& str, const Uint32& splitchar, | ||
| 33 | const bool& pushEmptyString ) { | ||
| 34 | std::vector<String> tmp; | ||
| 35 | String tmpstr; | ||
| 36 | |||
| 37 | for ( size_t i = 0; i < str.size(); i++ ) { | ||
| 38 | if ( str[i] == splitchar ) { | ||
| 39 | if ( pushEmptyString || tmpstr.size() ) { | ||
| 40 | tmp.push_back( tmpstr ); | ||
| 41 | tmpstr = ""; | ||
| 42 | } | ||
| 43 | } else { | ||
| 44 | tmpstr += str[i]; | ||
| 45 | } | ||
| 46 | } | ||
| 47 | |||
| 48 | if ( tmpstr.size() ) { | ||
| 49 | tmp.push_back( tmpstr ); | ||
| 50 | } | ||
| 51 | |||
| 52 | return tmp; | ||
| 53 | } | ||
| 54 | |||
| 55 | int String::strStartsWith( const std::string& start, const std::string& str ) { | ||
| 56 | int pos = -1; | ||
| 57 | size_t size = start.size(); | ||
| 58 | |||
| 59 | if ( str.size() >= size ) { | ||
| 60 | for ( std::size_t i = 0; i < size; i++ ) { | ||
| 61 | if ( start[i] == str[i] ) { | ||
| 62 | pos = (int)i; | ||
| 63 | } else { | ||
| 64 | pos = -1; | ||
| 65 | break; | ||
| 66 | } | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | return pos; | ||
| 71 | } | ||
| 72 | |||
| 73 | int String::strStartsWith( const String& start, const String& str ) { | ||
| 74 | int pos = -1; | ||
| 75 | size_t size = start.size(); | ||
| 76 | |||
| 77 | if ( str.size() >= size ) { | ||
| 78 | for ( std::size_t i = 0; i < size; i++ ) { | ||
| 79 | if ( start[i] == str[i] ) { | ||
| 80 | pos = (int)i; | ||
| 81 | } else { | ||
| 82 | pos = -1; | ||
| 83 | break; | ||
| 84 | } | ||
| 85 | } | ||
| 86 | } | ||
| 87 | |||
| 88 | return pos; | ||
| 89 | } | ||
| 90 | |||
| 91 | String::String() {} | ||
| 92 | |||
| 93 | String::String( char ansiChar, const std::locale& locale ) { | ||
| 94 | mString += Utf32::DecodeAnsi( ansiChar, locale ); | ||
| 95 | } | ||
| 96 | |||
| 97 | #ifndef EFSW_NO_WIDECHAR | ||
| 98 | String::String( wchar_t wideChar ) { | ||
| 99 | mString += Utf32::DecodeWide( wideChar ); | ||
| 100 | } | ||
| 101 | #endif | ||
| 102 | |||
| 103 | String::String( StringBaseType utf32Char ) { | ||
| 104 | mString += utf32Char; | ||
| 105 | } | ||
| 106 | |||
| 107 | String::String( const char* uf8String ) { | ||
| 108 | if ( uf8String ) { | ||
| 109 | std::size_t length = strlen( uf8String ); | ||
| 110 | |||
| 111 | if ( length > 0 ) { | ||
| 112 | mString.reserve( length + 1 ); | ||
| 113 | |||
| 114 | Utf8::ToUtf32( uf8String, uf8String + length, std::back_inserter( mString ) ); | ||
| 115 | } | ||
| 116 | } | ||
| 117 | } | ||
| 118 | |||
| 119 | String::String( const std::string& utf8String ) { | ||
| 120 | mString.reserve( utf8String.length() + 1 ); | ||
| 121 | |||
| 122 | Utf8::ToUtf32( utf8String.begin(), utf8String.end(), std::back_inserter( mString ) ); | ||
| 123 | } | ||
| 124 | |||
| 125 | String::String( const char* ansiString, const std::locale& locale ) { | ||
| 126 | if ( ansiString ) { | ||
| 127 | std::size_t length = strlen( ansiString ); | ||
| 128 | if ( length > 0 ) { | ||
| 129 | mString.reserve( length + 1 ); | ||
| 130 | Utf32::FromAnsi( ansiString, ansiString + length, std::back_inserter( mString ), | ||
| 131 | locale ); | ||
| 132 | } | ||
| 133 | } | ||
| 134 | } | ||
| 135 | |||
| 136 | String::String( const std::string& ansiString, const std::locale& locale ) { | ||
| 137 | mString.reserve( ansiString.length() + 1 ); | ||
| 138 | Utf32::FromAnsi( ansiString.begin(), ansiString.end(), std::back_inserter( mString ), locale ); | ||
| 139 | } | ||
| 140 | |||
| 141 | #ifndef EFSW_NO_WIDECHAR | ||
| 142 | String::String( const wchar_t* wideString ) { | ||
| 143 | if ( wideString ) { | ||
| 144 | std::size_t length = std::wcslen( wideString ); | ||
| 145 | if ( length > 0 ) { | ||
| 146 | mString.reserve( length + 1 ); | ||
| 147 | Utf32::FromWide( wideString, wideString + length, std::back_inserter( mString ) ); | ||
| 148 | } | ||
| 149 | } | ||
| 150 | } | ||
| 151 | |||
| 152 | String::String( const std::wstring& wideString ) { | ||
| 153 | mString.reserve( wideString.length() + 1 ); | ||
| 154 | Utf32::FromWide( wideString.begin(), wideString.end(), std::back_inserter( mString ) ); | ||
| 155 | } | ||
| 156 | #endif | ||
| 157 | |||
| 158 | String::String( const StringBaseType* utf32String ) { | ||
| 159 | if ( utf32String ) | ||
| 160 | mString = utf32String; | ||
| 161 | } | ||
| 162 | |||
| 163 | String::String( const StringType& utf32String ) : mString( utf32String ) {} | ||
| 164 | |||
| 165 | String::String( const String& str ) : mString( str.mString ) {} | ||
| 166 | |||
| 167 | String String::fromUtf8( const std::string& utf8String ) { | ||
| 168 | String::StringType utf32; | ||
| 169 | |||
| 170 | utf32.reserve( utf8String.length() + 1 ); | ||
| 171 | |||
| 172 | Utf8::ToUtf32( utf8String.begin(), utf8String.end(), std::back_inserter( utf32 ) ); | ||
| 173 | |||
| 174 | return String( utf32 ); | ||
| 175 | } | ||
| 176 | |||
| 177 | String::operator std::string() const { | ||
| 178 | return toAnsiString(); | ||
| 179 | } | ||
| 180 | |||
| 181 | std::string String::toAnsiString( const std::locale& locale ) const { | ||
| 182 | // Prepare the output string | ||
| 183 | std::string output; | ||
| 184 | output.reserve( mString.length() + 1 ); | ||
| 185 | |||
| 186 | // Convert | ||
| 187 | Utf32::ToAnsi( mString.begin(), mString.end(), std::back_inserter( output ), 0, locale ); | ||
| 188 | |||
| 189 | return output; | ||
| 190 | } | ||
| 191 | |||
| 192 | #ifndef EFSW_NO_WIDECHAR | ||
| 193 | std::wstring String::toWideString() const { | ||
| 194 | // Prepare the output string | ||
| 195 | std::wstring output; | ||
| 196 | output.reserve( mString.length() + 1 ); | ||
| 197 | |||
| 198 | // Convert | ||
| 199 | Utf32::ToWide( mString.begin(), mString.end(), std::back_inserter( output ), 0 ); | ||
| 200 | |||
| 201 | return output; | ||
| 202 | } | ||
| 203 | #endif | ||
| 204 | |||
| 205 | std::string String::toUtf8() const { | ||
| 206 | // Prepare the output string | ||
| 207 | std::string output; | ||
| 208 | output.reserve( mString.length() + 1 ); | ||
| 209 | |||
| 210 | // Convert | ||
| 211 | Utf32::toUtf8( mString.begin(), mString.end(), std::back_inserter( output ) ); | ||
| 212 | |||
| 213 | return output; | ||
| 214 | } | ||
| 215 | |||
| 216 | String& String::operator=( const String& right ) { | ||
| 217 | mString = right.mString; | ||
| 218 | return *this; | ||
| 219 | } | ||
| 220 | |||
| 221 | String& String::operator=( const StringBaseType& right ) { | ||
| 222 | mString = right; | ||
| 223 | return *this; | ||
| 224 | } | ||
| 225 | |||
| 226 | String& String::operator+=( const String& right ) { | ||
| 227 | mString += right.mString; | ||
| 228 | return *this; | ||
| 229 | } | ||
| 230 | |||
| 231 | String& String::operator+=( const StringBaseType& right ) { | ||
| 232 | mString += right; | ||
| 233 | return *this; | ||
| 234 | } | ||
| 235 | |||
| 236 | String::StringBaseType String::operator[]( std::size_t index ) const { | ||
| 237 | return mString[index]; | ||
| 238 | } | ||
| 239 | |||
| 240 | String::StringBaseType& String::operator[]( std::size_t index ) { | ||
| 241 | return mString[index]; | ||
| 242 | } | ||
| 243 | |||
| 244 | String::StringBaseType String::at( std::size_t index ) const { | ||
| 245 | return mString.at( index ); | ||
| 246 | } | ||
| 247 | |||
| 248 | void String::push_back( StringBaseType c ) { | ||
| 249 | mString.push_back( c ); | ||
| 250 | } | ||
| 251 | |||
| 252 | void String::swap( String& str ) { | ||
| 253 | mString.swap( str.mString ); | ||
| 254 | } | ||
| 255 | |||
| 256 | void String::clear() { | ||
| 257 | mString.clear(); | ||
| 258 | } | ||
| 259 | |||
| 260 | std::size_t String::size() const { | ||
| 261 | return mString.size(); | ||
| 262 | } | ||
| 263 | |||
| 264 | std::size_t String::length() const { | ||
| 265 | return mString.length(); | ||
| 266 | } | ||
| 267 | |||
| 268 | bool String::empty() const { | ||
| 269 | return mString.empty(); | ||
| 270 | } | ||
| 271 | |||
| 272 | void String::erase( std::size_t position, std::size_t count ) { | ||
| 273 | mString.erase( position, count ); | ||
| 274 | } | ||
| 275 | |||
| 276 | String& String::insert( std::size_t position, const String& str ) { | ||
| 277 | mString.insert( position, str.mString ); | ||
| 278 | return *this; | ||
| 279 | } | ||
| 280 | |||
| 281 | String& String::insert( std::size_t pos1, const String& str, std::size_t pos2, std::size_t n ) { | ||
| 282 | mString.insert( pos1, str.mString, pos2, n ); | ||
| 283 | return *this; | ||
| 284 | } | ||
| 285 | |||
| 286 | String& String::insert( size_t pos1, const char* s, size_t n ) { | ||
| 287 | String tmp( s ); | ||
| 288 | |||
| 289 | mString.insert( pos1, tmp.data(), n ); | ||
| 290 | |||
| 291 | return *this; | ||
| 292 | } | ||
| 293 | |||
| 294 | String& String::insert( size_t pos1, size_t n, char c ) { | ||
| 295 | mString.insert( pos1, n, c ); | ||
| 296 | return *this; | ||
| 297 | } | ||
| 298 | |||
| 299 | String& String::insert( size_t pos1, const char* s ) { | ||
| 300 | String tmp( s ); | ||
| 301 | |||
| 302 | mString.insert( pos1, tmp.data() ); | ||
| 303 | |||
| 304 | return *this; | ||
| 305 | } | ||
| 306 | |||
| 307 | String::Iterator String::insert( Iterator p, char c ) { | ||
| 308 | return mString.insert( p, c ); | ||
| 309 | } | ||
| 310 | |||
| 311 | void String::insert( Iterator p, size_t n, char c ) { | ||
| 312 | mString.insert( p, n, c ); | ||
| 313 | } | ||
| 314 | |||
| 315 | const String::StringBaseType* String::c_str() const { | ||
| 316 | return mString.c_str(); | ||
| 317 | } | ||
| 318 | |||
| 319 | const String::StringBaseType* String::data() const { | ||
| 320 | return mString.data(); | ||
| 321 | } | ||
| 322 | |||
| 323 | String::Iterator String::begin() { | ||
| 324 | return mString.begin(); | ||
| 325 | } | ||
| 326 | |||
| 327 | String::ConstIterator String::begin() const { | ||
| 328 | return mString.begin(); | ||
| 329 | } | ||
| 330 | |||
| 331 | String::Iterator String::end() { | ||
| 332 | return mString.end(); | ||
| 333 | } | ||
| 334 | |||
| 335 | String::ConstIterator String::end() const { | ||
| 336 | return mString.end(); | ||
| 337 | } | ||
| 338 | |||
| 339 | String::ReverseIterator String::rbegin() { | ||
| 340 | return mString.rbegin(); | ||
| 341 | } | ||
| 342 | |||
| 343 | String::ConstReverseIterator String::rbegin() const { | ||
| 344 | return mString.rbegin(); | ||
| 345 | } | ||
| 346 | |||
| 347 | String::ReverseIterator String::rend() { | ||
| 348 | return mString.rend(); | ||
| 349 | } | ||
| 350 | |||
| 351 | String::ConstReverseIterator String::rend() const { | ||
| 352 | return mString.rend(); | ||
| 353 | } | ||
| 354 | |||
| 355 | void String::resize( std::size_t n, StringBaseType c ) { | ||
| 356 | mString.resize( n, c ); | ||
| 357 | } | ||
| 358 | |||
| 359 | void String::resize( std::size_t n ) { | ||
| 360 | mString.resize( n ); | ||
| 361 | } | ||
| 362 | |||
| 363 | std::size_t String::max_size() const { | ||
| 364 | return mString.max_size(); | ||
| 365 | } | ||
| 366 | |||
| 367 | void String::reserve( size_t res_arg ) { | ||
| 368 | mString.reserve( res_arg ); | ||
| 369 | } | ||
| 370 | |||
| 371 | std::size_t String::capacity() const { | ||
| 372 | return mString.capacity(); | ||
| 373 | } | ||
| 374 | |||
| 375 | String& String::assign( const String& str ) { | ||
| 376 | mString.assign( str.mString ); | ||
| 377 | return *this; | ||
| 378 | } | ||
| 379 | |||
| 380 | String& String::assign( const String& str, size_t pos, size_t n ) { | ||
| 381 | mString.assign( str.mString, pos, n ); | ||
| 382 | return *this; | ||
| 383 | } | ||
| 384 | |||
| 385 | String& String::assign( const char* s, size_t n ) { | ||
| 386 | String tmp( s ); | ||
| 387 | |||
| 388 | mString.assign( tmp.mString ); | ||
| 389 | |||
| 390 | return *this; | ||
| 391 | } | ||
| 392 | |||
| 393 | String& String::assign( const char* s ) { | ||
| 394 | String tmp( s ); | ||
| 395 | |||
| 396 | mString.assign( tmp.mString ); | ||
| 397 | |||
| 398 | return *this; | ||
| 399 | } | ||
| 400 | |||
| 401 | String& String::assign( size_t n, char c ) { | ||
| 402 | mString.assign( n, c ); | ||
| 403 | |||
| 404 | return *this; | ||
| 405 | } | ||
| 406 | |||
| 407 | String& String::append( const String& str ) { | ||
| 408 | mString.append( str.mString ); | ||
| 409 | |||
| 410 | return *this; | ||
| 411 | } | ||
| 412 | |||
| 413 | String& String::append( const String& str, size_t pos, size_t n ) { | ||
| 414 | mString.append( str.mString, pos, n ); | ||
| 415 | |||
| 416 | return *this; | ||
| 417 | } | ||
| 418 | |||
| 419 | String& String::append( const char* s, size_t n ) { | ||
| 420 | String tmp( s ); | ||
| 421 | |||
| 422 | mString.append( tmp.mString ); | ||
| 423 | |||
| 424 | return *this; | ||
| 425 | } | ||
| 426 | |||
| 427 | String& String::append( const char* s ) { | ||
| 428 | String tmp( s ); | ||
| 429 | |||
| 430 | mString.append( tmp.mString ); | ||
| 431 | |||
| 432 | return *this; | ||
| 433 | } | ||
| 434 | |||
| 435 | String& String::append( size_t n, char c ) { | ||
| 436 | mString.append( n, c ); | ||
| 437 | |||
| 438 | return *this; | ||
| 439 | } | ||
| 440 | |||
| 441 | String& String::append( std::size_t n, StringBaseType c ) { | ||
| 442 | mString.append( n, c ); | ||
| 443 | |||
| 444 | return *this; | ||
| 445 | } | ||
| 446 | |||
| 447 | String& String::replace( size_t pos1, size_t n1, const String& str ) { | ||
| 448 | mString.replace( pos1, n1, str.mString ); | ||
| 449 | |||
| 450 | return *this; | ||
| 451 | } | ||
| 452 | |||
| 453 | String& String::replace( Iterator i1, Iterator i2, const String& str ) { | ||
| 454 | mString.replace( i1, i2, str.mString ); | ||
| 455 | |||
| 456 | return *this; | ||
| 457 | } | ||
| 458 | |||
| 459 | String& String::replace( size_t pos1, size_t n1, const String& str, size_t pos2, size_t n2 ) { | ||
| 460 | mString.replace( pos1, n1, str.mString, pos2, n2 ); | ||
| 461 | |||
| 462 | return *this; | ||
| 463 | } | ||
| 464 | |||
| 465 | String& String::replace( size_t pos1, size_t n1, const char* s, size_t n2 ) { | ||
| 466 | String tmp( s ); | ||
| 467 | |||
| 468 | mString.replace( pos1, n1, tmp.data(), n2 ); | ||
| 469 | |||
| 470 | return *this; | ||
| 471 | } | ||
| 472 | |||
| 473 | String& String::replace( Iterator i1, Iterator i2, const char* s, size_t n2 ) { | ||
| 474 | String tmp( s ); | ||
| 475 | |||
| 476 | mString.replace( i1, i2, tmp.data(), n2 ); | ||
| 477 | |||
| 478 | return *this; | ||
| 479 | } | ||
| 480 | |||
| 481 | String& String::replace( size_t pos1, size_t n1, const char* s ) { | ||
| 482 | String tmp( s ); | ||
| 483 | |||
| 484 | mString.replace( pos1, n1, tmp.mString ); | ||
| 485 | |||
| 486 | return *this; | ||
| 487 | } | ||
| 488 | |||
| 489 | String& String::replace( Iterator i1, Iterator i2, const char* s ) { | ||
| 490 | String tmp( s ); | ||
| 491 | |||
| 492 | mString.replace( i1, i2, tmp.mString ); | ||
| 493 | |||
| 494 | return *this; | ||
| 495 | } | ||
| 496 | |||
| 497 | String& String::replace( size_t pos1, size_t n1, size_t n2, char c ) { | ||
| 498 | mString.replace( pos1, n1, n2, (StringBaseType)c ); | ||
| 499 | |||
| 500 | return *this; | ||
| 501 | } | ||
| 502 | |||
| 503 | String& String::replace( Iterator i1, Iterator i2, size_t n2, char c ) { | ||
| 504 | mString.replace( i1, i2, n2, (StringBaseType)c ); | ||
| 505 | |||
| 506 | return *this; | ||
| 507 | } | ||
| 508 | |||
| 509 | std::size_t String::find( const String& str, std::size_t start ) const { | ||
| 510 | return mString.find( str.mString, start ); | ||
| 511 | } | ||
| 512 | |||
| 513 | std::size_t String::find( const char* s, std::size_t pos, std::size_t n ) const { | ||
| 514 | return find( String( s ), pos ); | ||
| 515 | } | ||
| 516 | |||
| 517 | std::size_t String::find( const char* s, std::size_t pos ) const { | ||
| 518 | return find( String( s ), pos ); | ||
| 519 | } | ||
| 520 | |||
| 521 | size_t String::find( char c, std::size_t pos ) const { | ||
| 522 | return mString.find( (StringBaseType)c, pos ); | ||
| 523 | } | ||
| 524 | |||
| 525 | std::size_t String::rfind( const String& str, std::size_t pos ) const { | ||
| 526 | return mString.rfind( str.mString, pos ); | ||
| 527 | } | ||
| 528 | |||
| 529 | std::size_t String::rfind( const char* s, std::size_t pos, std::size_t n ) const { | ||
| 530 | return rfind( String( s ), pos ); | ||
| 531 | } | ||
| 532 | |||
| 533 | std::size_t String::rfind( const char* s, std::size_t pos ) const { | ||
| 534 | return rfind( String( s ), pos ); | ||
| 535 | } | ||
| 536 | |||
| 537 | std::size_t String::rfind( char c, std::size_t pos ) const { | ||
| 538 | return mString.rfind( c, pos ); | ||
| 539 | } | ||
| 540 | |||
| 541 | std::size_t String::copy( StringBaseType* s, std::size_t n, std::size_t pos ) const { | ||
| 542 | return mString.copy( s, n, pos ); | ||
| 543 | } | ||
| 544 | |||
| 545 | String String::substr( std::size_t pos, std::size_t n ) const { | ||
| 546 | return String( mString.substr( pos, n ) ); | ||
| 547 | } | ||
| 548 | |||
| 549 | int String::compare( const String& str ) const { | ||
| 550 | return mString.compare( str.mString ); | ||
| 551 | } | ||
| 552 | |||
| 553 | int String::compare( const char* s ) const { | ||
| 554 | return compare( String( s ) ); | ||
| 555 | } | ||
| 556 | |||
| 557 | int String::compare( std::size_t pos1, std::size_t n1, const String& str ) const { | ||
| 558 | return mString.compare( pos1, n1, str.mString ); | ||
| 559 | } | ||
| 560 | |||
| 561 | int String::compare( std::size_t pos1, std::size_t n1, const char* s ) const { | ||
| 562 | return compare( pos1, n1, String( s ) ); | ||
| 563 | } | ||
| 564 | |||
| 565 | int String::compare( std::size_t pos1, std::size_t n1, const String& str, std::size_t pos2, | ||
| 566 | std::size_t n2 ) const { | ||
| 567 | return mString.compare( pos1, n1, str.mString, pos2, n2 ); | ||
| 568 | } | ||
| 569 | |||
| 570 | int String::compare( std::size_t pos1, std::size_t n1, const char* s, std::size_t n2 ) const { | ||
| 571 | return compare( pos1, n1, String( s ), 0, n2 ); | ||
| 572 | } | ||
| 573 | |||
| 574 | std::size_t String::find_first_of( const String& str, std::size_t pos ) const { | ||
| 575 | return mString.find_first_of( str.mString, pos ); | ||
| 576 | } | ||
| 577 | |||
| 578 | std::size_t String::find_first_of( const char* s, std::size_t pos, std::size_t n ) const { | ||
| 579 | return find_first_of( String( s ), pos ); | ||
| 580 | } | ||
| 581 | |||
| 582 | std::size_t String::find_first_of( const char* s, std::size_t pos ) const { | ||
| 583 | return find_first_of( String( s ), pos ); | ||
| 584 | } | ||
| 585 | |||
| 586 | std::size_t String::find_first_of( StringBaseType c, std::size_t pos ) const { | ||
| 587 | return mString.find_first_of( c, pos ); | ||
| 588 | } | ||
| 589 | |||
| 590 | std::size_t String::find_last_of( const String& str, std::size_t pos ) const { | ||
| 591 | return mString.find_last_of( str.mString, pos ); | ||
| 592 | } | ||
| 593 | |||
| 594 | std::size_t String::find_last_of( const char* s, std::size_t pos, std::size_t n ) const { | ||
| 595 | return find_last_of( String( s ), pos ); | ||
| 596 | } | ||
| 597 | |||
| 598 | std::size_t String::find_last_of( const char* s, std::size_t pos ) const { | ||
| 599 | return find_last_of( String( s ), pos ); | ||
| 600 | } | ||
| 601 | |||
| 602 | std::size_t String::find_last_of( StringBaseType c, std::size_t pos ) const { | ||
| 603 | return mString.find_last_of( c, pos ); | ||
| 604 | } | ||
| 605 | |||
| 606 | std::size_t String::find_first_not_of( const String& str, std::size_t pos ) const { | ||
| 607 | return mString.find_first_not_of( str.mString, pos ); | ||
| 608 | } | ||
| 609 | |||
| 610 | std::size_t String::find_first_not_of( const char* s, std::size_t pos, std::size_t n ) const { | ||
| 611 | return find_first_not_of( String( s ), pos ); | ||
| 612 | } | ||
| 613 | |||
| 614 | std::size_t String::find_first_not_of( const char* s, std::size_t pos ) const { | ||
| 615 | return find_first_not_of( String( s ), pos ); | ||
| 616 | } | ||
| 617 | |||
| 618 | std::size_t String::find_first_not_of( StringBaseType c, std::size_t pos ) const { | ||
| 619 | return mString.find_first_not_of( c, pos ); | ||
| 620 | } | ||
| 621 | |||
| 622 | std::size_t String::find_last_not_of( const String& str, std::size_t pos ) const { | ||
| 623 | return mString.find_last_not_of( str.mString, pos ); | ||
| 624 | } | ||
| 625 | |||
| 626 | std::size_t String::find_last_not_of( const char* s, std::size_t pos, std::size_t n ) const { | ||
| 627 | return find_last_not_of( String( s ), pos ); | ||
| 628 | } | ||
| 629 | |||
| 630 | std::size_t String::find_last_not_of( const char* s, std::size_t pos ) const { | ||
| 631 | return find_last_not_of( String( s ), pos ); | ||
| 632 | } | ||
| 633 | |||
| 634 | std::size_t String::find_last_not_of( StringBaseType c, std::size_t pos ) const { | ||
| 635 | return mString.find_last_not_of( c, pos ); | ||
| 636 | } | ||
| 637 | |||
| 638 | bool operator==( const String& left, const String& right ) { | ||
| 639 | return left.mString == right.mString; | ||
| 640 | } | ||
| 641 | |||
| 642 | bool operator!=( const String& left, const String& right ) { | ||
| 643 | return !( left == right ); | ||
| 644 | } | ||
| 645 | |||
| 646 | bool operator<( const String& left, const String& right ) { | ||
| 647 | return left.mString < right.mString; | ||
| 648 | } | ||
| 649 | |||
| 650 | bool operator>( const String& left, const String& right ) { | ||
| 651 | return right < left; | ||
| 652 | } | ||
| 653 | |||
| 654 | bool operator<=( const String& left, const String& right ) { | ||
| 655 | return !( right < left ); | ||
| 656 | } | ||
| 657 | |||
| 658 | bool operator>=( const String& left, const String& right ) { | ||
| 659 | return !( left < right ); | ||
| 660 | } | ||
| 661 | |||
| 662 | String operator+( const String& left, const String& right ) { | ||
| 663 | String string = left; | ||
| 664 | string += right; | ||
| 665 | |||
| 666 | return string; | ||
| 667 | } | ||
| 668 | |||
| 669 | } // namespace efsw | ||
