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 // Note: this guard is specifically made different to not clash with wtf/text/St
ringView.h. |
| 6 // It will be moved to v8 and changed in the future. |
| 7 #ifndef v8_inspector_StringView_h |
| 8 #define v8_inspector_StringView_h |
| 9 |
| 10 #include <cctype> |
| 11 #include <stdint.h> |
| 12 |
| 13 namespace v8_inspector { |
| 14 |
| 15 class StringView { |
| 16 public: |
| 17 StringView() : m_is8Bit(true), m_length(0) { m_characters8 = nullptr; } |
| 18 StringView(const uint8_t* characters, unsigned length) : m_is8Bit(true), m_l
ength(length) { m_characters8 = characters; } |
| 19 StringView(const uint16_t* characters, unsigned length) : m_is8Bit(false), m
_length(length) { m_characters16 = characters; } |
| 20 |
| 21 bool is8Bit() const { return m_is8Bit; } |
| 22 unsigned length() const { return m_length; } |
| 23 const uint8_t* characters8() const { return m_characters8; } |
| 24 const uint16_t* characters16() const { return m_characters16; } |
| 25 |
| 26 private: |
| 27 bool m_is8Bit; |
| 28 unsigned m_length; |
| 29 union { |
| 30 const uint8_t* m_characters8; |
| 31 const uint16_t* m_characters16; |
| 32 }; |
| 33 }; |
| 34 |
| 35 } // namespace v8_inspector |
| 36 |
| 37 #endif // v8_inspector_StringView_h |
OLD | NEW |