| 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 double toDouble(const char* s, size_t len, bool* ok) { |
| 49 double v = 0.0; |
| 50 *ok = base::StringToDouble(std::string(s, len), &v); |
| 51 return *ok ? v : 0.0; |
| 52 } |
| 48 static void builderAppend(StringBuilder& builder, const String& s) { | 53 static void builderAppend(StringBuilder& builder, const String& s) { |
| 49 builder.append(s); | 54 builder.append(s); |
| 50 } | 55 } |
| 51 static void builderAppend(StringBuilder& builder, char c) { | 56 static void builderAppend(StringBuilder& builder, char c) { |
| 52 builder.append(c); | 57 builder.append(c); |
| 53 } | 58 } |
| 54 static void builderAppend(StringBuilder& builder, const char* s, size_t len) { | 59 static void builderAppend(StringBuilder& builder, const char* s, size_t len) { |
| 55 builder.append(s, len); | 60 builder.append(s, len); |
| 56 } | 61 } |
| 57 static void builderReserve(StringBuilder& builder, unsigned capacity) { | 62 static void builderReserve(StringBuilder& builder, unsigned capacity) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 68 } | 73 } |
| 69 static const size_t kNotFound = static_cast<size_t>(-1); | 74 static const size_t kNotFound = static_cast<size_t>(-1); |
| 70 static std::unique_ptr<Value> parseJSON(const String& string); | 75 static std::unique_ptr<Value> parseJSON(const String& string); |
| 71 }; | 76 }; |
| 72 | 77 |
| 73 } // namespace protocol | 78 } // namespace protocol |
| 74 } // namespace devtools | 79 } // namespace devtools |
| 75 } // namespace ui | 80 } // namespace ui |
| 76 | 81 |
| 77 #endif // COMPONENTS_UI_DEVTOOLS_STRING_UTIL_H_ | 82 #endif // COMPONENTS_UI_DEVTOOLS_STRING_UTIL_H_ |
| OLD | NEW |