| 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 <cstdlib> | 9 #include <cstdlib> |
| 10 #include <cstring> | 10 #include <cstring> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 String16(const char* characters) : String16(characters, std::strlen(characte
rs)) { } | 32 String16(const char* characters) : String16(characters, std::strlen(characte
rs)) { } |
| 33 String16(const char* characters, size_t size) | 33 String16(const char* characters, size_t size) |
| 34 { | 34 { |
| 35 m_impl.resize(size); | 35 m_impl.resize(size); |
| 36 for (size_t i = 0; i < size; ++i) | 36 for (size_t i = 0; i < size; ++i) |
| 37 m_impl[i] = characters[i]; | 37 m_impl[i] = characters[i]; |
| 38 } | 38 } |
| 39 String16(const UChar* characters, size_t size) : m_impl(characters, size) {
} | 39 String16(const UChar* characters, size_t size) : m_impl(characters, size) {
} |
| 40 String16 isolatedCopy() const { return String16(m_impl); } | 40 String16 isolatedCopy() const { return String16(m_impl); } |
| 41 | 41 |
| 42 unsigned sizeInBytes() const { return m_impl.size() * sizeof(UChar); } | 42 size_t charactersSizeInBytes() const { return m_impl.size() * sizeof(UChar);
} |
| 43 const UChar* characters16() const { return m_impl.c_str(); } | 43 const UChar* characters16() const { return m_impl.c_str(); } |
| 44 std::string utf8() const; | 44 std::string utf8() const; |
| 45 static String16 fromUTF8(const char* stringStart, size_t length); | 45 static String16 fromUTF8(const char* stringStart, size_t length); |
| 46 static String16 fromInteger(int i) { return String16(String16::intToString(i
).c_str()); } | 46 static String16 fromInteger(int i) { return String16(String16::intToString(i
).c_str()); } |
| 47 static String16 fromDouble(double d) { return String16(String16::doubleToStr
ing(d).c_str()); } | 47 static String16 fromDouble(double d) { return String16(String16::doubleToStr
ing(d).c_str()); } |
| 48 static String16 fromDoubleFixedPrecision(double d, int len) { return String1
6(String16::doubleToString(d).c_str()); } | 48 static String16 fromDoubleFixedPrecision(double d, int len) { return String1
6(String16::doubleToString(d).c_str()); } |
| 49 | 49 |
| 50 static double charactersToDouble(const UChar* characters, size_t length, boo
l* ok = 0) | 50 static double charactersToDouble(const UChar* characters, size_t length, boo
l* ok = 0) |
| 51 { | 51 { |
| 52 std::string str; | 52 std::string str; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 254 } |
| 255 }; | 255 }; |
| 256 | 256 |
| 257 } // namespace std | 257 } // namespace std |
| 258 | 258 |
| 259 #endif // !defined(__APPLE__) || defined(_LIBCPP_VERSION) | 259 #endif // !defined(__APPLE__) || defined(_LIBCPP_VERSION) |
| 260 | 260 |
| 261 using String = WTF::String; | 261 using String = WTF::String; |
| 262 | 262 |
| 263 #endif // !defined(String16STL_h) | 263 #endif // !defined(String16STL_h) |
| OLD | NEW |