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/HashTableDeletedValueType.h" | 24 #include "wtf/HashTableDeletedValueType.h" |
25 #include "wtf/WTFExport.h" | 25 #include "wtf/WTFExport.h" |
26 #include "wtf/text/CString.h" | 26 #include "wtf/text/CString.h" |
27 #include "wtf/text/WTFString.h" | 27 #include "wtf/text/WTFString.h" |
28 | 28 |
29 // Define 'NO_IMPLICIT_ATOMICSTRING' before including this header, | |
30 // to disallow (expensive) implicit String-->AtomicString conversions. | |
31 #ifdef NO_IMPLICIT_ATOMICSTRING | |
32 #define ATOMICSTRING_CONVERSION explicit | |
33 #else | |
34 #define ATOMICSTRING_CONVERSION | |
35 #endif | |
36 | |
37 namespace WTF { | 29 namespace WTF { |
38 | 30 |
39 struct AtomicStringHash; | 31 struct AtomicStringHash; |
40 | 32 |
41 class WTF_EXPORT AtomicString { | 33 class WTF_EXPORT AtomicString { |
42 public: | 34 public: |
43 static void init(); | 35 static void init(); |
44 | 36 |
45 AtomicString() { } | 37 AtomicString() { } |
46 AtomicString(const LChar* s) : m_string(add(s)) { } | 38 AtomicString(const LChar* s) : m_string(add(s)) { } |
47 AtomicString(const char* s) : m_string(add(s)) { } | 39 AtomicString(const char* s) : m_string(add(s)) { } |
48 AtomicString(const LChar* s, unsigned length) : m_string(add(s, length)) { } | 40 AtomicString(const LChar* s, unsigned length) : m_string(add(s, length)) { } |
49 AtomicString(const UChar* s, unsigned length) : m_string(add(s, length)) { } | 41 AtomicString(const UChar* s, unsigned length) : m_string(add(s, length)) { } |
50 AtomicString(const UChar* s, unsigned length, unsigned existingHash) : m_str
ing(add(s, length, existingHash)) { } | 42 AtomicString(const UChar* s, unsigned length, unsigned existingHash) : m_str
ing(add(s, length, existingHash)) { } |
51 AtomicString(const UChar* s) : m_string(add(s)) { } | 43 AtomicString(const UChar* s) : m_string(add(s)) { } |
52 | 44 |
53 template<size_t inlineCapacity> | 45 template<size_t inlineCapacity> |
54 explicit AtomicString(const Vector<UChar, inlineCapacity>& characters) | 46 explicit AtomicString(const Vector<UChar, inlineCapacity>& characters) |
55 : m_string(add(characters.data(), characters.size())) | 47 : m_string(add(characters.data(), characters.size())) |
56 { | 48 { |
57 } | 49 } |
58 | 50 |
| 51 // Constructing an AtomicString from a String / StringImpl can be expensive
if |
| 52 // the StringImpl is not already atomic. |
59 explicit AtomicString(StringImpl* imp) : m_string(add(imp)) { } | 53 explicit AtomicString(StringImpl* imp) : m_string(add(imp)) { } |
60 ATOMICSTRING_CONVERSION AtomicString(const String& s) : m_string(add(s.impl(
))) { } | 54 explicit AtomicString(const String& s) : m_string(add(s.impl())) { } |
| 55 |
61 AtomicString(StringImpl* baseString, unsigned start, unsigned length) : m_st
ring(add(baseString, start, length)) { } | 56 AtomicString(StringImpl* baseString, unsigned start, unsigned length) : m_st
ring(add(baseString, start, length)) { } |
62 | 57 |
63 enum ConstructFromLiteralTag { ConstructFromLiteral }; | 58 enum ConstructFromLiteralTag { ConstructFromLiteral }; |
64 AtomicString(const char* characters, unsigned length, ConstructFromLiteralTa
g) | 59 AtomicString(const char* characters, unsigned length, ConstructFromLiteralTa
g) |
65 : m_string(addFromLiteralData(characters, length)) | 60 : m_string(addFromLiteralData(characters, length)) |
66 { | 61 { |
67 } | 62 } |
68 | 63 |
69 template<unsigned charactersCount> | 64 template<unsigned charactersCount> |
70 ALWAYS_INLINE AtomicString(const char (&characters)[charactersCount], Constr
uctFromLiteralTag) | 65 ALWAYS_INLINE AtomicString(const char (&characters)[charactersCount], Constr
uctFromLiteralTag) |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 using WTF::nullAtom; | 262 using WTF::nullAtom; |
268 using WTF::emptyAtom; | 263 using WTF::emptyAtom; |
269 using WTF::starAtom; | 264 using WTF::starAtom; |
270 using WTF::xmlAtom; | 265 using WTF::xmlAtom; |
271 using WTF::xmlnsAtom; | 266 using WTF::xmlnsAtom; |
272 using WTF::xlinkAtom; | 267 using WTF::xlinkAtom; |
273 #endif | 268 #endif |
274 | 269 |
275 #include "wtf/text/StringConcatenate.h" | 270 #include "wtf/text/StringConcatenate.h" |
276 #endif // AtomicString_h | 271 #endif // AtomicString_h |
OLD | NEW |