GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/inspector/node_string.h Lines: 22 28 78.6 %
Date: 2019-09-13 22:28:55 Branches: 0 0 - %

Line Branch Exec Source
1
// Bridges V8 Inspector generated code with the std::string used by the Node
2
// Compare to V8 counterpart - deps/v8/src/inspector/string-util.h
3
#ifndef SRC_INSPECTOR_NODE_STRING_H_
4
#define SRC_INSPECTOR_NODE_STRING_H_
5
6
#include "util.h"
7
#include "v8-inspector.h"
8
9
#include <cstring>
10
#include <sstream>
11
#include <string>
12
13
namespace node {
14
namespace inspector {
15
namespace protocol {
16
17
class Value;
18
19
using String = std::string;
20
using StringBuilder = std::ostringstream;
21
using ProtocolMessage = std::string;
22
23
namespace StringUtil {
24
// NOLINTNEXTLINE(runtime/references) This is V8 API...
25
730258
inline void builderAppend(StringBuilder& builder, char c) {
26
730258
  builder.put(c);
27
730264
}
28
29
// NOLINTNEXTLINE(runtime/references)
30
12816
inline void builderAppend(StringBuilder& builder, const char* value,
31
                          size_t length) {
32
12816
  builder.write(value, length);
33
12816
}
34
35
// NOLINTNEXTLINE(runtime/references)
36
12806
inline void builderAppend(StringBuilder& builder, const char* value) {
37
12806
  builderAppend(builder, value, std::strlen(value));
38
12806
}
39
40
// NOLINTNEXTLINE(runtime/references)
41
261
inline void builderAppend(StringBuilder& builder, const String& string) {
42
261
  builder << string;
43
261
}
44
45
// NOLINTNEXTLINE(runtime/references)
46
64334
inline void builderReserve(StringBuilder& builder, size_t) {
47
  // ostringstream does not have a counterpart
48
64334
}
49
36
inline String substring(const String& string, size_t start, size_t count) {
50
36
  return string.substr(start, count);
51
}
52
40
inline String fromInteger(int n) {
53
40
  return std::to_string(n);
54
}
55
64334
inline String builderToString(const StringBuilder& builder) {
56
64334
  return builder.str();
57
}
58
36
inline size_t find(const String& string, const char* substring) {
59
36
  return string.find(substring);
60
}
61
String fromDouble(double d);
62
double toDouble(const char* buffer, size_t length, bool* ok);
63
64
String StringViewToUtf8(v8_inspector::StringView view);
65
66
// NOLINTNEXTLINE(runtime/references)
67
void builderAppendQuotedString(StringBuilder& builder, const String&);
68
std::unique_ptr<Value> parseJSON(const String&);
69
std::unique_ptr<Value> parseJSON(v8_inspector::StringView view);
70
71
std::unique_ptr<Value> parseMessage(const std::string& message, bool binary);
72
ProtocolMessage jsonToMessage(String message);
73
ProtocolMessage binaryToMessage(std::vector<uint8_t> message);
74
String fromUTF8(const uint8_t* data, size_t length);
75
String fromUTF16(const uint16_t* data, size_t length);
76
const uint8_t* CharactersUTF8(const String& s);
77
size_t CharacterCount(const String& s);
78
79
// Unimplemented. The generated code will fall back to CharactersUTF8().
80
inline uint8_t* CharactersLatin1(const String& s) { return nullptr; }
81
inline const uint16_t* CharactersUTF16(const String& s) { return nullptr; }
82
83
extern size_t kNotFound;
84
}  // namespace StringUtil
85
86
// A read-only sequence of uninterpreted bytes with reference-counted storage.
87
// Though the templates for generating the protocol bindings reference
88
// this type, js_protocol.pdl doesn't have a field of type 'binary', so
89
// therefore it's unnecessary to provide an implementation here.
90
class Binary {
91
 public:
92
  const uint8_t* data() const { UNREACHABLE(); }
93
  size_t size() const { UNREACHABLE(); }
94
  String toBase64() const { UNREACHABLE(); }
95
  static Binary fromBase64(const String& base64, bool* success) {
96
    UNREACHABLE();
97
  }
98
  static Binary fromSpan(const uint8_t* data, size_t size) { UNREACHABLE(); }
99
};
100
101
}  // namespace protocol
102
}  // namespace inspector
103
}  // namespace node
104
105
#endif  // SRC_INSPECTOR_NODE_STRING_H_