OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 15 matching lines...) Expand all Loading... | |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef WebString_h | 31 #ifndef WebString_h |
32 #define WebString_h | 32 #define WebString_h |
33 | 33 |
34 #include "WebCommon.h" | 34 #include "WebCommon.h" |
35 #include "WebPrivatePtr.h" | 35 #include "WebPrivatePtr.h" |
36 #include <string> | |
36 | 37 |
37 #if INSIDE_WEBKIT | 38 #if INSIDE_WEBKIT |
38 #include <wtf/Forward.h> | 39 #include <wtf/Forward.h> |
39 #else | 40 #else |
40 #include <base/strings/latin1_string_conversions.h> | 41 #include <base/strings/latin1_string_conversions.h> |
41 #include <base/strings/nullable_string16.h> | 42 #include <base/strings/nullable_string16.h> |
42 #include <base/strings/string16.h> | 43 #include <base/strings/string16.h> |
43 #endif | 44 #endif |
44 | 45 |
45 namespace WTF { | 46 namespace WTF { |
(...skipping 26 matching lines...) Expand all Loading... | |
72 { | 73 { |
73 assign(s); | 74 assign(s); |
74 return *this; | 75 return *this; |
75 } | 76 } |
76 | 77 |
77 BLINK_COMMON_EXPORT void reset(); | 78 BLINK_COMMON_EXPORT void reset(); |
78 BLINK_COMMON_EXPORT void assign(const WebString&); | 79 BLINK_COMMON_EXPORT void assign(const WebString&); |
79 BLINK_COMMON_EXPORT void assign(const WebUChar* data, size_t len); | 80 BLINK_COMMON_EXPORT void assign(const WebUChar* data, size_t len); |
80 | 81 |
81 BLINK_COMMON_EXPORT bool equals(const WebString&) const; | 82 BLINK_COMMON_EXPORT bool equals(const WebString&) const; |
83 BLINK_COMMON_EXPORT bool lessThan(const WebString&) const; | |
82 | 84 |
83 BLINK_COMMON_EXPORT size_t length() const; | 85 BLINK_COMMON_EXPORT size_t length() const; |
84 | 86 |
85 // Caller must check bounds. | 87 // Caller must check bounds. |
86 BLINK_COMMON_EXPORT WebUChar at(unsigned) const; | 88 BLINK_COMMON_EXPORT WebUChar at(unsigned) const; |
87 | 89 |
88 bool isEmpty() const { return !length(); } | 90 bool isEmpty() const { return !length(); } |
89 bool isNull() const { return m_private.isNull(); } | 91 bool isNull() const { return m_private.isNull(); } |
90 | 92 |
91 BLINK_COMMON_EXPORT WebCString utf8() const; | 93 BLINK_COMMON_EXPORT WebCString utf8() const; |
94 BLINK_COMMON_EXPORT std::string toUTF8String() const; | |
abarth-chromium
2013/07/24 21:59:10
I'm not super happy with this name... Open to sug
Jeffrey Yasskin
2013/07/24 22:23:20
It would be clearer if it mentioned "std", but it
| |
92 | 95 |
93 BLINK_COMMON_EXPORT static WebString fromUTF8(const char* data, size_t lengt h); | 96 BLINK_COMMON_EXPORT static WebString fromUTF8(const char* data, size_t lengt h); |
94 BLINK_COMMON_EXPORT static WebString fromUTF8(const char* data); | 97 BLINK_COMMON_EXPORT static WebString fromUTF8(const char* data); |
95 | 98 |
96 template <int N> WebString(const char (&data)[N]) | 99 template <int N> WebString(const char (&data)[N]) |
97 { | 100 { |
98 assign(fromUTF8(data, N - 1)); | 101 assign(fromUTF8(data, N - 1)); |
99 } | 102 } |
100 | 103 |
101 template <int N> WebString& operator=(const char (&data)[N]) | 104 template <int N> WebString& operator=(const char (&data)[N]) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 private: | 165 private: |
163 BLINK_COMMON_EXPORT bool is8Bit() const; | 166 BLINK_COMMON_EXPORT bool is8Bit() const; |
164 BLINK_COMMON_EXPORT const WebLChar* data8() const; | 167 BLINK_COMMON_EXPORT const WebLChar* data8() const; |
165 BLINK_COMMON_EXPORT const WebUChar* data16() const; | 168 BLINK_COMMON_EXPORT const WebUChar* data16() const; |
166 | 169 |
167 BLINK_COMMON_EXPORT void assign(WTF::StringImpl*); | 170 BLINK_COMMON_EXPORT void assign(WTF::StringImpl*); |
168 | 171 |
169 WebPrivatePtr<WTF::StringImpl> m_private; | 172 WebPrivatePtr<WTF::StringImpl> m_private; |
170 }; | 173 }; |
171 | 174 |
175 inline bool operator<(const WebString& a, const WebString& b) | |
176 { | |
177 return a.lessThan(b); | |
178 } | |
179 | |
172 inline bool operator==(const WebString& a, const WebString& b) | 180 inline bool operator==(const WebString& a, const WebString& b) |
173 { | 181 { |
174 return a.equals(b); | 182 return a.equals(b); |
175 } | 183 } |
176 | 184 |
177 inline bool operator!=(const WebString& a, const WebString& b) | 185 inline bool operator!=(const WebString& a, const WebString& b) |
178 { | 186 { |
179 return !(a == b); | 187 return !(a == b); |
180 } | 188 } |
181 | 189 |
182 } // namespace WebKit | 190 } // namespace WebKit |
183 | 191 |
184 #endif | 192 #endif |
OLD | NEW |