| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. |
| 4 * All rights reserved. | 4 * 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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 static String fromUTF8(const CString&); | 401 static String fromUTF8(const CString&); |
| 402 | 402 |
| 403 // Tries to convert the passed in string to UTF-8, but will fall back to | 403 // Tries to convert the passed in string to UTF-8, but will fall back to |
| 404 // Latin-1 if the string is not valid UTF-8. | 404 // Latin-1 if the string is not valid UTF-8. |
| 405 static String fromUTF8WithLatin1Fallback(const LChar*, size_t); | 405 static String fromUTF8WithLatin1Fallback(const LChar*, size_t); |
| 406 static String fromUTF8WithLatin1Fallback(const char* s, size_t length) { | 406 static String fromUTF8WithLatin1Fallback(const char* s, size_t length) { |
| 407 return fromUTF8WithLatin1Fallback(reinterpret_cast<const LChar*>(s), | 407 return fromUTF8WithLatin1Fallback(reinterpret_cast<const LChar*>(s), |
| 408 length); | 408 length); |
| 409 } | 409 } |
| 410 | 410 |
| 411 bool containsOnlyASCII() const; | 411 bool containsOnlyASCII() const { |
| 412 return !m_impl || m_impl->containsOnlyASCII(); |
| 413 } |
| 412 bool containsOnlyLatin1() const; | 414 bool containsOnlyLatin1() const; |
| 413 bool containsOnlyWhitespace() const { | 415 bool containsOnlyWhitespace() const { |
| 414 return !m_impl || m_impl->containsOnlyWhitespace(); | 416 return !m_impl || m_impl->containsOnlyWhitespace(); |
| 415 } | 417 } |
| 416 | 418 |
| 417 size_t charactersSizeInBytes() const { | 419 size_t charactersSizeInBytes() const { |
| 418 return m_impl ? m_impl->charactersSizeInBytes() : 0; | 420 return m_impl ? m_impl->charactersSizeInBytes() : 0; |
| 419 } | 421 } |
| 420 | 422 |
| 421 // Hash table deleted values, which are only constructed and never copied or | 423 // Hash table deleted values, which are only constructed and never copied or |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 | 551 |
| 550 #ifdef __OBJC__ | 552 #ifdef __OBJC__ |
| 551 // This is for situations in WebKit where the long standing behavior has been | 553 // This is for situations in WebKit where the long standing behavior has been |
| 552 // "nil if empty", so we try to maintain longstanding behavior for the sake of | 554 // "nil if empty", so we try to maintain longstanding behavior for the sake of |
| 553 // entrenched clients | 555 // entrenched clients |
| 554 inline NSString* nsStringNilIfEmpty(const String& str) { | 556 inline NSString* nsStringNilIfEmpty(const String& str) { |
| 555 return str.isEmpty() ? nil : (NSString*)str; | 557 return str.isEmpty() ? nil : (NSString*)str; |
| 556 } | 558 } |
| 557 #endif | 559 #endif |
| 558 | 560 |
| 559 inline bool String::containsOnlyASCII() const { | |
| 560 if (isEmpty()) | |
| 561 return true; | |
| 562 | |
| 563 if (is8Bit()) | |
| 564 return charactersAreAllASCII(characters8(), m_impl->length()); | |
| 565 | |
| 566 return charactersAreAllASCII(characters16(), m_impl->length()); | |
| 567 } | |
| 568 | |
| 569 WTF_EXPORT int codePointCompare(const String&, const String&); | 561 WTF_EXPORT int codePointCompare(const String&, const String&); |
| 570 | 562 |
| 571 inline bool codePointCompareLessThan(const String& a, const String& b) { | 563 inline bool codePointCompareLessThan(const String& a, const String& b) { |
| 572 return codePointCompare(a.impl(), b.impl()) < 0; | 564 return codePointCompare(a.impl(), b.impl()) < 0; |
| 573 } | 565 } |
| 574 | 566 |
| 575 WTF_EXPORT int codePointCompareIgnoringASCIICase(const String&, const char*); | 567 WTF_EXPORT int codePointCompareIgnoringASCIICase(const String&, const char*); |
| 576 | 568 |
| 577 template <bool isSpecialCharacter(UChar), typename CharacterType> | 569 template <bool isSpecialCharacter(UChar), typename CharacterType> |
| 578 inline bool isAllSpecialCharacters(const CharacterType* characters, | 570 inline bool isAllSpecialCharacters(const CharacterType* characters, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 using WTF::emptyString; | 645 using WTF::emptyString; |
| 654 using WTF::emptyString16Bit; | 646 using WTF::emptyString16Bit; |
| 655 using WTF::charactersAreAllASCII; | 647 using WTF::charactersAreAllASCII; |
| 656 using WTF::equal; | 648 using WTF::equal; |
| 657 using WTF::find; | 649 using WTF::find; |
| 658 using WTF::isAllSpecialCharacters; | 650 using WTF::isAllSpecialCharacters; |
| 659 using WTF::isSpaceOrNewline; | 651 using WTF::isSpaceOrNewline; |
| 660 | 652 |
| 661 #include "wtf/text/AtomicString.h" | 653 #include "wtf/text/AtomicString.h" |
| 662 #endif // WTFString_h | 654 #endif // WTFString_h |
| OLD | NEW |