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

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

Issue 2251343003: [DevTools] Generate separate copies of inspector_protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: win compile 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <cstdlib>
6 #include <cstring>
7 #include <string>
8
9 namespace blink {
10 namespace protocol {
11
12 namespace internal {
13
14 void intToStr(int number, char* buffer, size_t length)
15 {
16 std::snprintf(buffer, length, "%d", number);
17 }
18
19 void doubleToStr(double number, char* buffer, size_t length)
20 {
21 std::snprintf(buffer, length, "%f", number);
22 }
23
24 void doubleToStr3(double number, char* buffer, size_t length)
25 {
26 std::snprintf(buffer, length, "%.3g", number);
27 }
28
29 void doubleToStr6(double number, char* buffer, size_t length)
30 {
31 std::snprintf(buffer, length, "%.6g", number);
32 }
33
34 int strToInt(const char* buffer, bool* ok)
35 {
36 char* endptr;
37 int result = std::strtol(buffer, &endptr, 10);
38 if (ok)
39 *ok = !(*endptr);
40 return result;
41 }
42
43 } // namespace internal
44
45 String16Builder::String16Builder()
46 {
47 }
48
49 void String16Builder::append(const String16& s)
50 {
51 m_buffer.insert(m_buffer.end(), s.characters16(), s.characters16() + s.lengt h());
52 }
53
54 void String16Builder::append(UChar c)
55 {
56 m_buffer.push_back(c);
57 }
58
59 void String16Builder::append(char c)
60 {
61 UChar u = c;
62 m_buffer.push_back(u);
63 }
64
65 void String16Builder::append(const UChar* characters, size_t length)
66 {
67 m_buffer.insert(m_buffer.end(), characters, characters + length);
68 }
69
70 void String16Builder::append(const char* characters, size_t length)
71 {
72 m_buffer.reserve(m_buffer.size() + length);
73 for (size_t i = 0; i < length; ++i, ++characters) {
74 UChar u = *characters;
75 m_buffer.push_back(u);
76 }
77 }
78
79 String16 String16Builder::toString()
80 {
81 return String16(m_buffer.data(), m_buffer.size());
82 }
83
84 void String16Builder::reserveCapacity(size_t capacity)
85 {
86 m_buffer.reserve(capacity);
87 }
88
89 } // namespace protocol
90 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698