OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef V8_INSPECTOR_PUBLIC_STRINGVIEW_H_ |
| 6 #define V8_INSPECTOR_PUBLIC_STRINGVIEW_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 #include <cctype> |
| 10 |
| 11 namespace v8_inspector { |
| 12 |
| 13 class PLATFORM_EXPORT StringView { |
| 14 public: |
| 15 StringView() : m_is8Bit(true), m_length(0), m_characters8(nullptr) {} |
| 16 |
| 17 StringView(const uint8_t* characters, unsigned length) |
| 18 : m_is8Bit(true), m_length(length), m_characters8(characters) {} |
| 19 |
| 20 StringView(const uint16_t* characters, unsigned length) |
| 21 : m_is8Bit(false), m_length(length), m_characters16(characters) {} |
| 22 |
| 23 bool is8Bit() const { return m_is8Bit; } |
| 24 unsigned length() const { return m_length; } |
| 25 |
| 26 // TODO(dgozman): add DCHECK(m_is8Bit) to accessors once platform can be used |
| 27 // here. |
| 28 const uint8_t* characters8() const { return m_characters8; } |
| 29 const uint16_t* characters16() const { return m_characters16; } |
| 30 |
| 31 private: |
| 32 bool m_is8Bit; |
| 33 unsigned m_length; |
| 34 union { |
| 35 const uint8_t* m_characters8; |
| 36 const uint16_t* m_characters16; |
| 37 }; |
| 38 }; |
| 39 |
| 40 } // namespace v8_inspector |
| 41 |
| 42 #endif // V8_INSPECTOR_PUBLIC_STRINGVIEW_H_ |
OLD | NEW |