| 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" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 class StringUtil { | 39 class StringUtil { |
| 40 public: | 40 public: |
| 41 static String substring(const String& s, unsigned pos, unsigned len) { | 41 static String substring(const String& s, unsigned pos, unsigned len) { |
| 42 return s.substr(pos, len); | 42 return s.substr(pos, len); |
| 43 } | 43 } |
| 44 static String fromInteger(int number) { return base::IntToString(number); } | 44 static String fromInteger(int number) { return base::IntToString(number); } |
| 45 static String fromDouble(double number) { | 45 static String fromDouble(double number) { |
| 46 return base::DoubleToString(number); | 46 return base::DoubleToString(number); |
| 47 } | 47 } |
| 48 static void builderAppend(StringBuilder& builder, const String& s) { |
| 49 builder.append(s); |
| 50 } |
| 51 static void builderAppend(StringBuilder& builder, char c) { |
| 52 builder.append(c); |
| 53 } |
| 54 static void builderAppend(StringBuilder& builder, const char* s, size_t len) { |
| 55 builder.append(s, len); |
| 56 } |
| 48 static void builderReserve(StringBuilder& builder, unsigned capacity) { | 57 static void builderReserve(StringBuilder& builder, unsigned capacity) { |
| 49 builder.reserveCapacity(capacity); | 58 builder.reserveCapacity(capacity); |
| 50 } | 59 } |
| 60 static String builderToString(StringBuilder& builder) { |
| 61 return builder.toString(); |
| 62 } |
| 51 static const size_t kNotFound = static_cast<size_t>(-1); | 63 static const size_t kNotFound = static_cast<size_t>(-1); |
| 52 static std::unique_ptr<Value> parseJSON(const String& string); | 64 static std::unique_ptr<Value> parseJSON(const String& string); |
| 53 }; | 65 }; |
| 54 | 66 |
| 55 } // namespace protocol | 67 } // namespace protocol |
| 56 } // namespace devtools | 68 } // namespace devtools |
| 57 } // namespace ui | 69 } // namespace ui |
| 58 | 70 |
| 59 #endif // COMPONENTS_UI_DEVTOOLS_STRING_UTIL_H_ | 71 #endif // COMPONENTS_UI_DEVTOOLS_STRING_UTIL_H_ |
| OLD | NEW |