| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef String16WTF_h | 5 #ifndef String16WTF_h |
| 6 #define String16WTF_h | 6 #define String16WTF_h |
| 7 | 7 |
| 8 #include "platform/Decimal.h" | 8 #include "platform/Decimal.h" |
| 9 #include "public/platform/WebString.h" | 9 #include "public/platform/WebString.h" |
| 10 #include "wtf/text/StringBuilder.h" | 10 #include "wtf/text/StringBuilder.h" |
| 11 #include "wtf/text/StringConcatenate.h" | 11 #include "wtf/text/StringConcatenate.h" |
| 12 #include "wtf/text/StringHash.h" | 12 #include "wtf/text/StringHash.h" |
| 13 #include "wtf/text/StringToNumber.h" | 13 #include "wtf/text/StringToNumber.h" |
| 14 #include "wtf/text/StringView.h" |
| 14 #include "wtf/text/WTFString.h" | 15 #include "wtf/text/WTFString.h" |
| 15 | 16 |
| 16 namespace blink { | 17 namespace blink { |
| 17 namespace protocol { | 18 namespace protocol { |
| 18 | 19 |
| 19 class PLATFORM_EXPORT String16 { | 20 class PLATFORM_EXPORT String16 { |
| 20 public: | 21 public: |
| 21 String16() { } | 22 String16() { } |
| 22 String16(const String16& other); | 23 String16(const String16& other); |
| 23 String16(const UChar*, unsigned); | 24 String16(const UChar*, unsigned); |
| 24 String16(const char*); | 25 String16(const char*); |
| 25 String16(const char*, size_t); | 26 String16(const char*, size_t); |
| 26 static String16 createUninitialized(unsigned length, UChar*& data); | 27 static String16 createUninitialized(unsigned length, UChar*& data); |
| 27 | 28 |
| 28 // WTF convenience constructors and helper methods. | 29 // WTF convenience constructors and helper methods. |
| 29 String16(const WebString& other) : String16(String(other)) { } | 30 String16(const WebString& other) : String16(String(other)) { } |
| 30 template<typename StringType1, typename StringType2> | 31 template<typename StringType1, typename StringType2> |
| 31 String16(const WTF::StringAppend<StringType1, StringType2>& impl) : String16
(String(impl)) { } | 32 String16(const WTF::StringAppend<StringType1, StringType2>& impl) : String16
(String(impl)) { } |
| 32 String16(const WTF::AtomicString& impl) : String16(String(impl)) { } | 33 String16(const WTF::AtomicString& impl) : String16(String(impl)) { } |
| 33 String16(const WTF::String& impl); | 34 String16(const WTF::String& impl); |
| 34 String16(WTF::HashTableDeletedValueType) : m_impl(WTF::HashTableDeletedValue
) { } | 35 String16(WTF::HashTableDeletedValueType) : m_impl(WTF::HashTableDeletedValue
) { } |
| 35 bool isHashTableDeletedValue() const { return m_impl.isHashTableDeletedValue
(); } | 36 bool isHashTableDeletedValue() const { return m_impl.isHashTableDeletedValue
(); } |
| 36 operator WTF::String() const { return m_impl; } | 37 operator WTF::String() const { return m_impl; } |
| 38 operator WTF::StringView() const { return StringView(m_impl); } |
| 37 operator WebString() { return m_impl; } | 39 operator WebString() { return m_impl; } |
| 38 const WTF::String& impl() const { return m_impl; } | 40 const WTF::String& impl() const { return m_impl; } |
| 39 String16 isolatedCopy() const { return String16(m_impl.isolatedCopy()); } | 41 String16 isolatedCopy() const { return String16(m_impl.isolatedCopy()); } |
| 40 | 42 |
| 41 ~String16() { } | 43 ~String16() { } |
| 42 | 44 |
| 43 static String16 number(int i) { return String::number(i); } | 45 static String16 number(int i) { return String::number(i); } |
| 44 static String16 fromDouble(double number) { return Decimal::fromDouble(numbe
r).toString(); } | 46 static String16 fromDouble(double number) { return Decimal::fromDouble(numbe
r).toString(); } |
| 45 static String16 fromDoubleFixedPrecision(double number, int precision) { ret
urn String::numberToStringFixedWidth(number, precision); } | 47 static String16 fromDoubleFixedPrecision(double number, int precision) { ret
urn String::numberToStringFixedWidth(number, precision); } |
| 46 | 48 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 68 bool endsWith(const String16& s) const { return m_impl.endsWith(s); } | 70 bool endsWith(const String16& s) const { return m_impl.endsWith(s); } |
| 69 bool endsWith(UChar character) const { return m_impl.endsWith(character); } | 71 bool endsWith(UChar character) const { return m_impl.endsWith(character); } |
| 70 | 72 |
| 71 private: | 73 private: |
| 72 WTF::String m_impl; | 74 WTF::String m_impl; |
| 73 }; | 75 }; |
| 74 | 76 |
| 75 class String16Builder { | 77 class String16Builder { |
| 76 public: | 78 public: |
| 77 String16Builder() { } | 79 String16Builder() { } |
| 78 void append(const String16& str) { m_impl.append(StringView(str)); }; | 80 void append(const String16& str) { m_impl.append(str); }; |
| 79 void append(UChar c) { m_impl.append(c); }; | 81 void append(UChar c) { m_impl.append(c); }; |
| 80 void append(LChar c) { m_impl.append(c); }; | 82 void append(LChar c) { m_impl.append(c); }; |
| 81 void append(char c) { m_impl.append(c); }; | 83 void append(char c) { m_impl.append(c); }; |
| 82 void append(const UChar* c, size_t size) { m_impl.append(c, size); }; | 84 void append(const UChar* c, size_t size) { m_impl.append(c, size); }; |
| 83 void append(const char* characters, unsigned length) { m_impl.append(charact
ers, length); } | 85 void append(const char* characters, unsigned length) { m_impl.append(charact
ers, length); } |
| 84 void appendNumber(int number) { m_impl.appendNumber(number); } | 86 void appendNumber(int number) { m_impl.appendNumber(number); } |
| 85 void appendNumber(double number) { m_impl.appendNumber(number); } | 87 void appendNumber(double number) { m_impl.appendNumber(number); } |
| 86 String16 toString() { return m_impl.toString(); } | 88 String16 toString() { return m_impl.toString(); } |
| 87 void reserveCapacity(unsigned newCapacity) { m_impl.reserveCapacity(newCapac
ity); } | 89 void reserveCapacity(unsigned newCapacity) { m_impl.reserveCapacity(newCapac
ity); } |
| 88 | 90 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 template<> struct hash<String16> { | 145 template<> struct hash<String16> { |
| 144 std::size_t operator()(const String16& string) const | 146 std::size_t operator()(const String16& string) const |
| 145 { | 147 { |
| 146 return StringHash::hash(string.impl()); | 148 return StringHash::hash(string.impl()); |
| 147 } | 149 } |
| 148 }; | 150 }; |
| 149 | 151 |
| 150 } // namespace std | 152 } // namespace std |
| 151 | 153 |
| 152 #endif // !defined(String16WTF_h) | 154 #endif // !defined(String16WTF_h) |
| OLD | NEW |