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 CONTENT_BROWSER_DEVTOOLS_PROTOCOL_STRING_H | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_STRING_H |
6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_STRING_H | 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_STRING_H |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 static String fromInteger(int number) { | 46 static String fromInteger(int number) { |
47 return base::IntToString(number); | 47 return base::IntToString(number); |
48 } | 48 } |
49 static String fromDouble(double number) { | 49 static String fromDouble(double number) { |
50 String s = base::DoubleToString(number); | 50 String s = base::DoubleToString(number); |
51 if (!s.empty() && s[0] == '.') | 51 if (!s.empty() && s[0] == '.') |
52 s = "0" + s; | 52 s = "0" + s; |
53 return s; | 53 return s; |
54 } | 54 } |
| 55 static double toDouble(const char* s, size_t len, bool* ok) { |
| 56 double v = 0.0; |
| 57 *ok = base::StringToDouble(std::string(s, len), &v); |
| 58 return *ok ? v : 0.0; |
| 59 } |
55 static size_t find(const String& s, const char* needle) { | 60 static size_t find(const String& s, const char* needle) { |
56 return s.find(needle); | 61 return s.find(needle); |
57 } | 62 } |
58 static size_t find(const String& s, const String& needle) { | 63 static size_t find(const String& s, const String& needle) { |
59 return s.find(needle); | 64 return s.find(needle); |
60 } | 65 } |
61 static const size_t kNotFound = static_cast<size_t>(-1); | 66 static const size_t kNotFound = static_cast<size_t>(-1); |
62 static void builderAppend(StringBuilder& builder, const String& s) { | 67 static void builderAppend(StringBuilder& builder, const String& s) { |
63 builder.append(s); | 68 builder.append(s); |
64 } | 69 } |
(...skipping 13 matching lines...) Expand all Loading... |
78 }; | 83 }; |
79 | 84 |
80 std::unique_ptr<protocol::Value> toProtocolValue( | 85 std::unique_ptr<protocol::Value> toProtocolValue( |
81 const base::Value* value, int depth); | 86 const base::Value* value, int depth); |
82 std::unique_ptr<base::Value> toBaseValue(protocol::Value* value, int depth); | 87 std::unique_ptr<base::Value> toBaseValue(protocol::Value* value, int depth); |
83 | 88 |
84 } // namespace protocol | 89 } // namespace protocol |
85 } // namespace content | 90 } // namespace content |
86 | 91 |
87 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_STRING_H | 92 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_STRING_H |
OLD | NEW |