GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage/nodes/benchmark/out/../src/inspector/node_string.h Lines: 22 22 100.0 %
Date: 2019-01-07 12:15:22 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
22
namespace StringUtil {
23
// NOLINTNEXTLINE(runtime/references) This is V8 API...
24
118481
inline void builderAppend(StringBuilder& builder, char c) {
25
118481
  builder.put(c);
26
118482
}
27
28
// NOLINTNEXTLINE(runtime/references)
29
13922
inline void builderAppend(StringBuilder& builder, const char* value,
30
                          size_t length) {
31
13922
  builder.write(value, length);
32
13922
}
33
34
// NOLINTNEXTLINE(runtime/references)
35
13918
inline void builderAppend(StringBuilder& builder, const char* value) {
36
13918
  builderAppend(builder, value, std::strlen(value));
37
13918
}
38
39
// NOLINTNEXTLINE(runtime/references)
40
204
inline void builderAppend(StringBuilder& builder, const String& string) {
41
204
  builder << string;
42
204
}
43
44
// NOLINTNEXTLINE(runtime/references)
45
2319
inline void builderReserve(StringBuilder& builder, size_t) {
46
  // ostringstream does not have a counterpart
47
2319
}
48
17
inline String substring(const String& string, size_t start, size_t count) {
49
17
  return string.substr(start, count);
50
}
51
21
inline String fromInteger(int n) {
52
21
  return std::to_string(n);
53
}
54
2319
inline String builderToString(const StringBuilder& builder) {
55
2319
  return builder.str();
56
}
57
17
inline size_t find(const String& string, const char* substring) {
58
17
  return string.find(substring);
59
}
60
String fromDouble(double d);
61
double toDouble(const char* buffer, size_t length, bool* ok);
62
63
String StringViewToUtf8(v8_inspector::StringView view);
64
65
// NOLINTNEXTLINE(runtime/references)
66
void builderAppendQuotedString(StringBuilder& builder, const String&);
67
std::unique_ptr<Value> parseJSON(const String&);
68
std::unique_ptr<Value> parseJSON(v8_inspector::StringView view);
69
70
extern size_t kNotFound;
71
}  // namespace StringUtil
72
}  // namespace protocol
73
}  // namespace inspector
74
}  // namespace node
75
76
#endif  // SRC_INSPECTOR_NODE_STRING_H_