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