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 String16STL_h | 5 #ifndef String16STL_h |
6 #define String16STL_h | 6 #define String16STL_h |
7 | 7 |
8 #include <cctype> | 8 #include <cctype> |
9 #include <climits> | 9 #include <climits> |
10 #include <cstdlib> | 10 #include <cstdlib> |
(...skipping 24 matching lines...) Expand all Loading... |
35 } | 35 } |
36 | 36 |
37 String16 isolatedCopy() const { return String16(m_impl); } | 37 String16 isolatedCopy() const { return String16(m_impl); } |
38 const UChar* characters16() const { return m_impl.c_str(); } | 38 const UChar* characters16() const { return m_impl.c_str(); } |
39 size_t length() const { return m_impl.length(); } | 39 size_t length() const { return m_impl.length(); } |
40 bool isEmpty() const { return !m_impl.length(); } | 40 bool isEmpty() const { return !m_impl.length(); } |
41 UChar operator[](unsigned index) const { return m_impl[index]; } | 41 UChar operator[](unsigned index) const { return m_impl[index]; } |
42 String16 substring(unsigned pos, unsigned len = UINT_MAX) const { return Str
ing16(m_impl.substr(pos, len)); } | 42 String16 substring(unsigned pos, unsigned len = UINT_MAX) const { return Str
ing16(m_impl.substr(pos, len)); } |
43 size_t find(const String16& str, unsigned start = 0) const { return m_impl.f
ind(str.m_impl, start); } | 43 size_t find(const String16& str, unsigned start = 0) const { return m_impl.f
ind(str.m_impl, start); } |
44 size_t reverseFind(const String16& str, unsigned start = UINT_MAX) const { r
eturn m_impl.rfind(str.m_impl, start); } | 44 size_t reverseFind(const String16& str, unsigned start = UINT_MAX) const { r
eturn m_impl.rfind(str.m_impl, start); } |
| 45 void swap(String16& other) { m_impl.swap(other.m_impl); } |
45 | 46 |
46 // Convenience methods. | 47 // Convenience methods. |
47 std::string utf8() const; | 48 std::string utf8() const; |
48 static String16 fromUTF8(const char* stringStart, size_t length); | 49 static String16 fromUTF8(const char* stringStart, size_t length); |
49 | 50 |
50 const std::basic_string<UChar>& impl() const { return m_impl; } | 51 const std::basic_string<UChar>& impl() const { return m_impl; } |
51 explicit String16(const std::basic_string<UChar>& impl) : m_impl(impl) { } | 52 explicit String16(const std::basic_string<UChar>& impl) : m_impl(impl) { } |
52 | 53 |
53 std::size_t hash() const | 54 std::size_t hash() const |
54 { | 55 { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 96 |
96 class InspectorProtocolConvenienceStringType { | 97 class InspectorProtocolConvenienceStringType { |
97 public: | 98 public: |
98 // This class should not be ever instantiated, so we don't implement constru
ctors. | 99 // This class should not be ever instantiated, so we don't implement constru
ctors. |
99 InspectorProtocolConvenienceStringType(); | 100 InspectorProtocolConvenienceStringType(); |
100 InspectorProtocolConvenienceStringType(const blink::protocol::String16& othe
r); | 101 InspectorProtocolConvenienceStringType(const blink::protocol::String16& othe
r); |
101 operator blink::protocol::String16() const { return blink::protocol::String1
6(); }; | 102 operator blink::protocol::String16() const { return blink::protocol::String1
6(); }; |
102 }; | 103 }; |
103 | 104 |
104 #endif // !defined(String16STL_h) | 105 #endif // !defined(String16STL_h) |
OLD | NEW |