//# This file is a part of toml++ and is subject to the the terms of the MIT license. //# Copyright (c) Mark Gillard //# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. // SPDX-License-Identifier: MIT #pragma once #include "std_string.h" #include "std_new.h" TOML_DISABLE_WARNINGS; #include #include #include #include #include #include #include #include #include #include TOML_ENABLE_WARNINGS; #include "header_start.h" //#--------------------------------------------------------------------------------------------------------------------- //# ENVIRONMENT GROUND-TRUTHS //#--------------------------------------------------------------------------------------------------------------------- /// \cond #ifndef TOML_DISABLE_ENVIRONMENT_CHECKS #define TOML_ENV_MESSAGE \ "If you're seeing this error it's because you're building toml++ for an environment that doesn't conform to " \ "one of the 'ground truths' assumed by the library. Essentially this just means that I don't have the " \ "resources to test on more platforms, but I wish I did! You can try disabling the checks by defining " \ "TOML_DISABLE_ENVIRONMENT_CHECKS, but your mileage may vary. Please consider filing an issue at " \ "https://github.com/marzer/tomlplusplus/issues to help me improve support for your target environment. " \ "Thanks!" static_assert(CHAR_BIT == 8, TOML_ENV_MESSAGE); static_assert(FLT_RADIX == 2, TOML_ENV_MESSAGE); static_assert('A' == 65, TOML_ENV_MESSAGE); static_assert(sizeof(double) == 8, TOML_ENV_MESSAGE); static_assert(std::numeric_limits::is_iec559, TOML_ENV_MESSAGE); static_assert(std::numeric_limits::digits == 53, TOML_ENV_MESSAGE); static_assert(std::numeric_limits::digits10 == 15, TOML_ENV_MESSAGE); #undef TOML_ENV_MESSAGE #endif // !TOML_DISABLE_ENVIRONMENT_CHECKS /// \endcond //#--------------------------------------------------------------------------------------------------------------------- //# UNDOCUMENTED TYPEDEFS AND FORWARD DECLARATIONS //#--------------------------------------------------------------------------------------------------------------------- /// \cond // undocumented forward declarations are hidden from doxygen because they fuck it up =/ namespace toml // non-abi namespace; this is not an error { using ::std::size_t; using ::std::intptr_t; using ::std::uintptr_t; using ::std::ptrdiff_t; using ::std::nullptr_t; using ::std::int8_t; using ::std::int16_t; using ::std::int32_t; using ::std::int64_t; using ::std::uint8_t; using ::std::uint16_t; using ::std::uint32_t; using ::std::uint64_t; using ::std::uint_least32_t; using ::std::uint_least64_t; } TOML_NAMESPACE_START { struct date; struct time; struct time_offset; TOML_ABI_NAMESPACE_BOOL(TOML_HAS_CUSTOM_OPTIONAL_TYPE, custopt, stdopt); struct date_time; TOML_ABI_NAMESPACE_END; struct source_position; struct source_region; class node; template class node_view; class array; class table; template class value; class toml_formatter; class json_formatter; class yaml_formatter; class xml_formatter; TOML_ABI_NAMESPACE_BOOL(TOML_EXCEPTIONS, ex, noex); #if TOML_EXCEPTIONS using parse_result = table; #else class parse_result; #endif TOML_ABI_NAMESPACE_END; // TOML_EXCEPTIONS } TOML_NAMESPACE_END; TOML_IMPL_NAMESPACE_START { TOML_ABI_NAMESPACE_BOOL(TOML_EXCEPTIONS, impl_ex, impl_noex); class parser; TOML_ABI_NAMESPACE_END; // TOML_EXCEPTIONS // clang-format off inline constexpr std::string_view low_character_escape_table[] = { "\\u0000"sv, "\\u0001"sv, "\\u0002"sv, "\\u0003"sv, "\\u0004"sv, "\\u0005"sv, "\\u0006"sv, "\\u0007"sv, "\\b"sv, "\\t"sv, "\\n"sv, "\\u000B"sv, "\\f"sv, "\\r"sv, "\\u000E"sv, "\\u000F"sv, "\\u0010"sv, "\\u0011"sv, "\\u0012"sv, "\\u0013"sv, "\\u0014"sv, "\\u0015"sv, "\\u0016"sv, "\\u0017"sv, "\\u0018"sv, "\\u0019"sv, "\\u001A"sv, "\\u001B"sv, "\\u001C"sv, "\\u001D"sv, "\\u001E"sv, "\\u001F"sv, }; inline constexpr std::string_view node_type_friendly_names[] = { "none"sv, "table"sv, "array"sv, "string"sv, "integer"sv, "floating-point"sv, "boolean"sv, "date"sv, "time"sv, "date-time"sv }; // clang-format on } TOML_IMPL_NAMESPACE_END; #if TOML_ABI_NAMESPACES #if TOML_EXCEPTIONS #define TOML_PARSER_TYPENAME TOML_NAMESPACE::impl::impl_ex::parser #else #define TOML_PARSER_TYPENAME TOML_NAMESPACE::impl::impl_noex::parser #endif #else #define TOML_PARSER_TYPENAME TOML_NAMESPACE::impl::parser #endif /// \endcond //#--------------------------------------------------------------------------------------------------------------------- //# DOCUMENTED TYPEDEFS AND FORWARD DECLARATIONS //#--------------------------------------------------------------------------------------------------------------------- /// \brief The root namespace for all toml++ functions and types. namespace toml { } TOML_NAMESPACE_START // abi namespace { /// \brief Convenience literal operators for working with toml++. /// /// \detail This namespace exists so you can safely hoist the toml++ literal operators into another scope /// without dragging in everything from the toml namespace: \cpp /// /// #include /// using namespace toml::literals; /// /// int main() /// { /// toml::table tbl = "vals = [1, 2, 3]"_toml; /// /// // ... do stuff with the table generated by the "_toml" literal ... /// /// return 0; /// } /// \ecpp /// inline namespace literals { } /// \brief TOML node type identifiers. enum class TOML_CLOSED_ENUM 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