Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: Source/wtf/text/StringImpl.h

Issue 15861022: Build WTF as dll in component build (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix AutoDrainedPool ctor and ThreadSpecificThreadExit exports Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/wtf/text/StringBuilder.h ('k') | Source/wtf/text/StringStatics.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to 17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 * 20 *
21 */ 21 */
22 22
23 #ifndef StringImpl_h 23 #ifndef StringImpl_h
24 #define StringImpl_h 24 #define StringImpl_h
25 25
26 #include <limits.h> 26 #include <limits.h>
27 #include <wtf/ASCIICType.h> 27 #include "wtf/ASCIICType.h"
28 #include <wtf/Forward.h> 28 #include "wtf/Forward.h"
29 #include <wtf/StdLibExtras.h> 29 #include "wtf/StdLibExtras.h"
30 #include <wtf/StringHasher.h> 30 #include "wtf/StringHasher.h"
31 #include <wtf/Vector.h> 31 #include "wtf/Vector.h"
32 #include <wtf/unicode/Unicode.h> 32 #include "wtf/WTFExport.h"
33 #include "wtf/unicode/Unicode.h"
33 34
34 #if USE(CF) 35 #if USE(CF)
35 typedef const struct __CFString * CFStringRef; 36 typedef const struct __CFString * CFStringRef;
36 #endif 37 #endif
37 38
38 #ifdef __OBJC__ 39 #ifdef __OBJC__
39 @class NSString; 40 @class NSString;
40 #endif 41 #endif
41 42
42 namespace WTF { 43 namespace WTF {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 #define STRING_STATS_REMOVE_STRING(string) StringImpl::stringStats().removeStrin g(string) 107 #define STRING_STATS_REMOVE_STRING(string) StringImpl::stringStats().removeStrin g(string)
107 #else 108 #else
108 #define STRING_STATS_ADD_8BIT_STRING(length) ((void)0) 109 #define STRING_STATS_ADD_8BIT_STRING(length) ((void)0)
109 #define STRING_STATS_ADD_8BIT_STRING2(length, isSubString) ((void)0) 110 #define STRING_STATS_ADD_8BIT_STRING2(length, isSubString) ((void)0)
110 #define STRING_STATS_ADD_16BIT_STRING(length) ((void)0) 111 #define STRING_STATS_ADD_16BIT_STRING(length) ((void)0)
111 #define STRING_STATS_ADD_16BIT_STRING2(length, isSubString) ((void)0) 112 #define STRING_STATS_ADD_16BIT_STRING2(length, isSubString) ((void)0)
112 #define STRING_STATS_ADD_UPCONVERTED_STRING(length) ((void)0) 113 #define STRING_STATS_ADD_UPCONVERTED_STRING(length) ((void)0)
113 #define STRING_STATS_REMOVE_STRING(string) ((void)0) 114 #define STRING_STATS_REMOVE_STRING(string) ((void)0)
114 #endif 115 #endif
115 116
116 class StringImpl { 117 class WTF_EXPORT StringImpl {
117 WTF_MAKE_NONCOPYABLE(StringImpl); 118 WTF_MAKE_NONCOPYABLE(StringImpl);
118 // This is needed because we malloc() space for a StringImpl plus an 119 // This is needed because we malloc() space for a StringImpl plus an
119 // immediately following buffer, as a performance tweak. 120 // immediately following buffer, as a performance tweak.
120 NEW_DELETE_SAME_AS_MALLOC_FREE; 121 NEW_DELETE_SAME_AS_MALLOC_FREE;
121 friend struct WTF::CStringTranslator; 122 friend struct WTF::CStringTranslator;
122 template<typename CharacterType> friend struct WTF::HashAndCharactersTransla tor; 123 template<typename CharacterType> friend struct WTF::HashAndCharactersTransla tor;
123 friend struct WTF::HashAndUTF8CharactersTranslator; 124 friend struct WTF::HashAndUTF8CharactersTranslator;
124 friend struct WTF::CharBufferFromLiteralDataTranslator; 125 friend struct WTF::CharBufferFromLiteralDataTranslator;
125 friend struct WTF::LCharBufferTranslator; 126 friend struct WTF::LCharBufferTranslator;
126 friend struct WTF::SubstringTranslator; 127 friend struct WTF::SubstringTranslator;
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 static void checkConsistency(const StringImpl*) { } 767 static void checkConsistency(const StringImpl*) { }
767 }; 768 };
768 #endif 769 #endif
769 770
770 template <> 771 template <>
771 ALWAYS_INLINE const LChar* StringImpl::getCharacters<LChar>() const { return cha racters8(); } 772 ALWAYS_INLINE const LChar* StringImpl::getCharacters<LChar>() const { return cha racters8(); }
772 773
773 template <> 774 template <>
774 ALWAYS_INLINE const UChar* StringImpl::getCharacters<UChar>() const { return cha racters(); } 775 ALWAYS_INLINE const UChar* StringImpl::getCharacters<UChar>() const { return cha racters(); }
775 776
776 bool equal(const StringImpl*, const StringImpl*); 777 WTF_EXPORT bool equal(const StringImpl*, const StringImpl*);
777 bool equal(const StringImpl*, const LChar*); 778 WTF_EXPORT bool equal(const StringImpl*, const LChar*);
778 inline bool equal(const StringImpl* a, const char* b) { return equal(a, reinterp ret_cast<const LChar*>(b)); } 779 inline bool equal(const StringImpl* a, const char* b) { return equal(a, reinterp ret_cast<const LChar*>(b)); }
779 bool equal(const StringImpl*, const LChar*, unsigned); 780 WTF_EXPORT bool equal(const StringImpl*, const LChar*, unsigned);
780 inline bool equal(const StringImpl* a, const char* b, unsigned length) { return equal(a, reinterpret_cast<const LChar*>(b), length); } 781 inline bool equal(const StringImpl* a, const char* b, unsigned length) { return equal(a, reinterpret_cast<const LChar*>(b), length); }
781 inline bool equal(const LChar* a, StringImpl* b) { return equal(b, a); } 782 inline bool equal(const LChar* a, StringImpl* b) { return equal(b, a); }
782 inline bool equal(const char* a, StringImpl* b) { return equal(b, reinterpret_ca st<const LChar*>(a)); } 783 inline bool equal(const char* a, StringImpl* b) { return equal(b, reinterpret_ca st<const LChar*>(a)); }
783 bool equal(const StringImpl*, const UChar*, unsigned); 784 WTF_EXPORT bool equal(const StringImpl*, const UChar*, unsigned);
784 bool equalNonNull(const StringImpl* a, const StringImpl* b); 785 WTF_EXPORT bool equalNonNull(const StringImpl* a, const StringImpl* b);
785 786
786 // Do comparisons 8 or 4 bytes-at-a-time on architectures where it's safe. 787 // Do comparisons 8 or 4 bytes-at-a-time on architectures where it's safe.
787 #if CPU(X86_64) 788 #if CPU(X86_64)
788 ALWAYS_INLINE bool equal(const LChar* a, const LChar* b, unsigned length) 789 ALWAYS_INLINE bool equal(const LChar* a, const LChar* b, unsigned length)
789 { 790 {
790 unsigned dwordLength = length >> 3; 791 unsigned dwordLength = length >> 3;
791 792
792 if (dwordLength) { 793 if (dwordLength) {
793 const uint64_t* aDWordCharacters = reinterpret_cast<const uint64_t*>(a); 794 const uint64_t* aDWordCharacters = reinterpret_cast<const uint64_t*>(a);
794 const uint64_t* bDWordCharacters = reinterpret_cast<const uint64_t*>(b); 795 const uint64_t* bDWordCharacters = reinterpret_cast<const uint64_t*>(b);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 ALWAYS_INLINE bool equal(const UChar* a, const LChar* b, unsigned length) 933 ALWAYS_INLINE bool equal(const UChar* a, const LChar* b, unsigned length)
933 { 934 {
934 for (unsigned i = 0; i != length; ++i) { 935 for (unsigned i = 0; i != length; ++i) {
935 if (a[i] != b[i]) 936 if (a[i] != b[i])
936 return false; 937 return false;
937 } 938 }
938 939
939 return true; 940 return true;
940 } 941 }
941 942
942 bool equalIgnoringCase(const StringImpl*, const StringImpl*); 943 WTF_EXPORT bool equalIgnoringCase(const StringImpl*, const StringImpl*);
943 bool equalIgnoringCase(const StringImpl*, const LChar*); 944 WTF_EXPORT bool equalIgnoringCase(const StringImpl*, const LChar*);
944 inline bool equalIgnoringCase(const LChar* a, const StringImpl* b) { return equa lIgnoringCase(b, a); } 945 inline bool equalIgnoringCase(const LChar* a, const StringImpl* b) { return equa lIgnoringCase(b, a); }
945 bool equalIgnoringCase(const LChar*, const LChar*, unsigned); 946 WTF_EXPORT bool equalIgnoringCase(const LChar*, const LChar*, unsigned);
946 bool equalIgnoringCase(const UChar*, const LChar*, unsigned); 947 WTF_EXPORT bool equalIgnoringCase(const UChar*, const LChar*, unsigned);
947 inline bool equalIgnoringCase(const UChar* a, const char* b, unsigned length) { return equalIgnoringCase(a, reinterpret_cast<const LChar*>(b), length); } 948 inline bool equalIgnoringCase(const UChar* a, const char* b, unsigned length) { return equalIgnoringCase(a, reinterpret_cast<const LChar*>(b), length); }
948 inline bool equalIgnoringCase(const LChar* a, const UChar* b, unsigned length) { return equalIgnoringCase(b, a, length); } 949 inline bool equalIgnoringCase(const LChar* a, const UChar* b, unsigned length) { return equalIgnoringCase(b, a, length); }
949 inline bool equalIgnoringCase(const char* a, const UChar* b, unsigned length) { return equalIgnoringCase(b, reinterpret_cast<const LChar*>(a), length); } 950 inline bool equalIgnoringCase(const char* a, const UChar* b, unsigned length) { return equalIgnoringCase(b, reinterpret_cast<const LChar*>(a), length); }
950 inline bool equalIgnoringCase(const char* a, const LChar* b, unsigned length) { return equalIgnoringCase(b, reinterpret_cast<const LChar*>(a), length); } 951 inline bool equalIgnoringCase(const char* a, const LChar* b, unsigned length) { return equalIgnoringCase(b, reinterpret_cast<const LChar*>(a), length); }
951 inline bool equalIgnoringCase(const UChar* a, const UChar* b, int length) 952 inline bool equalIgnoringCase(const UChar* a, const UChar* b, int length)
952 { 953 {
953 ASSERT(length >= 0); 954 ASSERT(length >= 0);
954 return !Unicode::umemcasecmp(a, b, length); 955 return !Unicode::umemcasecmp(a, b, length);
955 } 956 }
956 bool equalIgnoringCaseNonNull(const StringImpl*, const StringImpl*); 957 WTF_EXPORT bool equalIgnoringCaseNonNull(const StringImpl*, const StringImpl*);
957 958
958 bool equalIgnoringNullity(StringImpl*, StringImpl*); 959 WTF_EXPORT bool equalIgnoringNullity(StringImpl*, StringImpl*);
959 960
960 template<typename CharacterType> 961 template<typename CharacterType>
961 inline size_t find(const CharacterType* characters, unsigned length, CharacterTy pe matchCharacter, unsigned index = 0) 962 inline size_t find(const CharacterType* characters, unsigned length, CharacterTy pe matchCharacter, unsigned index = 0)
962 { 963 {
963 while (index < length) { 964 while (index < length) {
964 if (characters[index] == matchCharacter) 965 if (characters[index] == matchCharacter)
965 return index; 966 return index;
966 ++index; 967 ++index;
967 } 968 }
968 return notFound; 969 return notFound;
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 } 1197 }
1197 1198
1198 using WTF::StringImpl; 1199 using WTF::StringImpl;
1199 using WTF::equal; 1200 using WTF::equal;
1200 using WTF::equalNonNull; 1201 using WTF::equalNonNull;
1201 using WTF::TextCaseSensitivity; 1202 using WTF::TextCaseSensitivity;
1202 using WTF::TextCaseSensitive; 1203 using WTF::TextCaseSensitive;
1203 using WTF::TextCaseInsensitive; 1204 using WTF::TextCaseInsensitive;
1204 1205
1205 #endif 1206 #endif
OLDNEW
« no previous file with comments | « Source/wtf/text/StringBuilder.h ('k') | Source/wtf/text/StringStatics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698