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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 // | 72 // |
73 // * GURL WebStringToGURL(const WebString&) | 73 // * GURL WebStringToGURL(const WebString&) |
74 // * base::FilePath WebStringToFilePath(const WebString&) | 74 // * base::FilePath WebStringToFilePath(const WebString&) |
75 // * WebString FilePathToWebString(const base::FilePath&); | 75 // * WebString FilePathToWebString(const base::FilePath&); |
76 // | 76 // |
77 // It is inexpensive to copy a WebString object. | 77 // It is inexpensive to copy a WebString object. |
78 // WARNING: It is not safe to pass a WebString across threads!!! | 78 // WARNING: It is not safe to pass a WebString across threads!!! |
79 // | 79 // |
80 class WebString { | 80 class WebString { |
81 public: | 81 public: |
82 enum UTF8ConversionMode { | |
jochen (gone - plz use gerrit)
2017/01/13 08:42:31
nit. why not an enum class? constants should start
kinuko
2017/01/17 07:15:49
Done.
| |
83 LenientUTF8Conversion, | |
84 StrictUTF8Conversion, | |
85 StrictUTF8ConversionReplacingUnpairedSurrogatesWithFFFD | |
86 }; | |
87 | |
82 ~WebString() { reset(); } | 88 ~WebString() { reset(); } |
83 | 89 |
84 WebString() {} | 90 WebString() {} |
85 | 91 |
86 WebString(const WebUChar* data, size_t len) { assign(data, len); } | 92 WebString(const WebUChar* data, size_t len) { assign(data, len); } |
87 | 93 |
88 WebString(const WebString& s) { assign(s); } | 94 WebString(const WebString& s) { assign(s); } |
89 | 95 |
90 WebString& operator=(const WebString& s) { | 96 WebString& operator=(const WebString& s) { |
91 assign(s); | 97 assign(s); |
92 return *this; | 98 return *this; |
93 } | 99 } |
94 | 100 |
95 BLINK_COMMON_EXPORT void reset(); | 101 BLINK_COMMON_EXPORT void reset(); |
96 BLINK_COMMON_EXPORT void assign(const WebString&); | 102 BLINK_COMMON_EXPORT void assign(const WebString&); |
97 BLINK_COMMON_EXPORT void assign(const WebUChar* data, size_t len); | 103 BLINK_COMMON_EXPORT void assign(const WebUChar* data, size_t len); |
98 | 104 |
99 BLINK_COMMON_EXPORT bool equals(const WebString&) const; | 105 BLINK_COMMON_EXPORT bool equals(const WebString&) const; |
100 BLINK_COMMON_EXPORT bool equals(const char* characters) const; | 106 BLINK_COMMON_EXPORT bool equals(const char* characters) const; |
101 | 107 |
102 BLINK_COMMON_EXPORT size_t length() const; | 108 BLINK_COMMON_EXPORT size_t length() const; |
103 | 109 |
104 bool isEmpty() const { return !length(); } | 110 bool isEmpty() const { return !length(); } |
105 bool isNull() const { return m_private.isNull(); } | 111 bool isNull() const { return m_private.isNull(); } |
106 | 112 |
107 BLINK_COMMON_EXPORT std::string utf8() const; | 113 BLINK_COMMON_EXPORT std::string utf8( |
114 UTF8ConversionMode = LenientUTF8Conversion) const; | |
108 | 115 |
109 BLINK_COMMON_EXPORT static WebString fromUTF8(const char* data, | 116 BLINK_COMMON_EXPORT static WebString fromUTF8(const char* data, |
110 size_t length); | 117 size_t length); |
111 BLINK_COMMON_EXPORT static WebString fromUTF8(const char* data); | 118 BLINK_COMMON_EXPORT static WebString fromUTF8(const char* data); |
112 | 119 |
113 static WebString fromUTF8(const std::string& s) { | 120 static WebString fromUTF8(const std::string& s) { |
114 return fromUTF8(s.data(), s.length()); | 121 return fromUTF8(s.data(), s.length()); |
115 } | 122 } |
116 | 123 |
117 base::string16 utf16() const { | 124 base::string16 utf16() const { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 return a.equals(b); | 239 return a.equals(b); |
233 } | 240 } |
234 | 241 |
235 inline bool operator!=(const WebString& a, const WebString& b) { | 242 inline bool operator!=(const WebString& a, const WebString& b) { |
236 return !(a == b); | 243 return !(a == b); |
237 } | 244 } |
238 | 245 |
239 } // namespace blink | 246 } // namespace blink |
240 | 247 |
241 #endif | 248 #endif |
OLD | NEW |