NeBuild dev
Loading...
Searching...
No Matches
node.inl
Go to the documentation of this file.
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 "array.hpp"
15#include "at_path.hpp"
16#include "header_start.hpp"
17#include "node.hpp"
18#include "node_view.hpp"
19#include "table.hpp"
20#include "value.hpp"
21
24 node::node() noexcept = default;
25
27 node::~node() noexcept = default;
28
30 node::node(node && other) noexcept //
31 : source_{std::exchange(other.source_, {})} {}
32
34 node::node(const node& /*other*/) noexcept {
35 // does not copy source information - this is not an error
36 //
37 // see https://github.com/marzer/tomlplusplus/issues/49#issuecomment-665089577
38 }
39
41 node& node::operator=(const node& /*rhs*/) noexcept {
42 // does not copy source information - this is not an error
43 //
44 // see https://github.com/marzer/tomlplusplus/issues/49#issuecomment-665089577
45
46 source_ = {};
47 return *this;
48 }
49
51 node& node::operator=(node&& rhs) noexcept {
52 if (&rhs != this) source_ = std::exchange(rhs.source_, {});
53 return *this;
54 }
55
57 node_view<node> node::at_path(std::string_view path) noexcept {
58 return toml::at_path(*this, path);
59 }
60
62 node_view<const node> node::at_path(std::string_view path) const noexcept {
63 return toml::at_path(*this, path);
64 }
65
67 node_view<node> node::at_path(const path& p) noexcept {
68 return toml::at_path(*this, p);
69 }
70
72 node_view<const node> node::at_path(const path& p) const noexcept {
73 return toml::at_path(*this, p);
74 }
75
76#if TOML_ENABLE_WINDOWS_COMPAT
77
79 node_view<node> node::at_path(std::wstring_view path) {
80 return toml::at_path(*this, path);
81 }
82
84 node_view<const node> node::at_path(std::wstring_view path) const {
85 return toml::at_path(*this, path);
86 }
87
88#endif // TOML_ENABLE_WINDOWS_COMPAT
89
91 node_view<node> node::operator[](const path& p) noexcept {
92 return toml::at_path(*this, p);
93 }
94
96 node_view<const node> node::operator[](const path& p) const noexcept {
97 return toml::at_path(*this, p);
98 }
99}
101
105 bool TOML_CALLCONV node_deep_equality(const node* lhs, const node* rhs) noexcept {
106 // both same or both null
107 if (lhs == rhs) return true;
108
109 // lhs null != rhs null or different types
110 if ((!lhs != !rhs) || lhs->type() != rhs->type()) return false;
111
112 return lhs->visit([=](auto& l) noexcept {
113 using concrete_type = remove_cvref<decltype(l)>;
114
115 return l == *(rhs->as<concrete_type>());
116 });
117 }
118}
120
121#include "header_end.hpp"
A TOML path.
Definition path.hpp:239
#define TOML_CALLCONV
Calling convention to apply to exported free/static functions. \detail Not defined by default (let th...
Definition preprocessor.hpp:1134
TOML_NAMESPACE_START
Definition node.inl:22
TOML_IMPL_NAMESPACE_START
Definition node.inl:102
TOML_NAMESPACE_END
Definition node.inl:100
#define TOML_EXTERNAL_LINKAGE
Definition preprocessor.hpp:1339
#define TOML_PURE_GETTER
Definition preprocessor.hpp:474
#define TOML_IMPL_NAMESPACE_END
Definition preprocessor.hpp:1334