GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tracing/traced_value.h Lines: 2 2 100.0 %
Date: 2022-08-21 04:19:51 Branches: 0 0 - %

Line Branch Exec Source
1
// Copyright 2016 the V8 project 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 SRC_TRACING_TRACED_VALUE_H_
6
#define SRC_TRACING_TRACED_VALUE_H_
7
8
#include "node.h"
9
#include "util.h"
10
#include "v8.h"
11
12
#include <cstddef>
13
#include <memory>
14
#include <string>
15
16
namespace node {
17
namespace tracing {
18
19
class TracedValue : public v8::ConvertableToTraceFormat {
20
 public:
21
348
  ~TracedValue() override = default;
22
23
  static std::unique_ptr<TracedValue> Create();
24
  static std::unique_ptr<TracedValue> CreateArray();
25
26
  void EndDictionary();
27
  void EndArray();
28
29
  // These methods assume that |name| is a long lived "quoted" string.
30
  void SetInteger(const char* name, int value);
31
  void SetDouble(const char* name, double value);
32
  void SetBoolean(const char* name, bool value);
33
  void SetNull(const char* name);
34
  void SetString(const char* name, const char* value);
35
  void SetString(const char* name, const std::string& value) {
36
    SetString(name, value.c_str());
37
  }
38
  void BeginDictionary(const char* name);
39
  void BeginArray(const char* name);
40
41
  void AppendInteger(int);
42
  void AppendDouble(double);
43
  void AppendBoolean(bool);
44
  void AppendNull();
45
  void AppendString(const char*);
46
35
  void AppendString(const std::string& value) { AppendString(value.c_str()); }
47
  void BeginArray();
48
  void BeginDictionary();
49
50
  // ConvertableToTraceFormat implementation.
51
  void AppendAsTraceFormat(std::string* out) const override;
52
53
  TracedValue(const TracedValue&) = delete;
54
  TracedValue& operator=(const TracedValue&) = delete;
55
56
 private:
57
  explicit TracedValue(bool root_is_array = false);
58
59
  void WriteComma();
60
  void WriteName(const char* name);
61
62
  std::string data_;
63
  bool first_item_;
64
  bool root_is_array_;
65
};
66
67
}  // namespace tracing
68
}  // namespace node
69
70
#endif  // SRC_TRACING_TRACED_VALUE_H_