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

Side by Side Diff: ui/devtools/string_util.h

Issue 2374513002: Add ui devtools server (Closed)
Patch Set: Address @sadrul's comments Created 4 years, 2 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 #ifndef WS_STRINGUTIL_H_
6 #define WS_STRINGUTIL_H_
sadrul 2016/10/17 17:44:36 UI_DEVTOOLS_STRING_UTIL_H_
Sarmad Hashmi 2016/10/17 19:15:29 Done.
7
8 #include <memory>
9
10 #include "base/json/json_reader.h"
11 #include "base/strings/string_number_conversions.h"
12
13 namespace ui {
14 namespace devtools {
15
16 using String = std::string;
17
18 namespace protocol {
19
20 class Value;
21
22 std::unique_ptr<Value> parseJSON(const String& string);
23
24 class CustomStringBuilder {
25 String s_;
26
27 public:
28 CustomStringBuilder() : s_("") {}
29 CustomStringBuilder(String& s) : s_(s) {}
30 void reserveCapacity(std::size_t size) { s_.reserve(size); }
31 void append(const String& s) { s_ += s; }
32 void append(char c) { s_ += c; }
33 void append(const char*, unsigned int length) { return; }
34 String toString() { return s_; }
35 };
36
37 using StringBuilder = CustomStringBuilder;
38
39 class StringUtil {
40 public:
41 static String substring(const String& s, unsigned pos, unsigned len) {
42 return s.substr(pos, len);
43 }
44 static String fromInteger(int number) { return base::IntToString(number); }
45 static String fromDouble(double number) {
46 return base::DoubleToString(number);
47 }
48 static void builderReserve(StringBuilder& builder, unsigned capacity) {
49 builder.reserveCapacity(capacity);
50 }
51 static const size_t kNotFound = -1;
52 };
53
54 } // namespace protocol
55 } // namespace devtools
56 } // namespace ui
57
58 #endif // WS_STRINGUTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698