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

Side by Side Diff: third_party/WebKit/Source/platform/inspector_protocol/String16_h.template

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: better Created 4 years, 4 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 String16_h 5 #ifndef String16_h
6 #define String16_h 6 #define String16_h
7 7
8 //#include "Collections.h" 8 //#include "Collections.h"
9 //#include "Platform.h" 9 //#include "Platform.h"
10 #include "{{config.class_export.header}}" 10 #include "{{config.class_export.header}}"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 if (ok) 73 if (ok)
74 *ok = false; 74 *ok = false;
75 return 0; 75 return 0;
76 } 76 }
77 buffer.push_back(static_cast<char>(characters[i])); 77 buffer.push_back(static_cast<char>(characters[i]));
78 } 78 }
79 buffer.push_back('\0'); 79 buffer.push_back('\0');
80 return internal::strToDouble(buffer.data(), ok); 80 return internal::strToDouble(buffer.data(), ok);
81 } 81 }
82 82
83 static double charactersToDouble(const uint8_t* characters, size_t length, b ool* ok = nullptr)
84 {
85 std::string buffer(reinterpret_cast<const char*>(characters), length);
86 return internal::strToDouble(buffer.c_str(), ok);
87 }
88
83 static int charactersToInteger(const C* characters, size_t length, bool* ok = nullptr) 89 static int charactersToInteger(const C* characters, size_t length, bool* ok = nullptr)
84 { 90 {
85 std::vector<char> buffer; 91 std::vector<char> buffer;
86 buffer.reserve(length + 1); 92 buffer.reserve(length + 1);
87 for (size_t i = 0; i < length; ++i) { 93 for (size_t i = 0; i < length; ++i) {
88 if (!isASCII(characters[i])) { 94 if (!isASCII(characters[i])) {
89 if (ok) 95 if (ok)
90 *ok = false; 96 *ok = false;
91 return 0; 97 return 0;
92 } 98 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 return T(); 135 return T();
130 136
131 // skip white space from end 137 // skip white space from end
132 while (end && isSpaceOrNewLine(characters[end])) 138 while (end && isSpaceOrNewLine(characters[end]))
133 --end; 139 --end;
134 140
135 if (!start && end == length - 1) 141 if (!start && end == length - 1)
136 return T(static_cast<const T&>(*this)); 142 return T(static_cast<const T&>(*this));
137 return T(characters + start, end + 1 - start); 143 return T(characters + start, end + 1 - start);
138 } 144 }
139
140 bool startsWith(const char* prefix) const
141 {
142 const C* characters = static_cast<const T&>(*this).characters16();
143 size_t length = static_cast<const T&>(*this).length();
144 for (size_t i = 0, j = 0; prefix[j] && i < length; ++i, ++j) {
145 if (characters[i] != prefix[j])
146 return false;
147 }
148 return true;
149 }
150 }; 145 };
151 146
152 } // namespace protocol 147 } // namespace protocol
153 } // namespace blink 148 } // namespace blink
154 149
155 #include "{{config.lib.string16_header}}" 150 #include "{{config.lib.string16_header}}"
156 151
157 namespace blink { 152 namespace blink {
158 namespace protocol { 153 namespace protocol {
159 154
(...skipping 12 matching lines...) Expand all
172 std::vector<UChar> m_buffer; 167 std::vector<UChar> m_buffer;
173 }; 168 };
174 169
175 } // namespace protocol 170 } // namespace protocol
176 } // namespace blink 171 } // namespace blink
177 172
178 using String16 = blink::protocol::String16; 173 using String16 = blink::protocol::String16;
179 using String16Builder = blink::protocol::String16Builder; 174 using String16Builder = blink::protocol::String16Builder;
180 175
181 #endif // !defined(String16_h) 176 #endif // !defined(String16_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698