OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "platform/inspector_protocol/String16WTF.h" |
| 6 |
| 7 namespace blink { |
| 8 namespace protocol { |
| 9 |
| 10 String16::String16(const String16& other) : m_impl(other.m_impl) { } |
| 11 |
| 12 String16::String16(const UChar* u, unsigned length) : m_impl(u, length) { } |
| 13 |
| 14 String16::String16(const char* characters) : String16(characters, strlen(charact
ers)) { } |
| 15 |
| 16 String16::String16(const WTF::String& other) |
| 17 { |
| 18 if (other.isNull()) |
| 19 return; |
| 20 if (!other.is8Bit()) { |
| 21 m_impl = other; |
| 22 return; |
| 23 } |
| 24 |
| 25 UChar* data; |
| 26 const LChar* characters = other.characters8(); |
| 27 size_t length = other.length(); |
| 28 m_impl = String::createUninitialized(length, data); |
| 29 for (size_t i = 0; i < length; ++i) |
| 30 data[i] = characters[i]; |
| 31 } |
| 32 |
| 33 String16::String16(const char* characters, size_t length) |
| 34 { |
| 35 UChar* data; |
| 36 m_impl = String::createUninitialized(length, data); |
| 37 for (size_t i = 0; i < length; ++i) |
| 38 data[i] = characters[i]; |
| 39 } |
| 40 |
| 41 String16 String16::createUninitialized(unsigned length, UChar*& data) |
| 42 { |
| 43 return String::createUninitialized(length, data); |
| 44 } |
| 45 |
| 46 } // namespace protocol |
| 47 } // namespace blink |
OLD | NEW |