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 20 matching lines...) Expand all Loading... | |
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 #include <string> |
37 | 37 |
38 #if INSIDE_BLINK | 38 #if INSIDE_BLINK |
39 #include "wtf/Forward.h" | 39 #include "wtf/Forward.h" |
40 #else | 40 #else |
41 #include <base/strings/latin1_string_conversions.h> | 41 #include "base/strings/latin1_string_conversions.h" |
42 #include <base/strings/nullable_string16.h> | 42 #include "base/strings/nullable_string16.h" |
43 #include <base/strings/string16.h> | 43 #include "base/strings/string16.h" |
44 #endif | 44 #endif |
45 | 45 |
46 namespace WTF { | 46 namespace WTF { |
47 class StringImpl; | 47 class StringImpl; |
48 } | 48 } |
49 | 49 |
50 namespace blink { | 50 namespace blink { |
51 | 51 |
52 // A UTF-16 string container. It is inexpensive to copy a WebString | 52 // A UTF-16 string container. It is inexpensive to copy a WebString |
53 // object. | 53 // object. |
(...skipping 24 matching lines...) Expand all Loading... | |
78 BLINK_COMMON_EXPORT void assign(const WebUChar* data, size_t len); | 78 BLINK_COMMON_EXPORT void assign(const WebUChar* data, size_t len); |
79 | 79 |
80 BLINK_COMMON_EXPORT bool equals(const WebString&) const; | 80 BLINK_COMMON_EXPORT bool equals(const WebString&) const; |
81 BLINK_COMMON_EXPORT bool equals(const char* characters) const; | 81 BLINK_COMMON_EXPORT bool equals(const char* characters) const; |
82 | 82 |
83 BLINK_COMMON_EXPORT size_t length() const; | 83 BLINK_COMMON_EXPORT size_t length() const; |
84 | 84 |
85 bool isEmpty() const { return !length(); } | 85 bool isEmpty() const { return !length(); } |
86 bool isNull() const { return m_private.isNull(); } | 86 bool isNull() const { return m_private.isNull(); } |
87 | 87 |
88 // See also WebStringUTF8Adaptor which will allow getting a UTF-8 buffer | |
89 // without copying when the string is ASCII. | |
88 BLINK_COMMON_EXPORT std::string utf8() const; | 90 BLINK_COMMON_EXPORT std::string utf8() const; |
89 | 91 |
90 BLINK_COMMON_EXPORT static WebString fromUTF8(const char* data, size_t lengt h); | 92 BLINK_COMMON_EXPORT static WebString fromUTF8(const char* data, size_t lengt h); |
91 BLINK_COMMON_EXPORT static WebString fromUTF8(const char* data); | 93 BLINK_COMMON_EXPORT static WebString fromUTF8(const char* data); |
92 | 94 |
93 static WebString fromUTF8(const std::string& s) | 95 static WebString fromUTF8(const std::string& s) |
94 { | 96 { |
95 return fromUTF8(s.data(), s.length()); | 97 return fromUTF8(s.data(), s.length()); |
96 } | 98 } |
97 | 99 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 #endif | 166 #endif |
165 | 167 |
166 private: | 168 private: |
167 BLINK_COMMON_EXPORT bool is8Bit() const; | 169 BLINK_COMMON_EXPORT bool is8Bit() const; |
168 BLINK_COMMON_EXPORT const WebLChar* data8() const; | 170 BLINK_COMMON_EXPORT const WebLChar* data8() const; |
169 BLINK_COMMON_EXPORT const WebUChar* data16() const; | 171 BLINK_COMMON_EXPORT const WebUChar* data16() const; |
170 | 172 |
171 BLINK_COMMON_EXPORT void assign(WTF::StringImpl*); | 173 BLINK_COMMON_EXPORT void assign(WTF::StringImpl*); |
172 | 174 |
173 WebPrivatePtr<WTF::StringImpl> m_private; | 175 WebPrivatePtr<WTF::StringImpl> m_private; |
176 | |
177 friend class WebStringUTF8Adaptor; | |
esprehn
2016/01/13 02:02:31
you don't need friends.
| |
174 }; | 178 }; |
175 | 179 |
176 inline bool operator==(const WebString& a, const char* b) | 180 inline bool operator==(const WebString& a, const char* b) |
177 { | 181 { |
178 return a.equals(b); | 182 return a.equals(b); |
179 } | 183 } |
180 | 184 |
181 inline bool operator!=(const WebString& a, const char* b) | 185 inline bool operator!=(const WebString& a, const char* b) |
182 { | 186 { |
183 return !(a == b); | 187 return !(a == b); |
(...skipping 15 matching lines...) Expand all Loading... | |
199 } | 203 } |
200 | 204 |
201 inline bool operator!=(const WebString& a, const WebString& b) | 205 inline bool operator!=(const WebString& a, const WebString& b) |
202 { | 206 { |
203 return !(a == b); | 207 return !(a == b); |
204 } | 208 } |
205 | 209 |
206 } // namespace blink | 210 } // namespace blink |
207 | 211 |
208 #endif | 212 #endif |
OLD | NEW |