Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/String16WTF.h

Issue 2260233002: [DevTools] Migrate v8_inspector/public from String16 to String{View,Buffer}. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile on win Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef String16WTF_h 5 #ifndef String16WTF_h
6 #define String16WTF_h 6 #define String16WTF_h
7 7
8 #include "platform/Decimal.h" 8 #include "platform/Decimal.h"
9 #include "public/platform/WebString.h" 9 #include "public/platform/WebString.h"
10 #include "wtf/text/StringBuilder.h" 10 #include "wtf/text/StringBuilder.h"
11 #include "wtf/text/StringConcatenate.h" 11 #include "wtf/text/StringConcatenate.h"
12 #include "wtf/text/StringHash.h" 12 #include "wtf/text/StringHash.h"
13 #include "wtf/text/StringToNumber.h" 13 #include "wtf/text/StringToNumber.h"
14 #include "wtf/text/StringView.h"
15 #include "wtf/text/WTFString.h" 14 #include "wtf/text/WTFString.h"
16 15
17 namespace blink { 16 namespace blink {
18 namespace protocol { 17 namespace protocol {
19 18
20 class PLATFORM_EXPORT String16 : public String16Base<String16, UChar> { 19 class PLATFORM_EXPORT String16 : public String16Base<String16, UChar> {
21 public: 20 public:
22 static const size_t kNotFound = WTF::kNotFound; 21 static const size_t kNotFound = WTF::kNotFound;
23 22
24 String16() { } 23 String16() { }
(...skipping 11 matching lines...) Expand all
36 ~String16() { } 35 ~String16() { }
37 36
38 String16 isolatedCopy() const { return String16(m_impl.isolatedCopy()); } 37 String16 isolatedCopy() const { return String16(m_impl.isolatedCopy()); }
39 const UChar* characters16() const { return m_impl.isEmpty() ? nullptr : m_im pl.characters16(); } 38 const UChar* characters16() const { return m_impl.isEmpty() ? nullptr : m_im pl.characters16(); }
40 size_t length() const { return m_impl.length(); } 39 size_t length() const { return m_impl.length(); }
41 bool isEmpty() const { return m_impl.isEmpty(); } 40 bool isEmpty() const { return m_impl.isEmpty(); }
42 UChar operator[](unsigned index) const { return m_impl[index]; } 41 UChar operator[](unsigned index) const { return m_impl[index]; }
43 String16 substring(unsigned pos, unsigned len = UINT_MAX) const { return m_i mpl.substring(pos, len); } 42 String16 substring(unsigned pos, unsigned len = UINT_MAX) const { return m_i mpl.substring(pos, len); }
44 size_t find(const String16& str, unsigned start = 0) const { return m_impl.f ind(str.impl(), start); } 43 size_t find(const String16& str, unsigned start = 0) const { return m_impl.f ind(str.impl(), start); }
45 size_t reverseFind(const String16& str, unsigned start = UINT_MAX) const { r eturn m_impl.reverseFind(str.impl(), start); } 44 size_t reverseFind(const String16& str, unsigned start = UINT_MAX) const { r eturn m_impl.reverseFind(str.impl(), start); }
45 void swap(String16& other) { m_impl.swap(other.m_impl); }
46 46
47 // WTF convenience constructors and helper methods. 47 // WTF convenience constructors and helper methods.
48 String16(const WebString& other) : String16(String(other)) { } 48 String16(const WebString& other) : String16(String(other)) { }
49 template<typename StringType1, typename StringType2> 49 template<typename StringType1, typename StringType2>
50 String16(const WTF::StringAppend<StringType1, StringType2>& impl) : String16 (String(impl)) { } 50 String16(const WTF::StringAppend<StringType1, StringType2>& impl) : String16 (String(impl)) { }
51 String16(const WTF::AtomicString& impl) : String16(String(impl)) { } 51 String16(const WTF::AtomicString& impl) : String16(String(impl)) { }
52 String16(const WTF::String& impl) : m_impl(impl) { m_impl.ensure16Bit(); } 52 String16(const WTF::String& impl) : m_impl(impl) { m_impl.ensure16Bit(); }
53 String16(WTF::HashTableDeletedValueType) : m_impl(WTF::HashTableDeletedValue ) { } 53 String16(WTF::HashTableDeletedValueType) : m_impl(WTF::HashTableDeletedValue ) { }
54 bool isHashTableDeletedValue() const { return m_impl.isHashTableDeletedValue (); } 54 bool isHashTableDeletedValue() const { return m_impl.isHashTableDeletedValue (); }
55 operator WTF::String() const { return m_impl; } 55 operator WTF::String() const { return m_impl; }
56 operator WTF::StringView() const { return StringView(m_impl); }
57 operator WebString() { return m_impl; } 56 operator WebString() { return m_impl; }
58 const WTF::String& impl() const { return m_impl; } 57 const WTF::String& impl() const { return m_impl; }
59 58
60 private: 59 private:
61 WTF::String m_impl; 60 WTF::String m_impl;
62 }; 61 };
63 62
64 inline bool operator==(const String16& a, const String16& b) { return a.impl() = = b.impl(); } 63 inline bool operator==(const String16& a, const String16& b) { return a.impl() = = b.impl(); }
65 inline bool operator!=(const String16& a, const String16& b) { return a.impl() ! = b.impl(); } 64 inline bool operator!=(const String16& a, const String16& b) { return a.impl() ! = b.impl(); }
66 inline bool operator==(const String16& a, const char* b) { return a.impl() == b; } 65 inline bool operator==(const String16& a, const char* b) { return a.impl() == b; }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 101
103 template<> 102 template<>
104 struct HashTraits<blink::protocol::String16> : SimpleClassHashTraits<blink::prot ocol::String16> { 103 struct HashTraits<blink::protocol::String16> : SimpleClassHashTraits<blink::prot ocol::String16> {
105 static const bool hasIsEmptyValueFunction = true; 104 static const bool hasIsEmptyValueFunction = true;
106 static bool isEmptyValue(const blink::protocol::String16& a) { return a.impl ().isNull(); } 105 static bool isEmptyValue(const blink::protocol::String16& a) { return a.impl ().isNull(); }
107 }; 106 };
108 107
109 } // namespace WTF 108 } // namespace WTF
110 109
111 #endif // !defined(String16WTF_h) 110 #endif // !defined(String16WTF_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698