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

Side by Side Diff: third_party/WebKit/Source/platform/inspector_protocol/String16STL.h

Issue 2151083002: DevTools: explicitly differentiate ints vs doubles in the protocol bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lcean Created 4 years, 5 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 String16STL_h 5 #ifndef String16STL_h
6 #define String16STL_h 6 #define String16STL_h
7 7
8 #include <cstdlib> 8 #include <cstdlib>
9 #include <cstring> 9 #include <cstring>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 24 matching lines...) Expand all
35 for (size_t i = 0; i < size; ++i) 35 for (size_t i = 0; i < size; ++i)
36 m_impl[i] = characters[i]; 36 m_impl[i] = characters[i];
37 } 37 }
38 String16(const UChar* characters, size_t size) : m_impl(characters, size) { } 38 String16(const UChar* characters, size_t size) : m_impl(characters, size) { }
39 String16 isolatedCopy() const { return String16(m_impl); } 39 String16 isolatedCopy() const { return String16(m_impl); }
40 40
41 unsigned sizeInBytes() const { return m_impl.size() * sizeof(UChar); } 41 unsigned sizeInBytes() const { return m_impl.size() * sizeof(UChar); }
42 const UChar* characters16() const { return m_impl.c_str(); } 42 const UChar* characters16() const { return m_impl.c_str(); }
43 std::string utf8() const; 43 std::string utf8() const;
44 static String16 fromUTF8(const char* stringStart, size_t length); 44 static String16 fromUTF8(const char* stringStart, size_t length);
45 static String16 number(int i) { return String16(String16::intToString(i).c_s tr()); } 45 static String16 fromInteger(int i) { return String16(String16::intToString(i ).c_str()); }
46 static String16 fromDouble(double d) { return String16(String16::doubleToStr ing(d).c_str()); } 46 static String16 fromDouble(double d) { return String16(String16::doubleToStr ing(d).c_str()); }
47 static String16 fromDoubleFixedPrecision(double d, int len) { return String1 6(String16::doubleToString(d).c_str()); } 47 static String16 fromDoubleFixedPrecision(double d, int len) { return String1 6(String16::doubleToString(d).c_str()); }
48 48
49 static double charactersToDouble(const UChar* characters, size_t length, boo l* ok = 0) 49 static double charactersToDouble(const UChar* characters, size_t length, boo l* ok = 0)
50 { 50 {
51 std::string str; 51 std::string str;
52 str.resize(length); 52 str.resize(length);
53 for (size_t i = 0; i < length; ++i) 53 for (size_t i = 0; i < length; ++i)
54 str[i] = static_cast<char>(characters[i]); 54 str[i] = static_cast<char>(characters[i]);
55 55
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 m_impl += c; 163 m_impl += c;
164 } 164 }
165 165
166 void append(char c) 166 void append(char c)
167 { 167 {
168 m_impl += c; 168 m_impl += c;
169 } 169 }
170 170
171 void appendNumber(int i) 171 void appendNumber(int i)
172 { 172 {
173 m_impl = m_impl + String16::number(i).impl(); 173 m_impl = m_impl + String16::fromInteger(i).impl();
174 } 174 }
175 175
176 void appendNumber(double d) 176 void appendNumber(double d)
177 { 177 {
178 m_impl = m_impl + String16::fromDoubleFixedPrecision(d, 6).impl(); 178 m_impl = m_impl + String16::fromDoubleFixedPrecision(d, 6).impl();
179 } 179 }
180 180
181 void append(const UChar* c, size_t length) 181 void append(const UChar* c, size_t length)
182 { 182 {
183 // presubmit: allow wstring 183 // presubmit: allow wstring
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 { 250 {
251 return string.hash(); 251 return string.hash();
252 } 252 }
253 }; 253 };
254 254
255 } // namespace std 255 } // namespace std
256 256
257 using String = WTF::String; 257 using String = WTF::String;
258 258
259 #endif // !defined(String16STL_h) 259 #endif // !defined(String16STL_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698