#pragma once #include "toml_node.h" namespace toml { template class value final : public node { static_assert( impl::is_value, "Template type parameter must be one of the basic value types" ); private: friend class impl::parser; template [[nodiscard]] TOML_ALWAYS_INLINE static auto as_value([[maybe_unused]] V* ptr) noexcept { if constexpr (std::is_same_v) return ptr; else return nullptr; } T val_; public: template TOML_NODISCARD_CTOR explicit value(U&&... args) TOML_CONDITIONAL_NOEXCEPT(std::is_nothrow_constructible_v) : val_{ std::forward(args)... } {} TOML_NODISCARD_CTOR value(value&& other) noexcept : node{ std::move(other) }, val_{ std::move(other.val_) } {} value& operator= (value&& rhs) noexcept { node::operator=(std::move(rhs)); val_ = std::move(rhs.val_); return *this; } [[nodiscard]] node_type type() const noexcept override { if constexpr (std::is_same_v) return node_type::string; else if constexpr (std::is_same_v) return node_type::integer; else if constexpr (std::is_same_v) return node_type::floating_point; else if constexpr (std::is_same_v) return node_type::boolean; else if constexpr (std::is_same_v) return node_type::date; else if constexpr (std::is_same_v) return node_type::time; else if constexpr (std::is_same_v) return node_type::date_time; } [[nodiscard]] bool is_table() const noexcept override { return false; } [[nodiscard]] bool is_array() const noexcept override { return false; } [[nodiscard]] bool is_value() const noexcept override { return true; } [[nodiscard]] bool is_string() const noexcept override { return std::is_same_v; } [[nodiscard]] bool is_integer() const noexcept override { return std::is_same_v; } [[nodiscard]] bool is_floating_point() const noexcept override { return std::is_same_v; } [[nodiscard]] bool is_boolean() const noexcept override { return std::is_same_v; } [[nodiscard]] bool is_date() const noexcept override { return std::is_same_v; } [[nodiscard]] bool is_time() const noexcept override { return std::is_same_v; } [[nodiscard]] bool is_date_time() const noexcept override { return std::is_same_v; } [[nodiscard]] value* as_string() noexcept override { return as_value(this); } [[nodiscard]] value* as_integer() noexcept override { return as_value(this); } [[nodiscard]] value* as_floating_point() noexcept override { return as_value(this); } [[nodiscard]] value* as_boolean() noexcept override { return as_value(this); } [[nodiscard]] value* as_date() noexcept override { return as_value(this); } [[nodiscard]] value