OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_STRING_H |
| 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_STRING_H |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 |
| 11 #include "base/logging.h" |
| 12 #include "base/macros.h" |
| 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "content/common/content_export.h" |
| 15 |
| 16 namespace content { |
| 17 namespace protocol { |
| 18 |
| 19 class Value; |
| 20 |
| 21 using String = std::string; |
| 22 |
| 23 class CONTENT_EXPORT StringBuilder { |
| 24 public: |
| 25 StringBuilder(); |
| 26 ~StringBuilder(); |
| 27 void append(const std::string&); |
| 28 void append(char); |
| 29 void append(const char*, size_t); |
| 30 std::string toString(); |
| 31 void reserveCapacity(size_t); |
| 32 |
| 33 private: |
| 34 std::string string_; |
| 35 }; |
| 36 |
| 37 class CONTENT_EXPORT StringUtil { |
| 38 public: |
| 39 static String substring(const String& s, unsigned pos, unsigned len) { |
| 40 return s.substr(pos, len); |
| 41 } |
| 42 static String fromInteger(int number) { |
| 43 return base::IntToString(number); |
| 44 } |
| 45 static String fromDouble(double number) { |
| 46 return base::DoubleToString(number); |
| 47 } |
| 48 static const size_t kNotFound = static_cast<size_t>(-1); |
| 49 static void builderReserve(StringBuilder& builder, unsigned capacity) { |
| 50 builder.reserveCapacity(capacity); |
| 51 } |
| 52 static std::unique_ptr<protocol::Value> parseJSON(const String&); |
| 53 }; |
| 54 |
| 55 } // namespace protocol |
| 56 } // namespace content |
| 57 |
| 58 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_STRING_H |
OLD | NEW |