OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights
reserved. | 3 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights
reserved. |
4 * Copyright (C) 2009 Google Inc. All rights reserved. | 4 * Copyright (C) 2009 Google Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 struct AlreadyHashed; | 45 struct AlreadyHashed; |
46 struct CStringTranslator; | 46 struct CStringTranslator; |
47 template<typename CharacterType> struct HashAndCharactersTranslator; | 47 template<typename CharacterType> struct HashAndCharactersTranslator; |
48 struct HashAndUTF8CharactersTranslator; | 48 struct HashAndUTF8CharactersTranslator; |
49 struct LCharBufferTranslator; | 49 struct LCharBufferTranslator; |
50 struct CharBufferFromLiteralDataTranslator; | 50 struct CharBufferFromLiteralDataTranslator; |
51 struct SubstringTranslator; | 51 struct SubstringTranslator; |
52 struct UCharBufferTranslator; | 52 struct UCharBufferTranslator; |
53 template<typename> class RetainPtr; | 53 template<typename> class RetainPtr; |
54 | 54 |
55 enum TextCaseSensitivity { TextCaseSensitive, TextCaseInsensitive }; | 55 enum TextCaseSensitivity { TextCaseSensitive, TextCaseASCIIInsensitive, TextCase
Insensitive }; |
56 | 56 |
57 enum StripBehavior { StripExtraWhiteSpace, DoNotStripWhiteSpace }; | 57 enum StripBehavior { StripExtraWhiteSpace, DoNotStripWhiteSpace }; |
58 | 58 |
59 typedef bool (*CharacterMatchFunctionPtr)(UChar); | 59 typedef bool (*CharacterMatchFunctionPtr)(UChar); |
60 typedef bool (*IsWhiteSpaceFunctionPtr)(UChar); | 60 typedef bool (*IsWhiteSpaceFunctionPtr)(UChar); |
61 typedef HashMap<unsigned, StringImpl*, AlreadyHashed> StaticStringsTable; | 61 typedef HashMap<unsigned, StringImpl*, AlreadyHashed> StaticStringsTable; |
62 | 62 |
63 // Define STRING_STATS to turn on run time statistics of string sizes and memory
usage | 63 // Define STRING_STATS to turn on run time statistics of string sizes and memory
usage |
64 #undef STRING_STATS | 64 #undef STRING_STATS |
65 | 65 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 size_t find(char character, unsigned start = 0); | 367 size_t find(char character, unsigned start = 0); |
368 size_t find(UChar character, unsigned start = 0); | 368 size_t find(UChar character, unsigned start = 0); |
369 size_t find(CharacterMatchFunctionPtr, unsigned index = 0); | 369 size_t find(CharacterMatchFunctionPtr, unsigned index = 0); |
370 size_t find(const LChar*, unsigned index = 0); | 370 size_t find(const LChar*, unsigned index = 0); |
371 ALWAYS_INLINE size_t find(const char* s, unsigned index = 0) { return find(r
einterpret_cast<const LChar*>(s), index); } | 371 ALWAYS_INLINE size_t find(const char* s, unsigned index = 0) { return find(r
einterpret_cast<const LChar*>(s), index); } |
372 size_t find(StringImpl*); | 372 size_t find(StringImpl*); |
373 size_t find(StringImpl*, unsigned index); | 373 size_t find(StringImpl*, unsigned index); |
374 size_t findIgnoringCase(const LChar*, unsigned index = 0); | 374 size_t findIgnoringCase(const LChar*, unsigned index = 0); |
375 ALWAYS_INLINE size_t findIgnoringCase(const char* s, unsigned index = 0) { r
eturn findIgnoringCase(reinterpret_cast<const LChar*>(s), index); } | 375 ALWAYS_INLINE size_t findIgnoringCase(const char* s, unsigned index = 0) { r
eturn findIgnoringCase(reinterpret_cast<const LChar*>(s), index); } |
376 size_t findIgnoringCase(StringImpl*, unsigned index = 0); | 376 size_t findIgnoringCase(StringImpl*, unsigned index = 0); |
| 377 size_t findIgnoringASCIICase(StringImpl*, unsigned index = 0); |
377 | 378 |
378 size_t findNextLineStart(unsigned index = UINT_MAX); | 379 size_t findNextLineStart(unsigned index = UINT_MAX); |
379 | 380 |
380 size_t reverseFind(UChar, unsigned index = UINT_MAX); | 381 size_t reverseFind(UChar, unsigned index = UINT_MAX); |
381 size_t reverseFind(StringImpl*, unsigned index = UINT_MAX); | 382 size_t reverseFind(StringImpl*, unsigned index = UINT_MAX); |
382 | 383 |
383 size_t count(LChar) const; | 384 size_t count(LChar) const; |
384 | 385 |
385 bool startsWith(UChar) const; | 386 bool startsWith(UChar) const; |
386 bool startsWith(const char*, unsigned matchLength) const; | 387 bool startsWith(const char*, unsigned matchLength) const; |
387 bool startsWith(const StringImpl*) const; | 388 bool startsWith(const StringImpl*) const; |
388 bool startsWithIgnoringCase(const StringImpl*) const; | 389 bool startsWithIgnoringCase(const StringImpl*) const; |
| 390 bool startsWithIgnoringASCIICase(const StringImpl*) const; |
389 | 391 |
390 bool endsWith(UChar) const; | 392 bool endsWith(UChar) const; |
391 bool endsWith(const char*, unsigned matchLength) const; | 393 bool endsWith(const char*, unsigned matchLength) const; |
392 bool endsWith(const StringImpl*) const; | 394 bool endsWith(const StringImpl*) const; |
393 bool endsWithIgnoringCase(const StringImpl*) const; | 395 bool endsWithIgnoringCase(const StringImpl*) const; |
| 396 bool endsWithIgnoringASCIICase(const StringImpl*) const; |
394 | 397 |
395 PassRefPtr<StringImpl> replace(UChar, UChar); | 398 PassRefPtr<StringImpl> replace(UChar, UChar); |
396 PassRefPtr<StringImpl> replace(UChar, StringImpl*); | 399 PassRefPtr<StringImpl> replace(UChar, StringImpl*); |
397 ALWAYS_INLINE PassRefPtr<StringImpl> replace(UChar pattern, const char* repl
acement, unsigned replacementLength) { return replace(pattern, reinterpret_cast<
const LChar*>(replacement), replacementLength); } | 400 ALWAYS_INLINE PassRefPtr<StringImpl> replace(UChar pattern, const char* repl
acement, unsigned replacementLength) { return replace(pattern, reinterpret_cast<
const LChar*>(replacement), replacementLength); } |
398 PassRefPtr<StringImpl> replace(UChar, const LChar*, unsigned replacementLeng
th); | 401 PassRefPtr<StringImpl> replace(UChar, const LChar*, unsigned replacementLeng
th); |
399 PassRefPtr<StringImpl> replace(UChar, const UChar*, unsigned replacementLeng
th); | 402 PassRefPtr<StringImpl> replace(UChar, const UChar*, unsigned replacementLeng
th); |
400 PassRefPtr<StringImpl> replace(StringImpl*, StringImpl*); | 403 PassRefPtr<StringImpl> replace(StringImpl*, StringImpl*); |
401 PassRefPtr<StringImpl> replace(unsigned index, unsigned len, StringImpl*); | 404 PassRefPtr<StringImpl> replace(unsigned index, unsigned len, StringImpl*); |
402 PassRefPtr<StringImpl> upconvertedString(); | 405 PassRefPtr<StringImpl> upconvertedString(); |
403 | 406 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 inline bool equalIgnoringASCIICase(const CharacterTypeA* a, const CharacterTypeB
* b, unsigned length) | 502 inline bool equalIgnoringASCIICase(const CharacterTypeA* a, const CharacterTypeB
* b, unsigned length) |
500 { | 503 { |
501 for (unsigned i = 0; i < length; ++i) { | 504 for (unsigned i = 0; i < length; ++i) { |
502 if (toASCIILower(a[i]) != toASCIILower(b[i])) | 505 if (toASCIILower(a[i]) != toASCIILower(b[i])) |
503 return false; | 506 return false; |
504 } | 507 } |
505 return true; | 508 return true; |
506 } | 509 } |
507 | 510 |
508 template<typename CharacterTypeA, typename CharacterTypeB> | 511 template<typename CharacterTypeA, typename CharacterTypeB> |
509 bool startsWithIgnoringASCIICase(const CharacterTypeA& reference, const Characte
rTypeB& prefix) | 512 inline bool equalIgnoringASCIICase(const CharacterTypeA& a, const CharacterTypeB
& b) |
510 { | 513 { |
511 unsigned prefixLength = prefix.length(); | 514 unsigned length = b.length(); |
512 if (prefixLength > reference.length()) | 515 if (a.length() != length) |
513 return false; | 516 return false; |
514 | 517 if (a.is8Bit()) { |
515 if (reference.is8Bit()) { | 518 if (b.is8Bit()) |
516 if (prefix.is8Bit()) | 519 return equalIgnoringASCIICase(a.characters8(), b.characters8(), leng
th); |
517 return equalIgnoringASCIICase(reference.characters8(), prefix.charac
ters8(), prefixLength); | 520 return equalIgnoringASCIICase(a.characters8(), b.characters16(), length)
; |
518 return equalIgnoringASCIICase(reference.characters8(), prefix.characters
16(), prefixLength); | |
519 } | 521 } |
520 if (prefix.is8Bit()) | 522 if (b.is8Bit()) |
521 return equalIgnoringASCIICase(reference.characters16(), prefix.character
s8(), prefixLength); | 523 return equalIgnoringASCIICase(a.characters16(), b.characters8(), length)
; |
522 return equalIgnoringASCIICase(reference.characters16(), prefix.characters16(
), prefixLength); | 524 return equalIgnoringASCIICase(a.characters16(), b.characters16(), length); |
523 } | 525 } |
524 | 526 |
525 template<typename CharacterType> | 527 template<typename CharacterType> |
526 inline size_t find(const CharacterType* characters, unsigned length, CharacterTy
pe matchCharacter, unsigned index = 0) | 528 inline size_t find(const CharacterType* characters, unsigned length, CharacterTy
pe matchCharacter, unsigned index = 0) |
527 { | 529 { |
528 while (index < length) { | 530 while (index < length) { |
529 if (characters[index] == matchCharacter) | 531 if (characters[index] == matchCharacter) |
530 return index; | 532 return index; |
531 ++index; | 533 ++index; |
532 } | 534 } |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 typedef StringHash Hash; | 764 typedef StringHash Hash; |
763 }; | 765 }; |
764 | 766 |
765 } | 767 } |
766 | 768 |
767 using WTF::StringImpl; | 769 using WTF::StringImpl; |
768 using WTF::equal; | 770 using WTF::equal; |
769 using WTF::equalNonNull; | 771 using WTF::equalNonNull; |
770 using WTF::TextCaseSensitivity; | 772 using WTF::TextCaseSensitivity; |
771 using WTF::TextCaseSensitive; | 773 using WTF::TextCaseSensitive; |
| 774 using WTF::TextCaseASCIIInsensitive; |
772 using WTF::TextCaseInsensitive; | 775 using WTF::TextCaseInsensitive; |
773 | 776 |
774 #endif | 777 #endif |
OLD | NEW |