OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project 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 V8_INSPECTOR_STRING16_H_ | 5 #ifndef V8_INSPECTOR_STRING16_H_ |
6 #define V8_INSPECTOR_STRING16_H_ | 6 #define V8_INSPECTOR_STRING16_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <cctype> | 9 #include <cctype> |
10 #include <climits> | 10 #include <climits> |
(...skipping 14 matching lines...) Expand all Loading... |
25 String16(const UChar* characters, size_t size) : m_impl(characters, size) {} | 25 String16(const UChar* characters, size_t size) : m_impl(characters, size) {} |
26 String16(const UChar* characters) : m_impl(characters) {} | 26 String16(const UChar* characters) : m_impl(characters) {} |
27 String16(const char* characters) | 27 String16(const char* characters) |
28 : String16(characters, std::strlen(characters)) {} | 28 : String16(characters, std::strlen(characters)) {} |
29 String16(const char* characters, size_t size) { | 29 String16(const char* characters, size_t size) { |
30 m_impl.resize(size); | 30 m_impl.resize(size); |
31 for (size_t i = 0; i < size; ++i) m_impl[i] = characters[i]; | 31 for (size_t i = 0; i < size; ++i) m_impl[i] = characters[i]; |
32 } | 32 } |
33 | 33 |
34 static String16 fromInteger(int); | 34 static String16 fromInteger(int); |
35 static String16 fromInteger(size_t); | |
36 static String16 fromDouble(double); | 35 static String16 fromDouble(double); |
37 static String16 fromDoublePrecision3(double); | 36 static String16 fromDoublePrecision3(double); |
38 static String16 fromDoublePrecision6(double); | 37 static String16 fromDoublePrecision6(double); |
39 | 38 |
40 int toInteger(bool* ok = nullptr) const; | 39 int toInteger(bool* ok = nullptr) const; |
41 String16 stripWhiteSpace() const; | 40 String16 stripWhiteSpace() const; |
42 const UChar* characters16() const { return m_impl.c_str(); } | 41 const UChar* characters16() const { return m_impl.c_str(); } |
43 size_t length() const { return m_impl.length(); } | 42 size_t length() const { return m_impl.length(); } |
44 bool isEmpty() const { return !m_impl.length(); } | 43 bool isEmpty() const { return !m_impl.length(); } |
45 UChar operator[](size_t index) const { return m_impl[index]; } | 44 UChar operator[](unsigned index) const { return m_impl[index]; } |
46 String16 substring(size_t pos, size_t len = UINT_MAX) const { | 45 String16 substring(unsigned pos, unsigned len = UINT_MAX) const { |
47 return String16(m_impl.substr(pos, len)); | 46 return String16(m_impl.substr(pos, len)); |
48 } | 47 } |
49 size_t find(const String16& str, size_t start = 0) const { | 48 size_t find(const String16& str, unsigned start = 0) const { |
50 return m_impl.find(str.m_impl, start); | 49 return m_impl.find(str.m_impl, start); |
51 } | 50 } |
52 size_t reverseFind(const String16& str, size_t start = UINT_MAX) const { | 51 size_t reverseFind(const String16& str, unsigned start = UINT_MAX) const { |
53 return m_impl.rfind(str.m_impl, start); | 52 return m_impl.rfind(str.m_impl, start); |
54 } | 53 } |
55 void swap(String16& other) { m_impl.swap(other.m_impl); } | 54 void swap(String16& other) { m_impl.swap(other.m_impl); } |
56 | 55 |
57 // Convenience methods. | 56 // Convenience methods. |
58 std::string utf8() const; | 57 std::string utf8() const; |
59 static String16 fromUTF8(const char* stringStart, size_t length); | 58 static String16 fromUTF8(const char* stringStart, size_t length); |
60 | 59 |
61 const std::basic_string<UChar>& impl() const { return m_impl; } | 60 const std::basic_string<UChar>& impl() const { return m_impl; } |
62 explicit String16(const std::basic_string<UChar>& impl) : m_impl(impl) {} | 61 explicit String16(const std::basic_string<UChar>& impl) : m_impl(impl) {} |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 std::size_t operator()(const v8_inspector::String16& string) const { | 123 std::size_t operator()(const v8_inspector::String16& string) const { |
125 return string.hash(); | 124 return string.hash(); |
126 } | 125 } |
127 }; | 126 }; |
128 | 127 |
129 } // namespace std | 128 } // namespace std |
130 | 129 |
131 #endif // !defined(__APPLE__) || defined(_LIBCPP_VERSION) | 130 #endif // !defined(__APPLE__) || defined(_LIBCPP_VERSION) |
132 | 131 |
133 #endif // V8_INSPECTOR_STRING16_H_ | 132 #endif // V8_INSPECTOR_STRING16_H_ |
OLD | NEW |