| 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.
All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 * | 19 * |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 #ifndef WTFString_h | 22 #ifndef WTFString_h |
| 23 #define WTFString_h | 23 #define WTFString_h |
| 24 | 24 |
| 25 // This file would be called String.h, but that conflicts with <string.h> | 25 // This file would be called String.h, but that conflicts with <string.h> |
| 26 // on systems without case-sensitive file systems. | 26 // on systems without case-sensitive file systems. |
| 27 | 27 |
| 28 #include <wtf/text/ASCIIFastPath.h> | 28 #include "wtf/WTFExport.h" |
| 29 #include <wtf/text/StringImpl.h> | 29 #include "wtf/text/ASCIIFastPath.h" |
| 30 #include "wtf/text/StringImpl.h" |
| 30 | 31 |
| 31 #ifdef __OBJC__ | 32 #ifdef __OBJC__ |
| 32 #include <objc/objc.h> | 33 #include <objc/objc.h> |
| 33 #endif | 34 #endif |
| 34 | 35 |
| 35 namespace WTF { | 36 namespace WTF { |
| 36 | 37 |
| 37 class CString; | 38 class CString; |
| 38 class MemoryObjectInfo; | 39 class MemoryObjectInfo; |
| 39 struct StringHash; | 40 struct StringHash; |
| 40 | 41 |
| 41 // Declarations of string operations | 42 // Declarations of string operations |
| 42 | 43 |
| 43 int charactersToIntStrict(const LChar*, size_t, bool* ok = 0, int base = 10); | 44 WTF_EXPORT int charactersToIntStrict(const LChar*, size_t, bool* ok = 0, int bas
e = 10); |
| 44 int charactersToIntStrict(const UChar*, size_t, bool* ok = 0, int base = 10); | 45 WTF_EXPORT int charactersToIntStrict(const UChar*, size_t, bool* ok = 0, int bas
e = 10); |
| 45 unsigned charactersToUIntStrict(const LChar*, size_t, bool* ok = 0, int base = 1
0); | 46 WTF_EXPORT unsigned charactersToUIntStrict(const LChar*, size_t, bool* ok = 0, i
nt base = 10); |
| 46 unsigned charactersToUIntStrict(const UChar*, size_t, bool* ok = 0, int base = 1
0); | 47 WTF_EXPORT unsigned charactersToUIntStrict(const UChar*, size_t, bool* ok = 0, i
nt base = 10); |
| 47 int64_t charactersToInt64Strict(const LChar*, size_t, bool* ok = 0, int base = 1
0); | 48 WTF_EXPORT int64_t charactersToInt64Strict(const LChar*, size_t, bool* ok = 0, i
nt base = 10); |
| 48 int64_t charactersToInt64Strict(const UChar*, size_t, bool* ok = 0, int base = 1
0); | 49 WTF_EXPORT int64_t charactersToInt64Strict(const UChar*, size_t, bool* ok = 0, i
nt base = 10); |
| 49 uint64_t charactersToUInt64Strict(const LChar*, size_t, bool* ok = 0, int base =
10); | 50 WTF_EXPORT uint64_t charactersToUInt64Strict(const LChar*, size_t, bool* ok = 0,
int base = 10); |
| 50 uint64_t charactersToUInt64Strict(const UChar*, size_t, bool* ok = 0, int base =
10); | 51 WTF_EXPORT uint64_t charactersToUInt64Strict(const UChar*, size_t, bool* ok = 0,
int base = 10); |
| 51 intptr_t charactersToIntPtrStrict(const LChar*, size_t, bool* ok = 0, int base =
10); | 52 WTF_EXPORT intptr_t charactersToIntPtrStrict(const LChar*, size_t, bool* ok = 0,
int base = 10); |
| 52 intptr_t charactersToIntPtrStrict(const UChar*, size_t, bool* ok = 0, int base =
10); | 53 WTF_EXPORT intptr_t charactersToIntPtrStrict(const UChar*, size_t, bool* ok = 0,
int base = 10); |
| 53 | 54 |
| 54 int charactersToInt(const LChar*, size_t, bool* ok = 0); // ignores trailing gar
bage | 55 WTF_EXPORT int charactersToInt(const LChar*, size_t, bool* ok = 0); // ignores t
railing garbage |
| 55 int charactersToInt(const UChar*, size_t, bool* ok = 0); // ignores trailing gar
bage | 56 WTF_EXPORT int charactersToInt(const UChar*, size_t, bool* ok = 0); // ignores t
railing garbage |
| 56 unsigned charactersToUInt(const LChar*, size_t, bool* ok = 0); // ignores traili
ng garbage | 57 WTF_EXPORT unsigned charactersToUInt(const LChar*, size_t, bool* ok = 0); // ign
ores trailing garbage |
| 57 unsigned charactersToUInt(const UChar*, size_t, bool* ok = 0); // ignores traili
ng garbage | 58 WTF_EXPORT unsigned charactersToUInt(const UChar*, size_t, bool* ok = 0); // ign
ores trailing garbage |
| 58 int64_t charactersToInt64(const LChar*, size_t, bool* ok = 0); // ignores traili
ng garbage | 59 WTF_EXPORT int64_t charactersToInt64(const LChar*, size_t, bool* ok = 0); // ign
ores trailing garbage |
| 59 int64_t charactersToInt64(const UChar*, size_t, bool* ok = 0); // ignores traili
ng garbage | 60 WTF_EXPORT int64_t charactersToInt64(const UChar*, size_t, bool* ok = 0); // ign
ores trailing garbage |
| 60 uint64_t charactersToUInt64(const LChar*, size_t, bool* ok = 0); // ignores trai
ling garbage | 61 WTF_EXPORT uint64_t charactersToUInt64(const LChar*, size_t, bool* ok = 0); // i
gnores trailing garbage |
| 61 uint64_t charactersToUInt64(const UChar*, size_t, bool* ok = 0); // ignores trai
ling garbage | 62 WTF_EXPORT uint64_t charactersToUInt64(const UChar*, size_t, bool* ok = 0); // i
gnores trailing garbage |
| 62 intptr_t charactersToIntPtr(const LChar*, size_t, bool* ok = 0); // ignores trai
ling garbage | 63 WTF_EXPORT intptr_t charactersToIntPtr(const LChar*, size_t, bool* ok = 0); // i
gnores trailing garbage |
| 63 intptr_t charactersToIntPtr(const UChar*, size_t, bool* ok = 0); // ignores trai
ling garbage | 64 WTF_EXPORT intptr_t charactersToIntPtr(const UChar*, size_t, bool* ok = 0); // i
gnores trailing garbage |
| 64 | 65 |
| 65 // FIXME: Like the strict functions above, these give false for "ok" when there
is trailing garbage. | 66 // FIXME: Like the strict functions above, these give false for "ok" when there
is trailing garbage. |
| 66 // Like the non-strict functions above, these return the value when there is tra
iling garbage. | 67 // Like the non-strict functions above, these return the value when there is tra
iling garbage. |
| 67 // It would be better if these were more consistent with the above functions ins
tead. | 68 // It would be better if these were more consistent with the above functions ins
tead. |
| 68 double charactersToDouble(const LChar*, size_t, bool* ok = 0); | 69 WTF_EXPORT double charactersToDouble(const LChar*, size_t, bool* ok = 0); |
| 69 double charactersToDouble(const UChar*, size_t, bool* ok = 0); | 70 WTF_EXPORT double charactersToDouble(const UChar*, size_t, bool* ok = 0); |
| 70 float charactersToFloat(const LChar*, size_t, bool* ok = 0); | 71 WTF_EXPORT float charactersToFloat(const LChar*, size_t, bool* ok = 0); |
| 71 float charactersToFloat(const UChar*, size_t, bool* ok = 0); | 72 WTF_EXPORT float charactersToFloat(const UChar*, size_t, bool* ok = 0); |
| 72 float charactersToFloat(const LChar*, size_t, size_t& parsedLength); | 73 WTF_EXPORT float charactersToFloat(const LChar*, size_t, size_t& parsedLength); |
| 73 float charactersToFloat(const UChar*, size_t, size_t& parsedLength); | 74 WTF_EXPORT float charactersToFloat(const UChar*, size_t, size_t& parsedLength); |
| 74 | 75 |
| 75 class ASCIILiteral; | 76 class ASCIILiteral; |
| 76 | 77 |
| 77 enum TrailingZerosTruncatingPolicy { | 78 enum TrailingZerosTruncatingPolicy { |
| 78 KeepTrailingZeros, | 79 KeepTrailingZeros, |
| 79 TruncateTrailingZeros | 80 TruncateTrailingZeros |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 template<bool isSpecialCharacter(UChar), typename CharacterType> | 83 template<bool isSpecialCharacter(UChar), typename CharacterType> |
| 83 bool isAllSpecialCharacters(const CharacterType*, size_t); | 84 bool isAllSpecialCharacters(const CharacterType*, size_t); |
| 84 | 85 |
| 85 class String { | 86 class WTF_EXPORT String { |
| 86 public: | 87 public: |
| 87 // Construct a null string, distinguishable from an empty string. | 88 // Construct a null string, distinguishable from an empty string. |
| 88 String() { } | 89 String() { } |
| 89 | 90 |
| 90 // Construct a string with UTF-16 data. | 91 // Construct a string with UTF-16 data. |
| 91 String(const UChar* characters, unsigned length); | 92 String(const UChar* characters, unsigned length); |
| 92 | 93 |
| 93 // Construct a string by copying the contents of a vector. To avoid | 94 // Construct a string by copying the contents of a vector. To avoid |
| 94 // copying, consider using String::adopt instead. | 95 // copying, consider using String::adopt instead. |
| 95 // This method will never create a null string. Vectors with size() == 0 | 96 // This method will never create a null string. Vectors with size() == 0 |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 { | 566 { |
| 566 if (isEmpty()) | 567 if (isEmpty()) |
| 567 return true; | 568 return true; |
| 568 | 569 |
| 569 if (is8Bit()) | 570 if (is8Bit()) |
| 570 return charactersAreAllASCII(characters8(), m_impl->length()); | 571 return charactersAreAllASCII(characters8(), m_impl->length()); |
| 571 | 572 |
| 572 return charactersAreAllASCII(characters16(), m_impl->length()); | 573 return charactersAreAllASCII(characters16(), m_impl->length()); |
| 573 } | 574 } |
| 574 | 575 |
| 575 int codePointCompare(const String&, const String&); | 576 WTF_EXPORT int codePointCompare(const String&, const String&); |
| 576 | 577 |
| 577 inline bool codePointCompareLessThan(const String& a, const String& b) | 578 inline bool codePointCompareLessThan(const String& a, const String& b) |
| 578 { | 579 { |
| 579 return codePointCompare(a.impl(), b.impl()) < 0; | 580 return codePointCompare(a.impl(), b.impl()) < 0; |
| 580 } | 581 } |
| 581 | 582 |
| 582 template<size_t inlineCapacity> | 583 template<size_t inlineCapacity> |
| 583 inline void append(Vector<UChar, inlineCapacity>& vector, const String& string) | 584 inline void append(Vector<UChar, inlineCapacity>& vector, const String& string) |
| 584 { | 585 { |
| 585 vector.append(string.characters(), string.length()); | 586 vector.append(string.characters(), string.length()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 class ASCIILiteral { | 641 class ASCIILiteral { |
| 641 public: | 642 public: |
| 642 explicit ASCIILiteral(const char* characters) : m_characters(characters) { } | 643 explicit ASCIILiteral(const char* characters) : m_characters(characters) { } |
| 643 operator const char*() { return m_characters; } | 644 operator const char*() { return m_characters; } |
| 644 | 645 |
| 645 private: | 646 private: |
| 646 const char* m_characters; | 647 const char* m_characters; |
| 647 }; | 648 }; |
| 648 | 649 |
| 649 // Shared global empty string. | 650 // Shared global empty string. |
| 650 const String& emptyString(); | 651 WTF_EXPORT const String& emptyString(); |
| 651 | 652 |
| 652 } | 653 } |
| 653 | 654 |
| 654 using WTF::CString; | 655 using WTF::CString; |
| 655 using WTF::KeepTrailingZeros; | 656 using WTF::KeepTrailingZeros; |
| 656 using WTF::String; | 657 using WTF::String; |
| 657 using WTF::emptyString; | 658 using WTF::emptyString; |
| 658 using WTF::append; | 659 using WTF::append; |
| 659 using WTF::appendNumber; | 660 using WTF::appendNumber; |
| 660 using WTF::charactersAreAllASCII; | 661 using WTF::charactersAreAllASCII; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 673 using WTF::equal; | 674 using WTF::equal; |
| 674 using WTF::equalIgnoringCase; | 675 using WTF::equalIgnoringCase; |
| 675 using WTF::find; | 676 using WTF::find; |
| 676 using WTF::isAllSpecialCharacters; | 677 using WTF::isAllSpecialCharacters; |
| 677 using WTF::isSpaceOrNewline; | 678 using WTF::isSpaceOrNewline; |
| 678 using WTF::reverseFind; | 679 using WTF::reverseFind; |
| 679 using WTF::ASCIILiteral; | 680 using WTF::ASCIILiteral; |
| 680 | 681 |
| 681 #include <wtf/text/AtomicString.h> | 682 #include <wtf/text/AtomicString.h> |
| 682 #endif | 683 #endif |
| OLD | NEW |