| OLD | NEW |
| 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 COMPONENTS_UI_DEVTOOLS_STRING_UTIL_H_ | 5 #ifndef COMPONENTS_UI_DEVTOOLS_STRING_UTIL_H_ |
| 6 #define COMPONENTS_UI_DEVTOOLS_STRING_UTIL_H_ | 6 #define COMPONENTS_UI_DEVTOOLS_STRING_UTIL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 | 12 |
| 13 namespace ui { | 13 namespace ui { |
| 14 namespace devtools { | 14 namespace devtools { |
| 15 | 15 |
| 16 using String = std::string; | 16 using String = std::string; |
| 17 | 17 |
| 18 namespace protocol { | 18 namespace protocol { |
| 19 | 19 |
| 20 class Value; | 20 class Value; |
| 21 | 21 |
| 22 std::unique_ptr<Value> parseJSON(const String& string); | |
| 23 | |
| 24 class CustomStringBuilder { | 22 class CustomStringBuilder { |
| 25 String s_; | 23 String s_; |
| 26 | 24 |
| 27 public: | 25 public: |
| 28 CustomStringBuilder() {} | 26 CustomStringBuilder() {} |
| 29 CustomStringBuilder(String& s) : s_(s) {} | 27 CustomStringBuilder(String& s) : s_(s) {} |
| 30 void reserveCapacity(std::size_t size) { s_.reserve(size); } | 28 void reserveCapacity(std::size_t size) { s_.reserve(size); } |
| 31 void append(const String& s) { s_ += s; } | 29 void append(const String& s) { s_ += s; } |
| 32 void append(char c) { s_ += c; } | 30 void append(char c) { s_ += c; } |
| 33 void append(const char* data, unsigned int length) { | 31 void append(const char* data, unsigned int length) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 44 return s.substr(pos, len); | 42 return s.substr(pos, len); |
| 45 } | 43 } |
| 46 static String fromInteger(int number) { return base::IntToString(number); } | 44 static String fromInteger(int number) { return base::IntToString(number); } |
| 47 static String fromDouble(double number) { | 45 static String fromDouble(double number) { |
| 48 return base::DoubleToString(number); | 46 return base::DoubleToString(number); |
| 49 } | 47 } |
| 50 static void builderReserve(StringBuilder& builder, unsigned capacity) { | 48 static void builderReserve(StringBuilder& builder, unsigned capacity) { |
| 51 builder.reserveCapacity(capacity); | 49 builder.reserveCapacity(capacity); |
| 52 } | 50 } |
| 53 static const size_t kNotFound = static_cast<size_t>(-1); | 51 static const size_t kNotFound = static_cast<size_t>(-1); |
| 52 static std::unique_ptr<Value> parseJSON(const String& string); |
| 54 }; | 53 }; |
| 55 | 54 |
| 56 } // namespace protocol | 55 } // namespace protocol |
| 57 } // namespace devtools | 56 } // namespace devtools |
| 58 } // namespace ui | 57 } // namespace ui |
| 59 | 58 |
| 60 #endif // COMPONENTS_UI_DEVTOOLS_STRING_UTIL_H_ | 59 #endif // COMPONENTS_UI_DEVTOOLS_STRING_UTIL_H_ |
| OLD | NEW |