Chromium Code Reviews| Index: third_party/WebKit/Source/platform/v8_inspector/public/String.h |
| diff --git a/third_party/WebKit/Source/platform/v8_inspector/public/String.h b/third_party/WebKit/Source/platform/v8_inspector/public/String.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..440c5a49838979a822450bd8da1dc3335d26aa2f |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/v8_inspector/public/String.h |
| @@ -0,0 +1,46 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef String_h |
| +#define String_h |
| + |
| +#include "platform/PlatformExport.h" |
| + |
| +#include <cctype> |
| +#include <memory> |
| +#include <stdint.h> |
| + |
| +namespace v8_inspector { |
| + |
| +class PLATFORM_EXPORT StringView { |
| +public: |
| + StringView() : m_is8Bit(true), m_length(0) { m_characters8 = nullptr; } |
| + StringView(const uint8_t* characters, unsigned length) : m_is8Bit(true), m_length(length) { m_characters8 = characters; } |
|
esprehn
2016/08/23 17:35:39
you can just initialize an unnamed union member di
dgozman
2016/08/24 00:45:01
Done.
|
| + StringView(const uint16_t* characters, unsigned length) : m_is8Bit(false), m_length(length) { m_characters16 = characters; } |
|
esprehn
2016/08/23 17:35:39
ditto
|
| + |
| + bool is8Bit() const { return m_is8Bit; } |
| + unsigned length() const { return m_length; } |
| + const uint8_t* characters8() const { return m_characters8; } |
|
esprehn
2016/08/23 17:35:39
DCHECK(m_is8Bit)
dgozman
2016/08/24 00:45:01
Unfortunately, I cannot do that right now, since i
|
| + const uint16_t* characters16() const { return m_characters16; } |
|
esprehn
2016/08/23 17:35:39
DCHECK(!m_is8Bit)
|
| + |
| +private: |
| + bool m_is8Bit; |
| + unsigned m_length; |
| + union { |
| + const uint8_t* m_characters8; |
| + const uint16_t* m_characters16; |
| + }; |
| +}; |
| + |
| +class PLATFORM_EXPORT StringBuffer { |
|
esprehn
2016/08/23 17:35:39
can we put these in separate headers? StringView.h
dgozman
2016/08/24 00:45:01
Sure.
|
| +public: |
| + virtual ~StringBuffer() { } |
| + virtual const StringView& string() = 0; |
| + // This method copies contents. |
| + static std::unique_ptr<StringBuffer> create(const StringView&); |
| +}; |
| + |
| +} // namespace v8_inspector |
| + |
| +#endif // String_h |