Coverage Report

Created: 2025-10-28 07:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/tomlplusplus/include/toml++/impl/node.inl
Line
Count
Source
1
//# This file is a part of toml++ and is subject to the the terms of the MIT license.
2
//# Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>
3
//# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
4
// SPDX-License-Identifier: MIT
5
#pragma once
6
7
//# {{
8
#include "preprocessor.hpp"
9
#if !TOML_IMPLEMENTATION
10
#error This is an implementation-only header.
11
#endif
12
//# }}
13
14
#include "node.hpp"
15
#include "node_view.hpp"
16
#include "at_path.hpp"
17
#include "table.hpp"
18
#include "array.hpp"
19
#include "value.hpp"
20
#include "header_start.hpp"
21
22
TOML_NAMESPACE_START
23
{
24
  TOML_EXTERNAL_LINKAGE
25
1.73M
  node::node() noexcept = default;
26
27
  TOML_EXTERNAL_LINKAGE
28
1.73M
  node::~node() noexcept = default;
29
30
  TOML_EXTERNAL_LINKAGE
31
  node::node(node && other) noexcept //
32
3.59k
    : source_{ std::exchange(other.source_, {}) }
33
3.59k
  {}
34
35
  TOML_EXTERNAL_LINKAGE
36
  node::node(const node& /*other*/) noexcept
37
  {
38
    // does not copy source information - this is not an error
39
    //
40
    // see https://github.com/marzer/tomlplusplus/issues/49#issuecomment-665089577
41
  }
42
43
  TOML_EXTERNAL_LINKAGE
44
  node& node::operator=(const node& /*rhs*/) noexcept
45
0
  {
46
0
    // does not copy source information - this is not an error
47
0
    //
48
0
    // see https://github.com/marzer/tomlplusplus/issues/49#issuecomment-665089577
49
0
50
0
    source_ = {};
51
0
    return *this;
52
0
  }
53
54
  TOML_EXTERNAL_LINKAGE
55
  node& node::operator=(node&& rhs) noexcept
56
0
  {
57
0
    if (&rhs != this)
58
0
      source_ = std::exchange(rhs.source_, {});
59
0
    return *this;
60
0
  }
61
62
  TOML_EXTERNAL_LINKAGE
63
  node_view<node> node::at_path(std::string_view path) noexcept
64
0
  {
65
0
    return toml::at_path(*this, path);
66
0
  }
67
68
  TOML_EXTERNAL_LINKAGE
69
  node_view<const node> node::at_path(std::string_view path) const noexcept
70
0
  {
71
0
    return toml::at_path(*this, path);
72
0
  }
73
74
  TOML_EXTERNAL_LINKAGE
75
  node_view<node> node::at_path(const path& p) noexcept
76
0
  {
77
0
    return toml::at_path(*this, p);
78
0
  }
79
80
  TOML_EXTERNAL_LINKAGE
81
  node_view<const node> node::at_path(const path& p) const noexcept
82
0
  {
83
0
    return toml::at_path(*this, p);
84
0
  }
85
86
#if TOML_ENABLE_WINDOWS_COMPAT
87
88
  TOML_EXTERNAL_LINKAGE
89
  node_view<node> node::at_path(std::wstring_view path)
90
  {
91
    return toml::at_path(*this, path);
92
  }
93
94
  TOML_EXTERNAL_LINKAGE
95
  node_view<const node> node::at_path(std::wstring_view path) const
96
  {
97
    return toml::at_path(*this, path);
98
  }
99
100
#endif // TOML_ENABLE_WINDOWS_COMPAT
101
102
  TOML_EXTERNAL_LINKAGE
103
  node_view<node> node::operator[](const path& p) noexcept
104
0
  {
105
0
    return toml::at_path(*this, p);
106
0
  }
107
108
  TOML_EXTERNAL_LINKAGE
109
  node_view<const node> node::operator[](const path& p) const noexcept
110
0
  {
111
0
    return toml::at_path(*this, p);
112
0
  }
113
}
114
TOML_NAMESPACE_END;
115
116
TOML_IMPL_NAMESPACE_START
117
{
118
  TOML_PURE_GETTER
119
  TOML_EXTERNAL_LINKAGE
120
  bool TOML_CALLCONV node_deep_equality(const node* lhs, const node* rhs) noexcept
121
0
  {
122
0
    // both same or both null
123
0
    if (lhs == rhs)
124
0
      return true;
125
0
126
0
    // lhs null != rhs null or different types
127
0
    if ((!lhs != !rhs) || lhs->type() != rhs->type())
128
0
      return false;
129
0
130
0
    return lhs->visit(
131
0
      [=](auto& l) noexcept
132
0
      {
133
0
        using concrete_type = remove_cvref<decltype(l)>;
134
0
135
0
        return l == *(rhs->as<concrete_type>());
136
0
      });
137
0
  }
138
}
139
TOML_IMPL_NAMESPACE_END;
140
141
#include "header_end.hpp"