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

Unified Diff: components/ui_devtools/string_util.h

Issue 2374513002: Add ui devtools server (Closed)
Patch Set: Move everything to components/ui_devtools 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 side-by-side diff with in-line comments
Download patch
Index: components/ui_devtools/string_util.h
diff --git a/components/ui_devtools/string_util.h b/components/ui_devtools/string_util.h
new file mode 100644
index 0000000000000000000000000000000000000000..7dc4b7e79f1cf49910caf00bc359d7808e7546db
--- /dev/null
+++ b/components/ui_devtools/string_util.h
@@ -0,0 +1,60 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_DEVTOOLS_STRING_UTIL_H_
+#define UI_DEVTOOLS_STRING_UTIL_H_
+
+#include <memory>
+
+#include "base/json/json_reader.h"
+#include "base/strings/string_number_conversions.h"
+
+namespace ui {
+namespace devtools {
+
+using String = std::string;
+
+namespace protocol {
+
+class Value;
+
+std::unique_ptr<Value> parseJSON(const String& string);
+
+class CustomStringBuilder {
+ String s_;
+
+ public:
+ CustomStringBuilder() {}
+ CustomStringBuilder(String& s) : s_(s) {}
+ void reserveCapacity(std::size_t size) { s_.reserve(size); }
+ void append(const String& s) { s_ += s; }
+ void append(char c) { s_ += c; }
+ void append(const char* data, unsigned int length) {
+ s_.append(data, length);
+ }
+ String toString() { return s_; }
+};
+
+using StringBuilder = CustomStringBuilder;
+
+class StringUtil {
+ public:
+ static String substring(const String& s, unsigned pos, unsigned len) {
+ return s.substr(pos, len);
+ }
+ static String fromInteger(int number) { return base::IntToString(number); }
+ static String fromDouble(double number) {
+ return base::DoubleToString(number);
+ }
+ static void builderReserve(StringBuilder& builder, unsigned capacity) {
+ builder.reserveCapacity(capacity);
+ }
+ static const size_t kNotFound = -1;
+};
+
+} // namespace protocol
+} // namespace devtools
+} // namespace ui
+
+#endif // UI_DEVTOOLS_STRING_UTIL_H_

Powered by Google App Engine
This is Rietveld 408576698