OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 * | 18 * |
19 */ | 19 */ |
20 | 20 |
21 #ifndef AtomicString_h | 21 #ifndef AtomicString_h |
22 #define AtomicString_h | 22 #define AtomicString_h |
23 | 23 |
| 24 #include "wtf/HashSet.h" |
24 #include "wtf/HashTableDeletedValueType.h" | 25 #include "wtf/HashTableDeletedValueType.h" |
25 #include "wtf/WTFExport.h" | 26 #include "wtf/WTFExport.h" |
26 #include "wtf/text/CString.h" | 27 #include "wtf/text/CString.h" |
27 #include "wtf/text/WTFString.h" | 28 #include "wtf/text/WTFString.h" |
28 | 29 |
29 namespace WTF { | 30 namespace WTF { |
30 | 31 |
31 struct AtomicStringHash; | 32 struct AtomicStringHash; |
| 33 class AtomicStringTable; |
32 | 34 |
33 class WTF_EXPORT AtomicString { | 35 class WTF_EXPORT AtomicString { |
34 public: | 36 public: |
35 static void init(); | 37 static void init(); |
36 | 38 |
37 AtomicString() { } | 39 AtomicString() { } |
38 AtomicString(const LChar* s) : m_string(add(s)) { } | 40 AtomicString(const LChar* s) : m_string(add(s)) { } |
39 AtomicString(const char* s) : m_string(add(s)) { } | 41 AtomicString(const char* s) : m_string(add(s)) { } |
40 AtomicString(const LChar* s, unsigned length) : m_string(add(s, length)) { } | 42 AtomicString(const LChar* s, unsigned length) : m_string(add(s, length)) { } |
41 AtomicString(const UChar* s, unsigned length) : m_string(add(s, length)) { } | 43 AtomicString(const UChar* s, unsigned length) : m_string(add(s, length)) { } |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 } | 177 } |
176 static PassRefPtr<StringImpl> addFromLiteralData(const char* characters, uns
igned length); | 178 static PassRefPtr<StringImpl> addFromLiteralData(const char* characters, uns
igned length); |
177 static PassRefPtr<StringImpl> addSlowCase(StringImpl*); | 179 static PassRefPtr<StringImpl> addSlowCase(StringImpl*); |
178 #if USE(CF) | 180 #if USE(CF) |
179 static PassRefPtr<StringImpl> add(CFStringRef); | 181 static PassRefPtr<StringImpl> add(CFStringRef); |
180 #endif | 182 #endif |
181 | 183 |
182 static AtomicString fromUTF8Internal(const char*, const char*); | 184 static AtomicString fromUTF8Internal(const char*, const char*); |
183 }; | 185 }; |
184 | 186 |
| 187 class AtomicStringTable { |
| 188 WTF_MAKE_NONCOPYABLE(AtomicStringTable); |
| 189 public: |
| 190 StringImpl* addStringImpl(StringImpl*); |
| 191 |
| 192 HashSet<StringImpl*>& table() { return m_table; } |
| 193 |
| 194 private: |
| 195 AtomicStringTable() = default; |
| 196 static AtomicStringTable* create(); |
| 197 static void destroy(AtomicStringTable*); |
| 198 friend class WTFThreadData; |
| 199 |
| 200 HashSet<StringImpl*> m_table; |
| 201 }; |
| 202 |
185 inline bool operator==(const AtomicString& a, const AtomicString& b) { return a.
impl() == b.impl(); } | 203 inline bool operator==(const AtomicString& a, const AtomicString& b) { return a.
impl() == b.impl(); } |
186 WTF_EXPORT bool operator==(const AtomicString&, const LChar*); | 204 WTF_EXPORT bool operator==(const AtomicString&, const LChar*); |
187 inline bool operator==(const AtomicString& a, const char* b) { return WTF::equal
(a.impl(), reinterpret_cast<const LChar*>(b)); } | 205 inline bool operator==(const AtomicString& a, const char* b) { return WTF::equal
(a.impl(), reinterpret_cast<const LChar*>(b)); } |
188 inline bool operator==(const AtomicString& a, const Vector<UChar>& b) { return a
.impl() && equal(a.impl(), b.data(), b.size()); } | 206 inline bool operator==(const AtomicString& a, const Vector<UChar>& b) { return a
.impl() && equal(a.impl(), b.data(), b.size()); } |
189 inline bool operator==(const AtomicString& a, const String& b) { return equal(a.
impl(), b.impl()); } | 207 inline bool operator==(const AtomicString& a, const String& b) { return equal(a.
impl(), b.impl()); } |
190 inline bool operator==(const LChar* a, const AtomicString& b) { return b == a; } | 208 inline bool operator==(const LChar* a, const AtomicString& b) { return b == a; } |
191 inline bool operator==(const char* a, const AtomicString& b) { return b == a; } | 209 inline bool operator==(const char* a, const AtomicString& b) { return b == a; } |
192 inline bool operator==(const String& a, const AtomicString& b) { return equal(a.
impl(), b.impl()); } | 210 inline bool operator==(const String& a, const AtomicString& b) { return equal(a.
impl(), b.impl()); } |
193 inline bool operator==(const Vector<UChar>& a, const AtomicString& b) { return b
== a; } | 211 inline bool operator==(const Vector<UChar>& a, const AtomicString& b) { return b
== a; } |
194 | 212 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 using WTF::AtomicString; | 268 using WTF::AtomicString; |
251 using WTF::nullAtom; | 269 using WTF::nullAtom; |
252 using WTF::emptyAtom; | 270 using WTF::emptyAtom; |
253 using WTF::starAtom; | 271 using WTF::starAtom; |
254 using WTF::xmlAtom; | 272 using WTF::xmlAtom; |
255 using WTF::xmlnsAtom; | 273 using WTF::xmlnsAtom; |
256 using WTF::xlinkAtom; | 274 using WTF::xlinkAtom; |
257 | 275 |
258 #include "wtf/text/StringConcatenate.h" | 276 #include "wtf/text/StringConcatenate.h" |
259 #endif // AtomicString_h | 277 #endif // AtomicString_h |
OLD | NEW |