2021-10-23 09:22:41 +00:00
|
|
|
//# This file is a part of toml++ and is subject to the the terms of the MIT license.
|
|
|
|
//# Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>
|
|
|
|
//# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#pragma once
|
2021-10-24 22:04:23 +00:00
|
|
|
|
2021-10-23 09:22:41 +00:00
|
|
|
//# {{
|
|
|
|
#include "preprocessor.h"
|
|
|
|
#if !TOML_IMPLEMENTATION
|
2021-10-24 22:04:23 +00:00
|
|
|
#error This is an implementation-only header.
|
2021-10-23 09:22:41 +00:00
|
|
|
#endif
|
|
|
|
//# }}
|
|
|
|
|
|
|
|
#include "node.h"
|
2021-10-24 22:04:23 +00:00
|
|
|
#include "node_view.h"
|
2022-01-06 11:26:01 +00:00
|
|
|
#include "at_path.h"
|
|
|
|
#include "table.h"
|
|
|
|
#include "array.h"
|
|
|
|
#include "value.h"
|
2021-10-24 10:21:32 +00:00
|
|
|
#include "header_start.h"
|
2021-10-23 09:22:41 +00:00
|
|
|
|
|
|
|
TOML_NAMESPACE_START
|
|
|
|
{
|
2022-02-12 12:25:43 +00:00
|
|
|
TOML_EXTERNAL_LINKAGE
|
|
|
|
node::node() noexcept = default;
|
|
|
|
|
|
|
|
TOML_EXTERNAL_LINKAGE
|
|
|
|
node::~node() noexcept = default;
|
|
|
|
|
2021-10-23 09:22:41 +00:00
|
|
|
TOML_EXTERNAL_LINKAGE
|
|
|
|
node::node(node && other) noexcept //
|
|
|
|
: source_{ std::exchange(other.source_, {}) }
|
|
|
|
{}
|
|
|
|
|
|
|
|
TOML_EXTERNAL_LINKAGE
|
|
|
|
node::node(const node& /*other*/) noexcept
|
|
|
|
{
|
|
|
|
// does not copy source information - this is not an error
|
|
|
|
//
|
|
|
|
// see https://github.com/marzer/tomlplusplus/issues/49#issuecomment-665089577
|
|
|
|
}
|
|
|
|
|
|
|
|
TOML_EXTERNAL_LINKAGE
|
|
|
|
node& node::operator=(const node& /*rhs*/) noexcept
|
|
|
|
{
|
|
|
|
// does not copy source information - this is not an error
|
|
|
|
//
|
|
|
|
// see https://github.com/marzer/tomlplusplus/issues/49#issuecomment-665089577
|
|
|
|
|
|
|
|
source_ = {};
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
TOML_EXTERNAL_LINKAGE
|
|
|
|
node& node::operator=(node&& rhs) noexcept
|
|
|
|
{
|
|
|
|
if (&rhs != this)
|
|
|
|
source_ = std::exchange(rhs.source_, {});
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2022-01-06 11:26:01 +00:00
|
|
|
TOML_EXTERNAL_LINKAGE
|
|
|
|
node_view<node> node::at_path(std::string_view path) noexcept
|
|
|
|
{
|
|
|
|
return toml::at_path(*this, path);
|
|
|
|
}
|
|
|
|
|
|
|
|
TOML_EXTERNAL_LINKAGE
|
|
|
|
node_view<const node> node::at_path(std::string_view path) const noexcept
|
|
|
|
{
|
|
|
|
return toml::at_path(*this, path);
|
|
|
|
}
|
|
|
|
|
2022-06-04 13:49:26 +00:00
|
|
|
TOML_EXTERNAL_LINKAGE
|
2022-06-06 20:46:04 +00:00
|
|
|
node_view<node> node::at_path(const path& p) noexcept
|
2022-06-04 13:49:26 +00:00
|
|
|
{
|
2022-06-06 20:46:04 +00:00
|
|
|
return toml::at_path(*this, p);
|
2022-06-04 13:49:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TOML_EXTERNAL_LINKAGE
|
2022-06-06 20:46:04 +00:00
|
|
|
node_view<const node> node::at_path(const path& p) const noexcept
|
2022-06-04 13:49:26 +00:00
|
|
|
{
|
2022-06-06 20:46:04 +00:00
|
|
|
return toml::at_path(*this, p);
|
2022-06-04 13:49:26 +00:00
|
|
|
}
|
|
|
|
|
2022-01-06 11:26:01 +00:00
|
|
|
#if TOML_ENABLE_WINDOWS_COMPAT
|
|
|
|
|
|
|
|
TOML_EXTERNAL_LINKAGE
|
|
|
|
node_view<node> node::at_path(std::wstring_view path)
|
|
|
|
{
|
|
|
|
return toml::at_path(*this, path);
|
|
|
|
}
|
|
|
|
|
|
|
|
TOML_EXTERNAL_LINKAGE
|
|
|
|
node_view<const node> node::at_path(std::wstring_view path) const
|
|
|
|
{
|
|
|
|
return toml::at_path(*this, path);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // TOML_ENABLE_WINDOWS_COMPAT
|
2022-06-06 20:46:04 +00:00
|
|
|
|
|
|
|
TOML_EXTERNAL_LINKAGE
|
|
|
|
node_view<node> node::operator[](const path& p) noexcept
|
|
|
|
{
|
|
|
|
return toml::at_path(*this, p);
|
|
|
|
}
|
|
|
|
|
|
|
|
TOML_EXTERNAL_LINKAGE
|
|
|
|
node_view<const node> node::operator[](const path& p) const noexcept
|
|
|
|
{
|
|
|
|
return toml::at_path(*this, p);
|
|
|
|
}
|
2021-10-23 09:22:41 +00:00
|
|
|
}
|
|
|
|
TOML_NAMESPACE_END;
|
2021-10-24 10:21:32 +00:00
|
|
|
|
2022-01-06 11:26:01 +00:00
|
|
|
TOML_IMPL_NAMESPACE_START
|
|
|
|
{
|
2022-07-31 12:47:42 +00:00
|
|
|
TOML_PURE_GETTER
|
2022-01-06 11:26:01 +00:00
|
|
|
TOML_EXTERNAL_LINKAGE
|
2022-06-06 09:21:46 +00:00
|
|
|
bool TOML_CALLCONV node_deep_equality(const node* lhs, const node* rhs) noexcept
|
2022-01-06 11:26:01 +00:00
|
|
|
{
|
|
|
|
// both same or both null
|
|
|
|
if (lhs == rhs)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// lhs null != rhs null or different types
|
|
|
|
if ((!lhs != !rhs) || lhs->type() != rhs->type())
|
|
|
|
return false;
|
|
|
|
|
2022-04-24 17:21:59 +00:00
|
|
|
return lhs->visit(
|
|
|
|
[=](auto& l) noexcept
|
2022-01-06 11:26:01 +00:00
|
|
|
{
|
|
|
|
using concrete_type = remove_cvref<decltype(l)>;
|
|
|
|
|
2022-04-24 17:21:59 +00:00
|
|
|
return l == *(rhs->as<concrete_type>());
|
2022-01-06 11:26:01 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TOML_IMPL_NAMESPACE_END;
|
|
|
|
|
2021-10-24 10:21:32 +00:00
|
|
|
#include "header_end.h"
|