//# This file is a part of toml++ and is subject to the the terms of the MIT license. //# Copyright (c) 2019-2020 Mark Gillard //# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. // SPDX-License-Identifier: MIT #pragma once #include "toml_preprocessor.h" ////////// INCLUDES TOML_PUSH_WARNINGS TOML_DISABLE_ALL_WARNINGS #if __has_include() #include #endif #include #include //memcpy, memset #include #include #include #include #include #include #include #include #include #if !TOML_HAS_CUSTOM_OPTIONAL_TYPE #include #endif TOML_POP_WARNINGS #ifdef __cpp_lib_launder #define TOML_LAUNDER(x) std::launder(x) #else #define TOML_LAUNDER(x) x #endif ////////// ENVIRONMENT GROUND-TRUTHS static_assert(CHAR_BIT == 8); static_assert(FLT_RADIX == 2); static_assert('A' == 65); static_assert(sizeof(double) == 8); static_assert(std::numeric_limits::is_iec559); static_assert(std::numeric_limits::digits == 53); static_assert(std::numeric_limits::digits10 == 15); static_assert(std::numeric_limits::max_digits10 == 17); ////////// FORWARD DECLARATIONS & TYPEDEFS TOML_PUSH_WARNINGS TOML_DISABLE_PADDING_WARNINGS TOML_DISABLE_SHADOW_WARNINGS /// \brief The root namespace for all toml++ functions and types. namespace toml { TOML_ABI_NAMESPACE_VERSION TOML_ABI_NAMESPACE_END } #if TOML_WINDOWS_COMPAT namespace toml { TOML_IMPL_NAMESPACE_START [[nodiscard]] TOML_API std::string narrow(std::wstring_view) noexcept; [[nodiscard]] TOML_API std::wstring widen(std::string_view) noexcept; #ifdef __cpp_lib_char8_t [[nodiscard]] TOML_API std::wstring widen(std::u8string_view) noexcept; #endif TOML_IMPL_NAMESPACE_END } #endif // TOML_WINDOWS_COMPAT namespace toml { TOML_ABI_NAMESPACE_VERSION using namespace std::string_literals; using namespace std::string_view_literals; using size_t = std::size_t; using ptrdiff_t = std::ptrdiff_t; [[nodiscard]] TOML_ATTR(const) TOML_ALWAYS_INLINE TOML_CONSTEVAL size_t operator"" _sz(unsigned long long n) noexcept { return static_cast(n); } // legacy typedefs using string_char = char; using string = std::string; using string_view = std::string_view; #if !TOML_DOXYGEN // foward declarations are hidden from doxygen // because they fuck it up =/ struct date; struct time; struct time_offset; class node; class array; class table; template class node_view; template class value; template class default_formatter; template class json_formatter; TOML_ABI_NAMESPACE_BOOL(TOML_HAS_CUSTOM_OPTIONAL_TYPE, custopt, stdopt) struct date_time; TOML_ABI_NAMESPACE_END // TOML_HAS_CUSTOM_OPTIONAL_TYPE #endif // !TOML_DOXYGEN /// \brief TOML node type identifiers. enum class node_type : uint8_t { none, ///< Not-a-node. table, ///< The node is a toml::table. array, ///< The node is a toml::array. string, ///< The node is a toml::value. integer, ///< The node is a toml::value. floating_point, ///< The node is a toml::value. boolean, ///< The node is a toml::value. date, ///< The node is a toml::value. time, ///< The node is a toml::value