@@ -31,56 +31,14 @@ using String = std::string;
3131using StringBuilder = std::ostringstream;
3232using ProtocolMessage = std::string;
3333
34+ // Implements StringUtil methods used in `inspector_protocol/lib/`.
3435struct StringUtil {
35- // NOLINTNEXTLINE(runtime/references) This is V8 API...
36- inline static void builderAppend (StringBuilder& builder, char c) {
37- builder.put (c);
38- }
39-
40- // NOLINTNEXTLINE(runtime/references)
41- inline static void builderAppend (StringBuilder& builder,
42- const char * value,
43- size_t length) {
44- builder.write (value, length);
45- }
46-
47- // NOLINTNEXTLINE(runtime/references)
48- inline static void builderAppend (StringBuilder& builder, const char * value) {
49- builderAppend (builder, value, std::strlen (value));
50- }
51-
52- // NOLINTNEXTLINE(runtime/references)
53- inline static void builderAppend (StringBuilder& builder,
54- const String& string) {
55- builder << string;
56- }
57-
58- // NOLINTNEXTLINE(runtime/references)
59- inline static void builderReserve (StringBuilder& builder, size_t ) {
60- // ostringstream does not have a counterpart
61- }
62- inline static String substring (const String& string,
63- size_t start,
64- size_t count) {
65- return string.substr (start, count);
66- }
67- inline static String fromInteger (int n) { return std::to_string (n); }
68- inline static String builderToString (const StringBuilder& builder) {
69- return builder.str ();
70- }
71- inline static size_t find (const String& string, const char * substring) {
72- return string.find (substring);
73- }
74- static String fromDouble (double d);
75- static double toDouble (const char * buffer, size_t length, bool * ok);
76-
36+ // Convert Utf16 in local endianness to Utf8 if needed.
7737 static String StringViewToUtf8 (v8_inspector::StringView view);
7838
7939 static std::unique_ptr<Value> parseJSON (const std::string_view);
8040 static std::unique_ptr<Value> parseJSON (v8_inspector::StringView view);
8141
82- static ProtocolMessage jsonToMessage (String message);
83- static ProtocolMessage binaryToMessage (std::vector<uint8_t > message);
8442 static String fromUTF8 (const uint8_t * data, size_t length);
8543 static String fromUTF16LE (const uint16_t * data, size_t length);
8644 static const uint8_t * CharactersUTF8 (const std::string_view s);
0 commit comments