//# 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 #ifndef TOML_OPTIONAL_TYPE #include #endif TOML_POP_WARNINGS #if TOML_CHAR_8_STRINGS && !defined(__cpp_lib_char8_t) #error toml++ requires implementation support to use char8_t strings, but yours does not provide it. #endif #ifdef __cpp_lib_launder #define TOML_LAUNDER(x) std::launder(x) #else #define TOML_LAUNDER(x) x #endif ////////// FORWARD DECLARATIONS & TYPEDEFS /// \brief The root namespace for all toml++ functions and types. namespace toml { 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); } #if TOML_CHAR_8_STRINGS using string_char = char8_t; using string = std::u8string; using string_view = std::u8string_view; #else /// \brief The base character type for keys and string values. /// \remarks This will be an alias for char8_t if #TOML_CHAR_8_STRINGS is enabled. using string_char = char; /// \brief The string type for keys and string values. /// \remarks This will be an alias for std::u8string if #TOML_CHAR_8_STRINGS is enabled. using string = std::string; /// \brief The string type for keys and string values. /// \remarks This will be an alias for std::u8string_view if #TOML_CHAR_8_STRINGS is enabled. using string_view = std::string_view; #endif TOML_PUSH_WARNINGS TOML_DISABLE_PADDING_WARNINGS TOML_DISABLE_SHADOW_WARNINGS // false positive on gcc #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; #ifdef TOML_OPTIONAL_TYPE TOML_ABI_NAMESPACE_START(custopt) #else TOML_ABI_NAMESPACE_START(stdopt) #endif struct date_time; TOML_ABI_NAMESPACE_END // TOML_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