44#ifndef TOMLPLUSPLUS_HPP
45#define TOMLPLUSPLUS_HPP
47#define INCLUDE_TOMLPLUSPLUS_H
53# error toml++ is a C++ library.
58# if _MSVC_LANG > __cplusplus
59# define TOML_CPP _MSVC_LANG
63# define TOML_CPP __cplusplus
65# if TOML_CPP >= 202900L
68# elif TOML_CPP >= 202600L
71# elif TOML_CPP >= 202302L
74# elif TOML_CPP >= 202002L
77# elif TOML_CPP >= 201703L
80# elif TOML_CPP >= 201402L
83# elif TOML_CPP >= 201103L
93# error toml++ requires C++17 or higher. For a pre-C++11 TOML library see https:
95# error toml++ requires C++17 or higher. For a C++11 TOML library see https:
98#ifndef TOML_MAKE_VERSION
99# define TOML_MAKE_VERSION(major, minor, patch) \
100 (((major)*10000) + ((minor)*100) + ((patch)))
103#ifndef TOML_INTELLISENSE
104# ifdef __INTELLISENSE__
105# define TOML_INTELLISENSE 1
107# define TOML_INTELLISENSE 0
112# if defined(DOXYGEN) || defined(__DOXYGEN) || defined(__DOXYGEN__) || \
113 defined(__doxygen__) || defined(__POXY__) || defined(__poxy__)
114# define TOML_DOXYGEN 1
116# define TOML_DOXYGEN 0
122# define TOML_CLANG __clang_major__
132# if TOML_CLANG && defined(__apple_build_version__)
134# define TOML_CLANG_VERSION \
135 TOML_MAKE_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
136# if TOML_CLANG_VERSION >= TOML_MAKE_VERSION(15, 0, 0)
137# define TOML_CLANG 16
138# elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(14, 3, 0)
139# define TOML_CLANG 15
140# elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(14, 0, 0)
141# define TOML_CLANG 14
142# elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(13, 1, 6)
143# define TOML_CLANG 13
144# elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(13, 0, 0)
145# define TOML_CLANG 12
146# elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(12, 0, 5)
147# define TOML_CLANG 11
148# elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(12, 0, 0)
149# define TOML_CLANG 10
150# elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(11, 0, 3)
152# elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(11, 0, 0)
154# elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(10, 0, 1)
159# undef TOML_CLANG_VERSION
164# ifdef __INTEL_COMPILER
165# define TOML_ICC __INTEL_COMPILER
167# define TOML_ICC_CL TOML_ICC
169# define TOML_ICC_CL 0
173# define TOML_ICC_CL 0
177#ifndef TOML_MSVC_LIKE
179# define TOML_MSVC_LIKE _MSC_VER
181# define TOML_MSVC_LIKE 0
186# if TOML_MSVC_LIKE && !TOML_CLANG && !TOML_ICC
187# define TOML_MSVC TOML_MSVC_LIKE
195# define TOML_GCC_LIKE __GNUC__
197# define TOML_GCC_LIKE 0
202# if TOML_GCC_LIKE && !TOML_CLANG && !TOML_ICC
203# define TOML_GCC TOML_GCC_LIKE
210# if defined(__CUDACC__) || defined(__CUDA_ARCH__) || \
211 defined(__CUDA_LIBDEVICE__)
219# ifdef __NVCOMPILER_MAJOR__
220# define TOML_NVCC __NVCOMPILER_MAJOR__
226#ifndef TOML_ARCH_ITANIUM
227# if defined(__ia64__) || defined(__ia64) || defined(_IA64) || \
228 defined(__IA64__) || defined(_M_IA64)
229# define TOML_ARCH_ITANIUM 1
230# define TOML_ARCH_BITNESS 64
232# define TOML_ARCH_ITANIUM 0
236#ifndef TOML_ARCH_AMD64
237# if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || \
238 defined(__x86_64) || defined(_M_AMD64)
239# define TOML_ARCH_AMD64 1
240# define TOML_ARCH_BITNESS 64
242# define TOML_ARCH_AMD64 0
247# if defined(__i386__) || defined(_M_IX86)
248# define TOML_ARCH_X86 1
249# define TOML_ARCH_BITNESS 32
251# define TOML_ARCH_X86 0
256# if defined(__aarch64__) || defined(__ARM_ARCH_ISA_A64) || \
257 defined(_M_ARM64) || defined(__ARM_64BIT_STATE) || defined(_M_ARM64EC)
258# define TOML_ARCH_ARM32 0
259# define TOML_ARCH_ARM64 1
260# define TOML_ARCH_ARM 1
261# define TOML_ARCH_BITNESS 64
262# elif defined(__arm__) || defined(_M_ARM) || defined(__ARM_32BIT_STATE)
263# define TOML_ARCH_ARM32 1
264# define TOML_ARCH_ARM64 0
265# define TOML_ARCH_ARM 1
266# define TOML_ARCH_BITNESS 32
268# define TOML_ARCH_ARM32 0
269# define TOML_ARCH_ARM64 0
270# define TOML_ARCH_ARM 0
274#ifndef TOML_ARCH_BITNESS
275# define TOML_ARCH_BITNESS 0
279# if TOML_ARCH_BITNESS == 64
280# define TOML_ARCH_X64 1
282# define TOML_ARCH_X64 0
286#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || \
287 defined(__NT__) || defined(__CYGWIN__)
288# define TOML_WINDOWS 1
290# define TOML_WINDOWS 0
306#ifndef TOML_HAS_INCLUDE
308# define TOML_HAS_INCLUDE(header) __has_include(header)
310# define TOML_HAS_INCLUDE(header) 0
315#ifndef TOML_HAS_BUILTIN
317# define TOML_HAS_BUILTIN(name) __has_builtin(name)
319# define TOML_HAS_BUILTIN(name) 0
324#ifndef TOML_HAS_FEATURE
326# define TOML_HAS_FEATURE(name) __has_feature(name)
328# define TOML_HAS_FEATURE(name) 0
334# ifdef __has_attribute
335# define TOML_HAS_ATTR(attr) __has_attribute(attr)
337# define TOML_HAS_ATTR(attr) 0
342#ifndef TOML_HAS_CPP_ATTR
343# ifdef __has_cpp_attribute
344# define TOML_HAS_CPP_ATTR(attr) __has_cpp_attribute(attr)
346# define TOML_HAS_CPP_ATTR(attr) 0
352# if TOML_CLANG || TOML_GCC_LIKE
353# define TOML_ATTR(...) __attribute__((__VA_ARGS__))
355# define TOML_ATTR(...)
362# define TOML_DECLSPEC(...) __declspec(__VA_ARGS__)
364# define TOML_DECLSPEC(...)
369#ifndef TOML_COMPILER_HAS_EXCEPTIONS
370# if defined(__EXCEPTIONS) || defined(_CPPUNWIND) || defined(__cpp_exceptions)
371# define TOML_COMPILER_HAS_EXCEPTIONS 1
373# define TOML_COMPILER_HAS_EXCEPTIONS 0
378#ifndef TOML_COMPILER_HAS_RTTI
379# if defined(_CPPRTTI) || defined(__GXX_RTTI) || TOML_HAS_FEATURE(cxx_rtti)
380# define TOML_COMPILER_HAS_RTTI 1
382# define TOML_COMPILER_HAS_RTTI 0
387#define TOML_CONCAT_1(x, y) x##y
388#define TOML_CONCAT(x, y) TOML_CONCAT_1(x, y)
391#define TOML_MAKE_STRING_1(s) #s
392#define TOML_MAKE_STRING(s) TOML_MAKE_STRING_1(s)
396# define TOML_PRAGMA_CLANG(decl) _Pragma(TOML_MAKE_STRING(clang decl))
398# define TOML_PRAGMA_CLANG(decl)
401# define TOML_PRAGMA_CLANG_GE_8(decl) TOML_PRAGMA_CLANG(decl)
403# define TOML_PRAGMA_CLANG_GE_8(decl)
406# define TOML_PRAGMA_CLANG_GE_9(decl) TOML_PRAGMA_CLANG(decl)
408# define TOML_PRAGMA_CLANG_GE_9(decl)
411# define TOML_PRAGMA_CLANG_GE_10(decl) TOML_PRAGMA_CLANG(decl)
413# define TOML_PRAGMA_CLANG_GE_10(decl)
416# define TOML_PRAGMA_CLANG_GE_11(decl) TOML_PRAGMA_CLANG(decl)
418# define TOML_PRAGMA_CLANG_GE_11(decl)
421# define TOML_PRAGMA_GCC(decl) _Pragma(TOML_MAKE_STRING(GCC decl))
423# define TOML_PRAGMA_GCC(decl)
426# define TOML_PRAGMA_MSVC(...) __pragma(__VA_ARGS__)
428# define TOML_PRAGMA_MSVC(...)
431# define TOML_PRAGMA_ICC(...) __pragma(__VA_ARGS__)
433# define TOML_PRAGMA_ICC(...)
437#ifndef TOML_ALWAYS_INLINE
439# define TOML_ALWAYS_INLINE __forceinline
440# elif TOML_GCC || TOML_CLANG || TOML_HAS_ATTR(__always_inline__)
441# define TOML_ALWAYS_INLINE \
442 TOML_ATTR(__always_inline__) \
445# define TOML_ALWAYS_INLINE inline
450#ifndef TOML_NEVER_INLINE
452# define TOML_NEVER_INLINE TOML_DECLSPEC(noinline)
454# define TOML_NEVER_INLINE TOML_ATTR(noinline)
456# if TOML_GCC || TOML_CLANG || TOML_HAS_ATTR(__noinline__)
457# define TOML_NEVER_INLINE TOML_ATTR(__noinline__)
460# ifndef TOML_NEVER_INLINE
461# define TOML_NEVER_INLINE
466#ifndef TOML_ABSTRACT_INTERFACE
467# define TOML_ABSTRACT_INTERFACE TOML_DECLSPEC(novtable)
469#ifndef TOML_EMPTY_BASES
470# define TOML_EMPTY_BASES TOML_DECLSPEC(empty_bases)
474#ifndef TOML_TRIVIAL_ABI
475# if TOML_CLANG || TOML_HAS_ATTR(__trivial_abi__)
476# define TOML_TRIVIAL_ABI TOML_ATTR(__trivial_abi__)
478# define TOML_TRIVIAL_ABI
483#ifndef TOML_NODISCARD
484# if TOML_CPP >= 17 && TOML_HAS_CPP_ATTR(nodiscard) >= 201603
485# define TOML_NODISCARD [[nodiscard]]
486# elif TOML_CLANG || TOML_GCC || TOML_HAS_ATTR(__warn_unused_result__)
487# define TOML_NODISCARD TOML_ATTR(__warn_unused_result__)
489# define TOML_NODISCARD
494#ifndef TOML_NODISCARD_CTOR
495# if TOML_CPP >= 17 && TOML_HAS_CPP_ATTR(nodiscard) >= 201907
496# define TOML_NODISCARD_CTOR [[nodiscard]]
498# define TOML_NODISCARD_CTOR
506 TOML_DECLSPEC(noalias) \
515 TOML_DECLSPEC(noalias) \
521#ifndef TOML_INLINE_GETTER
522# define TOML_INLINE_GETTER \
526#ifndef TOML_PURE_GETTER
527# define TOML_PURE_GETTER \
531#ifndef TOML_PURE_INLINE_GETTER
532# define TOML_PURE_INLINE_GETTER \
537#ifndef TOML_CONST_GETTER
538# define TOML_CONST_GETTER \
542#ifndef TOML_CONST_INLINE_GETTER
543# define TOML_CONST_INLINE_GETTER \
552# define TOML_ASSUME(expr) __assume(expr)
553# elif TOML_ICC || TOML_CLANG || TOML_HAS_BUILTIN(__builtin_assume)
554# define TOML_ASSUME(expr) __builtin_assume(expr)
555# elif TOML_HAS_CPP_ATTR(assume) >= 202207
556# define TOML_ASSUME(expr) [[assume(expr)]]
557# elif TOML_HAS_ATTR(__assume__)
558# define TOML_ASSUME(expr) __attribute__((__assume__(expr)))
560# define TOML_ASSUME(expr) static_cast<void>(0)
565#ifndef TOML_UNREACHABLE
567# define TOML_UNREACHABLE __assume(0)
568# elif TOML_ICC || TOML_CLANG || TOML_GCC || \
569 TOML_HAS_BUILTIN(__builtin_unreachable)
570# define TOML_UNREACHABLE __builtin_unreachable()
572# define TOML_UNREACHABLE static_cast<void>(0)
577#if TOML_CPP >= 20 && TOML_HAS_CPP_ATTR(likely) >= 201803
578# define TOML_LIKELY(...) (__VA_ARGS__) [[likely]]
579# define TOML_LIKELY_CASE [[likely]]
580#elif TOML_GCC || TOML_CLANG || TOML_HAS_BUILTIN(__builtin_expect)
581# define TOML_LIKELY(...) (__builtin_expect(!!(__VA_ARGS__), 1))
583# define TOML_LIKELY(...) (__VA_ARGS__)
585#ifndef TOML_LIKELY_CASE
586# define TOML_LIKELY_CASE
590#if TOML_CPP >= 20 && TOML_HAS_CPP_ATTR(unlikely) >= 201803
591# define TOML_UNLIKELY(...) (__VA_ARGS__) [[unlikely]]
592# define TOML_UNLIKELY_CASE [[unlikely]]
593#elif TOML_GCC || TOML_CLANG || TOML_HAS_BUILTIN(__builtin_expect)
594# define TOML_UNLIKELY(...) (__builtin_expect(!!(__VA_ARGS__), 0))
596# define TOML_UNLIKELY(...) (__VA_ARGS__)
598#ifndef TOML_UNLIKELY_CASE
599# define TOML_UNLIKELY_CASE
603#if TOML_CLANG || TOML_HAS_ATTR(flag_enum)
604# define TOML_FLAGS_ENUM __attribute__((flag_enum))
606# define TOML_FLAGS_ENUM
610#if TOML_CLANG || TOML_HAS_ATTR(enum_extensibility)
611# define TOML_OPEN_ENUM __attribute__((enum_extensibility(open)))
612# define TOML_CLOSED_ENUM __attribute__((enum_extensibility(closed)))
614# define TOML_OPEN_ENUM
615# define TOML_CLOSED_ENUM
619#define TOML_OPEN_FLAGS_ENUM TOML_OPEN_ENUM TOML_FLAGS_ENUM
620#define TOML_CLOSED_FLAGS_ENUM TOML_CLOSED_ENUM TOML_FLAGS_ENUM
623#define TOML_MAKE_FLAGS_2(T, op, linkage) \
624 TOML_CONST_INLINE_GETTER \
625 linkage constexpr T operator op(T lhs, T rhs) noexcept \
627 using under = std::underlying_type_t<T>; \
628 return static_cast<T>(static_cast<under>(lhs) op static_cast<under>(rhs)); \
631 linkage constexpr T &operator TOML_CONCAT(op, =)(T &lhs, T rhs) noexcept \
633 return lhs = (lhs op rhs); \
637#define TOML_MAKE_FLAGS_1(T, linkage) \
638 static_assert(std::is_enum_v<T>); \
640 TOML_MAKE_FLAGS_2(T, &, linkage); \
641 TOML_MAKE_FLAGS_2(T, |, linkage); \
642 TOML_MAKE_FLAGS_2(T, ^, linkage); \
644 TOML_CONST_INLINE_GETTER \
645 linkage constexpr T operator~(T val) noexcept \
647 using under = std::underlying_type_t<T>; \
648 return static_cast<T>(~static_cast<under>(val)); \
651 TOML_CONST_INLINE_GETTER \
652 linkage constexpr bool operator!(T val) noexcept \
654 using under = std::underlying_type_t<T>; \
655 return !static_cast<under>(val); \
659#define TOML_MAKE_FLAGS(T) TOML_MAKE_FLAGS_1(T, )
661#define TOML_UNUSED(...) static_cast<void>(__VA_ARGS__)
663#define TOML_DELETE_DEFAULTS(T) \
664 T(const T &) = delete; \
666 T &operator=(const T &) = delete; \
667 T &operator=(T &&) = delete
669#define TOML_ASYMMETRICAL_EQUALITY_OPS(LHS, RHS, ...) \
670 __VA_ARGS__ TOML_NODISCARD friend bool operator==(RHS rhs, LHS lhs) noexcept \
674 __VA_ARGS__ TOML_NODISCARD friend bool operator!=(LHS lhs, RHS rhs) noexcept \
676 return !(lhs == rhs); \
678 __VA_ARGS__ TOML_NODISCARD friend bool operator!=(RHS rhs, LHS lhs) noexcept \
680 return !(lhs == rhs); \
684#define TOML_EVAL_BOOL_1(T, F) T
685#define TOML_EVAL_BOOL_0(T, F) F
687#if !defined(__POXY__) && !defined(POXY_IMPLEMENTATION_DETAIL)
688# define POXY_IMPLEMENTATION_DETAIL(...) __VA_ARGS__
695# define TOML_PUSH_WARNINGS \
696 TOML_PRAGMA_CLANG(diagnostic push) \
697 TOML_PRAGMA_CLANG(diagnostic ignored "-Wunknown-warning-option") \
700# define TOML_DISABLE_SWITCH_WARNINGS \
701 TOML_PRAGMA_CLANG(diagnostic ignored "-Wswitch") \
704# define TOML_DISABLE_ARITHMETIC_WARNINGS \
705 TOML_PRAGMA_CLANG_GE_10(diagnostic ignored \
706 "-Wimplicit-int-float-conversion") \
707 TOML_PRAGMA_CLANG(diagnostic ignored "-Wfloat-equal") \
708 TOML_PRAGMA_CLANG(diagnostic ignored "-Wdouble-promotion") \
709 TOML_PRAGMA_CLANG(diagnostic ignored "-Wchar-subscripts") \
710 TOML_PRAGMA_CLANG(diagnostic ignored "-Wshift-sign-overflow") \
713# define TOML_DISABLE_SPAM_WARNINGS \
714 TOML_PRAGMA_CLANG_GE_8(diagnostic ignored "-Wdefaulted-function-deleted") \
715 TOML_PRAGMA_CLANG_GE_9(diagnostic ignored "-Wctad-maybe-unsupported") \
716 TOML_PRAGMA_CLANG_GE_10(diagnostic ignored \
717 "-Wzero-as-null-pointer-constant") \
718 TOML_PRAGMA_CLANG_GE_11(diagnostic ignored \
719 "-Wsuggest-destructor-override") \
720 TOML_PRAGMA_CLANG(diagnostic ignored "-Wweak-vtables") \
721 TOML_PRAGMA_CLANG(diagnostic ignored "-Wweak-template-vtables") \
722 TOML_PRAGMA_CLANG(diagnostic ignored "-Wdouble-promotion") \
723 TOML_PRAGMA_CLANG(diagnostic ignored "-Wchar-subscripts") \
724 TOML_PRAGMA_CLANG(diagnostic ignored "-Wmissing-field-initializers") \
725 TOML_PRAGMA_CLANG(diagnostic ignored "-Wpadded") \
728# define TOML_POP_WARNINGS \
729 TOML_PRAGMA_CLANG(diagnostic pop) \
732# define TOML_DISABLE_WARNINGS \
733 TOML_PRAGMA_CLANG(diagnostic push) \
734 TOML_PRAGMA_CLANG(diagnostic ignored "-Weverything") \
735 static_assert(true, "")
737# define TOML_ENABLE_WARNINGS \
738 TOML_PRAGMA_CLANG(diagnostic pop) \
741# define TOML_SIMPLE_STATIC_ASSERT_MESSAGES 1
745# define TOML_PUSH_WARNINGS __pragma(warning(push)) static_assert(true)
747# if TOML_HAS_INCLUDE(<CodeAnalysis / Warnings.h>)
748# pragma warning(push, 0)
749# include <CodeAnalysis/Warnings.h>
751# define TOML_DISABLE_CODE_ANALYSIS_WARNINGS \
752 __pragma(warning(disable \
753 : ALL_CODE_ANALYSIS_WARNINGS)) static_assert(true)
755# define TOML_DISABLE_CODE_ANALYSIS_WARNINGS static_assert(true)
758# define TOML_DISABLE_SWITCH_WARNINGS \
759 __pragma(warning(disable : 4061)) __pragma(warning(disable : 4062)) \
760 __pragma(warning(disable : 4063)) __pragma(warning( \
762 __pragma(warning(disable : 26819)) \
765# define TOML_DISABLE_SPAM_WARNINGS \
766 __pragma(warning(disable : 4127)) \
769 __pragma(warning(disable : 4348)) __pragma( \
770 warning(disable : 4464)) \
772 warning(disable : 4505)) \
776 warning(disable : 4582)) \
778 warning(disable : 4619)) \
785 __pragma(warning(disable : 4710)) \
788 __pragma(warning(disable : 4820)) \
798 warning(disable : 5045)) \
801 __pragma(warning(disable : 26451)) __pragma(warning(disable : 26490)) \
802 __pragma(warning(disable : 26495)) __pragma(warning(disable : 26812)) \
803 __pragma(warning(disable : 26819)) static_assert(true)
805# define TOML_DISABLE_ARITHMETIC_WARNINGS \
806 __pragma(warning(disable : 4365)) \
808 warning(disable : 4738)) \
813# define TOML_POP_WARNINGS __pragma(warning(pop)) static_assert(true)
815# define TOML_DISABLE_WARNINGS \
816 __pragma(warning(push, 0)) __pragma(warning(disable : 4348)) \
817 __pragma(warning(disable : 4668)) __pragma(warning(disable : 5105)) \
818 __pragma(warning(disable : 5264)) TOML_DISABLE_CODE_ANALYSIS_WARNINGS; \
819 TOML_DISABLE_SWITCH_WARNINGS; \
820 TOML_DISABLE_SPAM_WARNINGS; \
821 TOML_DISABLE_ARITHMETIC_WARNINGS; \
824# define TOML_ENABLE_WARNINGS TOML_POP_WARNINGS
828# define TOML_PUSH_WARNINGS __pragma(warning(push)) static_assert(true)
830# define TOML_DISABLE_SPAM_WARNINGS \
831 __pragma(warning(disable : 82)) \
833 warning(disable : 111)) \
834 __pragma(warning(disable : 869)) \
835 __pragma(warning(disable : 1011)) \
837 warning(disable : 2261)) \
840# define TOML_POP_WARNINGS __pragma(warning(pop)) static_assert(true)
842# define TOML_DISABLE_WARNINGS \
843 __pragma(warning(push, 0)) TOML_DISABLE_SPAM_WARNINGS
845# define TOML_ENABLE_WARNINGS __pragma(warning(pop)) static_assert(true)
849# define TOML_PUSH_WARNINGS \
850 TOML_PRAGMA_GCC(diagnostic push) \
853# define TOML_DISABLE_SWITCH_WARNINGS \
854 TOML_PRAGMA_GCC(diagnostic ignored "-Wswitch") \
855 TOML_PRAGMA_GCC(diagnostic ignored "-Wswitch-enum") \
856 TOML_PRAGMA_GCC(diagnostic ignored "-Wswitch-default") \
859# define TOML_DISABLE_ARITHMETIC_WARNINGS \
860 TOML_PRAGMA_GCC(diagnostic ignored "-Wfloat-equal") \
861 TOML_PRAGMA_GCC(diagnostic ignored "-Wsign-conversion") \
862 TOML_PRAGMA_GCC(diagnostic ignored "-Wchar-subscripts") \
865# define TOML_DISABLE_SUGGEST_ATTR_WARNINGS \
866 TOML_PRAGMA_GCC(diagnostic ignored "-Wsuggest-attribute=const") \
867 TOML_PRAGMA_GCC(diagnostic ignored "-Wsuggest-attribute=pure") \
870# define TOML_DISABLE_SPAM_WARNINGS \
871 TOML_PRAGMA_GCC(diagnostic ignored "-Wpadded") \
872 TOML_PRAGMA_GCC(diagnostic ignored "-Wcast-align") \
873 TOML_PRAGMA_GCC(diagnostic ignored "-Wcomment") \
874 TOML_PRAGMA_GCC(diagnostic ignored "-Wtype-limits") \
875 TOML_PRAGMA_GCC(diagnostic ignored "-Wuseless-cast") \
876 TOML_PRAGMA_GCC(diagnostic ignored "-Wchar-subscripts") \
877 TOML_PRAGMA_GCC(diagnostic ignored "-Wsubobject-linkage") \
878 TOML_PRAGMA_GCC(diagnostic ignored "-Wmissing-field-initializers") \
879 TOML_PRAGMA_GCC(diagnostic ignored "-Wmaybe-uninitialized") \
880 TOML_PRAGMA_GCC(diagnostic ignored "-Wnoexcept") \
881 TOML_PRAGMA_GCC(diagnostic ignored "-Wnull-dereference") \
882 TOML_PRAGMA_GCC(diagnostic ignored "-Wduplicated-branches") \
885# define TOML_POP_WARNINGS \
886 TOML_PRAGMA_GCC(diagnostic pop) \
889# define TOML_DISABLE_WARNINGS \
890 TOML_PRAGMA_GCC(diagnostic push) \
891 TOML_PRAGMA_GCC(diagnostic ignored "-Wall") \
892 TOML_PRAGMA_GCC(diagnostic ignored "-Wextra") \
893 TOML_PRAGMA_GCC(diagnostic ignored "-Wpedantic") \
894 TOML_DISABLE_SWITCH_WARNINGS; \
895 TOML_DISABLE_ARITHMETIC_WARNINGS; \
896 TOML_DISABLE_SUGGEST_ATTR_WARNINGS; \
897 TOML_DISABLE_SPAM_WARNINGS; \
900# define TOML_ENABLE_WARNINGS \
901 TOML_PRAGMA_GCC(diagnostic pop) \
906#ifndef TOML_PUSH_WARNINGS
907# define TOML_PUSH_WARNINGS static_assert(true)
909#ifndef TOML_DISABLE_CODE_ANALYSIS_WARNINGS
910# define TOML_DISABLE_CODE_ANALYSIS_WARNINGS static_assert(true)
912#ifndef TOML_DISABLE_SWITCH_WARNINGS
913# define TOML_DISABLE_SWITCH_WARNINGS static_assert(true)
915#ifndef TOML_DISABLE_SUGGEST_ATTR_WARNINGS
916# define TOML_DISABLE_SUGGEST_ATTR_WARNINGS static_assert(true)
918#ifndef TOML_DISABLE_SPAM_WARNINGS
919# define TOML_DISABLE_SPAM_WARNINGS static_assert(true)
921#ifndef TOML_DISABLE_ARITHMETIC_WARNINGS
922# define TOML_DISABLE_ARITHMETIC_WARNINGS static_assert(true)
924#ifndef TOML_POP_WARNINGS
925# define TOML_POP_WARNINGS static_assert(true)
927#ifndef TOML_DISABLE_WARNINGS
928# define TOML_DISABLE_WARNINGS static_assert(true)
930#ifndef TOML_ENABLE_WARNINGS
931# define TOML_ENABLE_WARNINGS static_assert(true)
933#ifndef TOML_SIMPLE_STATIC_ASSERT_MESSAGES
934# define TOML_SIMPLE_STATIC_ASSERT_MESSAGES 0
937#ifdef TOML_CONFIG_HEADER
938# include TOML_CONFIG_HEADER
942#ifndef TOML_SHARED_LIB
943# define TOML_SHARED_LIB 0
947#if !defined(TOML_HEADER_ONLY) && \
948 defined(TOML_ALL_INLINE)
949# define TOML_HEADER_ONLY TOML_ALL_INLINE
951#if !defined(TOML_HEADER_ONLY) || \
952 (defined(TOML_HEADER_ONLY) && TOML_HEADER_ONLY) || TOML_INTELLISENSE
953# undef TOML_HEADER_ONLY
954# define TOML_HEADER_ONLY 1
956#if TOML_DOXYGEN || TOML_SHARED_LIB
957# undef TOML_HEADER_ONLY
958# define TOML_HEADER_ONLY 0
962#if defined(TOML_IMPLEMENTATION) || TOML_HEADER_ONLY
963# undef TOML_IMPLEMENTATION
964# define TOML_IMPLEMENTATION 1
966# define TOML_IMPLEMENTATION 0
970#if !defined(TOML_EXPORTED_MEMBER_FUNCTION) && \
971 !defined(TOML_EXPORTED_STATIC_FUNCTION) && \
972 !defined(TOML_EXPORTED_FREE_FUNCTION) && !defined(TOML_EXPORTED_CLASS) && \
974# define TOML_EXPORTED_MEMBER_FUNCTION TOML_API
975# define TOML_EXPORTED_STATIC_FUNCTION TOML_API
976# define TOML_EXPORTED_FREE_FUNCTION TOML_API
982# undef TOML_EXPORTED_CLASS
983# undef TOML_EXPORTED_MEMBER_FUNCTION
984# undef TOML_EXPORTED_STATIC_FUNCTION
985# undef TOML_EXPORTED_FREE_FUNCTION
987# if TOML_IMPLEMENTATION
988# define TOML_EXPORTED_CLASS __declspec(dllexport)
989# define TOML_EXPORTED_FREE_FUNCTION __declspec(dllexport)
991# define TOML_EXPORTED_CLASS __declspec(dllimport)
992# define TOML_EXPORTED_FREE_FUNCTION __declspec(dllimport)
994# ifndef TOML_CALLCONV
995# define TOML_CALLCONV __cdecl
997# elif defined(__GNUC__) && __GNUC__ >= 4
998# define TOML_EXPORTED_CLASS __attribute__((visibility("default")))
999# define TOML_EXPORTED_MEMBER_FUNCTION __attribute__((visibility("default")))
1000# define TOML_EXPORTED_STATIC_FUNCTION __attribute__((visibility("default")))
1001# define TOML_EXPORTED_FREE_FUNCTION __attribute__((visibility("default")))
1004#ifndef TOML_EXPORTED_CLASS
1005# define TOML_EXPORTED_CLASS
1007#ifndef TOML_EXPORTED_MEMBER_FUNCTION
1008# define TOML_EXPORTED_MEMBER_FUNCTION
1010#ifndef TOML_EXPORTED_STATIC_FUNCTION
1011# define TOML_EXPORTED_STATIC_FUNCTION
1013#ifndef TOML_EXPORTED_FREE_FUNCTION
1014# define TOML_EXPORTED_FREE_FUNCTION
1018#if !defined(TOML_ENABLE_UNRELEASED_FEATURES) && \
1019 defined(TOML_UNRELEASED_FEATURES)
1021# define TOML_ENABLE_UNRELEASED_FEATURES TOML_UNRELEASED_FEATURES
1024 defined(TOML_ENABLE_UNRELEASED_FEATURES) && \
1025 TOML_ENABLE_UNRELEASED_FEATURES) || \
1027# undef TOML_ENABLE_UNRELEASED_FEATURES
1028# define TOML_ENABLE_UNRELEASED_FEATURES 1
1030#ifndef TOML_ENABLE_UNRELEASED_FEATURES
1031# define TOML_ENABLE_UNRELEASED_FEATURES 0
1035#if !defined(TOML_ENABLE_PARSER) && \
1036 defined(TOML_PARSER)
1037# define TOML_ENABLE_PARSER TOML_PARSER
1039#if !defined(TOML_ENABLE_PARSER) || \
1040 (defined(TOML_ENABLE_PARSER) && TOML_ENABLE_PARSER) || TOML_INTELLISENSE
1041# undef TOML_ENABLE_PARSER
1042# define TOML_ENABLE_PARSER 1
1046#if !defined(TOML_ENABLE_FORMATTERS) || \
1047 (defined(TOML_ENABLE_FORMATTERS) && TOML_ENABLE_FORMATTERS) || \
1049# undef TOML_ENABLE_FORMATTERS
1050# define TOML_ENABLE_FORMATTERS 1
1054#if !defined(TOML_ENABLE_SIMD) || \
1055 (defined(TOML_ENABLE_SIMD) && TOML_ENABLE_SIMD) || TOML_INTELLISENSE
1056# undef TOML_ENABLE_SIMD
1057# define TOML_ENABLE_SIMD 1
1061#if !defined(TOML_ENABLE_WINDOWS_COMPAT) && \
1062 defined(TOML_WINDOWS_COMPAT)
1063# define TOML_ENABLE_WINDOWS_COMPAT TOML_WINDOWS_COMPAT
1065#if !defined(TOML_ENABLE_WINDOWS_COMPAT) || \
1066 (defined(TOML_ENABLE_WINDOWS_COMPAT) && TOML_ENABLE_WINDOWS_COMPAT) || \
1068# undef TOML_ENABLE_WINDOWS_COMPAT
1069# define TOML_ENABLE_WINDOWS_COMPAT 1
1073# undef TOML_ENABLE_WINDOWS_COMPAT
1074# define TOML_ENABLE_WINDOWS_COMPAT 0
1077#ifndef TOML_INCLUDE_WINDOWS_H
1078# define TOML_INCLUDE_WINDOWS_H 0
1082#ifdef TOML_OPTIONAL_TYPE
1083# define TOML_HAS_CUSTOM_OPTIONAL_TYPE 1
1085# define TOML_HAS_CUSTOM_OPTIONAL_TYPE 0
1089#if TOML_COMPILER_HAS_EXCEPTIONS
1090# if !defined(TOML_EXCEPTIONS) || (defined(TOML_EXCEPTIONS) && TOML_EXCEPTIONS)
1091# undef TOML_EXCEPTIONS
1092# define TOML_EXCEPTIONS 1
1095# if defined(TOML_EXCEPTIONS) && TOML_EXCEPTIONS
1096#error TOML_EXCEPTIONS was explicitly enabled but exceptions are disabled/unsupported by the compiler.
1098# undef TOML_EXCEPTIONS
1099# define TOML_EXCEPTIONS 0
1103#ifndef TOML_CALLCONV
1104# define TOML_CALLCONV
1107#ifndef TOML_UNDEF_MACROS
1108# define TOML_UNDEF_MACROS 1
1111#ifndef TOML_MAX_NESTED_VALUES
1112# define TOML_MAX_NESTED_VALUES 256
1117#ifdef TOML_CHAR_8_STRINGS
1118# if TOML_CHAR_8_STRINGS
1119#error TOML_CHAR_8_STRINGS was removed in toml++ 2.0.0; all value setters and getters now work with char8_t strings implicitly.
1123#ifdef TOML_LARGE_FILES
1124# if !TOML_LARGE_FILES
1125# error Support for !TOML_LARGE_FILES (i.e. 'small files') was removed in toml++ 3.0.0.
1129#ifndef TOML_LIFETIME_HOOKS
1130# define TOML_LIFETIME_HOOKS 0
1135# define TOML_ASSERT(expr) static_assert(true)
1143# define TOML_ASSERT(expr) assert(expr)
1146# define TOML_ASSERT_ASSUME(expr) TOML_ASSUME(expr)
1148# define TOML_ASSERT_ASSUME(expr) TOML_ASSERT(expr)
1151#ifndef TOML_ENABLE_FLOAT16
1152# define TOML_ENABLE_FLOAT16 0
1155#if !defined(TOML_FLOAT_CHARCONV) && \
1156 (TOML_GCC || TOML_CLANG || (TOML_ICC && !TOML_ICC_CL))
1159# define TOML_FLOAT_CHARCONV 0
1161#if !defined(TOML_INT_CHARCONV) && \
1162 (defined(__EMSCRIPTEN__) || defined(__APPLE__))
1165# define TOML_INT_CHARCONV 0
1167#ifndef TOML_INT_CHARCONV
1168# define TOML_INT_CHARCONV 1
1170#ifndef TOML_FLOAT_CHARCONV
1171# define TOML_FLOAT_CHARCONV 1
1173#if (TOML_INT_CHARCONV || TOML_FLOAT_CHARCONV) && !TOML_HAS_INCLUDE(<charconv>)
1174# undef TOML_INT_CHARCONV
1175# undef TOML_FLOAT_CHARCONV
1176# define TOML_INT_CHARCONV 0
1177# define TOML_FLOAT_CHARCONV 0
1180#if defined(__cpp_concepts) && __cpp_concepts >= 201907
1181# define TOML_REQUIRES(...) requires(__VA_ARGS__)
1183# define TOML_REQUIRES(...)
1185#define TOML_ENABLE_IF(...) \
1186 , typename std::enable_if<(__VA_ARGS__), int>::type = 0
1187#define TOML_CONSTRAINED_TEMPLATE(condition, ...) \
1188 template <__VA_ARGS__ TOML_ENABLE_IF(condition)> \
1189 TOML_REQUIRES(condition)
1190#define TOML_HIDDEN_CONSTRAINT(condition, ...) \
1191 TOML_CONSTRAINED_TEMPLATE(condition, __VA_ARGS__)
1193#if defined(__SIZEOF_FLOAT128__) && defined(__FLT128_MANT_DIG__) && \
1194 defined(__LDBL_MANT_DIG__) && __FLT128_MANT_DIG__ > __LDBL_MANT_DIG__
1195# define TOML_FLOAT128 __float128
1198#ifdef __SIZEOF_INT128__
1199# define TOML_INT128 __int128_t
1200# define TOML_UINT128 __uint128_t
1207#define TOML_LIB_MAJOR 3
1208#define TOML_LIB_MINOR 4
1209#define TOML_LIB_PATCH 0
1211#define TOML_LANG_MAJOR 1
1212#define TOML_LANG_MINOR 0
1213#define TOML_LANG_PATCH 0
1217#define TOML_LIB_SINGLE_HEADER 1
1219#if TOML_ENABLE_UNRELEASED_FEATURES
1220 #define TOML_LANG_EFFECTIVE_VERSION \
1221 TOML_MAKE_VERSION(TOML_LANG_MAJOR, TOML_LANG_MINOR, TOML_LANG_PATCH+1)
1223 #define TOML_LANG_EFFECTIVE_VERSION \
1224 TOML_MAKE_VERSION(TOML_LANG_MAJOR, TOML_LANG_MINOR, TOML_LANG_PATCH)
1227#define TOML_LANG_HIGHER_THAN(major, minor, patch) \
1228 (TOML_LANG_EFFECTIVE_VERSION > TOML_MAKE_VERSION(major, minor, patch))
1230#define TOML_LANG_AT_LEAST(major, minor, patch) \
1231 (TOML_LANG_EFFECTIVE_VERSION >= TOML_MAKE_VERSION(major, minor, patch))
1233#define TOML_LANG_UNRELEASED \
1234 TOML_LANG_HIGHER_THAN(TOML_LANG_MAJOR, TOML_LANG_MINOR, TOML_LANG_PATCH)
1236#ifndef TOML_ABI_NAMESPACES
1238 #define TOML_ABI_NAMESPACES 0
1240 #define TOML_ABI_NAMESPACES 1
1243#if TOML_ABI_NAMESPACES
1244 #define TOML_NAMESPACE_START namespace toml { inline namespace TOML_CONCAT(v, TOML_LIB_MAJOR)
1245 #define TOML_NAMESPACE_END } static_assert(true)
1246 #define TOML_NAMESPACE ::toml::TOML_CONCAT(v, TOML_LIB_MAJOR)
1247 #define TOML_ABI_NAMESPACE_START(name) inline namespace name { static_assert(true)
1248 #define TOML_ABI_NAMESPACE_BOOL(cond, T, F) TOML_ABI_NAMESPACE_START(TOML_CONCAT(TOML_EVAL_BOOL_, cond)(T, F))
1249 #define TOML_ABI_NAMESPACE_END } static_assert(true)
1251 #define TOML_NAMESPACE_START namespace toml
1252 #define TOML_NAMESPACE_END static_assert(true)
1253 #define TOML_NAMESPACE toml
1254 #define TOML_ABI_NAMESPACE_START(...) static_assert(true)
1255 #define TOML_ABI_NAMESPACE_BOOL(...) static_assert(true)
1256 #define TOML_ABI_NAMESPACE_END static_assert(true)
1258#define TOML_IMPL_NAMESPACE_START TOML_NAMESPACE_START { namespace impl
1259#define TOML_IMPL_NAMESPACE_END } TOML_NAMESPACE_END
1261 #define TOML_ANON_NAMESPACE_START static_assert(TOML_IMPLEMENTATION); TOML_IMPL_NAMESPACE_START
1262 #define TOML_ANON_NAMESPACE_END TOML_IMPL_NAMESPACE_END
1263 #define TOML_ANON_NAMESPACE TOML_NAMESPACE::impl
1264 #define TOML_EXTERNAL_LINKAGE inline
1265 #define TOML_INTERNAL_LINKAGE inline
1267 #define TOML_ANON_NAMESPACE_START static_assert(TOML_IMPLEMENTATION); \
1268 using namespace toml; \
1270 #define TOML_ANON_NAMESPACE_END static_assert(true)
1271 #define TOML_ANON_NAMESPACE
1272 #define TOML_EXTERNAL_LINKAGE
1273 #define TOML_INTERNAL_LINKAGE static
1280#if TOML_SIMPLE_STATIC_ASSERT_MESSAGES
1282 #define TOML_SA_NEWLINE " "
1283 #define TOML_SA_LIST_SEP ", "
1284 #define TOML_SA_LIST_BEG " ("
1285 #define TOML_SA_LIST_END ")"
1286 #define TOML_SA_LIST_NEW " "
1287 #define TOML_SA_LIST_NXT ", "
1291 #define TOML_SA_NEWLINE "\n| "
1292 #define TOML_SA_LIST_SEP TOML_SA_NEWLINE " - "
1293 #define TOML_SA_LIST_BEG TOML_SA_LIST_SEP
1294 #define TOML_SA_LIST_END
1295 #define TOML_SA_LIST_NEW TOML_SA_NEWLINE TOML_SA_NEWLINE
1296 #define TOML_SA_LIST_NXT TOML_SA_LIST_NEW
1300#define TOML_SA_NATIVE_VALUE_TYPE_LIST \
1301 TOML_SA_LIST_BEG "std::string" \
1302 TOML_SA_LIST_SEP "int64_t" \
1303 TOML_SA_LIST_SEP "double" \
1304 TOML_SA_LIST_SEP "bool" \
1305 TOML_SA_LIST_SEP "toml::date" \
1306 TOML_SA_LIST_SEP "toml::time" \
1307 TOML_SA_LIST_SEP "toml::date_time" \
1310#define TOML_SA_NODE_TYPE_LIST \
1311 TOML_SA_LIST_BEG "toml::table" \
1312 TOML_SA_LIST_SEP "toml::array" \
1313 TOML_SA_LIST_SEP "toml::value<std::string>" \
1314 TOML_SA_LIST_SEP "toml::value<int64_t>" \
1315 TOML_SA_LIST_SEP "toml::value<double>" \
1316 TOML_SA_LIST_SEP "toml::value<bool>" \
1317 TOML_SA_LIST_SEP "toml::value<toml::date>" \
1318 TOML_SA_LIST_SEP "toml::value<toml::time>" \
1319 TOML_SA_LIST_SEP "toml::value<toml::date_time>" \
1322#define TOML_SA_UNWRAPPED_NODE_TYPE_LIST \
1323 TOML_SA_LIST_NEW "A native TOML value type" \
1324 TOML_SA_NATIVE_VALUE_TYPE_LIST \
1326 TOML_SA_LIST_NXT "A TOML node type" \
1327 TOML_SA_NODE_TYPE_LIST
1338# pragma warning(disable : 5031)
1340# pragma warning(disable : 4251)
1344# if TOML_CLANG >= 12
1347# if TOML_CLANG == 13
1358#if (!defined(__apple_build_version__) && TOML_CLANG >= 8) || TOML_GCC >= 7 || \
1359 TOML_ICC >= 1910 || TOML_MSVC >= 1914
1360# define TOML_LAUNDER(x) __builtin_launder(x)
1361#elif defined(__cpp_lib_launder) && __cpp_lib_launder >= 201606
1362# define TOML_LAUNDER(x) std::launder(x)
1364# define TOML_LAUNDER(x) x
1370#include <string_view>
1374#if TOML_DOXYGEN || \
1375 (defined(__cpp_char8_t) && __cpp_char8_t >= 201811 && \
1376 defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201907)
1377# define TOML_HAS_CHAR8 1
1379# define TOML_HAS_CHAR8 0
1384using namespace std::string_literals;
1385using namespace std::string_view_literals;
1388#if TOML_ENABLE_WINDOWS_COMPAT
1394 std::string narrow(std::wstring_view);
1398 std::wstring widen(std::string_view);
1404 std::wstring widen(std::u8string_view);
1415#if !TOML_HAS_CUSTOM_OPTIONAL_TYPE
1422#if TOML_HAS_CUSTOM_OPTIONAL_TYPE
1424 template <
typename T>
1425 using optional = TOML_OPTIONAL_TYPE<T>;
1429 template <
typename T>
1430 using optional = std::optional<T>;
1448#include <type_traits>
1453# pragma inline_recursion(on)
1455# pragma push_macro("min")
1456# pragma push_macro("max")
1461#ifndef TOML_DISABLE_ENVIRONMENT_CHECKS
1462# define TOML_ENV_MESSAGE \
1463 "If you're seeing this error it's because you're building toml++ for an " \
1464 "environment that doesn't conform to " \
1465 "one of the 'ground truths' assumed by the library. Essentially this " \
1466 "just means that I don't have the " \
1467 "resources to test on more platforms, but I wish I did! You can try " \
1468 "disabling the checks by defining " \
1469 "TOML_DISABLE_ENVIRONMENT_CHECKS, but your mileage may vary. Please " \
1470 "consider filing an issue at " \
1471 "https://github.com/marzer/tomlplusplus/issues to help me improve " \
1472 "support for your target environment. " \
1483static_assert(std::numeric_limits<double>::digits10 == 15,
TOML_ENV_MESSAGE);
1486# undef TOML_ENV_MESSAGE
1493using ::std::int16_t;
1494using ::std::int32_t;
1495using ::std::int64_t;
1497using ::std::intptr_t;
1498using ::std::nullptr_t;
1499using ::std::ptrdiff_t;
1501using ::std::uint16_t;
1502using ::std::uint32_t;
1503using ::std::uint64_t;
1504using ::std::uint8_t;
1505using ::std::uint_least32_t;
1506using ::std::uint_least64_t;
1507using ::std::uintptr_t;
1535 class toml_formatter;
1536 class json_formatter;
1537 class yaml_formatter;
1551 using node_ptr = std::unique_ptr<node>;
1613#if TOML_ABI_NAMESPACES
1615# define TOML_PARSER_TYPENAME TOML_NAMESPACE::impl::impl_ex::parser
1617# define TOML_PARSER_TYPENAME TOML_NAMESPACE::impl::impl_noex::parser
1620# define TOML_PARSER_TYPENAME TOML_NAMESPACE::impl::parser
1647 template <
typename Char>
1649 std::basic_ostream<Char> &lhs, node_type rhs)
1651 const auto str = impl::node_type_friendly_names
1652 [
static_cast<std::underlying_type_t<node_type>
>(rhs)];
1653 using str_char_t =
decltype(str)::value_type;
1654 if constexpr (std::is_same_v<Char, str_char_t>)
1658 if constexpr (
sizeof(Char) ==
sizeof(str_char_t))
1659 return lhs << std::basic_string_view<Char>{
1660 reinterpret_cast<const Char *
>(str.data()), str.length()};
1662 return lhs << str.data();
1678 value_flags{
static_cast<std::underlying_type_t<value_flags>
>(-1)});
1700 template <
typename T>
1703 static_assert(std::is_reference_v<T>);
1707 template <
typename T>
1709 template <
typename T>
1718 template <
typename T>
1719 using remove_cvref = std::remove_cv_t<std::remove_reference_t<T>>;
1721 template <
typename...
T>
1724 template <
typename T,
typename... U>
1725 inline constexpr bool is_one_of = (
false || ... || std::is_same_v<T, U>);
1727 template <
typename...
T>
1730 template <
typename T>
1732 std::is_reference_v<T> || std::is_const_v<T> || std::is_volatile_v<T>;
1734 template <
typename T>
1742 template <
typename T>
1744 !std::is_same_v<remove_cvref<T>, std::string>
1746 && !std::is_same_v<remove_cvref<T>, std::u8string>
1751 template <
typename,
typename>
1753 template <
typename Dest,
typename Src>
1756 template <
typename Dest,
typename Src>
1762 template <
typename Dest,
typename Src>
1765 using type = std::add_lvalue_reference_t<Dest>;
1768 template <
typename Dest,
typename Src>
1771 using type = std::add_rvalue_reference_t<Dest>;
1774 template <
typename,
typename>
1776 template <
typename Dest,
typename Src>
1779 template <
typename Dest,
typename Src>
1785 template <
typename Dest,
typename Src>
1788 using type = std::add_const_t<Dest>;
1791 template <
typename Dest,
typename Src>
1794 using type = std::add_volatile_t<Dest>;
1797 template <
typename Dest,
typename Src>
1803 template <
typename Dest,
typename Src>
1810 template <
typename...>
1813 template <
typename T,
typename... U>
1815 template <
typename T,
typename... U>
1818 template <
typename T,
bool = std::is_enum_v<T>>
1821 using type = std::underlying_type_t<T>;
1823 template <
typename T>
1828 template <
typename T>
1840 static constexpr auto type = node_type::none;
1843 template <
typename T>
1846 template <
typename T,
bool = std::is_enum_v<T>>
1853 template <
typename T>
1861 template <
typename T>
1865 template <
typename T>
1869 template <
typename T>
1873 template <
typename T>
1877 template <
typename T>
1881 template <
typename T>
1887 template <
typename T>
1891 T{(std::numeric_limits<underlying_type<T>>
::min)()};
1893 T{(std::numeric_limits<underlying_type<T>>
::max)()};
1895 template <
typename T>
1903 static constexpr auto type = node_type::integer;
1906 template <
typename T>
1913 template <
typename T>
1919 (-9223372036854775807LL - 1LL) &&
1923 (-9223372036854775807LL - 1LL) &&
1926 template <typename T, bool S = integer_traits_base<T>::is_signed>
1930 template <
typename T>
1985 static constexpr TOML_INT128
max =
static_cast<TOML_INT128
>(
1986 (TOML_UINT128{1u} << ((__SIZEOF_INT128__ *
CHAR_BIT) - 1)) - 1);
1987 static constexpr TOML_INT128
min = -
max - TOML_INT128{1};
1992 static constexpr TOML_UINT128
min = TOML_UINT128{};
1993 static constexpr TOML_UINT128
max =
2005#ifdef TOML_SMALL_INT_TYPE
2014 template <
typename T,
int MantissaDigits,
int DecimalDigits>
2017 static constexpr auto type = node_type::floating_point;
2019 static constexpr bool is_native = std::is_same_v<T, native_type>;
2023 static constexpr int digits = MantissaDigits;
2037 template <
typename T>
2040 std::numeric_limits<T>::digits,
2041 std::numeric_limits<T>::digits10>
2044#if TOML_ENABLE_FLOAT16
2072#if TOML_ENABLE_FLOAT16
2084#ifdef TOML_SMALL_FLOAT_TYPE
2097 template <
typename T>
2101 static constexpr bool is_native = std::is_same_v<T, native_type>;
2104 !std::is_array_v<T> &&
2105 (!std::is_pointer_v<T> || std::is_const_v<std::remove_pointer_t<T>>);
2107 static constexpr auto type = node_type::string;
2163#if TOML_ENABLE_WINDOWS_COMPAT
2164 template <
typename T>
2165 struct wstring_traits
2167 using native_type = std::string;
2168 static constexpr bool is_native =
false;
2171 std::is_same_v<T, std::wstring>;
2173 static constexpr auto type = node_type::string;
2180 struct value_traits<
std::wstring_view> : wstring_traits<std::wstring_view>
2202 template <
typename T, node_type NodeType>
2210 static constexpr auto type = NodeType;
2231 template <
typename T>
2233 template <
typename T>
2235 template <
typename T>
2238 template <
typename T>
2241 template <
typename T>
2244 template <
typename T,
typename... U>
2248 template <
typename T>
2253 template <
typename T>
2256 using type = std::add_const_t<typename node_wrapper<T>::type>;
2258 template <
typename T>
2261 using type = std::add_volatile_t<typename node_wrapper<T>::type>;
2263 template <
typename T>
2267 std::add_const_t<std::add_volatile_t<typename node_wrapper<T>::type>>;
2304 template <
typename T>
2308 template <
typename T>
2313 template <
typename T>
2318 template <
typename T>
2323 template <
typename T>
2326 using type = std::add_volatile_t<T>;
2328 template <
typename T>
2331 using type = std::add_volatile_t<std::add_const_t<T>>;
2333 template <
typename T>
2336 template <
typename T>
2344 static constexpr auto value = node_type::table;
2349 static constexpr auto value = node_type::array;
2354 static constexpr auto value = node_type::none;
2356 template <
typename T>
2360 template <
typename T,
typename ConvertFrom>
2362 std::is_constructible_v<T, ConvertFrom>
2363 || std::is_convertible_v<ConvertFrom, T>;
2369 template <
typename T>
2370 inline constexpr bool is_table = std::is_same_v<impl::remove_cvref<T>,
table>;
2372 template <
typename T>
2375 template <
typename T>
2378 template <
typename T>
2380 impl::remove_cvref<impl::wrap_node<impl::remove_cvref<T>>>,
2383 template <
typename T>
2385 impl::remove_cvref<impl::wrap_node<impl::remove_cvref<T>>>,
2388 template <
typename T>
2390 impl::remove_cvref<impl::wrap_node<impl::remove_cvref<T>>>,
2393 template <
typename T>
2396 template <
typename T>
2398 impl::remove_cvref<impl::wrap_node<impl::remove_cvref<T>>>,
2401 template <
typename T>
2403 impl::remove_cvref<impl::wrap_node<impl::remove_cvref<T>>>,
2406 template <
typename T>
2408 impl::remove_cvref<impl::wrap_node<impl::remove_cvref<T>>>,
2411 template <
typename T>
2413 impl::remove_cvref<impl::wrap_node<impl::remove_cvref<T>>>,
2416 template <
typename T>
2420 template <
typename T>
2424 template <
typename T>
2426 std::is_same_v<toml::node, impl::remove_cvref<T>>
2427 || std::is_base_of_v<toml::node, impl::remove_cvref<T>>;
2429 template <
typename T>
2437 template <
typename T>
2441 return static_cast<std::underlying_type_t<T>
>(val);
2457 static_assert(
sizeof(uint64_t) ==
sizeof(double));
2459 static constexpr uint64_t sign =
2460 0b1000000000000000000000000000000000000000000000000000000000000000ull;
2461 static constexpr uint64_t exponent =
2462 0b0111111111110000000000000000000000000000000000000000000000000000ull;
2463 static constexpr uint64_t mantissa =
2464 0b0000000000001111111111111111111111111111111111111111111111111111ull;
2467 std::memcpy(&val_bits, &val,
sizeof(val));
2468 if ((val_bits & exponent) != exponent)
2469 return fp_class::ok;
2470 if ((val_bits & mantissa))
2471 return fp_class::nan;
2472 return (val_bits & sign) ? fp_class::neg_inf : fp_class::pos_inf;
2479 template <
typename Iterator,
typename T>
2481 Iterator start, Iterator end,
const T &needle)
noexcept
2482 ->decltype(&(*start))
2484 for (; start != end; start++)
2485 if (*start == needle)
2490 template <
typename T>
2492 const T &a,
const T &b)
noexcept
2494 return a < b ? a : b;
2500# pragma pop_macro("min")
2501# pragma pop_macro("max")
2503# pragma inline_recursion(off)
2513# pragma inline_recursion(on)
2515# pragma push_macro("min")
2516# pragma push_macro("max")
2543 std::ostream &,
signed char,
value_flags = {},
size_t min_digits = 0);
2547 std::ostream &,
signed short,
value_flags = {},
size_t min_digits = 0);
2551 std::ostream &,
signed int,
value_flags = {},
size_t min_digits = 0);
2555 std::ostream &,
signed long,
value_flags = {},
size_t min_digits = 0);
2559 std::ostream &,
signed long long,
value_flags = {},
size_t min_digits = 0);
2563 std::ostream &,
unsigned char,
value_flags = {},
size_t min_digits = 0);
2567 std::ostream &,
unsigned short,
value_flags = {},
size_t min_digits = 0);
2571 std::ostream &,
unsigned int,
value_flags = {},
size_t min_digits = 0);
2575 std::ostream &,
unsigned long,
value_flags = {},
size_t min_digits = 0);
2582 size_t min_digits = 0);
2586 std::ostream &,
float,
value_flags = {},
bool relaxed_precision =
false);
2590 std::ostream &,
double,
value_flags = {},
bool relaxed_precision =
false);
2613#if TOML_ENABLE_FORMATTERS
2645 template <
typename T,
typename U>
2647 std::ostream & stream,
const T &val,
const U &bookend)
2657# pragma pop_macro("min")
2658# pragma pop_macro("max")
2660# pragma inline_recursion(off)
2670# pragma inline_recursion(on)
2672# pragma push_macro("min")
2673# pragma push_macro("max")
2680 using source_index = uint32_t;
2691 explicit constexpr operator bool() const noexcept
2693 return line > source_index{}
2694 &&
column > source_index{};
2698 friend constexpr bool
2701 return lhs.line == rhs.line
2702 && lhs.column == rhs.column;
2706 friend constexpr bool
2709 return !(lhs == rhs);
2716 return static_cast<uint64_t
>(
pos.line) << 32 |
2717 static_cast<uint64_t
>(
pos.column);
2722 friend constexpr bool
2725 return pack(lhs) < pack(rhs);
2729 friend constexpr bool
2732 return pack(lhs) <= pack(rhs);
2736 friend constexpr bool
2739 return pack(lhs) > pack(rhs);
2743 friend constexpr bool
2746 return pack(lhs) >= pack(rhs);
2749 friend std::ostream &
2752 impl::print_to_stream(lhs, rhs);
2765#if TOML_ENABLE_WINDOWS_COMPAT
2768 optional<std::wstring> wide_path()
const
2772 return {impl::widen(*
path)};
2779 impl::print_to_stream(lhs, rhs);
2787# pragma pop_macro("min")
2788# pragma pop_macro("max")
2790# pragma inline_recursion(off)
2800# pragma inline_recursion(on)
2802# pragma push_macro("min")
2803# pragma push_macro("max")
2819 date() noexcept = default;
2827 constexpr date(Y y, M m, D d) noexcept
2828 : year{
static_cast<uint16_t
>(y)},
2829 month{
static_cast<uint8_t
>(m)},
2830 day{
static_cast<uint8_t
>(d)}
2835 friend constexpr bool operator==(
const date &lhs,
const date &rhs)
noexcept
2837 return lhs.year == rhs.year
2838 && lhs.month == rhs.month
2839 && lhs.day == rhs.day;
2843 friend constexpr bool operator!=(
const date &lhs,
const date &rhs)
noexcept
2845 return !(lhs == rhs);
2850 static constexpr uint32_t pack(
const date &d)
noexcept
2852 return (
static_cast<uint32_t
>(d.year) << 16) |
2853 (
static_cast<uint32_t
>(d.month) << 8) |
2854 static_cast<uint32_t
>(d.day);
2859 friend constexpr bool operator<(
const date &lhs,
const date &rhs)
noexcept
2861 return pack(lhs) < pack(rhs);
2865 friend constexpr bool operator<=(
const date &lhs,
const date &rhs)
noexcept
2867 return pack(lhs) <= pack(rhs);
2871 friend constexpr bool operator>(
const date &lhs,
const date &rhs)
noexcept
2873 return pack(lhs) > pack(rhs);
2877 friend constexpr bool operator>=(
const date &lhs,
const date &rhs)
noexcept
2879 return pack(lhs) >= pack(rhs);
2882 friend std::ostream &
operator<<(std::ostream &lhs,
const date &rhs)
2884 impl::print_to_stream(lhs, rhs);
2906 typename S = uint8_t,
2907 typename NS = uint32_t)
2909 constexpr
time(H h, M
m, S
s = S{}, NS ns = NS{})
noexcept
2910 : hour{
static_cast<uint8_t
>(h)},
2911 minute{
static_cast<uint8_t
>(m)},
2912 second{
static_cast<uint8_t
>(s)},
2913 nanosecond{
static_cast<uint32_t
>(ns)}
2918 friend constexpr bool operator==(
const time &lhs,
const time &rhs)
noexcept
2920 return lhs.hour == rhs.hour
2921 && lhs.minute == rhs.minute
2922 && lhs.second == rhs.second
2923 && lhs.nanosecond == rhs.nanosecond;
2927 friend constexpr bool operator!=(
const time &lhs,
const time &rhs)
noexcept
2929 return !(lhs == rhs);
2934 static constexpr uint64_t pack(
const time &t)
noexcept
2936 return static_cast<uint64_t
>(t.hour) << 48 |
2937 static_cast<uint64_t
>(t.minute) << 40 |
2938 static_cast<uint64_t
>(t.second) << 32 |
2939 static_cast<uint64_t
>(t.nanosecond);
2944 friend constexpr bool operator<(
const time &lhs,
const time &rhs)
noexcept
2946 return pack(lhs) < pack(rhs);
2950 friend constexpr bool operator<=(
const time &lhs,
const time &rhs)
noexcept
2952 return pack(lhs) <= pack(rhs);
2956 friend constexpr bool operator>(
const time &lhs,
const time &rhs)
noexcept
2958 return pack(lhs) > pack(rhs);
2962 friend constexpr bool operator>=(
const time &lhs,
const time &rhs)
noexcept
2964 return pack(lhs) >= pack(rhs);
2967 friend std::ostream &
operator<<(std::ostream &lhs,
const time &rhs)
2969 impl::print_to_stream(lhs, rhs);
2987 :
minutes{
static_cast<int16_t
>(
2988 static_cast<impl::common_signed_type<H, M>
>(h) *
2989 impl::common_signed_type<H, M>{60} +
2990 static_cast<impl::common_signed_type<H, M>
>(m))}
2997 return lhs.minutes == rhs.minutes;
3003 return lhs.minutes != rhs.minutes;
3009 return lhs.minutes < rhs.minutes;
3015 return lhs.minutes <= rhs.minutes;
3021 return lhs.minutes > rhs.minutes;
3027 return lhs.minutes >= rhs.minutes;
3032 impl::print_to_stream(lhs, rhs);
3070 const toml::date &d,
3071 const toml::time &t,
3072 const toml::time_offset &off) noexcept
3080 return !
offset.has_value();
3084 friend constexpr bool
3087 return lhs.date == rhs.date
3088 && lhs.time == rhs.time
3089 && lhs.offset == rhs.offset;
3093 friend constexpr bool
3096 return !(lhs == rhs);
3100 friend constexpr bool
3103 if (lhs.date != rhs.date)
3104 return lhs.date < rhs.date;
3105 if (lhs.time != rhs.time)
3106 return lhs.time < rhs.time;
3107 return lhs.offset < rhs.offset;
3111 friend constexpr bool
3114 if (lhs.date != rhs.date)
3115 return lhs.date < rhs.date;
3116 if (lhs.time != rhs.time)
3117 return lhs.time < rhs.time;
3118 return lhs.offset <= rhs.offset;
3122 friend constexpr bool
3125 return !(lhs <= rhs);
3129 friend constexpr bool
3132 return !(lhs < rhs);
3137 impl::print_to_stream(lhs, rhs);
3147# pragma pop_macro("min")
3148# pragma pop_macro("max")
3150# pragma inline_recursion(off)
3159 template <
typename T>
3166 parse_path_callback<std::string_view>,
3167 parse_path_callback<size_t>);
3176 node & root, std::string_view
path)
noexcept;
3181 const node &root, std::string_view
path)
noexcept;
3183#if TOML_ENABLE_WINDOWS_COMPAT
3192 const node &root, std::wstring_view
path);
3210# pragma inline_recursion(on)
3212# pragma push_macro("min")
3213# pragma push_macro("max")
3230 static constexpr size_t size =
3231 (
sizeof(
size_t) <
sizeof(std::string) ?
sizeof(std::string)
3233 static constexpr size_t align =
3234 (
alignof(
size_t) <
alignof(std::string) ?
alignof(std::string)
3237 alignas(align)
unsigned char bytes[size];
3239 alignas(storage_t::align)
mutable storage_t value_storage_;
3241 path_component_type type_;
3248 template <
typename Type>
3251 return TOML_LAUNDER(
reinterpret_cast<Type *
>(s.bytes));
3254 static void store_key(std::string_view
key, storage_t &storage_)
3256 ::new (
static_cast<void *
>(storage_.bytes)) std::string{
key};
3259 static void store_index(
size_t index, storage_t &storage_)
noexcept
3261 ::new (
static_cast<void *
>(storage_.bytes)) std::size_t{
index};
3264 void destroy()
noexcept
3266 if (type_ == path_component_type::key)
3267 get_as<std::string>(value_storage_)->~basic_string();
3271 size_t &index_ref()
noexcept
3274 return *get_as<size_t>(value_storage_);
3278 std::string &key_ref()
noexcept
3281 return *get_as<std::string>(value_storage_);
3297#if TOML_ENABLE_WINDOWS_COMPAT
3325#if TOML_ENABLE_WINDOWS_COMPAT
3341 return *get_as<const size_t>(value_storage_);
3351 const std::string &
key() const noexcept
3354 return *get_as<const std::string>(value_storage_);
3358 explicit operator const std::string &()
const noexcept
3364 path_component_type
type() const noexcept
3373 return equal(lhs, rhs);
3380 return !equal(lhs, rhs);
3387 std::vector<path_component> components_;
3390 void print_to(std::ostream &)
const;
3404#if TOML_ENABLE_WINDOWS_COMPAT
3408 explicit path(std::wstring_view);
3423 return components_.size();
3427 explicit operator bool() const noexcept
3429 return !components_.empty();
3435 return components_.empty();
3442 return components_[index];
3449 return components_[index];
3459#if TOML_ENABLE_WINDOWS_COMPAT
3475 return *
this = std::move(p);
3484#if TOML_ENABLE_WINDOWS_COMPAT
3487 path &assign(std::wstring_view str)
3503#if TOML_ENABLE_WINDOWS_COMPAT
3519 return *
this += std::move(p);
3525 return *
this +=
str;
3528#if TOML_ENABLE_WINDOWS_COMPAT
3531 path &append(std::wstring_view str)
3533 return *
this += str;
3547#if TOML_ENABLE_WINDOWS_COMPAT
3578#if TOML_ENABLE_WINDOWS_COMPAT
3589 friend path
operator+(std::wstring_view lhs,
const path &rhs)
3611 explicit operator std::string()
const
3616#if TOML_ENABLE_WINDOWS_COMPAT
3620 std::wstring wide_str()
const;
3624 explicit operator std::wstring()
const
3634 return equal(lhs, rhs);
3640 return !equal(lhs, rhs);
3647 return lhs ==
path{rhs};
3661 return lhs !=
path{rhs};
3671#if TOML_ENABLE_WINDOWS_COMPAT
3677 return lhs ==
path{rhs};
3682 friend bool operator==(std::wstring_view lhs,
const path &rhs)
3689 friend bool operator!=(
const path &lhs, std::wstring_view rhs)
3691 return lhs != path{rhs};
3696 friend bool operator!=(std::wstring_view lhs,
const path &rhs)
3703 using iterator = std::vector<path_component>::iterator;
3710 return components_.begin();
3716 return components_.end();
3722 return components_.begin();
3728 return components_.end();
3734 return components_.begin();
3740 return components_.end();
3774 path operator"" _tpath(
const char *str,
size_t len)
3776 return path(std::string_view{str, len});
3783 node & root,
const toml::path &
path)
noexcept;
3788 const node &root,
const toml::path &
path)
noexcept;
3793# pragma pop_macro("min")
3794# pragma pop_macro("max")
3796# pragma inline_recursion(off)
3812# pragma inline_recursion(on)
3814# pragma push_macro("min")
3815# pragma push_macro("max")
3822# define TOML_NVCC_WORKAROUND \
3827# define TOML_NVCC_WORKAROUND = 0
3838 template <
typename T>
3840 noexcept(impl::value_retrieval_is_nothrow<T>);
3842 template <
typename T,
typename N>
3843 using ref_type_ = std::conditional_t<
3844 std::is_reference_v<T>,
3846 impl::copy_cv<impl::unwrap_node<T>, std::remove_reference_t<N>>,
3848 impl::copy_cvref<impl::unwrap_node<T>,
N>
3851 template <
typename T,
typename N>
3852 using ref_type = std::conditional_t<
3853 std::is_reference_v<N>,
3855 ref_type_<T, std::add_lvalue_reference_t<N>>
3858 template <
typename T,
typename N>
3861 using unwrapped_type = impl::unwrap_node<T>;
3863 toml::is_value<unwrapped_type> || toml::is_container<unwrapped_type>,
3864 "The template type argument of node::ref() must be one "
3868 n.template is<unwrapped_type>() &&
3869 "template type argument provided to toml::node::ref() didn't match the "
3870 "node's actual type");
3872 using node_ref = std::remove_volatile_t<std::remove_reference_t<N>> &;
3873 using val_type = std::remove_volatile_t<unwrapped_type>;
3874 using out_ref = ref_type<T, N &&>;
3875 static_assert(std::is_reference_v<out_ref>);
3877 if constexpr (toml::is_value<unwrapped_type>)
3878 return static_cast<out_ref
>(
3879 const_cast<node_ref
>(n).
template ref_cast<val_type>().get());
3881 return static_cast<out_ref
>(
3882 const_cast<node_ref
>(n).template ref_cast<val_type>());
3890 node(
const node &)
noexcept;
3893 node(node &&)
noexcept;
3896 node &operator=(
const node &)
noexcept;
3899 node &operator=(node &&)
noexcept;
3901 template <
typename T,
typename N>
3902 using ref_cast_type_ = std::conditional_t<
3903 std::is_reference_v<T>,
3905 impl::copy_cv<impl::wrap_node<T>, std::remove_reference_t<N>>,
3907 impl::copy_cvref<impl::wrap_node<T>,
N>
3910 template <
typename T,
typename N>
3911 using ref_cast_type = std::conditional_t<
3912 std::is_reference_v<N>,
3913 ref_cast_type_<T, N>,
3914 ref_cast_type_<T, std::add_lvalue_reference_t<N>>
3917 template <
typename T>
3920 using out_ref = ref_cast_type<T, node &>;
3921 using out_type = std::remove_reference_t<out_ref>;
3922 return static_cast<out_ref
>(*
reinterpret_cast<out_type *
>(
this));
3925 template <
typename T>
3928 using out_ref = ref_cast_type<T, node &&>;
3929 using out_type = std::remove_reference_t<out_ref>;
3930 return static_cast<out_ref
>(*
reinterpret_cast<out_type *
>(
this));
3933 template <
typename T>
3935 ref_cast()
const &
noexcept
3937 using out_ref = ref_cast_type<T, const node &>;
3938 using out_type = std::remove_reference_t<out_ref>;
3939 return static_cast<out_ref
>(*
reinterpret_cast<out_type *
>(
this));
3942 template <
typename T>
3944 ref_cast()
const &&
noexcept
3946 using out_ref = ref_cast_type<T, const node &&>;
3947 using out_type = std::remove_reference_t<out_ref>;
3948 return static_cast<out_ref
>(*
reinterpret_cast<out_type *
>(
this));
3953 virtual ~node()
noexcept;
3957 is_homogeneous(node_type ntype, node *&first_nonmatch)
noexcept = 0;
3960 virtual bool is_homogeneous(node_type ntype,
const node *&first_nonmatch)
3964 virtual bool is_homogeneous(node_type ntype)
const noexcept = 0;
3966 template <
typename ElemType =
void>
3969 using type = impl::remove_cvref<impl::unwrap_node<ElemType>>;
3971 std::is_void_v<type> || toml::is_value<type> ||
3972 toml::is_container<type>,
3973 "The template type argument of node::is_homogeneous() must be void or "
3977 return is_homogeneous(impl::node_type_of<type>);
3987 virtual bool is_array()
const noexcept = 0;
3993 virtual bool is_value()
const noexcept = 0;
3996 virtual bool is_string()
const noexcept = 0;
3999 virtual bool is_integer()
const noexcept = 0;
4005 virtual bool is_number()
const noexcept = 0;
4008 virtual bool is_boolean()
const noexcept = 0;
4011 virtual bool is_date()
const noexcept = 0;
4014 virtual bool is_time()
const noexcept = 0;
4019 template <
typename T>
4022 using type = impl::remove_cvref<impl::unwrap_node<T>>;
4024 toml::is_value<type> || toml::is_container<type>,
4025 "The template type argument of node::is() must be one "
4028 if constexpr (std::is_same_v<type, table>)
4030 else if constexpr (std::is_same_v<type, array>)
4032 else if constexpr (std::is_same_v<type, std::string>)
4034 else if constexpr (std::is_same_v<type, int64_t>)
4036 else if constexpr (std::is_same_v<type, double>)
4038 else if constexpr (std::is_same_v<type, bool>)
4040 else if constexpr (std::is_same_v<type, date>)
4042 else if constexpr (std::is_same_v<type, time>)
4044 else if constexpr (std::is_same_v<type, date_time>)
4051 virtual table *as_table()
noexcept = 0;
4054 virtual array *as_array()
noexcept = 0;
4057 virtual toml::value<std::string> *as_string()
noexcept = 0;
4060 virtual toml::value<int64_t> *as_integer()
noexcept = 0;
4063 virtual toml::value<double> *as_floating_point()
noexcept = 0;
4066 virtual toml::value<bool> *as_boolean()
noexcept = 0;
4069 virtual toml::value<date> *as_date()
noexcept = 0;
4072 virtual toml::value<time> *as_time()
noexcept = 0;
4075 virtual toml::value<date_time> *as_date_time()
noexcept = 0;
4078 virtual const table *as_table()
const noexcept = 0;
4081 virtual const array *as_array()
const noexcept = 0;
4084 virtual const toml::value<std::string> *as_string()
const noexcept = 0;
4087 virtual const toml::value<int64_t> *as_integer()
const noexcept = 0;
4090 virtual const toml::value<double> *as_floating_point()
const noexcept = 0;
4093 virtual const toml::value<bool> *as_boolean()
const noexcept = 0;
4096 virtual const toml::value<date> *as_date()
const noexcept = 0;
4099 virtual const toml::value<time> *as_time()
const noexcept = 0;
4102 virtual const toml::value<date_time> *as_date_time()
const noexcept = 0;
4104 template <
typename T>
4107 using unwrapped_type = impl::unwrap_node<impl::remove_cvref<T>>;
4109 toml::is_value<unwrapped_type> || toml::is_container<unwrapped_type>,
4110 "The template type argument of node::as() must be one "
4113 if constexpr (std::is_same_v<unwrapped_type, table>)
4115 else if constexpr (std::is_same_v<unwrapped_type, array>)
4117 else if constexpr (std::is_same_v<unwrapped_type, std::string>)
4119 else if constexpr (std::is_same_v<unwrapped_type, int64_t>)
4120 return as_integer();
4121 else if constexpr (std::is_same_v<unwrapped_type, double>)
4122 return as_floating_point();
4123 else if constexpr (std::is_same_v<unwrapped_type, bool>)
4124 return as_boolean();
4125 else if constexpr (std::is_same_v<unwrapped_type, date>)
4127 else if constexpr (std::is_same_v<unwrapped_type, time>)
4129 else if constexpr (std::is_same_v<unwrapped_type, date_time>)
4130 return as_date_time();
4135 template <
typename T>
4138 using unwrapped_type = impl::unwrap_node<impl::remove_cvref<T>>;
4140 toml::is_value<unwrapped_type> || toml::is_container<unwrapped_type>,
4141 "The template type argument of node::as() must be one "
4144 if constexpr (std::is_same_v<unwrapped_type, table>)
4146 else if constexpr (std::is_same_v<unwrapped_type, array>)
4148 else if constexpr (std::is_same_v<unwrapped_type, std::string>)
4150 else if constexpr (std::is_same_v<unwrapped_type, int64_t>)
4151 return as_integer();
4152 else if constexpr (std::is_same_v<unwrapped_type, double>)
4153 return as_floating_point();
4154 else if constexpr (std::is_same_v<unwrapped_type, bool>)
4155 return as_boolean();
4156 else if constexpr (std::is_same_v<unwrapped_type, date>)
4158 else if constexpr (std::is_same_v<unwrapped_type, time>)
4160 else if constexpr (std::is_same_v<unwrapped_type, date_time>)
4161 return as_date_time();
4166 template <
typename T>
4168 noexcept(impl::value_retrieval_is_nothrow<T>);
4170 template <
typename T>
4172 noexcept(impl::value_retrieval_is_nothrow<T>);
4174 template <
typename T>
4176 noexcept(impl::value_retrieval_is_nothrow<T>);
4178 template <
typename T>
4181 return do_ref<T>(*
this);
4184 template <
typename T>
4187 return do_ref<T>(std::move(*
this));
4190 template <
typename T>
4193 return do_ref<T>(*
this);
4196 template <
typename T>
4199 return do_ref<T>(std::move(*
this));
4209 template <
typename Func,
typename Node,
typename T>
4210 static constexpr bool can_visit =
4211 std::is_invocable_v<Func, ref_cast_type<T, Node>>;
4213 template <
typename Func,
typename Node,
typename T>
4214 static constexpr bool can_visit_nothrow =
4215 std::is_nothrow_invocable_v<Func, ref_cast_type<T, Node>>;
4217 template <
typename Func,
typename Node>
4218 static constexpr bool can_visit_any =
4219 can_visit<Func, Node, table>
4220 || can_visit<Func, Node, array>
4221 || can_visit<Func, Node, std::string>
4222 || can_visit<Func, Node, int64_t>
4223 || can_visit<Func, Node, double>
4224 || can_visit<Func, Node, bool>
4225 || can_visit<Func, Node, date>
4226 || can_visit<Func, Node, time>
4227 || can_visit<Func, Node, date_time>;
4231 template <
typename Func,
typename Node>
4232 static constexpr bool can_visit_all = can_visit<Func, Node, table>
4233 && can_visit<Func, Node, array>
4234 && can_visit<Func, Node, std::string>
4235 && can_visit<Func, Node, int64_t>
4236 && can_visit<Func, Node, double>
4237 && can_visit<Func, Node, bool>
4238 && can_visit<Func, Node, date>
4239 && can_visit<Func, Node, time>
4240 && can_visit<Func, Node, date_time>;
4242 template <
typename Func,
typename Node,
typename T>
4243 static constexpr bool visit_is_nothrow_one = !can_visit<Func, Node, T> || can_visit_nothrow<Func, Node, T>;
4245 template <
typename Func,
typename Node>
4246 static constexpr bool visit_is_nothrow = visit_is_nothrow_one<Func, Node, table>
4247 && visit_is_nothrow_one<Func, Node, array>
4248 && visit_is_nothrow_one<Func, Node, std::string>
4249 && visit_is_nothrow_one<Func, Node, int64_t>
4250 && visit_is_nothrow_one<Func, Node, double>
4251 && visit_is_nothrow_one<Func, Node, bool>
4252 && visit_is_nothrow_one<Func, Node, date>
4253 && visit_is_nothrow_one<Func, Node, time>
4254 && visit_is_nothrow_one<Func, Node, date_time>;
4262 bool = can_visit<Func, Node, T>>
4263 struct visit_return_type_
4266 decltype(std::declval<Func>()(std::declval<ref_cast_type<T, Node>>()));
4268 template <
typename Func,
typename Node,
typename T>
4269 struct visit_return_type_<Func, Node,
T,
false>
4274 template <
typename Func,
typename Node,
typename T>
4275 using visit_return_type =
typename visit_return_type_<Func, Node, T>::type;
4277 template <
typename A,
typename B>
4278 using nonvoid = std::conditional_t<std::is_void_v<A>, B,
A>;
4280 template <
typename Func,
typename Node>
4281 static decltype(
auto) do_visit(Func &&visitor, Node &&n)
noexcept(
4282 visit_is_nothrow<Func &&, Node &&>)
4285 can_visit_any<Func &&, Node &&>,
4286 "TOML node visitors must be invocable for at least one of the "
4292 case node_type::table:
4293 if constexpr (can_visit<Func &&, Node &&, table>)
4294 return static_cast<Func &&
>(visitor)(
4295 static_cast<Node &&
>(n).template ref_cast<table>());
4298 case node_type::array:
4299 if constexpr (can_visit<Func &&, Node &&, array>)
4300 return static_cast<Func &&
>(visitor)(
4301 static_cast<Node &&
>(n).template ref_cast<array>());
4304 case node_type::string:
4305 if constexpr (can_visit<Func &&, Node &&, std::string>)
4306 return static_cast<Func &&
>(visitor)(
4307 static_cast<Node &&
>(n).template ref_cast<std::string>());
4310 case node_type::integer:
4311 if constexpr (can_visit<Func &&, Node &&, int64_t>)
4312 return static_cast<Func &&
>(visitor)(
4313 static_cast<Node &&
>(n).template ref_cast<int64_t>());
4316 case node_type::floating_point:
4317 if constexpr (can_visit<Func &&, Node &&, double>)
4318 return static_cast<Func &&
>(visitor)(
4319 static_cast<Node &&
>(n).template ref_cast<double>());
4322 case node_type::boolean:
4323 if constexpr (can_visit<Func &&, Node &&, bool>)
4324 return static_cast<Func &&
>(visitor)(
4325 static_cast<Node &&
>(n).template ref_cast<bool>());
4328 case node_type::date:
4329 if constexpr (can_visit<Func &&, Node &&, date>)
4330 return static_cast<Func &&
>(visitor)(
4331 static_cast<Node &&
>(n).template ref_cast<date>());
4334 case node_type::time:
4335 if constexpr (can_visit<Func &&, Node &&, time>)
4336 return static_cast<Func &&
>(visitor)(
4337 static_cast<Node &&
>(n).template ref_cast<time>());
4340 case node_type::date_time:
4341 if constexpr (can_visit<Func &&, Node &&, date_time>)
4342 return static_cast<Func &&
>(visitor)(
4343 static_cast<Node &&
>(n).template ref_cast<date_time>());
4346 case node_type::none:
4352 if constexpr (!can_visit_all<Func &&, Node &&>)
4357 nonvoid<visit_return_type<Func&&, Node&&, table>,
4358 nonvoid<visit_return_type<Func&&, Node&&, array>,
4359 nonvoid<visit_return_type<Func&&, Node&&, std::string>,
4360 nonvoid<visit_return_type<Func&&, Node&&, int64_t>,
4361 nonvoid<visit_return_type<Func&&, Node&&, double>,
4362 nonvoid<visit_return_type<Func&&, Node&&, bool>,
4363 nonvoid<visit_return_type<Func&&, Node&&, date>,
4364 nonvoid<visit_return_type<Func&&, Node&&, time>,
4365 visit_return_type<Func&&, Node&&, date_time>
4370 if constexpr (!std::is_void_v<return_type>)
4373 std::is_default_constructible_v<return_type>,
4374 "Non-exhaustive visitors must return a default-constructible type, "
4376 return return_type{};
4382 template <
typename Func>
4384 visit(Func &&visitor) &
noexcept(visit_is_nothrow<Func &&, node &>)
4386 return do_visit(
static_cast<Func &&
>(visitor), *
this);
4389 template <
typename Func>
4391 visit(Func &&visitor) &&
noexcept(visit_is_nothrow<Func &&, node &&>)
4394 static_cast<Func &&
>(visitor),
static_cast<node &&
>(*
this));
4397 template <
typename Func>
4398 decltype(
auto) visit(Func &&visitor)
const &
noexcept(
4399 visit_is_nothrow<Func &&, const node &>)
4401 return do_visit(
static_cast<Func &&
>(visitor), *
this);
4404 template <
typename Func>
4405 decltype(
auto) visit(Func &&visitor)
const &&
noexcept(
4406 visit_is_nothrow<Func &&, const node &&>)
4409 static_cast<Func &&
>(visitor),
static_cast<const node &&
>(*
this));
4434#if TOML_ENABLE_WINDOWS_COMPAT
4461 bool TOML_CALLCONV node_deep_equality(
const node *,
const node *)
noexcept;
4465#undef TOML_NVCC_WORKAROUND
4468# pragma pop_macro("min")
4469# pragma pop_macro("max")
4471# pragma inline_recursion(off)
4479#include <initializer_list>
4487# pragma inline_recursion(on)
4489# pragma push_macro("min")
4490# pragma push_macro("max")
4499 template <
typename ViewedType>
4503 impl::is_one_of<ViewedType, toml::node, const toml::node>,
4504 "A toml::node_view<> must wrap toml::node or const toml::node.");
4507 using viewed_type = ViewedType;
4510 template <
typename T>
4513 mutable viewed_type *node_ =
nullptr;
4520 explicit node_view(viewed_type *node)
noexcept
4526 explicit node_view(viewed_type &node)
noexcept
4542 explicit operator bool()
const noexcept
4544 return node_ !=
nullptr;
4548 viewed_type *node()
const noexcept
4554 node_type type()
const noexcept
4556 return node_ ? node_->type() : node_type::none;
4560 bool is_table()
const noexcept
4562 return node_ && node_->is_table();
4568 return node_ && node_->is_array();
4574 return node_ && node_->is_value();
4580 return node_ && node_->is_string();
4586 return node_ && node_->is_integer();
4592 return node_ && node_->is_floating_point();
4598 return node_ && node_->is_number();
4604 return node_ && node_->is_boolean();
4610 return node_ && node_->is_date();
4616 return node_ && node_->is_time();
4622 return node_ && node_->is_date_time();
4626 bool is_array_of_tables()
const noexcept
4628 return node_ && node_->is_array_of_tables();
4631 template <
typename T>
4635 ? node_->template is<impl::unwrap_node<impl::remove_cvref<T>>>()
4641 is_homogeneous(node_type ntype, viewed_type *&first_nonmatch)
const noexcept
4645 first_nonmatch = {};
4648 return node_->is_homogeneous(ntype, first_nonmatch);
4652 bool is_homogeneous(node_type ntype)
const noexcept
4654 return node_ ? node_->is_homogeneous(ntype) :
false;
4657 template <
typename ElemType =
void>
4660 return node_ ? node_->template is_homogeneous<
4661 impl::unwrap_node<impl::remove_cvref<ElemType>>>()
4665 template <
typename T>
4668 return node_ ? node_->template as<T>() :
nullptr;
4672 auto *as_table()
const noexcept
4678 auto *as_array()
const noexcept
4684 auto *as_string()
const noexcept
4686 return as<std::string>();
4690 auto *as_integer()
const noexcept
4692 return as<int64_t>();
4696 auto *as_floating_point()
const noexcept
4698 return as<double>();
4702 auto *as_boolean()
const noexcept
4708 auto *as_date()
const noexcept
4714 auto *as_time()
const noexcept
4720 auto *as_date_time()
const noexcept
4722 return as<date_time>();
4725 template <
typename T>
4727 noexcept(impl::value_retrieval_is_nothrow<T>)
4730 return node_->template value_exact<T>();
4734 template <
typename T>
4736 noexcept(impl::value_retrieval_is_nothrow<T>)
4743 template <
typename T>
4745 noexcept(impl::value_retrieval_is_nothrow<T>)
4747 using namespace ::toml::impl;
4751 "Retrieving values as wide-character strings is only "
4752 "supported on Windows with TOML_ENABLE_WINDOWS_COMPAT enabled.");
4756#if TOML_ENABLE_WINDOWS_COMPAT
4759 return node_->value_or(
static_cast<T &&
>(default_value));
4760 return std::wstring{
static_cast<T &&
>(default_value)};
4764 static_assert(impl::always_false<T>,
"Evaluated unreachable branch!");
4770 using value_type = std::conditional_t<
4771 std::is_pointer_v<std::decay_t<T>>,
4773 std::add_const_t<std::remove_pointer_t<std::decay_t<T>>>>,
4777 return node_->value_or(
static_cast<T &&
>(default_value));
4778 if constexpr (std::is_pointer_v<value_type>)
4779 return value_type{default_value};
4781 return static_cast<T &&
>(default_value);
4785 template <
typename T>
4790 "toml::node_view::ref() called on a node_view that did not reference a "
4792 return node_->template ref<T>();
4796 template <
typename Func>
4797 static constexpr bool visit_is_nothrow =
4798 noexcept(std::declval<viewed_type *>()->visit(std::declval<Func>()));
4801 template <
typename Func>
4802 decltype(
auto) visit(Func &&visitor)
const
4803 noexcept(visit_is_nothrow<Func &&>)
4805 using return_type =
decltype(node_->visit(
static_cast<Func &&
>(visitor)));
4807 return node_->visit(
static_cast<Func &&
>(visitor));
4808 if constexpr (!std::is_void_v<return_type>)
4809 return return_type{};
4813 template <
typename T>
4817 return impl::node_deep_equality(lhs.node_, rhs.node_);
4820 template <
typename T>
4824 return !impl::node_deep_equality(lhs.node_, rhs.node_);
4830 if (lhs.node_ == &rhs)
4832 const auto tbl = lhs.as<
table>();
4833 return tbl && *tbl == rhs;
4840 if (lhs.node_ == &rhs)
4842 const auto arr = lhs.as<
array>();
4843 return arr && *arr == rhs;
4847 template <
typename T>
4851 if (lhs.node_ == &rhs)
4853 const auto val = lhs.as<
T>();
4854 return val && *val == rhs;
4858 const toml::value<T> &,
4859 template <typename T>
4863 impl::is_losslessly_convertible_to_native<T>,
4867 !impl::is_wide_string<T>)
4871 "Comparison with wide-character strings is only "
4872 "supported on Windows with TOML_ENABLE_WINDOWS_COMPAT enabled.");
4874 if constexpr (impl::is_wide_string<T>)
4876#if TOML_ENABLE_WINDOWS_COMPAT
4877 return lhs == impl::narrow(rhs);
4879 static_assert(impl::always_false<T>,
"Evaluated unreachable branch!");
4884 const auto val = lhs.as<impl::native_type_of<T>>();
4885 return val && *val == rhs;
4892 impl::is_losslessly_convertible_to_native<T>,
4895 template <
typename T>
4898 const std::initializer_list<T> &rhs)
noexcept(!impl::is_wide_string<T>)
4900 const auto arr = lhs.as<
array>();
4901 return arr && *arr == rhs;
4905 const std::initializer_list<T> &,
4906 template <typename T>
4909 template <
typename T>
4912 const std::vector<T> &rhs)
noexcept(!impl::is_wide_string<T>)
4914 const auto arr = lhs.as<
array>();
4915 return arr && *arr == rhs;
4919 const std::vector<T> &,
4920 template <typename T>
4924 node_view operator[](std::string_view
key)
const noexcept
4926 if (
auto tbl = this->as_table())
4949#if TOML_ENABLE_WINDOWS_COMPAT
4954 if (
auto tbl = this->as_table())
4968 node_view operator[](
size_t index)
const noexcept
4970 if (
auto arr = this->as_array())
4975#if TOML_ENABLE_FORMATTERS
4980 nv.node_->visit([&
os](
const auto &n) {
os << n; });
4987 template <
typename T>
4990 template <
typename T>
4993 template <
typename T>
4996 template <
typename T>
5016# pragma pop_macro("min")
5017# pragma pop_macro("max")
5019# pragma inline_recursion(off)
5029# pragma inline_recursion(on)
5031# pragma push_macro("min")
5032# pragma push_macro("max")
5041#if TOML_ENABLE_WINDOWS_COMPAT
5042 #define TOML_SA_VALUE_MESSAGE_WSTRING TOML_SA_LIST_SEP "std::wstring"
5044 #define TOML_SA_VALUE_MESSAGE_WSTRING
5047 #define TOML_SA_VALUE_MESSAGE_U8STRING_VIEW TOML_SA_LIST_SEP "std::u8string_view"
5048 #define TOML_SA_VALUE_MESSAGE_CONST_CHAR8 TOML_SA_LIST_SEP "const char8_t*"
5050 #define TOML_SA_VALUE_MESSAGE_U8STRING_VIEW
5051 #define TOML_SA_VALUE_MESSAGE_CONST_CHAR8
5054#define TOML_SA_VALUE_EXACT_FUNC_MESSAGE(type_arg) \
5055 "The " type_arg " must be one of:" \
5056 TOML_SA_LIST_NEW "A native TOML value type" \
5057 TOML_SA_NATIVE_VALUE_TYPE_LIST \
5059 TOML_SA_LIST_NXT "A non-view type capable of losslessly representing a native TOML value type" \
5060 TOML_SA_LIST_BEG "std::string" \
5061 TOML_SA_VALUE_MESSAGE_WSTRING \
5062 TOML_SA_LIST_SEP "any signed integer type >= 64 bits" \
5063 TOML_SA_LIST_SEP "any floating-point type >= 64 bits" \
5066 TOML_SA_LIST_NXT "An immutable view type not requiring additional temporary storage" \
5067 TOML_SA_LIST_BEG "std::string_view" \
5068 TOML_SA_VALUE_MESSAGE_U8STRING_VIEW \
5069 TOML_SA_LIST_SEP "const char*" \
5070 TOML_SA_VALUE_MESSAGE_CONST_CHAR8 \
5073#define TOML_SA_VALUE_FUNC_MESSAGE(type_arg) \
5074 "The " type_arg " must be one of:" \
5075 TOML_SA_LIST_NEW "A native TOML value type" \
5076 TOML_SA_NATIVE_VALUE_TYPE_LIST \
5078 TOML_SA_LIST_NXT "A non-view type capable of losslessly representing a native TOML value type" \
5079 TOML_SA_LIST_BEG "std::string" \
5080 TOML_SA_VALUE_MESSAGE_WSTRING \
5081 TOML_SA_LIST_SEP "any signed integer type >= 64 bits" \
5082 TOML_SA_LIST_SEP "any floating-point type >= 64 bits" \
5085 TOML_SA_LIST_NXT "A non-view type capable of (reasonably) representing a native TOML value type" \
5086 TOML_SA_LIST_BEG "any other integral type" \
5087 TOML_SA_LIST_SEP "any floating-point type" \
5090 TOML_SA_LIST_NXT "An immutable view type not requiring additional temporary storage" \
5091 TOML_SA_LIST_BEG "std::string_view" \
5092 TOML_SA_VALUE_MESSAGE_U8STRING_VIEW \
5093 TOML_SA_LIST_SEP "const char*" \
5094 TOML_SA_VALUE_MESSAGE_CONST_CHAR8 \
5100 template <
typename T,
typename...>
5101 struct native_value_maker
5103 template <
typename... Args>
5105 std::is_nothrow_constructible_v<
T, Args &&...>)
5107 if constexpr (std::is_aggregate_v<T>)
5108 return T{
static_cast<Args &&
>(args)...};
5110 return T(
static_cast<Args &&
>(args)...);
5114 template <
typename T>
5115 struct native_value_maker<
T,
T>
5117 template <
typename U>
5120 return static_cast<U &&
>(val);
5124#if TOML_HAS_CHAR8 || TOML_ENABLE_WINDOWS_COMPAT
5128 template <
typename T>
5131 using arg_type = std::decay_t<T>;
5136 reinterpret_cast<const char *
>(
static_cast<const char8_t *
>(arg)));
5141 reinterpret_cast<const char *
>(
5142 static_cast<const char8_t *
>(arg.data())),
5147# if TOML_ENABLE_WINDOWS_COMPAT
5150 return narrow(
static_cast<T &&
>(arg));
5158 struct native_value_maker<
std::
string, char8_t *> : string_maker
5162 struct native_value_maker<
std::
string, const char8_t *> : string_maker
5166 struct native_value_maker<
std::
string, std::u8string> : string_maker
5170 struct native_value_maker<
std::
string, std::u8string_view> : string_maker
5175# if TOML_ENABLE_WINDOWS_COMPAT
5185 struct native_value_maker<
std::
string, std::wstring> : string_maker
5189 struct native_value_maker<
std::
string, std::wstring_view> : string_maker
5196 template <
typename T>
5203 if constexpr (!traits::is_signed)
5205 if constexpr ((
sizeof(
T) *
CHAR_BIT) < 63)
5207 using common_t =
decltype(int64_t{} +
T{});
5210 static_cast<common_t
>(val) >
static_cast<common_t
>(traits::max))
5215 if (val < int64_t{})
5221 if (val < traits::min || val > traits::max)
5224 return {
static_cast<T>(val)};
5227 template <
typename...>
5232 template <
typename T,
typename... Args>
5242 template <
typename ValueType>
5243 class value :
public node
5246 impl::is_native<ValueType> && !impl::is_cvref<ValueType>,
5247 "A toml::value<> must model one of the native TOML value "
5253 template <
typename T,
typename U>
5255 as_value([[maybe_unused]] U *ptr)
noexcept
5257 if constexpr (std::is_same_v<value_type, T>)
5267 using value_type = ValueType;
5271 std::is_same_v<value_type, std::string>,
5274 impl::is_one_of<value_type, double, int64_t, bool>,
5276 const value_type &>>);
5279 (impl::value_variadic_ctor_allowed<
5281 impl::remove_cvref<Args>...>
::value),
5284 explicit value(Args &&...args)
noexcept(
noexcept(value_type(
5285 impl::native_value_maker<value_type, std::decay_t<Args>...>::make(
5286 static_cast<Args &&
>(args)...))))
5287 : val_(impl::native_value_maker<value_type, std::decay_t<Args>...>::make(
5288 static_cast<Args &&>(
args)...))
5290#if TOML_LIFETIME_HOOKS
5299#if TOML_LIFETIME_HOOKS
5310#if TOML_LIFETIME_HOOKS
5317 : node(std::move(
other)),
5318 val_{std::move(
other.val_)},
5321#if TOML_LIFETIME_HOOKS
5328 : node(std::move(
other)),
5329 val_{std::move(
other.val_)},
5332#if TOML_LIFETIME_HOOKS
5340 node::operator=(rhs);
5342 flags_ = rhs.flags_;
5350 node::operator=(std::move(rhs));
5351 val_ = std::move(rhs.val_);
5352 flags_ = std::exchange(rhs.flags_,
value_flags{});
5357#if TOML_LIFETIME_HOOKS
5360 TOML_VALUE_DESTROYED;
5365 node_type
type() const noexcept final
5367 return impl::node_type_of<value_type>;
5371 bool is_homogeneous(node_type ntype)
const noexcept final
5373 return ntype == node_type::none ||
5374 ntype == impl::node_type_of<value_type>;
5378 bool is_homogeneous(node_type ntype, node *&first_nonmatch)
noexcept final
5380 if (ntype != node_type::none && ntype != impl::node_type_of<value_type>)
5382 first_nonmatch =
this;
5389 bool is_homogeneous(node_type ntype,
const node *&first_nonmatch)
5390 const noexcept final
5392 if (ntype != node_type::none && ntype != impl::node_type_of<value_type>)
5394 first_nonmatch =
this;
5400 template <
typename ElemType =
void>
5403 using type = impl::remove_cvref<impl::unwrap_node<ElemType>>;
5405 std::is_void_v<type> || toml::is_value<type> ||
5406 toml::is_container<type>,
5407 "The template type argument of value::is_homogeneous() must be void or "
5411 if constexpr (std::is_void_v<type>)
5414 return impl::node_type_of<type> == impl::node_type_of<value_type>;
5417 bool is_table() const noexcept final
5423 bool is_array() const noexcept final
5429 bool is_array_of_tables() const noexcept final
5435 bool is_value() const noexcept final
5443 return std::is_same_v<value_type, std::string>;
5449 return std::is_same_v<value_type, int64_t>;
5455 return std::is_same_v<value_type, double>;
5461 return impl::is_one_of<value_type, int64_t, double>;
5467 return std::is_same_v<value_type, bool>;
5471 bool is_date() const noexcept final
5473 return std::is_same_v<value_type, date>;
5477 bool is_time() const noexcept final
5479 return std::is_same_v<value_type, time>;
5485 return std::is_same_v<value_type, date_time>;
5489 table *as_table() noexcept final
5495 array *as_array() noexcept final
5501 value<std::string> *as_string() noexcept final
5503 return as_value<std::string>(
this);
5507 value<int64_t> *as_integer() noexcept final
5509 return as_value<int64_t>(
this);
5513 value<double> *as_floating_point() noexcept final
5515 return as_value<double>(
this);
5519 value<bool> *as_boolean() noexcept final
5521 return as_value<bool>(
this);
5525 value<date> *as_date() noexcept final
5527 return as_value<date>(
this);
5531 value<time> *as_time() noexcept final
5533 return as_value<time>(
this);
5537 value<date_time> *as_date_time() noexcept final
5539 return as_value<date_time>(
this);
5543 const table *as_table() const noexcept final
5549 const array *as_array() const noexcept final
5555 const value<std::string> *as_string() const noexcept final
5557 return as_value<std::string>(
this);
5561 const value<int64_t> *as_integer() const noexcept final
5563 return as_value<int64_t>(
this);
5567 const value<double> *as_floating_point() const noexcept final
5569 return as_value<double>(
this);
5573 const value<bool> *as_boolean() const noexcept final
5575 return as_value<bool>(
this);
5579 const value<date> *as_date() const noexcept final
5581 return as_value<date>(
this);
5585 const value<time> *as_time() const noexcept final
5587 return as_value<time>(
this);
5591 const value<date_time> *as_date_time() const noexcept final
5593 return as_value<date_time>(
this);
5597 value_type &get() &
noexcept
5603 value_type &&get() &&
noexcept
5605 return static_cast<value_type &&
>(val_);
5609 const value_type &get() const &noexcept
5615 const value_type &&get() const &&noexcept
5617 return static_cast<const value_type &&
>(val_);
5629 return static_cast<value_type &&
>(val_);
5633 const value_type &
operator*() const &noexcept
5639 const value_type &&
operator*() const &&noexcept
5641 return static_cast<const value_type &&
>(val_);
5645 explicit operator value_type &() &
noexcept
5651 explicit operator value_type &&() &&
noexcept
5653 return static_cast<value_type &&
>(val_);
5657 explicit operator const value_type &()
const &
noexcept
5663 explicit operator const value_type &&() &&
noexcept
5665 return static_cast<const value_type &&
>(val_);
5670 value_type *operator->() noexcept
5677 const value_type *operator->() const noexcept
5694 value &operator=(value_arg rhs)
noexcept
5696 if constexpr (std::is_same_v<value_type, std::string>)
5704 (std::is_same_v<T, std::string>),
5705 typename T = value_type)
5706 value &operator=(std::string &&rhs)
noexcept
5708 val_ = std::move(rhs);
5715 if constexpr (std::is_same_v<value_type, double>)
5717 const auto lhs_nan = impl::fpclassify(lhs.val_) == impl::fp_class::nan;
5718 const auto rhs_nan = impl::fpclassify(rhs) == impl::fp_class::nan;
5719 if (lhs_nan != rhs_nan)
5724 return lhs.val_ == rhs;
5731 return lhs.val_ < rhs;
5737 return lhs < rhs.val_;
5743 return lhs.val_ <= rhs;
5749 return lhs <= rhs.val_;
5755 return lhs.val_ > rhs;
5761 return lhs > rhs.val_;
5767 return lhs.val_ >= rhs;
5773 return lhs >= rhs.val_;
5776 template <
typename T>
5780 if constexpr (std::is_same_v<value_type, T>)
5788 template <
typename T>
5792 return !(lhs == rhs);
5795 template <
typename T>
5799 if constexpr (std::is_same_v<value_type, T>)
5800 return lhs.val_ < rhs.val_;
5802 return impl::node_type_of<value_type> < impl::node_type_of<T>;
5805 template <
typename T>
5809 if constexpr (std::is_same_v<value_type, T>)
5810 return lhs.val_ <= rhs.val_;
5812 return impl::node_type_of<value_type> <= impl::node_type_of<T>;
5815 template <
typename T>
5819 if constexpr (std::is_same_v<value_type, T>)
5820 return lhs.val_ > rhs.val_;
5822 return impl::node_type_of<value_type> > impl::node_type_of<T>;
5825 template <
typename T>
5829 if constexpr (std::is_same_v<value_type, T>)
5830 return lhs.val_ >= rhs.val_;
5832 return impl::node_type_of<value_type> >= impl::node_type_of<T>;
5835#if TOML_ENABLE_FORMATTERS
5839 impl::print_to_stream(lhs, rhs);
5846 template <
typename T>
5848 template <
typename T>
5851 template <
typename T>
5855 using namespace impl;
5866 const auto &str = *ref_cast<std::string>();
5867 if constexpr (std::is_same_v<T, std::string>)
5869 else if constexpr (std::is_same_v<T, std::string_view>)
5871 else if constexpr (std::is_same_v<T, const char *>)
5874 else if constexpr (std::is_same_v<T, std::wstring>)
5876#if TOML_ENABLE_WINDOWS_COMPAT
5887 return T(
reinterpret_cast<const char8_t *
>(str.c_str()), str.length());
5888 else if constexpr (std::is_same_v<T, const char8_t *>)
5889 return reinterpret_cast<const char8_t *
>(str.c_str());
5896 return static_cast<T>(*ref_cast<native_type_of<T>>());
5899 template <
typename T>
5903 using namespace impl;
5907 "Retrieving values as wide-character strings with node::value_exact() is "
5909 "supported on Windows with TOML_ENABLE_WINDOWS_COMPAT enabled.");
5919 return {this->get_value_exact<T>()};
5925 template <
typename T>
5929 using namespace impl;
5933 "Retrieving values as wide-character strings with node::value() is only "
5934 "supported on Windows with TOML_ENABLE_WINDOWS_COMPAT enabled.");
5945 return {this->get_value_exact<T>()};
5956 case node_type::integer:
5962 return static_cast<T>(*ref_cast<int64_t>());
5970 const int64_t val = *ref_cast<int64_t>();
5971 if constexpr (std::numeric_limits<T>::digits < 64)
5973 constexpr auto largest_whole_float =
5974 (int64_t{1} << std::numeric_limits<T>::digits);
5975 if (val < -largest_whole_float || val > largest_whole_float)
5978 return static_cast<T>(val);
5983 return static_cast<bool>(*ref_cast<int64_t>());
5991 case node_type::floating_point:
5997 return {
static_cast<T>(*ref_cast<double>())};
6000 const double val = *ref_cast<double>();
6002 impl::fpclassify(val) == fp_class::ok &&
6003 (val < (std::numeric_limits<T>::lowest)() ||
6004 val > (std::numeric_limits<T>::max)()))
6006 return {
static_cast<T>(val)};
6013 const double val = *ref_cast<double>();
6015 impl::fpclassify(val) == fp_class::ok &&
6016 static_cast<double>(
static_cast<int64_t
>(val)) == val)
6028 case node_type::boolean:
6032 return {*ref_cast<bool>()};
6036 return {
static_cast<T>(*ref_cast<bool>())};
6049 template <
typename T>
6051 const noexcept(impl::value_retrieval_is_nothrow<T>)
6053 using namespace impl;
6057 "Retrieving values as wide-character strings with node::value_or() is "
6059 "supported on Windows with TOML_ENABLE_WINDOWS_COMPAT enabled.");
6063#if TOML_ENABLE_WINDOWS_COMPAT
6065 if (
type() == node_type::string)
6066 return widen(*ref_cast<std::string>());
6067 return std::wstring{
static_cast<T &&
>(default_value)};
6077 using value_type = std::conditional_t<
6078 std::is_pointer_v<std::decay_t<T>>,
6080 std::add_const_t<std::remove_pointer_t<std::decay_t<T>>>>,
6087 traits::is_native || traits::can_represent_native || traits::can_partially_represent_native,
6088 "The default value type of node::value_or() must be one of:"
6092 TOML_SA_LIST_NXT "A non-view type capable of losslessly representing a native TOML value type"
6094 #if TOML_ENABLE_WINDOWS_COMPAT
6101 TOML_SA_LIST_NXT "A non-view type capable of (reasonably) representing a native TOML value type"
6111 #if TOML_ENABLE_WINDOWS_COMPAT
6118 #if TOML_ENABLE_WINDOWS_COMPAT
6128 traits::is_native || traits::can_represent_native ||
6129 traits::can_partially_represent_native)
6131 if constexpr (traits::is_native)
6134 return *ref_cast<typename traits::native_type>();
6138 if constexpr (std::is_pointer_v<value_type>)
6139 return value_type{default_value};
6141 return static_cast<T &&
>(default_value);
6149# pragma pop_macro("min")
6150# pragma pop_macro("max")
6152# pragma inline_recursion(off)
6162# pragma inline_recursion(on)
6164# pragma push_macro("min")
6165# pragma push_macro("max")
6172 template <
typename T>
6177 static_assert(!std::is_same_v<unwrapped_type, node>);
6183 return new unwrapped_type(
static_cast<T &&
>(val));
6195 if constexpr (std::is_same_v<remove_cvref<T>, value_type>)
6197 out =
new value_type{
static_cast<T &&
>(val), flags};
6205 "Instantiating values from wide-character strings is only "
6206 "supported on Windows with TOML_ENABLE_WINDOWS_COMPAT enabled.");
6210 if constexpr (std::is_same_v<native_type, int64_t>)
6213 "Integral value initializers must be losslessly convertible to "
6215 else if constexpr (std::is_same_v<native_type, double>)
6218 "Floating-point value initializers must be losslessly "
6219 "convertible to double");
6223 "Value initializers must be losslessly convertible to one of the "
6224 "TOML value types");
6229#if TOML_ENABLE_WINDOWS_COMPAT
6230 out =
new value_type{narrow(
static_cast<T &&
>(val))};
6236 out =
new value_type{
static_cast<T &&
>(val)};
6246 template <
typename T>
6257 return static_cast<toml::node *
>(
nullptr);
6260 return static_cast<T &&
>(val).visit(
6261 [flags](
auto &&concrete)
6263 return static_cast<toml::node *
>(make_node_impl_specialized(
6264 static_cast<decltype(concrete) &&
>(concrete), flags));
6268 return make_node_impl_specialized(
static_cast<T &&
>(val), flags);
6271 template <
typename T>
6275 return make_node_impl(
static_cast<T &&
>(val.value), flags);
6283 struct inserted_type_of_
6286 std::remove_pointer_t<decltype(make_node_impl(std::declval<T>()))>;
6289 template <
typename T>
6295 template <
typename T>
6301 template <
typename T>
6305 return node_ptr{make_node_impl(
static_cast<T &&
>(val), flags)};
6308 template <
typename...
T>
6314 template <
typename T>
6320 typename inserted_type_of_<T>::type>;
6323 template <
typename T>
6329 template <
typename...
T>
6336 template <
typename T>
6338 typename impl::inserted_type_of_<impl::remove_cvref<T>>::type);
6343# pragma pop_macro("min")
6344# pragma pop_macro("max")
6346# pragma inline_recursion(off)
6356# pragma inline_recursion(on)
6358# pragma push_macro("min")
6359# pragma push_macro("max")
6364#ifndef TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN
6365# if TOML_GCC && TOML_GCC <= 7
6366# define TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN 1
6368# define TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN 0
6372#if TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN && \
6373 !defined(TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_ACKNOWLEDGED)
6374# define TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_MESSAGE \
6375 "If you're seeing this error it's because you're using one of toml++'s " \
6376 "for_each() functions on a compiler with " \
6377 "known bugs in that area (e.g. GCC 7). On these compilers returning a " \
6378 "bool (or bool-convertible) value from the " \
6379 "for_each() callable causes spurious compilation failures, while " \
6380 "returning nothing (void) works fine. " \
6381 "If you believe this message is incorrect for your compiler, you can try " \
6382 "your luck by #defining " \
6383 "TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN as 0 and recompiling - if it " \
6384 "works, great! Let me know at " \
6385 "https://github.com/marzer/tomlplusplus/issues. Alternatively, if you " \
6386 "don't have any need for early-exiting from " \
6387 "for_each(), you can suppress this error by #defining " \
6388 "TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_ACKNOWLEDGED " \
6389 "and moving on with your life."
6394 template <
bool IsConst>
6399 friend class array_iterator;
6401 using mutable_vector_iterator = std::vector<node_ptr>::iterator;
6402 using const_vector_iterator = std::vector<node_ptr>::const_iterator;
6403 using vector_iterator = std::
6404 conditional_t<IsConst, const_vector_iterator, mutable_vector_iterator>;
6406 mutable vector_iterator iter_;
6409 using value_type = std::conditional_t<IsConst, const node, node>;
6410 using reference = value_type &;
6411 using pointer = value_type *;
6413 using iterator_category =
6414 typename std::iterator_traits<vector_iterator>::iterator_category;
6417 array_iterator()
noexcept =
default;
6420 explicit array_iterator(mutable_vector_iterator iter)
noexcept
6427 explicit array_iterator(const_vector_iterator iter)
noexcept
6434 array_iterator(
const array_iterator<false> &
other)
noexcept
6435 : iter_{
other.iter_}
6440 array_iterator(
const array_iterator &)
noexcept =
default;
6442 array_iterator &operator=(
const array_iterator &)
noexcept =
default;
6444 array_iterator &operator++()
noexcept
6450 array_iterator operator++(
int)
noexcept
6452 array_iterator out{iter_};
6457 array_iterator &operator--()
noexcept
6463 array_iterator operator--(
int)
noexcept
6465 array_iterator out{iter_};
6473 return *iter_->get();
6477 pointer operator->()
const noexcept
6479 return iter_->get();
6483 explicit operator const vector_iterator &()
const noexcept
6490 explicit operator const const_vector_iterator()
const noexcept
6495 array_iterator &operator+=(
ptrdiff_t rhs)
noexcept
6508 friend array_iterator
6511 return array_iterator{lhs.iter_ + rhs};
6515 friend array_iterator
6518 return array_iterator{rhs.iter_ + lhs};
6522 friend array_iterator
6525 return array_iterator{lhs.iter_ - rhs};
6530 operator-(
const array_iterator &lhs,
const array_iterator &rhs)
noexcept
6532 return lhs.iter_ - rhs.iter_;
6537 operator==(
const array_iterator &lhs,
const array_iterator &rhs)
noexcept
6539 return lhs.iter_ == rhs.iter_;
6544 operator!=(
const array_iterator &lhs,
const array_iterator &rhs)
noexcept
6546 return lhs.iter_ != rhs.iter_;
6551 operator<(
const array_iterator &lhs,
const array_iterator &rhs)
noexcept
6553 return lhs.iter_ < rhs.iter_;
6558 operator<=(
const array_iterator &lhs,
const array_iterator &rhs)
noexcept
6560 return lhs.iter_ <= rhs.iter_;
6565 operator>(
const array_iterator &lhs,
const array_iterator &rhs)
noexcept
6567 return lhs.iter_ > rhs.iter_;
6572 operator>=(
const array_iterator &lhs,
const array_iterator &rhs)
noexcept
6574 return lhs.iter_ >= rhs.iter_;
6578 reference operator[](
ptrdiff_t idx)
const noexcept
6580 return *(iter_ + idx)->get();
6588 template <
typename T>
6600 using array_iterator =
6609 using vector_type = std::vector<impl::node_ptr>;
6610 using vector_iterator =
typename vector_type::iterator;
6611 using const_vector_iterator =
typename vector_type::const_iterator;
6616 array(
const impl::array_init_elem *,
const impl::array_init_elem *);
6621 std::initializer_list<impl::array_init_elem> elems)
6622 : array{elems.begin(), elems.end()}
6627 void preinsertion_resize(
size_t idx,
size_t count);
6630 void insert_at_back(impl::node_ptr &&);
6633 vector_iterator insert_at(const_vector_iterator, impl::node_ptr &&);
6635 template <
typename T>
6636 void emplace_back_if_not_empty_view(
T &&val,
value_flags flags)
6643 insert_at_back(impl::make_node(
static_cast<T &&
>(val), flags));
6648 size_t total_leaf_count()
const noexcept;
6651 void flatten_child(array &&child,
size_t &dest_index)
noexcept;
6669 array(const array &);
6676 (sizeof...(ElemTypes) > 0 ||
6677 !
std::is_same_v<impl::remove_cvref<ElemType>, array>),
6679 typename... ElemTypes)
6681 explicit array(ElemType &&val, ElemTypes &&...
vals)
6684 std::initializer_list<impl::array_init_elem>{
6685 static_cast<ElemType &&
>(val),
6686 static_cast<ElemTypes &&
>(
vals)...}}
6691 array &operator=(
const array &);
6697 node_type
type() const noexcept final
6699 return node_type::array;
6713 const noexcept final;
6715 template <
typename ElemType =
void>
6718 using type = impl::remove_cvref<impl::unwrap_node<ElemType>>;
6720 std::is_void_v<type> || toml::is_value<type> ||
6721 toml::is_container<type>,
6722 "The template type argument of array::is_homogeneous() must be void or "
6867 const toml::value<std::string> *
as_string() const noexcept final
6891 const toml::value<date> *
as_date() const noexcept final
6897 const toml::value<time> *
as_time() const noexcept final
6909 node *
get(
size_t index)
noexcept
6911 return index < elems_.size() ? elems_[index].get() :
nullptr;
6915 const node *
get(
size_t index)
const noexcept
6917 return const_cast<array &
>(*this).get(index);
6920 template <
typename ElemType>
6923 if (
auto val =
get(index))
6924 return val->template as<ElemType>();
6928 template <
typename ElemType>
6935 using node::operator[];
6939 return *elems_[index];
6945 return *elems_[index];
6953 const node &
at(
size_t index)
const
6955 return const_cast<array &
>(*this).at(index);
6961 return *elems_.front();
6967 return *elems_.front();
6973 return *elems_.back();
6979 return *elems_.back();
7023 template <
typename T,
typename Array>
7024 using for_each_elem_ref = impl::copy_cvref<
7025 impl::wrap_node<impl::remove_cvref<impl::unwrap_node<T>>>,
7028 template <
typename Func,
typename Array,
typename T>
7029 using can_for_each = std::disjunction<
7030 std::is_invocable<Func, for_each_elem_ref<T, Array>,
size_t>,
7031 std::is_invocable<Func, size_t, for_each_elem_ref<T, Array>>,
7032 std::is_invocable<Func, for_each_elem_ref<T, Array>>>;
7034 template <
typename Func,
typename Array,
typename T>
7035 using can_for_each_nothrow = std::conditional_t<
7037 std::is_invocable_v<Func, for_each_elem_ref<T, Array>,
size_t>,
7038 std::is_nothrow_invocable<Func, for_each_elem_ref<T, Array>,
size_t>,
7041 std::is_invocable_v<Func, size_t, for_each_elem_ref<T, Array>>,
7042 std::is_nothrow_invocable<Func, size_t, for_each_elem_ref<T, Array>>,
7045 std::is_invocable_v<Func, for_each_elem_ref<T, Array>>,
7046 std::is_nothrow_invocable<Func, for_each_elem_ref<T, Array>>,
7049 template <
typename Func,
typename Array>
7050 using can_for_each_any = std::disjunction<
7051 can_for_each<Func, Array, table>,
7052 can_for_each<Func, Array, array>,
7053 can_for_each<Func, Array, std::string>,
7054 can_for_each<Func, Array, int64_t>,
7055 can_for_each<Func, Array, double>,
7056 can_for_each<Func, Array, bool>,
7057 can_for_each<Func, Array, date>,
7058 can_for_each<Func, Array, time>,
7059 can_for_each<Func, Array, date_time>>;
7061 template <
typename Func,
typename Array,
typename T>
7062 using for_each_is_nothrow_one = std::disjunction<
7063 std::negation<can_for_each<Func, Array, T>>,
7064 can_for_each_nothrow<Func, Array, T>>;
7066 template <
typename Func,
typename Array>
7067 using for_each_is_nothrow = std::conjunction<
7068 for_each_is_nothrow_one<Func, Array, table>,
7069 for_each_is_nothrow_one<Func, Array, array>,
7070 for_each_is_nothrow_one<Func, Array, std::string>,
7071 for_each_is_nothrow_one<Func, Array, int64_t>,
7072 for_each_is_nothrow_one<Func, Array, double>,
7073 for_each_is_nothrow_one<Func, Array, bool>,
7074 for_each_is_nothrow_one<Func, Array, date>,
7075 for_each_is_nothrow_one<Func, Array, time>,
7076 for_each_is_nothrow_one<Func, Array, date_time>>;
7078 template <
typename Func,
typename Array>
7079 static void do_for_each(Func &&visitor, Array &&arr)
7080 noexcept(for_each_is_nothrow<Func &&, Array &&>::value)
7083 can_for_each_any<Func &&, Array &&>::value,
7084 "TOML array for_each visitors must be invocable for at least one of "
7088 for (
size_t i = 0; i < arr.size(); i++)
7090 using node_ref = impl::copy_cvref<toml::node, Array &&>;
7091 static_assert(std::is_reference_v<node_ref>);
7093#if TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN
7095# ifndef TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_ACKNOWLEDGED
7097 impl::always_false<Func, Array, node_ref>,
7098 TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_MESSAGE);
7101 static_cast<node_ref
>(
static_cast<Array &&
>(arr)[i])
7103 [&]([[maybe_unused]]
auto &&elem)
7105 for_each_is_nothrow_one<Func &&, Array &&,
decltype(elem)>
::value)
7107 using elem_ref = for_each_elem_ref<
decltype(elem), Array &&>;
7108 static_assert(std::is_reference_v<elem_ref>);
7111 if constexpr (std::is_invocable_v<Func &&, elem_ref, size_t>)
7113 static_cast<Func &&
>(visitor)(
static_cast<elem_ref
>(elem), i);
7117 else if constexpr (std::is_invocable_v<Func &&, size_t, elem_ref>)
7119 static_cast<Func &&
>(visitor)(i,
static_cast<elem_ref
>(elem));
7123 else if constexpr (std::is_invocable_v<Func &&, elem_ref>)
7125 static_cast<Func &&
>(visitor)(
static_cast<elem_ref
>(elem));
7130 const auto keep_going =
7131 static_cast<node_ref
>(
static_cast<Array &&
>(arr)[i])
7133 [&]([[maybe_unused]]
auto &&elem)
7135 for_each_is_nothrow_one<Func &&, Array &&,
decltype(elem)>::
7138 using elem_ref = for_each_elem_ref<
decltype(elem), Array &&>;
7139 static_assert(std::is_reference_v<elem_ref>);
7142 if constexpr (std::is_invocable_v<Func &&, elem_ref, size_t>)
7144 using return_type =
decltype(
static_cast<Func &&
>(visitor)(
7145 static_cast<elem_ref
>(elem), i));
7147 if constexpr (impl::is_constructible_or_convertible<
7151 return static_cast<bool>(
static_cast<Func &&
>(visitor)(
7152 static_cast<elem_ref
>(elem), i));
7156 static_cast<Func &&
>(visitor)(
7157 static_cast<elem_ref
>(elem), i);
7163 else if constexpr (std::
7164 is_invocable_v<Func &&, size_t, elem_ref>)
7166 using return_type =
decltype(
static_cast<Func &&
>(visitor)(
7167 i,
static_cast<elem_ref
>(elem)));
7169 if constexpr (impl::is_constructible_or_convertible<
7173 return static_cast<bool>(
static_cast<Func &&
>(visitor)(
7174 i,
static_cast<elem_ref
>(elem)));
7178 static_cast<Func &&
>(visitor)(
7179 i,
static_cast<elem_ref
>(elem));
7185 else if constexpr (std::is_invocable_v<Func &&, elem_ref>)
7187 using return_type =
decltype(
static_cast<Func &&
>(visitor)(
7188 static_cast<elem_ref
>(elem)));
7190 if constexpr (impl::is_constructible_or_convertible<
7194 return static_cast<bool>(
static_cast<Func &&
>(visitor)(
7195 static_cast<elem_ref
>(elem)));
7199 static_cast<Func &&
>(visitor)(
static_cast<elem_ref
>(elem));
7216 template <
typename Func>
7218 noexcept(for_each_is_nothrow<Func &&, array &>::value)
7220 do_for_each(
static_cast<Func &&
>(visitor), *
this);
7224 template <
typename Func>
7226 noexcept(for_each_is_nothrow<Func &&, array &&>::value)
7228 do_for_each(
static_cast<Func &&
>(visitor),
static_cast<array &&
>(*
this));
7229 return static_cast<array &&
>(*this);
7232 template <
typename Func>
7234 noexcept(for_each_is_nothrow<Func &&, const array &>::value)
7236 do_for_each(
static_cast<Func &&
>(visitor), *
this);
7240 template <
typename Func>
7242 noexcept(for_each_is_nothrow<Func &&, const array &&>::value)
7245 static_cast<Func &&
>(visitor),
static_cast<const array &&
>(*
this));
7246 return static_cast<const array &&
>(*this);
7252 return elems_.empty();
7258 return elems_.size();
7264 return elems_.max_size();
7270 return elems_.capacity();
7282 template <
typename ElemType>
7285 ElemType &&default_init_val,
7290 "The default element type argument to toml::array::resize may not be "
7291 "toml::node_view.");
7295 else if (new_size > elems_.size())
7298 new_size - elems_.size(),
7299 static_cast<ElemType &&
>(default_init_val),
7300 default_init_flags);
7316 return static_cast<toml::array &&
>(this->
flatten());
7320 array &
prune(
bool recursive =
true) &
noexcept;
7322 array &&
prune(
bool recursive =
true) &&
noexcept
7324 return static_cast<toml::array &&
>(this->
prune(recursive));
7333 template <typename ElemType>
7345 const_vector_iterator{
pos},
7346 impl::make_node(
static_cast<ElemType &&
>(val), flags))};
7349 template <
typename ElemType>
7365 elems_.begin() + (const_vector_iterator{
pos} - elems_.cbegin())};
7367 return insert(
pos,
static_cast<ElemType &&
>(val), flags);
7370 const auto start_idx =
7371 static_cast<size_t>(const_vector_iterator{
pos} - elems_.cbegin());
7372 preinsertion_resize(start_idx,
count);
7373 size_t i = start_idx;
7374 for (
size_t e = start_idx +
count - 1u; i < e; i++)
7375 elems_[i] = impl::make_node(val, flags);
7377 elems_[i] = impl::make_node(
static_cast<ElemType &&
>(val), flags);
7383 template <
typename Iter>
7390 const auto distance = std::distance(first, last);
7393 elems_.begin() + (const_vector_iterator{
pos} - elems_.cbegin())};
7396 auto count = distance;
7397 using deref_type =
decltype(*first);
7400 for (
auto it = first; it != last; it++)
7405 elems_.begin() + (const_vector_iterator{
pos} - elems_.cbegin())};
7407 const auto start_idx =
7408 static_cast<size_t>(const_vector_iterator{
pos} - elems_.cbegin());
7409 preinsertion_resize(start_idx,
static_cast<size_t>(
count));
7410 size_t i = start_idx;
7411 for (
auto it = first; it != last; it++)
7418 if constexpr (std::is_rvalue_reference_v<deref_type>)
7419 elems_[i++] = impl::make_node(std::move(*it), flags);
7421 elems_[i++] = impl::make_node(*it, flags);
7427 template <
typename ElemType>
7430 std::initializer_list<ElemType> ilist,
7433 return insert(
pos, ilist.begin(), ilist.end(), flags);
7436 template <
typename ElemType = void,
typename... Args>
7439 using raw_elem_type = impl::remove_cvref<ElemType>;
7440 using elem_type = std::conditional_t<
7441 std::is_void_v<raw_elem_type>,
7442 impl::emplaced_type_of<Args &&...>,
7445 using type = impl::remove_cvref<impl::unwrap_node<elem_type>>;
7447 impl::is_native<type> || impl::is_one_of<type, table, array>,
7448 "Emplacement type parameter must be one "
7452 const_vector_iterator{
pos},
7454 new impl::wrap_node<type>{
static_cast<Args &&
>(args)...}})};
7457 template <
typename ElemType>
7472 elems_.begin() + (const_vector_iterator{
pos} - elems_.cbegin());
7473 *it = impl::make_node(
static_cast<ElemType &&
>(val), flags);
7477 template <
typename ElemType>
7481 emplace_back_if_not_empty_view(
static_cast<ElemType &&
>(val), flags);
7484 template <
typename ElemType = void,
typename... Args>
7487 using raw_elem_type = impl::remove_cvref<ElemType>;
7488 using elem_type = std::conditional_t<
7489 std::is_void_v<raw_elem_type>,
7490 impl::emplaced_type_of<Args &&...>,
7493 static constexpr auto moving_node_ptr =
7494 std::is_same_v<elem_type, impl::node_ptr>
7495 &&
sizeof...(Args) == 1u
7496 && impl::first_is_same<impl::node_ptr &&, Args &&...>;
7498 using unwrapped_type = impl::remove_cvref<impl::unwrap_node<elem_type>>;
7502 || impl::is_native<unwrapped_type>
7503 || impl::is_one_of<unwrapped_type, table, array>,
7504 "ElemType argument of array::emplace_back() must be one "
7507 if constexpr (moving_node_ptr)
7509 insert_at_back(
static_cast<Args &&
>(args)...);
7510 return *elems_.back();
7515 new impl::wrap_node<unwrapped_type>{
static_cast<Args &&
>(args)...};
7516 insert_at_back(impl::node_ptr{ptr});
7526 template <
typename T>
7528 equal_to_container(
const array &lhs,
const T &rhs)
noexcept
7530 using element_type = std::remove_const_t<typename T::value_type>;
7532 impl::is_losslessly_convertible_to_native<element_type>,
7533 "Container element type must be losslessly convertible one of the "
7534 "native TOML value types");
7536 if (lhs.size() != rhs.size())
7538 if (rhs.size() == 0u)
7542 for (
auto &list_elem : rhs)
7544 const auto elem = lhs.get_as<impl::native_type_of<element_type>>(i++);
7545 if (!elem || *elem != list_elem)
7554 friend bool operator==(
const array &lhs,
const array &rhs)
noexcept
7556 return equal(lhs, rhs);
7560 friend bool operator!=(
const array &lhs,
const array &rhs)
noexcept
7562 return !equal(lhs, rhs);
7565 template <
typename T>
7567 operator==(
const array &lhs,
const std::initializer_list<T> &rhs)
noexcept
7569 return equal_to_container(lhs, rhs);
7573 const std::initializer_list<T> &,
7574 template <typename T>
7577 template <
typename T>
7581 return equal_to_container(lhs, rhs);
7585 const std::vector<T> &,
7586 template <typename T>
7589#if TOML_ENABLE_FORMATTERS
7591 friend std::ostream &
operator<<(std::ostream &lhs,
const array &rhs)
7593 impl::print_to_stream(lhs, rhs);
7603# pragma pop_macro("min")
7604# pragma pop_macro("max")
7606# pragma inline_recursion(off)
7616# pragma inline_recursion(on)
7618# pragma push_macro("min")
7619# pragma push_macro("max")
7630 source_region source_;
7634 key() noexcept = default;
7637 explicit
key(std::string_view k, source_region &&src = {})
7638 : key_{k}, source_{std::move(src)}
7643 explicit key(std::string_view k,
const source_region &src)
7644 : key_{k}, source_{src}
7649 explicit key(std::string &&k, source_region &&src = {})
noexcept
7650 : key_{std::move(k)}, source_{std::move(src)}
7655 explicit key(std::string &&k,
const source_region &src)
noexcept
7656 : key_{std::move(k)}, source_{src}
7661 explicit key(
const char *k, source_region &&src = {})
7662 : key_{k}, source_{std::move(src)}
7667 explicit key(
const char *k,
const source_region &src)
7668 : key_{k}, source_{src}
7672#if TOML_ENABLE_WINDOWS_COMPAT
7675 explicit key(std::wstring_view k, source_region &&src = {})
7676 : key_{impl::narrow(k)}, source_{std::move(src)}
7681 explicit key(std::wstring_view k,
const source_region &src)
7682 : key_{impl::narrow(k)}, source_{src}
7689 std::string_view str() const noexcept
7691 return std::string_view{key_};
7695 operator std::string_view() const noexcept
7701 bool empty() const noexcept
7703 return key_.empty();
7707 const char *data() const noexcept
7713 size_t length() const noexcept
7715 return key_.length();
7719 const source_region &source() const noexcept
7727 return lhs.key_ == rhs.key_;
7733 return lhs.key_ != rhs.key_;
7739 return lhs.key_ < rhs.key_;
7745 return lhs.key_ <= rhs.key_;
7751 return lhs.key_ > rhs.key_;
7757 return lhs.key_ >= rhs.key_;
7761 friend bool operator==(
const key &lhs, std::string_view rhs)
noexcept
7763 return lhs.key_ == rhs;
7767 friend bool operator!=(
const key &lhs, std::string_view rhs)
noexcept
7769 return lhs.key_ != rhs;
7773 friend bool operator<(
const key &lhs, std::string_view rhs)
noexcept
7775 return lhs.key_ < rhs;
7779 friend bool operator<=(
const key &lhs, std::string_view rhs)
noexcept
7781 return lhs.key_ <= rhs;
7785 friend bool operator>(
const key &lhs, std::string_view rhs)
noexcept
7787 return lhs.key_ > rhs;
7791 friend bool operator>=(
const key &lhs, std::string_view rhs)
noexcept
7793 return lhs.key_ >= rhs;
7797 friend bool operator==(std::string_view lhs,
const key &rhs)
noexcept
7799 return lhs == rhs.key_;
7803 friend bool operator!=(std::string_view lhs,
const key &rhs)
noexcept
7805 return lhs != rhs.key_;
7809 friend bool operator<(std::string_view lhs,
const key &rhs)
noexcept
7811 return lhs < rhs.key_;
7815 friend bool operator<=(std::string_view lhs,
const key &rhs)
noexcept
7817 return lhs <= rhs.key_;
7821 friend bool operator>(std::string_view lhs,
const key &rhs)
noexcept
7823 return lhs > rhs.key_;
7827 friend bool operator>=(std::string_view lhs,
const key &rhs)
noexcept
7829 return lhs >= rhs.key_;
7832 using const_iterator =
const char *;
7834 using iterator = const_iterator;
7837 const_iterator begin() const noexcept
7843 const_iterator
end() const noexcept
7845 return key_.data() + key_.length();
7848 friend std::ostream &
operator<<(std::ostream &lhs,
const key &rhs)
7850 impl::print_to_stream(lhs, rhs.key_);
7855 template <
typename T>
7857 std::is_same_v<impl::remove_cvref<T>, toml::key>;
7859 template <
typename T>
7862 || impl::is_constructible_or_convertible<toml::key, T>;
7867# pragma pop_macro("min")
7868# pragma pop_macro("max")
7870# pragma inline_recursion(off)
7887# pragma inline_recursion(on)
7889# pragma push_macro("min")
7890# pragma push_macro("max")
7897 template <
bool IsConst>
7898 struct table_proxy_pair
7900 using value_type = std::conditional_t<IsConst, const node, node>;
7902 const toml::key &first;
7906 template <
bool IsConst>
7913 using proxy_type = table_proxy_pair<IsConst>;
7914 using mutable_map_iterator =
7915 std::map<toml::key, node_ptr, std::less<>>::iterator;
7916 using const_map_iterator =
7917 std::map<toml::key, node_ptr, std::less<>>::const_iterator;
7918 using map_iterator =
7919 std::conditional_t<IsConst, const_map_iterator, mutable_map_iterator>;
7921 mutable map_iterator iter_;
7922 alignas(proxy_type)
mutable unsigned char proxy_[
sizeof(proxy_type)];
7923 mutable bool proxy_instantiated_ =
false;
7926 proxy_type *get_proxy() const noexcept
7928 if (!proxy_instantiated_)
7930 auto p = ::new (
static_cast<void *
>(proxy_))
7931 proxy_type{iter_->first, *iter_->second.get()};
7932 proxy_instantiated_ =
true;
7936 return TOML_LAUNDER(
reinterpret_cast<proxy_type *
>(proxy_));
7959 : iter_{
other.iter_}
7965 : iter_{
other.iter_}
7972 proxy_instantiated_ =
false;
7980 typename std::iterator_traits<map_iterator>::difference_type;
7982 typename std::iterator_traits<map_iterator>::iterator_category;
7987 proxy_instantiated_ =
false;
7995 proxy_instantiated_ =
false;
8002 proxy_instantiated_ =
false;
8010 proxy_instantiated_ =
false;
8017 return *get_proxy();
8027 explicit operator const map_iterator &()
const noexcept
8034 explicit operator const const_map_iterator() const noexcept
8043 return lhs.iter_ == rhs.iter_;
8050 return lhs.iter_ != rhs.iter_;
8059 template <
typename K,
typename V>
8082 using map_type = std::map<toml::key, impl::node_ptr, std::less<>>;
8083 using map_pair = std::pair<const toml::key, impl::node_ptr>;
8084 using map_iterator =
typename map_type::iterator;
8085 using const_map_iterator =
typename map_type::const_iterator;
8088 bool inline_ =
false;
8092 table(
const impl::table_init_pair *,
const impl::table_init_pair *);
8104 table(const table &);
8124 node_type
type() const noexcept final
8126 return node_type::table;
8140 const noexcept final;
8142 template <
typename ElemType =
void>
8145 using type = impl::remove_cvref<impl::unwrap_node<ElemType>>;
8147 std::is_void_v<type> || toml::is_value<type> ||
8148 toml::is_container<type>,
8149 "The template type argument of table::is_homogeneous() must be void or "
8294 const toml::value<std::string> *
as_string() const noexcept final
8318 const toml::value<date> *
as_date() const noexcept final
8324 const toml::value<time> *
as_time() const noexcept final
8351 const node *
get(std::string_view
key)
const noexcept
8353 return const_cast<table &
>(*this).get(
key);
8356#if TOML_ENABLE_WINDOWS_COMPAT
8359 node *get(std::wstring_view
key)
8364 return get(impl::narrow(
key));
8368 const node *get(std::wstring_view
key)
const
8370 return const_cast<table &
>(*this).get(
key);
8375 template <
typename T>
8378 const auto n = this->
get(
key);
8379 return n ? n->template as<T>() :
nullptr;
8382 template <
typename T>
8386 return const_cast<table &
>(*this).template
get_as<T>(
key);
8389#if TOML_ENABLE_WINDOWS_COMPAT
8391 template <
typename T>
8397 return get_as<T>(impl::narrow(
key));
8400 template <
typename T>
8403 return const_cast<table &
>(*this).template get_as<T>(
key);
8413 const node &
at(std::string_view
key)
const
8415 return const_cast<table &
>(*this).at(
key);
8418#if TOML_ENABLE_WINDOWS_COMPAT
8421 node &at(std::wstring_view
key)
8423 return at(impl::narrow(
key));
8427 const node &
at(std::wstring_view
key)
const
8429 return const_cast<table &
>(*this).at(
key);
8475 template <
typename T,
typename Table>
8476 using for_each_value_ref = impl::copy_cvref<
8477 impl::wrap_node<impl::remove_cvref<impl::unwrap_node<T>>>,
8480 template <
typename Func,
typename Table,
typename T>
8481 using can_for_each = std::disjunction<
8482 std::is_invocable<Func, const key &, for_each_value_ref<T, Table>>,
8483 std::is_invocable<Func, for_each_value_ref<T, Table>>>;
8485 template <
typename Func,
typename Table,
typename T>
8486 using can_for_each_nothrow = std::conditional_t<
8488 std::is_invocable_v<Func, const key &, for_each_value_ref<T, Table>>,
8490 is_nothrow_invocable<Func, const key &, for_each_value_ref<T, Table>>,
8493 std::is_invocable_v<Func, for_each_value_ref<T, Table>>,
8494 std::is_nothrow_invocable<Func, for_each_value_ref<T, Table>>,
8497 template <
typename Func,
typename Table>
8498 using can_for_each_any = std::disjunction<
8499 can_for_each<Func, Table, table>,
8500 can_for_each<Func, Table, array>,
8501 can_for_each<Func, Table, std::string>,
8502 can_for_each<Func, Table, int64_t>,
8503 can_for_each<Func, Table, double>,
8504 can_for_each<Func, Table, bool>,
8505 can_for_each<Func, Table, date>,
8506 can_for_each<Func, Table, time>,
8507 can_for_each<Func, Table, date_time>>;
8509 template <
typename Func,
typename Table,
typename T>
8510 using for_each_is_nothrow_one = std::disjunction<
8511 std::negation<can_for_each<Func, Table, T>>,
8512 can_for_each_nothrow<Func, Table, T>>;
8514 template <
typename Func,
typename Table>
8515 using for_each_is_nothrow = std::conjunction<
8516 for_each_is_nothrow_one<Func, Table, table>,
8517 for_each_is_nothrow_one<Func, Table, array>,
8518 for_each_is_nothrow_one<Func, Table, std::string>,
8519 for_each_is_nothrow_one<Func, Table, int64_t>,
8520 for_each_is_nothrow_one<Func, Table, double>,
8521 for_each_is_nothrow_one<Func, Table, bool>,
8522 for_each_is_nothrow_one<Func, Table, date>,
8523 for_each_is_nothrow_one<Func, Table, time>,
8524 for_each_is_nothrow_one<Func, Table, date_time>>;
8526 template <
typename Func,
typename Table>
8527 static void do_for_each(Func &&visitor, Table &&tbl)
8528 noexcept(for_each_is_nothrow<Func &&, Table &&>::value)
8531 can_for_each_any<Func &&, Table &&>::value,
8532 "TOML table for_each visitors must be invocable for at least one of "
8536 using kvp_type = impl::copy_cv<map_pair, std::remove_reference_t<Table>>;
8538 for (kvp_type &kvp : tbl.map_)
8540 using node_ref = impl::copy_cvref<toml::node, Table &&>;
8541 static_assert(std::is_reference_v<node_ref>);
8543#if TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN
8545# ifndef TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_ACKNOWLEDGED
8547 impl::always_false<Func, Table, kvp_type, node_ref>,
8548 TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_MESSAGE);
8551 static_cast<node_ref
>(*kvp.second)
8553 [&]([[maybe_unused]]
auto &&v)
8555 for_each_is_nothrow_one<Func &&, Table &&,
decltype(v)>
::value)
8557 using value_ref = for_each_value_ref<
decltype(v), Table &&>;
8558 static_assert(std::is_reference_v<value_ref>);
8562 is_invocable_v<Func &&, const key &, value_ref>)
8564 static_cast<Func &&
>(visitor)(
8565 static_cast<const key &
>(kvp.first),
8566 static_cast<value_ref
>(v));
8570 else if constexpr (std::is_invocable_v<Func &&, value_ref>)
8572 static_cast<Func &&
>(visitor)(
static_cast<value_ref
>(v));
8577 const auto keep_going =
8578 static_cast<node_ref
>(*kvp.second)
8580 [&]([[maybe_unused]]
auto &&v)
8582 for_each_is_nothrow_one<Func &&, Table &&,
decltype(v)>
::value)
8584 using value_ref = for_each_value_ref<
decltype(v), Table &&>;
8585 static_assert(std::is_reference_v<value_ref>);
8589 is_invocable_v<Func &&, const key &, value_ref>)
8591 using return_type =
decltype(
static_cast<Func &&
>(visitor)(
8592 static_cast<const key &
>(kvp.first),
8593 static_cast<value_ref
>(v)));
8595 if constexpr (impl::is_constructible_or_convertible<
8599 return static_cast<bool>(
static_cast<Func &&
>(visitor)(
8600 static_cast<const key &
>(kvp.first),
8601 static_cast<value_ref
>(v)));
8605 static_cast<Func &&
>(visitor)(
8606 static_cast<const key &
>(kvp.first),
8607 static_cast<value_ref
>(v));
8613 else if constexpr (std::is_invocable_v<Func &&, value_ref>)
8615 using return_type =
decltype(
static_cast<Func &&
>(visitor)(
8616 static_cast<value_ref
>(v)));
8618 if constexpr (impl::is_constructible_or_convertible<
8622 return static_cast<bool>(
8623 static_cast<Func &&
>(visitor)(
static_cast<value_ref
>(v)));
8627 static_cast<Func &&
>(visitor)(
static_cast<value_ref
>(v));
8644 template <
typename Func>
8646 noexcept(for_each_is_nothrow<Func &&, table &>::value)
8648 do_for_each(
static_cast<Func &&
>(visitor), *
this);
8652 template <
typename Func>
8654 noexcept(for_each_is_nothrow<Func &&, table &&>::value)
8656 do_for_each(
static_cast<Func &&
>(visitor),
static_cast<table &&
>(*
this));
8657 return static_cast<table &&
>(*this);
8660 template <
typename Func>
8662 noexcept(for_each_is_nothrow<Func &&, const table &>::value)
8664 do_for_each(
static_cast<Func &&
>(visitor), *
this);
8668 template <
typename Func>
8670 noexcept(for_each_is_nothrow<Func &&, const table &&>::value)
8673 static_cast<Func &&
>(visitor),
static_cast<const table &&
>(*
this));
8674 return static_cast<const table &&
>(*this);
8680 return map_.empty();
8692 map_iterator get_lower_bound(std::string_view)
noexcept;
8707#if TOML_ENABLE_WINDOWS_COMPAT
8710 iterator lower_bound(std::wstring_view
key)
8715 return lower_bound(impl::narrow(
key));
8719 const_iterator lower_bound(std::wstring_view
key)
const
8724 return lower_bound(impl::narrow(
key));
8740 return get(
key) !=
nullptr;
8743#if TOML_ENABLE_WINDOWS_COMPAT
8746 iterator
find(std::wstring_view
key)
8751 return find(impl::narrow(
key));
8755 const_iterator
find(std::wstring_view
key)
const
8757 return find(impl::narrow(
key));
8761 bool contains(std::wstring_view
key)
const
8763 return contains(impl::narrow(
key));
8770 map_iterator erase(const_map_iterator)
noexcept;
8773 map_iterator erase(const_map_iterator, const_map_iterator)
noexcept;
8789 erase(const_map_iterator{
begin}, const_map_iterator{
end})};
8795#if TOML_ENABLE_WINDOWS_COMPAT
8797 size_t erase(std::wstring_view
key)
8802 return erase(impl::narrow(
key));
8808 table &
prune(
bool recursive =
true) &
noexcept;
8810 table &&
prune(
bool recursive =
true) &&
noexcept
8812 return static_cast<toml::table &&
>(this->
prune(recursive));
8825 typename ValueType =
void,
8827 typename... ValueArgs)
8833 "Emplacement using wide-character keys is only supported on Windows "
8835 "TOML_ENABLE_WINDOWS_COMPAT enabled.");
8839 std::is_void_v<raw_value_type>,
8840 impl::emplaced_type_of<ValueArgs &&...>,
8843 if constexpr (impl::is_wide_string<KeyType>)
8845#if TOML_ENABLE_WINDOWS_COMPAT
8846 return emplace_hint<value_type>(
8848 impl::narrow(
static_cast<KeyType &&
>(
key)),
8849 static_cast<ValueArgs &&
>(
args)...);
8852 impl::always_false<KeyType>,
"Evaluated unreachable branch!");
8857 static constexpr auto moving_node_ptr =
8858 std::is_same_v<value_type, impl::node_ptr>
8859 &&
sizeof...(ValueArgs) == 1u
8860 && impl::first_is_same<impl::node_ptr &&, ValueArgs &&...>;
8862 impl::remove_cvref<impl::unwrap_node<value_type>>;
8866 || impl::is_native<unwrapped_type>
8867 || impl::is_one_of<unwrapped_type, table, array>,
8868 "ValueType argument of table::emplace_hint() must be one "
8871 map_iterator
ipos = insert_with_hint(
8872 hint, toml::key{
static_cast<KeyType &&
>(
key)},
nullptr);
8878 if constexpr (moving_node_ptr)
8879 ipos->second = std::move(
static_cast<ValueArgs &&
>(
args)...);
8882#if TOML_COMPILER_HAS_EXCEPTIONS
8886 ipos->second.reset(
new impl::wrap_node<unwrapped_type>{
8887 static_cast<ValueArgs &&
>(
args)...});
8888#if TOML_COMPILER_HAS_EXCEPTIONS
8892 erase(const_map_iterator{
ipos});
8908 std::pair<iterator, bool> insert(
8915 "Insertion using wide-character keys is only supported on Windows with "
8916 "TOML_ENABLE_WINDOWS_COMPAT enabled.");
8921 return {
end(),
false};
8924 if constexpr (impl::is_wide_string<KeyType>)
8926#if TOML_ENABLE_WINDOWS_COMPAT
8928 impl::narrow(
static_cast<KeyType &&
>(
key)),
8929 static_cast<ValueType &&
>(val),
8933 impl::always_false<KeyType>,
"Evaluated unreachable branch!");
8938 const auto key_view = std::string_view{
key};
8939 map_iterator
ipos = get_lower_bound(key_view);
8940 if (
ipos == map_.end() ||
ipos->first != key_view)
8942 ipos = insert_with_hint(
8944 toml::key{
static_cast<KeyType &&
>(
key)},
8945 impl::make_node(
static_cast<ValueType &&
>(val),
flags));
8962 for (
auto it =
begin; it !=
end; it++)
8964 if constexpr (std::is_rvalue_reference_v<
decltype(*it)>)
8965 insert(std::move((*it).first), std::move((*it).second),
flags);
8967 insert((*it).first, (*it).second,
flags);
8982 "Insertion using wide-character keys is only supported on Windows with "
8983 "TOML_ENABLE_WINDOWS_COMPAT enabled.");
8988 return {
end(),
false};
8991 if constexpr (impl::is_wide_string<KeyType>)
8993#if TOML_ENABLE_WINDOWS_COMPAT
8995 impl::narrow(
static_cast<KeyType &&
>(
key)),
8996 static_cast<ValueType &&
>(val),
9000 impl::always_false<KeyType>,
"Evaluated unreachable branch!");
9005 const auto key_view = std::string_view{
key};
9006 map_iterator
ipos = get_lower_bound(key_view);
9007 if (
ipos == map_.end() ||
ipos->first != key_view)
9009 ipos = insert_with_hint(
9011 toml::key{
static_cast<KeyType &&
>(
key)},
9012 impl::make_node(
static_cast<ValueType &&
>(val),
flags));
9018 impl::make_node(
static_cast<ValueType &&
>(val),
flags);
9026 typename ValueType =
void,
9028 typename... ValueArgs)
9029 std::pair<iterator, bool> emplace(KeyType &&
key, ValueArgs &&...
args)
9033 "Emplacement using wide-character keys is only supported on Windows "
9035 "TOML_ENABLE_WINDOWS_COMPAT enabled.");
9039 std::is_void_v<raw_value_type>,
9040 impl::emplaced_type_of<ValueArgs &&...>,
9043 if constexpr (impl::is_wide_string<KeyType>)
9045#if TOML_ENABLE_WINDOWS_COMPAT
9046 return emplace<value_type>(
9047 impl::narrow(
static_cast<KeyType &&
>(
key)),
9048 static_cast<ValueArgs &&
>(
args)...);
9051 impl::always_false<KeyType>,
"Evaluated unreachable branch!");
9057 impl::remove_cvref<impl::unwrap_node<value_type>>;
9059 (impl::is_native<unwrapped_type> ||
9060 impl::is_one_of<unwrapped_type, table, array>),
9061 "ValueType argument of table::emplace() must be one "
9064 const auto key_view = std::string_view{
key};
9065 auto ipos = get_lower_bound(key_view);
9066 if (
ipos == map_.end() ||
ipos->first != key_view)
9068 ipos = insert_with_hint(
9070 toml::key{
static_cast<KeyType &&
>(
key)},
9071 impl::node_ptr{
new impl::wrap_node<unwrapped_type>{
9072 static_cast<ValueArgs &&
>(
args)...}});
9079 using node::operator[];
9093#if TOML_ENABLE_WINDOWS_COMPAT
9116 friend bool operator==(
const table &lhs,
const table &rhs)
noexcept
9118 return equal(lhs, rhs);
9122 friend bool operator!=(
const table &lhs,
const table &rhs)
noexcept
9124 return !equal(lhs, rhs);
9127#if TOML_ENABLE_FORMATTERS
9129 friend std::ostream &
operator<<(std::ostream &lhs,
const table &rhs)
9131 impl::print_to_stream(lhs, rhs);
9141# pragma pop_macro("min")
9142# pragma pop_macro("max")
9144# pragma inline_recursion(off)
9154# pragma inline_recursion(on)
9156# pragma push_macro("min")
9157# pragma push_macro("max")
9162#if TOML_GCC && TOML_GCC < 9
9163# pragma GCC push_options
9164# pragma GCC optimize("O1")
9172 constexpr bool is_ascii_horizontal_whitespace(
char32_t c)
noexcept
9174 return c ==
U'\t' || c ==
U' ';
9178 constexpr bool is_non_ascii_horizontal_whitespace(
char32_t c)
noexcept
9182 if (c < U
'\xA0' || c > U
'\uFEFF')
9185 const auto child_index_0 =
9186 (
static_cast<uint_least64_t
>(c) - 0xA0ull) / 0x3FAull;
9187 if ((1ull << child_index_0) & 0x7FFFFFFFFFFFF75Eull)
9189 if (c == U
'\xA0' || c == U
'\u3000' || c == U
'\uFEFF')
9191 switch (child_index_0)
9194 return c ==
U'\u1680' || c ==
U'\u180E';
9196 return (U
'\u2000' <= c && c <= U
'\u200B') ||
9197 (
U'\u205F' <= c && c <=
U'\u2060') || c == U
'\u202F';
9206 constexpr bool is_ascii_vertical_whitespace(
char32_t c)
noexcept
9208 return c >=
U'\n' && c <=
U'\r';
9212 constexpr bool is_non_ascii_vertical_whitespace(
char32_t c)
noexcept
9214 return (U
'\u2028' <= c && c <= U
'\u2029') || c ==
U'\x85';
9218 constexpr bool is_ascii_bare_key_character(
char32_t c)
noexcept
9220#if TOML_LANG_UNRELEASED
9226 if (c < U
'-' || c > U
'z')
9229 return (((
static_cast<uint_least64_t
>(c) - 0x2Dull) / 0x40ull) != 0ull) ||
9230 ((1ull << (
static_cast<uint_least64_t
>(c) - 0x2Dull)) &
9231 0xFFF43FFFFFF01FF9ull);
9234#if TOML_LANG_UNRELEASED
9237 constexpr bool is_non_ascii_bare_key_character(
char32_t c)
noexcept
9241 if (c < U
'\xB2' || c > U
'\U000EFFFF')
9244 const auto child_index_0 =
9245 (
static_cast<uint_least64_t
>(c) - 0xB2ull) / 0x3BFEull;
9246 if ((1ull << child_index_0) & 0xFFFFFFFFFFFFFFE6ull)
9248 switch (child_index_0)
9256 constexpr uint_least64_t bitmask_table_1[] = {
9257 0xFFFFFFDFFFFFDC83u, 0xFFFFFFFFFFFFFFDFu, 0xFFFFFFFFFFFFFFFFu,
9258 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9259 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9260 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFEFFFu,
9261 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9262 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9263 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9264 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9265 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9266 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9267 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9268 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9269 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9270 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9271 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9272 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9273 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9274 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9275 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9276 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9277 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9278 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9279 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9280 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9281 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9282 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9283 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9284 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9285 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9286 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9287 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9288 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9289 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9290 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9291 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9292 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9293 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9294 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9295 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9296 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9297 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9298 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0x000000000C003FFFu,
9299 0xC000000000006000u, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9300 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0x000000003FFFFFFFu,
9301 0x0000000000000000u, 0x0000000000000000u, 0x0000000000000000u,
9302 0x0000000000000000u, 0x0000000000000000u, 0x0000000000000000u,
9303 0x0000000000000000u, 0x0000000000000000u, 0x0000000000000000u,
9304 0x0000000000000000u, 0xFFFFC00000000000u, 0xFFFFFFFFFFFFFFFFu,
9305 0xFFFFFFFFFFFFFFFFu, 0x0000000000003FFFu, 0x0000000000000000u,
9306 0x0000000000000000u, 0x0000000000000000u, 0x0000000000000000u,
9307 0x0000000000000000u, 0x0000000000000000u, 0x0000000000000000u,
9308 0x0000000000000000u, 0x0000000000000000u, 0x0000000000000000u,
9309 0x0000000000000000u, 0x0000000000000000u, 0x0000000000000000u,
9310 0x0000000000000000u, 0x0000000000000000u, 0x0000000000000000u,
9311 0x0000000000000000u, 0x0000000000000000u, 0x0000000000000000u,
9312 0x0000000000000000u, 0x0000000000000000u, 0x0000000000000000u,
9313 0x0000000000000000u, 0x0000000000000000u, 0x0000000000000000u,
9314 0x0000000000000000u, 0x0000000000000000u, 0xFFFFFFFFFFFFC000u,
9315 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9316 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9317 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9318 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9319 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0x3FFFFFFFFFFFFFFFu,
9320 0xFFFFFFFFFFFF8000u, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9321 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9322 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9323 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9324 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9325 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9326 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9327 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9328 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9329 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9330 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9331 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9332 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9333 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9334 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9335 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu,
9336 0xFFFFFFFFFFFFFFFFu, 0xFFFFFFFFFFFFFFFFu, 0x3FFFFFFFFFFFFFFFu,
9338 return bitmask_table_1
9339 [(
static_cast<uint_least64_t
>(c) - 0xB2ull) / 0x40ull] &
9340 (0x1ull << ((
static_cast<uint_least64_t
>(c) - 0xB2ull) % 0x40ull));
9343 return c <=
U'\uD7FF';
9345 return (U
'\uF900' <= c && c <= U
'\uFDCF') ||
9346 (
U'\uFDF0' <= c && c <=
U'\uFFFD') || U
'\U00010000' <= c;
9358#if TOML_GCC && TOML_GCC < 9
9359# pragma GCC pop_options
9363# pragma pop_macro("min")
9364# pragma pop_macro("max")
9366# pragma inline_recursion(off)
9376# pragma inline_recursion(on)
9378# pragma push_macro("min")
9379# pragma push_macro("max")
9387 constexpr bool is_string_delimiter(
char32_t c)
noexcept
9389 return c ==
U'"' || c ==
U'\'';
9393 constexpr bool is_ascii_letter(
char32_t c)
noexcept
9395 return (c >= U
'a' && c <= U
'z') || (c >=
U'A' && c <=
U'Z');
9399 constexpr bool is_binary_digit(
char32_t c)
noexcept
9401 return c ==
U'0' || c ==
U'1';
9405 constexpr bool is_octal_digit(
char32_t c)
noexcept
9407 return (c >= U
'0' && c <= U
'7');
9411 constexpr bool is_decimal_digit(
char32_t c)
noexcept
9413 return (c >= U
'0' && c <= U
'9');
9417 constexpr bool is_hexadecimal_digit(
char32_t c)
noexcept
9419 return U'0' <= c && c <=
U'f' &&
9420 (1ull << (
static_cast<uint_least64_t
>(c) - 0x30u)) &
9421 0x7E0000007E03FFull;
9424 template <
typename T>
9427 if constexpr (std::is_same_v<remove_cvref<T>, uint_least32_t>)
9429 ? 10u + (c | 0x20u) - 0x61u
9433 return hex_to_dec(
static_cast<uint_least32_t
>(c));
9437 constexpr bool is_horizontal_whitespace(
char32_t c)
noexcept
9439 return is_ascii_horizontal_whitespace(c) ||
9440 is_non_ascii_horizontal_whitespace(c);
9444 constexpr bool is_vertical_whitespace(
char32_t c)
noexcept
9446 return is_ascii_vertical_whitespace(c) ||
9447 is_non_ascii_vertical_whitespace(c);
9451 constexpr bool is_whitespace(
char32_t c)
noexcept
9453 return is_horizontal_whitespace(c) || is_vertical_whitespace(c);
9457 constexpr bool is_bare_key_character(
char32_t c)
noexcept
9459 return is_ascii_bare_key_character(c)
9460#if TOML_LANG_UNRELEASED
9461 || is_non_ascii_bare_key_character(c)
9467 constexpr bool is_value_terminator(
char32_t c)
noexcept
9469 return is_whitespace(c) || c ==
U']' || c ==
U'}' || c ==
U',' || c ==
U'#';
9473 constexpr bool is_control_character(
char c)
noexcept
9475 return c <=
'\u001F' || c ==
'\u007F';
9479 constexpr bool is_control_character(
char32_t c)
noexcept
9481 return c <=
U'\u001F' || c ==
U'\u007F';
9485 constexpr bool is_nontab_control_character(
char32_t c)
noexcept
9487 return c <=
U'\u0008' || (c >=
U'\u000A' && c <=
U'\u001F') ||
9492 constexpr bool is_unicode_surrogate(
char32_t c)
noexcept
9494 return c >= 0xD800u && c <= 0xDFFF;
9502 uint_least32_t state{};
9503 char32_t codepoint{};
9505 static constexpr uint8_t state_table[]{
9506 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9507 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9508 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9509 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9510 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9511 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9512 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9513 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
9514 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7,
9515 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
9516 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 2, 2, 2, 2,
9517 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
9518 2, 2, 2, 2, 2, 2, 2, 2, 10, 3, 3, 3, 3, 3, 3, 3, 3, 3,
9519 3, 3, 3, 4, 3, 3, 11, 6, 6, 6, 5, 8, 8, 8, 8, 8, 8, 8,
9520 8, 8, 8, 8, 0, 12, 24, 36, 60, 96, 84, 12, 12, 12, 48, 72, 12, 12,
9521 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 0, 12, 12, 12, 12, 12, 0,
9522 12, 0, 12, 12, 12, 24, 12, 12, 12, 12, 12, 24, 12, 24, 12, 12, 12, 12,
9523 12, 12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 12,
9524 12, 24, 12, 12, 12, 12, 12, 12, 12, 12, 12, 36, 12, 36, 12, 12, 12, 36,
9525 12, 12, 12, 12, 12, 36, 12, 36, 12, 12, 12, 36, 12, 12, 12, 12, 12, 12,
9529 constexpr bool error() const noexcept
9531 return state == uint_least32_t{12u};
9535 constexpr bool has_code_point() const noexcept
9537 return state == uint_least32_t{};
9541 constexpr bool needs_more_input() const noexcept
9543 return !has_code_point() && !
error();
9546 constexpr void operator()(uint8_t
byte)
noexcept
9550 const auto type = state_table[byte];
9552 codepoint =
static_cast<char32_t>(
9553 has_code_point() ? (uint_least32_t{255u} >>
type) &
byte
9554 : (byte & uint_least32_t{63u}) |
9555 (static_cast<uint_least32_t>(codepoint) << 6));
9557 state = state_table[state + uint_least32_t{256u} +
type];
9561 constexpr void operator()(
char c)
noexcept
9563 operator()(
static_cast<uint8_t
>(c));
9567 constexpr void reset() noexcept
9580# pragma pop_macro("min")
9581# pragma pop_macro("max")
9583# pragma inline_recursion(off)
9590#if TOML_ENABLE_PARSER
9596# include <stdexcept>
9605# pragma inline_recursion(on)
9607# pragma push_macro("min")
9608# pragma push_macro("max")
9613# if TOML_DOXYGEN || !TOML_EXCEPTIONS
9614# define TOML_PARSE_ERROR_BASE
9616# define TOML_PARSE_ERROR_BASE : public std::runtime_error
9626# if !TOML_EXCEPTIONS
9627 std::string description_;
9637 : std::runtime_error{desc}, source_{std::move(src)}
9662 : description_{std::move(desc)}, source_{std::move(src)}
9687 return std::string_view{what()};
9689 return description_;
9701 impl::print_to_stream(lhs, rhs.description());
9702 impl::print_to_stream(lhs,
"\n\t(error occurred at "sv);
9703 impl::print_to_stream(lhs, rhs.source());
9704 impl::print_to_stream(lhs,
")"sv);
9713# undef TOML_PARSE_ERROR_BASE
9716# pragma pop_macro("min")
9717# pragma pop_macro("max")
9719# pragma inline_recursion(off)
9728#if TOML_DOXYGEN || (TOML_ENABLE_PARSER && !TOML_EXCEPTIONS)
9733# pragma inline_recursion(on)
9735# pragma push_macro("min")
9736# pragma push_macro("max")
9750 static constexpr size_t size =
9751 (
sizeof(toml::table) <
sizeof(parse_error) ?
sizeof(parse_error)
9752 :
sizeof(toml::table));
9753 static constexpr size_t align =
9754 (
alignof(toml::table) <
alignof(parse_error) ?
alignof(parse_error)
9755 :
alignof(toml::table));
9757 alignas(align)
unsigned char bytes[size];
9760 alignas(storage_t::align)
mutable storage_t storage_;
9763 template <
typename Type>
9766 return TOML_LAUNDER(
reinterpret_cast<Type *
>(s.bytes));
9769 void destroy()
noexcept
9772 get_as<parse_error>(storage_)->~parse_error();
9774 get_as<toml::table>(storage_)->~table();
9782 ::new (
static_cast<void *
>(storage_.bytes))
9783 parse_error{std::string{}, source_region{}};
9790 ::new (
static_cast<void *
>(storage_.bytes))
toml::
table{std::move(tbl)};
9797 ::new (
static_cast<void *
>(storage_.bytes)) parse_error{std::move(err)};
9805 ::new (
static_cast<void *
>(storage_.bytes))
9806 parse_error{std::move(res).error()};
9808 ::new (
static_cast<void *
>(storage_.bytes))
9809 toml::
table{std::move(res).table()};
9814 if (err_ != rhs.err_)
9819 ::new (
static_cast<void *
>(storage_.bytes))
9820 parse_error{std::move(rhs).error()};
9822 ::new (
static_cast<void *
>(storage_.bytes))
9823 toml::table{std::move(rhs).table()};
9828 error() = std::move(rhs).error();
9830 table() = std::move(rhs).table();
9853 explicit operator bool() const noexcept
9862 return *get_as<toml::table>(storage_);
9869 return static_cast<toml::table &&
>(*get_as<toml::table>(storage_));
9873 const toml::table &
table() const &noexcept
9876 return *get_as<const toml::table>(storage_);
9880 operator toml::table &()
noexcept
9886 operator toml::table &&()
noexcept
9888 return std::move(
table());
9892 operator const toml::table &()
const noexcept
9901 return *get_as<parse_error>(storage_);
9908 return static_cast<parse_error &&
>(*get_as<parse_error>(storage_));
9912 const parse_error &
error() const &noexcept
9915 return *get_as<const parse_error>(storage_);
9919 explicit operator parse_error &()
noexcept
9925 explicit operator parse_error &&()
noexcept
9927 return std::move(
error());
9931 explicit operator const parse_error &()
const noexcept
10000# if TOML_ENABLE_WINDOWS_COMPAT
10040# if TOML_ENABLE_WINDOWS_COMPAT
10056# if TOML_ENABLE_FORMATTERS
10058 friend std::ostream &
10061 return result.err_ ? (
os << result.
error()) : (
os << result.
table());
10072# pragma pop_macro("min")
10073# pragma pop_macro("max")
10075# pragma inline_recursion(off)
10084#if TOML_ENABLE_PARSER
10089# pragma inline_recursion(on)
10091# pragma push_macro("min")
10092# pragma push_macro("max")
10104 std::string_view doc, std::string_view source_path = {});
10109 std::string_view doc, std::string && source_path);
10120 std::u8string_view doc, std::string_view source_path = {});
10125 std::u8string_view doc, std::string && source_path);
10133# if TOML_ENABLE_WINDOWS_COMPAT
10138 std::string_view doc, std::wstring_view source_path);
10143 std::istream & doc, std::wstring_view source_path);
10151# if TOML_HAS_CHAR8 && TOML_ENABLE_WINDOWS_COMPAT
10156 std::u8string_view doc, std::wstring_view source_path);
10163 std::istream & doc, std::string_view source_path = {});
10168 std::istream & doc, std::string && source_path);
10180 return parse(std::string_view{str, len});
10187 parse_result
operator"" _toml(
const char8_t *str,
size_t len)
10189 return parse(std::u8string_view{str, len});
10200# pragma pop_macro("min")
10201# pragma pop_macro("max")
10203# pragma inline_recursion(off)
10212#if TOML_ENABLE_FORMATTERS
10217# pragma inline_recursion(on)
10219# pragma push_macro("min")
10220# pragma push_macro("max")
10227 struct formatter_constants
10232 std::string_view float_pos_inf;
10233 std::string_view float_neg_inf;
10234 std::string_view float_nan;
10236 std::string_view bool_true;
10237 std::string_view bool_false;
10249 const node *source_;
10250# if TOML_ENABLE_PARSER && !TOML_EXCEPTIONS
10253 const formatter_constants *constants_;
10255 size_t indent_columns_;
10257 std::ostream *stream_;
10259 bool naked_newline_;
10298 return indent_columns_;
10304 return !!(config_.flags & format_flags::indent_array_elements);
10310 return !!(config_.flags & format_flags::indent_sub_tables);
10316 return !!(config_.flags & format_flags::allow_literal_strings);
10322 return !!(config_.flags & format_flags::allow_multi_line_strings);
10328 return !!(config_.flags & format_flags::allow_real_tabs_in_strings);
10334 return !!(config_.flags & format_flags::allow_unicode_strings);
10340 return !!(config_.flags & format_flags::terse_key_value_pairs);
10344 void attach(std::ostream &stream)
noexcept;
10347 void detach() noexcept;
10350 void print_newline(
bool force =
false);
10353 void print_indent();
10356 void print_unformatted(
char);
10359 void print_unformatted(
std::string_view);
10363 std::string_view str,
10364 bool allow_multi_line =
true,
10365 bool allow_bare =
false,
10366 bool allow_literal_whitespace =
true);
10369 void print(const
value<
std::
string> &);
10372 void print(const
value<int64_t> &);
10375 void print(const
value<
double> &);
10378 void print(const
value<
bool> &);
10381 void print(const
value<date> &);
10390 void print_value(const node &, node_type);
10394 bool dump_failed_parse_result();
10401 const formatter_constants &,
10408# pragma pop_macro("min")
10409# pragma pop_macro("max")
10411# pragma inline_recursion(off)
10420#if TOML_ENABLE_FORMATTERS
10425# pragma inline_recursion(on)
10427# pragma push_macro("min")
10428# pragma push_macro("max")
10438 using base = impl::formatter;
10439 std::vector<const key *> key_path_;
10440 bool pending_table_separator_ =
false;
10443 void print_pending_table_separator();
10446 void print(
const key &);
10449 void print_inline(
const toml::table &);
10452 void print(
const toml::array &);
10455 void print(
const toml::table &);
10460 static constexpr impl::formatter_constants constants = {
10461 format_flags::none,
10462 format_flags::none,
10471 constants.mandatory_flags
10472 | format_flags::allow_literal_strings
10473 | format_flags::allow_multi_line_strings
10474 | format_flags::allow_unicode_strings
10475 | format_flags::allow_real_tabs_in_strings
10476 | format_flags::allow_binary_integers
10477 | format_flags::allow_octal_integers
10478 | format_flags::allow_hexadecimal_integers
10479 | format_flags::indentation;
10482 explicit toml_formatter(
10483 const toml::node &source,
10485 :
base{&source,
nullptr, constants, {flags,
" "sv}}
10489# if TOML_DOXYGEN || (TOML_ENABLE_PARSER && !TOML_EXCEPTIONS)
10492 explicit toml_formatter(
10493 const toml::parse_result &result,
10495 :
base{
nullptr, &result, constants, {
10504 friend std::ostream &
operator<<(std::ostream &lhs, toml_formatter &rhs)
10507 rhs.key_path_.clear();
10513 friend std::ostream &
operator<<(std::ostream &lhs, toml_formatter &&rhs)
10522# pragma pop_macro("min")
10523# pragma pop_macro("max")
10525# pragma inline_recursion(off)
10534#if TOML_ENABLE_FORMATTERS
10539# pragma inline_recursion(on)
10541# pragma push_macro("min")
10542# pragma push_macro("max")
10552 using base = impl::formatter;
10555 void print(
const toml::table &);
10558 void print(
const toml::array &);
10563 static constexpr impl::formatter_constants constants = {
10564 format_flags::quote_dates_and_times,
10565 format_flags::allow_literal_strings |
10566 format_flags::allow_multi_line_strings,
10575 constants.mandatory_flags
10576 | format_flags::quote_infinities_and_nans
10577 | format_flags::allow_unicode_strings
10578 | format_flags::indentation;
10581 explicit json_formatter(
10582 const toml::node &source,
10584 :
base{&source,
nullptr, constants, {flags,
" "sv}}
10588# if TOML_DOXYGEN || (TOML_ENABLE_PARSER && !TOML_EXCEPTIONS)
10591 explicit json_formatter(
10592 const toml::parse_result &result,
10594 :
base{
nullptr, &result, constants, {
10603 friend std::ostream &
operator<<(std::ostream &lhs, json_formatter &rhs)
10611 friend std::ostream &
operator<<(std::ostream &lhs, json_formatter &&rhs)
10620# pragma pop_macro("min")
10621# pragma pop_macro("max")
10623# pragma inline_recursion(off)
10632#if TOML_ENABLE_FORMATTERS
10637# pragma inline_recursion(on)
10639# pragma push_macro("min")
10640# pragma push_macro("max")
10650 using base = impl::formatter;
10653 void print_yaml_string(
const value<std::string> &);
10656 void print(
const toml::table &,
bool =
false);
10659 void print(
const toml::array &,
bool =
false);
10664 static constexpr impl::formatter_constants constants = {
10666 format_flags::quote_dates_and_times |
10667 format_flags::indentation,
10668 format_flags::allow_multi_line_strings,
10677 constants.mandatory_flags
10678 | format_flags::allow_literal_strings
10679 | format_flags::allow_unicode_strings
10680 | format_flags::allow_octal_integers
10681 | format_flags::allow_hexadecimal_integers;
10684 explicit yaml_formatter(
10685 const toml::node &source,
10687 :
base{&source,
nullptr, constants, {flags,
" "sv}}
10691# if TOML_DOXYGEN || (TOML_ENABLE_PARSER && !TOML_EXCEPTIONS)
10694 explicit yaml_formatter(
10695 const toml::parse_result &result,
10697 :
base{
nullptr, &result, constants, {
10707 operator<<(std::ostream &lhs, yaml_formatter &rhs)
10716 operator<<(std::ostream &lhs, yaml_formatter &&rhs)
10725# pragma pop_macro("min")
10726# pragma pop_macro("max")
10728# pragma inline_recursion(off)
10735#if TOML_IMPLEMENTATION
10742# if TOML_INCLUDE_WINDOWS_H
10743# include <Windows.h>
10746extern "C" __declspec(dllimport)
int __stdcall WideCharToMultiByte(
10747 unsigned int CodePage,
10748 unsigned long dwFlags,
10749 const wchar_t *lpWideCharStr,
10751 char *lpMultiByteStr,
10753 const char *lpDefaultChar,
10754 int *lpUsedDefaultChar);
10756extern "C" __declspec(dllimport)
int __stdcall MultiByteToWideChar(
10757 unsigned int CodePage,
10758 unsigned long dwFlags,
10759 const char *lpMultiByteStr,
10761 wchar_t *lpWideCharStr,
10770# pragma inline_recursion(on)
10772# pragma push_macro("min")
10773# pragma push_macro("max")
10781 std::string narrow(std::wstring_view str)
10787 const auto len = ::WideCharToMultiByte(
10791 static_cast<int>(str.length()),
10798 s.resize(
static_cast<size_t>(len));
10799 ::WideCharToMultiByte(
10803 static_cast<int>(str.length()),
10813 std::wstring widen(std::string_view str)
10819 const auto len = ::MultiByteToWideChar(
10820 65001, 0, str.data(),
static_cast<int>(str.length()),
nullptr, 0);
10823 s.resize(
static_cast<size_t>(len));
10824 ::MultiByteToWideChar(
10825 65001, 0, str.data(),
static_cast<int>(str.length()), s.data(), len);
10833 std::wstring widen(std::u8string_view str)
10838 return widen(std::string_view{
10839 reinterpret_cast<const char *
>(str.data()), str.length()});
10847# pragma pop_macro("min")
10848# pragma pop_macro("max")
10850# pragma inline_recursion(off)
10861# if TOML_INT_CHARCONV || TOML_FLOAT_CHARCONV
10862# include <charconv>
10864# if !TOML_INT_CHARCONV || !TOML_FLOAT_CHARCONV
10867# if !TOML_INT_CHARCONV
10874# pragma inline_recursion(on)
10876# pragma push_macro("min")
10877# pragma push_macro("max")
10884 template <
typename T>
10885 inline constexpr size_t charconv_buffer_length = 0;
10923 template <
typename T>
10925 std::ostream & stream,
10928 size_t min_digits = 0)
10935 for (
size_t i = 0; i < min_digits; i++)
10941 static constexpr auto value_flags_mask = value_flags::format_as_binary |
10942 value_flags::format_as_octal |
10943 value_flags::format_as_hexadecimal;
10944 format &= value_flags_mask;
10947 if (format != value_flags::none && val >
T{})
10951 case value_flags::format_as_binary:
10954 case value_flags::format_as_octal:
10957 case value_flags::format_as_hexadecimal:
10965# if TOML_INT_CHARCONV
10968 const auto res = std::to_chars(buf, buf +
sizeof(buf), val,
base);
10969 const auto len =
static_cast<size_t>(res.ptr - buf);
10970 for (
size_t i = len; i < min_digits; i++)
10974 for (
size_t i = 0; i < len; i++)
10978 impl::print_to_stream(stream, buf, len);
10982 using unsigned_type = std::conditional_t<
10983 (
sizeof(
T) >
sizeof(unsigned)),
10984 std::make_unsigned_t<T>,
10986 using cast_type = std::conditional_t<
10987 std::is_signed_v<T>,
10988 std::make_signed_t<unsigned_type>,
10994 for (
size_t i = len; i < min_digits; i++)
10997 bool found_one =
false;
10998 const auto v =
static_cast<unsigned_type
>(val);
10999 unsigned_type mask = unsigned_type{1} << (len - 1u);
11000 for (
size_t i = 0; i < len; i++)
11007 else if (found_one)
11014 std::ostringstream ss;
11015 ss.imbue(std::locale::classic());
11016 ss << std::uppercase << std::setbase(
base);
11018 ss << std::setfill('0') << std::setw(static_cast<int>(min_digits));
11019 ss << static_cast<cast_type>(val);
11020 const auto str = std::move(ss).str();
11021 impl::print_to_stream(stream, str);
11027 template <
typename T>
11029 std::ostream & stream,
11032 [[maybe_unused]]
bool relaxed_precision)
11034 switch (impl::fpclassify(val))
11036 case impl::fp_class::neg_inf:
11037 impl::print_to_stream(stream,
"-inf"sv);
11040 case impl::fp_class::pos_inf:
11041 impl::print_to_stream(stream,
"inf"sv);
11044 case impl::fp_class::nan:
11045 impl::print_to_stream(stream,
"nan"sv);
11048 case impl::fp_class::ok:
11050 static constexpr auto needs_decimal_point = [](
auto &&s)
noexcept
11053 if (c ==
'.' || c ==
'E' || c ==
'e')
11058# if TOML_FLOAT_CHARCONV
11060 const auto hex = !!(format & value_flags::format_as_hexadecimal);
11061 char buf[charconv_buffer_length<T>];
11063 hex ? std::to_chars(buf, buf +
sizeof(buf), val, std::chars_format::hex)
11064 : std::to_chars(buf, buf +
sizeof(buf), val);
11065 auto str = std::string_view{buf,
static_cast<size_t>(res.ptr - buf)};
11067 char buf2[charconv_buffer_length<T>];
11068 if (!hex && relaxed_precision)
11070 res = std::to_chars(
11071 buf2, buf2 +
sizeof(buf2), val, std::chars_format::general, 6);
11073 std::string_view{buf2,
static_cast<size_t>(res.ptr - buf2)};
11074 if (str2.length() < str.length())
11078 impl::print_to_stream(stream, str);
11079 if (!hex && needs_decimal_point(str))
11080 toml::impl::print_to_stream(stream,
".0"sv);
11084 std::ostringstream ss;
11085 ss.imbue(std::locale::classic());
11086 if (!relaxed_precision)
11087 ss.precision(std::numeric_limits<T>::max_digits10);
11088 if (!!(format & value_flags::format_as_hexadecimal))
11089 ss << std::hexfloat;
11091 const auto str = std::move(ss).str();
11092 impl::print_to_stream(stream, str);
11094 !(format & value_flags::format_as_hexadecimal) &&
11095 needs_decimal_point(str))
11096 impl::print_to_stream(stream,
".0"sv);
11114 std::ostream & stream,
const char *val,
size_t len)
11116 stream.write(val,
static_cast<std::streamsize
>(len));
11121 std::ostream & stream, std::string_view val)
11123 stream.write(val.data(),
static_cast<std::streamsize
>(val.length()));
11128 std::ostream & stream,
const std::string &val)
11130 stream.write(val.data(),
static_cast<std::streamsize
>(val.length()));
11141 std::ostream & stream,
11146 TOML_ANON_NAMESPACE::print_integer_to_stream(
11147 stream, val, format, min_digits);
11152 std::ostream & stream,
11157 TOML_ANON_NAMESPACE::print_integer_to_stream(
11158 stream, val, format, min_digits);
11163 std::ostream & stream,
11168 TOML_ANON_NAMESPACE::print_integer_to_stream(
11169 stream, val, format, min_digits);
11174 std::ostream & stream,
11179 TOML_ANON_NAMESPACE::print_integer_to_stream(
11180 stream, val, format, min_digits);
11185 std::ostream & stream,
11186 signed long long val,
11190 TOML_ANON_NAMESPACE::print_integer_to_stream(
11191 stream, val, format, min_digits);
11196 std::ostream & stream,
11201 TOML_ANON_NAMESPACE::print_integer_to_stream(
11202 stream, val, format, min_digits);
11207 std::ostream & stream,
11208 unsigned short val,
11212 TOML_ANON_NAMESPACE::print_integer_to_stream(
11213 stream, val, format, min_digits);
11218 std::ostream & stream,
11223 TOML_ANON_NAMESPACE::print_integer_to_stream(
11224 stream, val, format, min_digits);
11229 std::ostream & stream,
11234 TOML_ANON_NAMESPACE::print_integer_to_stream(
11235 stream, val, format, min_digits);
11240 std::ostream & stream,
11241 unsigned long long val,
11245 TOML_ANON_NAMESPACE::print_integer_to_stream(
11246 stream, val, format, min_digits);
11251 std::ostream & stream,
11254 bool relaxed_precision)
11256 TOML_ANON_NAMESPACE::print_floating_point_to_stream(
11257 stream, val, format, relaxed_precision);
11262 std::ostream & stream,
11265 bool relaxed_precision)
11267 TOML_ANON_NAMESPACE::print_floating_point_to_stream(
11268 stream, val, format, relaxed_precision);
11279 std::ostream & stream,
const toml::date &val)
11290 std::ostream & stream,
const toml::time &val)
11297 if (val.nanosecond && val.nanosecond <= 999999999u)
11300 auto ns = val.nanosecond;
11301 size_t digits = 9u;
11302 while (ns % 10u == 0u)
11313 std::ostream & stream,
const toml::time_offset &val)
11321 auto mins =
static_cast<int>(val.minutes);
11329 const auto hours = mins / 60;
11333 mins -= hours * 60;
11343 std::ostream & stream,
const toml::date_time &val)
11375# if TOML_ENABLE_FORMATTERS
11380 stream << toml_formatter{arr};
11386 stream << toml_formatter{tbl};
11393 stream << toml_formatter{val};
11400 stream << toml_formatter{val};
11407 stream << toml_formatter{val};
11414 stream << toml_formatter{val};
11421 stream << toml_formatter{val};
11428 stream << toml_formatter{val};
11435 stream << toml_formatter{val};
11443# pragma pop_macro("min")
11444# pragma pop_macro("max")
11446# pragma inline_recursion(off)
11456# pragma inline_recursion(on)
11458# pragma push_macro("min")
11459# pragma push_macro("max")
11467 node::node() noexcept = default;
11470 node::~node() noexcept = default;
11473 node::node(node &&
other) noexcept
11474 : source_{std::exchange(
other.source_, {})}
11479 node::node(
const node & )
noexcept
11487 node &node::operator=(
const node & )
noexcept
11498 node &node::operator=(node &&rhs)
noexcept
11501 source_ = std::exchange(rhs.source_, {});
11508 return toml::at_path(*
this, path);
11514 return toml::at_path(*
this, path);
11520 return toml::at_path(*
this, p);
11526 return toml::at_path(*
this, p);
11529# if TOML_ENABLE_WINDOWS_COMPAT
11534 return toml::at_path(*
this, path);
11540 return toml::at_path(*
this, path);
11548 return toml::at_path(*
this, p);
11554 return toml::at_path(*
this, p);
11564 const node *lhs,
const node *rhs)
noexcept
11571 if ((!lhs != !rhs) || lhs->type() != rhs->type())
11575 [=](
auto &l)
noexcept
11577 using concrete_type = remove_cvref<
decltype(l)>;
11579 return l == *(rhs->as<concrete_type>());
11586# pragma pop_macro("min")
11587# pragma pop_macro("max")
11589# pragma inline_recursion(off)
11597# if TOML_INT_CHARCONV
11598# include <charconv>
11606# pragma inline_recursion(on)
11608# pragma push_macro("min")
11609# pragma push_macro("max")
11618 const std::string_view path,
11620 const parse_path_callback<std::string_view> on_key,
11621 const parse_path_callback<size_t> on_index)
11625 return on_key(data,
""sv);
11628 const auto end = path.length();
11629 bool prev_was_array_indexer =
false;
11630 bool prev_was_dot =
true;
11635 if (path[
pos] ==
'[')
11638 size_t index_start =
pos + 1u;
11644 const auto c = path[index_start];
11647 else if (c ==
' ' || c ==
'\t')
11656 size_t index_end = index_start + 1u;
11663 const auto c = path[index_end];
11664 if (c >=
'0' && c <=
'9')
11666 else if (c ==
']' || c ==
' ' || c ==
'\t' || c ==
'.' || c ==
'[')
11681 const auto c = path[
pos];
11689 else if (c ==
'\t' || c ==
' ')
11696 auto index_str = path.substr(index_start, index_end - index_start);
11700 if (index_str.length() == 1u)
11701 index = static_cast<
size_t>(index_str[0] -
'0');
11704# if TOML_INT_CHARCONV
11706 auto fc_result = std::from_chars(
11707 index_str.data(), index_str.data() + index_str.length(), index);
11708 if (fc_result.ec != std::errc{})
11713 std::stringstream ss;
11714 ss.imbue(std::locale::classic());
11716 index_str.data(),
static_cast<std::streamsize
>(index_str.length()));
11717 if (!(ss >> index))
11723 prev_was_dot =
false;
11724 prev_was_array_indexer =
true;
11726 if (!on_index(data, index))
11731 else if (path[
pos] ==
'.')
11742 if (prev_was_dot && !on_key(data,
""sv))
11746 prev_was_dot =
true;
11747 prev_was_array_indexer =
false;
11757 const auto subkey_start =
pos;
11758 const auto subkey_len =
11760 path.find_first_of(
".[]"sv, subkey_start + 1u), path.length()) -
11762 const auto subkey = path.substr(subkey_start, subkey_len);
11770 if (prev_was_array_indexer)
11772 auto non_ws = subkey.find_first_not_of(
" \t");
11773 if (non_ws == std::string_view::npos)
11776 prev_was_dot =
false;
11777 prev_was_array_indexer =
false;
11785 prev_was_dot =
false;
11786 prev_was_array_indexer =
false;
11788 if (!on_key(data, subkey))
11794 if (prev_was_dot && !on_key(data,
""sv))
11806 node & root, std::string_view path)
noexcept
11809 if (root.is_value())
11811 if (
auto tbl = root.as_table(); tbl && tbl->empty())
11813 if (
auto arr = root.as_array(); arr && arr->empty())
11816 node *current = &root;
11818 static constexpr auto on_key =
11819 [](
void *data, std::string_view
key)
noexcept ->
bool
11821 auto &curr = *
static_cast<node **
>(data);
11824 const auto current_table = curr->as<table>();
11825 if (!current_table)
11828 curr = current_table->get(
key);
11829 return curr !=
nullptr;
11832 static constexpr auto on_index =
11833 [](
void *data,
size_t index)
noexcept ->
bool
11835 auto &curr = *
static_cast<node **
>(data);
11838 const auto current_array = curr->as<
array>();
11839 if (!current_array)
11842 curr = current_array->get(index);
11843 return curr !=
nullptr;
11846 if (!impl::parse_path(path, ¤t, on_key, on_index))
11854 const node &root, std::string_view path)
noexcept
11857 at_path(
const_cast<node &
>(root), path).node()};
11860# if TOML_ENABLE_WINDOWS_COMPAT
11868 if (root.is_value())
11870 if (
auto tbl = root.as_table(); tbl && tbl->empty())
11872 if (
auto arr = root.as_array(); arr && arr->empty())
11875 return at_path(root, impl::narrow(path));
11880 const node &root, std::wstring_view path)
11883 at_path(
const_cast<node &
>(root), path).node()};
11891# pragma pop_macro("min")
11892# pragma pop_macro("max")
11894# pragma inline_recursion(off)
11902# if TOML_INT_CHARCONV
11903# include <charconv>
11910# pragma inline_recursion(on)
11912# pragma push_macro("min")
11913# pragma push_macro("max")
11922 : type_{path_component_type::
key}
11924 store_key(
"", value_storage_);
11929 : type_(path_component_type::array_index)
11931 store_index(index, value_storage_);
11936 : type_(path_component_type::
key)
11938 store_key(
key, value_storage_);
11941# if TOML_ENABLE_WINDOWS_COMPAT
11955 if (type_ == path_component_type::array_index)
11956 store_index(pc.
index(), value_storage_);
11958 store_key(pc.
key(), value_storage_);
11965 if (type_ == path_component_type::array_index)
11966 store_index(pc.index_ref(), value_storage_);
11968 store_key(std::move(pc.key_ref()), value_storage_);
11974 if (type_ != rhs.type_)
11979 if (type_ == path_component_type::array_index)
11980 store_index(rhs.
index(), value_storage_);
11982 store_key(rhs.
key(), value_storage_);
11986 if (type_ == path_component_type::array_index)
11987 index_ref() = rhs.
index();
11989 key_ref() = rhs.
key();
11997 if (type_ != rhs.type_)
12002 if (type_ == path_component_type::array_index)
12003 store_index(rhs.
index(), value_storage_);
12005 store_key(std::move(rhs.key_ref()), value_storage_);
12009 if (type_ == path_component_type::array_index)
12010 index_ref() = rhs.
index();
12012 key_ref() = std::move(rhs.key_ref());
12023 if (lhs.type_ != rhs.type_)
12026 if (lhs.type_ == path_component_type::array_index)
12027 return lhs.index() == rhs.
index();
12029 return lhs.key() == rhs.
key();
12038 type_ = path_component_type::array_index;
12039 store_index(new_index, value_storage_);
12047 if (type_ == path_component_type::key)
12048 key_ref() = new_key;
12051 type_ = path_component_type::key;
12052 store_key(new_key, value_storage_);
12058# if TOML_ENABLE_WINDOWS_COMPAT
12063 if (type_ == path_component_type::key)
12064 key_ref() = impl::narrow(new_key);
12067 type_ = path_component_type::key;
12068 store_key(impl::narrow(new_key), value_storage_);
12081 bool parse_path_into(
12082 std::string_view path_str, std::vector<path_component> & components)
12084 using components_type = std::remove_reference_t<
decltype(components)>;
12086 const auto original_size = components.size();
12088 static constexpr auto on_key = [](
void *data, std::string_view
key) ->
bool
12090 auto &comps = *
static_cast<components_type *
>(data);
12091 comps.emplace_back(
key);
12095 static constexpr auto on_index = [](
void *data,
size_t index) ->
bool
12097 auto &comps = *
static_cast<components_type *
>(data);
12098 comps.emplace_back(index);
12102 if (!impl::parse_path(path_str, &components, on_key, on_index))
12104 components.resize(original_size);
12116 void path::print_to(std::ostream &
os)
const
12119 for (
const auto &component : components_)
12121 if (component.type() == path_component_type::key)
12124 impl::print_to_stream(os,
'.');
12125 impl::print_to_stream(os, component.key());
12127 else if (component.type() == path_component_type::array_index)
12129 impl::print_to_stream(os,
'[');
12130 impl::print_to_stream(os, component.index());
12131 impl::print_to_stream(os,
']');
12141 return lhs.components_ == rhs.components_;
12147 TOML_ANON_NAMESPACE::parse_path_into(str, components_);
12150# if TOML_ENABLE_WINDOWS_COMPAT
12154 :
path(impl::narrow(str))
12163 components_.
clear();
12164 TOML_ANON_NAMESPACE::parse_path_into(rhs, components_);
12168# if TOML_ENABLE_WINDOWS_COMPAT
12173 return assign(impl::narrow(rhs));
12181 components_.insert(components_.cend(), rhs.
begin(), rhs.
end());
12188 components_.insert(
12190 std::make_move_iterator(rhs.components_.begin()),
12191 std::make_move_iterator(rhs.components_.end()));
12198 TOML_ANON_NAMESPACE::parse_path_into(str, components_);
12202# if TOML_ENABLE_WINDOWS_COMPAT
12207 return *
this += impl::narrow(str);
12215 components_.insert(
12216 components_.begin(),
12217 source.components_.begin(),
12218 source.components_.end());
12225 components_.insert(
12226 components_.begin(),
12227 std::make_move_iterator(source.components_.begin()),
12228 std::make_move_iterator(source.components_.end()));
12235 return prepend(path{source});
12238# if TOML_ENABLE_WINDOWS_COMPAT
12243 return prepend(impl::narrow(source));
12254 std::ostringstream ss;
12256 return std::move(ss).str();
12259# if TOML_ENABLE_WINDOWS_COMPAT
12262 std::wstring path::wide_str()
const
12264 return impl::widen(str());
12272 components_.clear();
12278 n = n > components_.
size() ? components_.size() : n;
12280 auto it_end = components_.end();
12281 components_.erase(it_end -
static_cast<int>(n), it_end);
12289 path truncated_path{};
12291 n = n > components_.
size() ? components_.size() : n;
12296 truncated_path.components_.insert(
12297 truncated_path.components_.begin(),
12298 components_.begin(),
12299 components_.end() -
static_cast<int>(n));
12301 return truncated_path;
12315 n = n > components_.
size() ? components_.size() : n;
12319 leaf_path.components_.insert(
12320 leaf_path.components_.begin(),
12321 components_.end() -
static_cast<int>(n),
12322 components_.end());
12330 std::vector<path_component>::const_iterator start,
12331 std::vector<path_component>::const_iterator end)
const
12337 subpath.components_.insert(subpath.components_.begin(), start, end);
12345 begin() +
static_cast<int>(start),
12346 begin() +
static_cast<int>(start + length));
12355 node & root,
const toml::path &
path)
noexcept
12358 if (root.is_value())
12360 if (
auto tbl = root.as_table(); tbl && tbl->empty())
12362 if (
auto arr = root.as_array(); arr && arr->empty())
12365 node *current = &root;
12367 for (
const auto &component :
path)
12369 auto type = component.type();
12370 if (type == path_component_type::array_index)
12372 const auto current_array = current->as<
array>();
12373 if (!current_array)
12376 current = current_array->get(component.index());
12378 else if (type == path_component_type::key)
12380 const auto current_table = current->as<
table>();
12381 if (!current_table)
12384 current = current_table->get(component.key());
12401 const node &root,
const toml::path &
path)
noexcept
12410# pragma pop_macro("min")
12411# pragma pop_macro("max")
12413# pragma inline_recursion(off)
12423# pragma inline_recursion(on)
12425# pragma push_macro("min")
12426# pragma push_macro("max")
12436# if TOML_LIFETIME_HOOKS
12437 TOML_ARRAY_CREATED;
12444# if TOML_LIFETIME_HOOKS
12445 TOML_ARRAY_DESTROYED;
12450 array::array(
const impl::array_init_elem *b,
const impl::array_init_elem *e)
12452# if TOML_LIFETIME_HOOKS
12453 TOML_ARRAY_CREATED;
12464 for (
auto it = b; it !=
e; it++)
12472 elems_.reserve(cap);
12473 for (; b !=
e; b++)
12476 elems_.push_back(std::move(b->value));
12484 elems_.reserve(
other.elems_.size());
12485 for (
const auto &elem :
other)
12486 elems_.emplace_back(impl::make_node(elem));
12489 TOML_ARRAY_CREATED;
12495 : node(std::move(
other)), elems_(std::move(
other.elems_))
12497# if TOML_LIFETIME_HOOKS
12498 TOML_ARRAY_CREATED;
12507 node::operator=(rhs);
12509 elems_.reserve(rhs.elems_.size());
12510 for (
const auto &elem : rhs)
12511 elems_.emplace_back(impl::make_node(elem));
12521 node::operator=(std::move(rhs));
12522 elems_ = std::move(rhs.elems_);
12528 void array::preinsertion_resize(
size_t idx,
size_t count)
12532 const auto old_size = elems_.size();
12533 const auto new_size = old_size +
count;
12534 const auto inserting_at_end = idx == old_size;
12535 elems_.resize(new_size);
12536 if (!inserting_at_end)
12538 for (
size_t left = old_size, right = new_size - 1u; left-- > idx; right--)
12539 elems_[right] = std::move(elems_[left]);
12544 void array::insert_at_back(impl::node_ptr && elem)
12547 elems_.push_back(std::move(elem));
12551 array::vector_iterator array::insert_at(
12552 const_vector_iterator
pos, impl::node_ptr && elem)
12554 return elems_.insert(
pos, std::move(elem));
12561 if (elems_.empty())
12564 if (ntype == node_type::none)
12565 ntype = elems_[0]->type();
12567 for (
const auto &val : elems_)
12568 if (val->type() != ntype)
12578 if (elems_.empty())
12580 first_nonmatch = {};
12583 if (ntype == node_type::none)
12584 ntype = elems_[0]->type();
12585 for (
const auto &val : elems_)
12587 if (val->type() != ntype)
12589 first_nonmatch = val.get();
12601 node *fnm =
nullptr;
12603 first_nonmatch = fnm;
12610# if TOML_COMPILER_HAS_EXCEPTIONS
12612 return *elems_.at(index);
12616 auto n =
get(index);
12626 elems_.reserve(new_capacity);
12632 elems_.shrink_to_fit();
12638 if (new_size < elems_.size())
12639 elems_.resize(new_size);
12645 return iterator{elems_.erase(const_vector_iterator{
pos})};
12650 const_iterator first, const_iterator last)
noexcept
12653 elems_.erase(const_vector_iterator{first}, const_vector_iterator{last})};
12657 size_t array::total_leaf_count() const noexcept
12660 for (
size_t i = 0, e = elems_.size(); i < e; i++)
12662 auto arr = elems_[i]->as_array();
12663 leaves += arr ? arr->total_leaf_count() :
size_t{1};
12669 void array::flatten_child(
array && child,
size_t & dest_index)
noexcept
12671 for (
size_t i = 0, e = child.size(); i < e; i++)
12673 auto type = child.elems_[i]->type();
12674 if (type == node_type::array)
12676 array &arr = *
reinterpret_cast<array *
>(child.elems_[i].get());
12678 flatten_child(std::move(arr), dest_index);
12681 elems_[dest_index++] = std::move(child.elems_[i]);
12688 if (elems_.empty())
12691 bool requires_flattening =
false;
12692 size_t size_after_flattening = elems_.size();
12693 for (
size_t i = elems_.size(); i-- > 0u;)
12698 size_after_flattening--;
12699 const auto leaf_count = arr->total_leaf_count();
12700 if (leaf_count > 0u)
12702 requires_flattening =
true;
12703 size_after_flattening += leaf_count;
12706 elems_.erase(elems_.cbegin() +
static_cast<ptrdiff_t>(i));
12709 if (!requires_flattening)
12712 elems_.reserve(size_after_flattening);
12715 while (i < elems_.size())
12724 impl::node_ptr arr_storage = std::move(elems_[i]);
12725 const auto leaf_count = arr->total_leaf_count();
12726 if (leaf_count > 1u)
12727 preinsertion_resize(i + 1u, leaf_count - 1u);
12728 flatten_child(std::move(*arr), i);
12737 if (elems_.empty())
12740 for (
size_t i = elems_.size(); i-- > 0u;)
12742 if (
auto arr = elems_[i]->as_array())
12749 else if (
auto tbl = elems_[i]->as_table())
12754 elems_.erase(elems_.cbegin() +
static_cast<ptrdiff_t>(i));
12778 if (lhs.elems_.size() != rhs.elems_.size())
12780 for (
size_t i = 0, e = lhs.elems_.size(); i < e; i++)
12782 const auto lhs_type = lhs.elems_[i]->type();
12783 const node &rhs_ = *rhs.elems_[i];
12784 const auto rhs_type = rhs_.type();
12785 if (lhs_type != rhs_type)
12788 const bool equal = lhs.elems_[i]->visit(
12789 [&](
const auto &lhs_)
noexcept
12792 *
reinterpret_cast<std::remove_reference_t<decltype(lhs_)
> *>(
12804# pragma pop_macro("min")
12805# pragma pop_macro("max")
12807# pragma inline_recursion(off)
12817# pragma inline_recursion(on)
12819# pragma push_macro("min")
12820# pragma push_macro("max")
12830# if TOML_LIFETIME_HOOKS
12831 TOML_TABLE_CREATED;
12838# if TOML_LIFETIME_HOOKS
12839 TOML_TABLE_DESTROYED;
12844 table::table(
const impl::table_init_pair *b,
const impl::table_init_pair *e)
12846# if TOML_LIFETIME_HOOKS
12847 TOML_TABLE_CREATED;
12857 for (; b !=
e; b++)
12862 map_.insert_or_assign(std::move(b->key), std::move(b->value));
12870 for (
auto &&[k, v] :
other.map_)
12871 map_.emplace_hint(map_.end(), k, impl::make_node(*v));
12874 TOML_TABLE_CREATED;
12880 : node(std::move(
other)),
12881 map_{std::move(
other.map_)},
12882 inline_{
other.inline_}
12884# if TOML_LIFETIME_HOOKS
12885 TOML_TABLE_CREATED;
12894 node::operator=(rhs);
12896 for (
auto &&[k, v] : rhs.map_)
12897 map_.emplace_hint(map_.end(), k, impl::make_node(*v));
12898 inline_ = rhs.inline_;
12908 node::operator=(std::move(rhs));
12909 map_ = std::move(rhs.map_);
12910 inline_ = rhs.inline_;
12922 if (ntype == node_type::none)
12923 ntype = map_.cbegin()->second->type();
12925 for (
auto &&[k, v] : map_)
12928 if (v->type() != ntype)
12941 first_nonmatch = {};
12944 if (ntype == node_type::none)
12945 ntype = map_.cbegin()->second->type();
12946 for (
const auto &[k, v] : map_)
12949 if (v->type() != ntype)
12951 first_nonmatch = v.get();
12963 node *fnm =
nullptr;
12965 first_nonmatch = fnm;
12973 if (
auto it = map_.find(
key); it != map_.end())
12974 return it->second.get();
12983# if TOML_COMPILER_HAS_EXCEPTIONS
12987 auto err =
"key '"s;
12989 err.append(
"' not found in table"sv);
12990 throw std::out_of_range{err};
13004 table::map_iterator table::get_lower_bound(std::string_view
key)
noexcept
13006 return map_.lower_bound(
key);
13013 return iterator{map_.find(
key)};
13020 return const_iterator{map_.find(
key)};
13024 table::map_iterator table::erase(const_map_iterator
pos)
noexcept
13026 return map_.erase(
pos);
13030 table::map_iterator table::erase(
13031 const_map_iterator begin, const_map_iterator end)
noexcept
13033 return map_.erase(begin, end);
13037 size_t table::erase(std::string_view
key)
noexcept
13039 if (
auto it = map_.find(
key); it != map_.end())
13053 for (
auto it = map_.begin(); it != map_.end();)
13055 if (
auto arr = it->second->as_array())
13062 it = map_.erase(it);
13066 else if (
auto tbl = it->second->as_table())
13073 it = map_.erase(it);
13090 table::map_iterator table::insert_with_hint(
13091 const_iterator hint,
key && k, impl::node_ptr && v)
13093 return map_.emplace_hint(
13094 const_map_iterator{hint}, std::move(k), std::move(v));
13103 if (lhs.map_.size() != rhs.map_.size())
13106 for (
auto l = lhs.map_.begin(), r = rhs.map_.begin(), e = lhs.map_.end();
13110 if (l->first != r->first)
13113 const auto lhs_type = l->second->type();
13114 const node &rhs_ = *r->second;
13115 const auto rhs_type = rhs_.type();
13116 if (lhs_type != rhs_type)
13119 const bool equal = l->second->visit(
13120 [&](
const auto &lhs_)
noexcept
13123 *
reinterpret_cast<std::remove_reference_t<decltype(lhs_)
> *>(
13135# pragma pop_macro("min")
13136# pragma pop_macro("max")
13138# pragma inline_recursion(off)
13145# if TOML_ENABLE_SIMD
13147# if defined(__SSE2__) || \
13148 (defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_X64) || \
13149 (defined(_M_IX86_FP) && _M_IX86_FP >= 2)))
13150# define TOML_HAS_SSE2 1
13153# if defined(__SSE4_1__) || \
13154 (defined(_MSC_VER) && (defined(__AVX__) || defined(__AVX2__)))
13155# define TOML_HAS_SSE4_1 1
13160# ifndef TOML_HAS_SSE2
13161# define TOML_HAS_SSE2 0
13163# ifndef TOML_HAS_SSE4_1
13164# define TOML_HAS_SSE4_1 0
13168# if TOML_HAS_SSE4_1
13169# include <smmintrin.h>
13172# include <emmintrin.h>
13181# pragma inline_recursion(on)
13183# pragma push_macro("min")
13184# pragma push_macro("max")
13193 bool is_ascii(
const char *str,
size_t len)
noexcept
13195 const char *
const end = str + len;
13197# if TOML_HAS_SSE2 && (128 % CHAR_BIT) == 0
13199 constexpr size_t chars_per_vector = 128u /
CHAR_BIT;
13201 if (
const size_t simdable = len - (len % chars_per_vector))
13203 __m128i mask = _mm_setzero_si128();
13204 for (
const char *
const e = str + simdable; str < e;
13205 str += chars_per_vector)
13207 const __m128i current_bytes =
13208 _mm_loadu_si128(
reinterpret_cast<const __m128i *
>(str));
13209 mask = _mm_or_si128(mask, current_bytes);
13211 const __m128i has_error = _mm_cmpgt_epi8(_mm_setzero_si128(), mask);
13213# if TOML_HAS_SSE4_1
13214 if (!_mm_testz_si128(has_error, has_error))
13218 _mm_movemask_epi8(_mm_cmpeq_epi8(has_error, _mm_setzero_si128())) !=
13226 for (; str < end; str++)
13227 if (
static_cast<unsigned char>(*str) > 127u)
13236# pragma pop_macro("min")
13237# pragma pop_macro("max")
13239# pragma inline_recursion(off)
13246# if TOML_ENABLE_PARSER
13251# if TOML_INT_CHARCONV || TOML_FLOAT_CHARCONV
13252# include <charconv>
13254# if !TOML_INT_CHARCONV || !TOML_FLOAT_CHARCONV
13257# if !TOML_INT_CHARCONV
13264# pragma inline_recursion(on)
13266# pragma push_macro("min")
13267# pragma push_macro("max")
13274 template <
typename T>
13275 class utf8_byte_stream;
13280 template <
typename Char>
13283 static_assert(
sizeof(Char) == 1);
13286 std::basic_string_view<Char> source_;
13287 size_t position_ = {};
13292 std::basic_string_view<Char> sv)
noexcept
13297 source_.length() >= 3u &&
13309 constexpr bool eof() const noexcept
13311 return position_ >= source_.length();
13315 explicit constexpr operator bool() const noexcept
13328 size_t operator()(
void *dest,
size_t num) noexcept
13332 num = impl::min(position_ + num, source_.length()) - position_;
13333 std::memcpy(dest, source_.data() + position_, num);
13343 std::istream *source_;
13354 const auto initial_pos = source_->tellg();
13356 source_->read(bom, 3);
13358 source_->bad() || (source_->gcount() == 3 &&
13363 source_->seekg(initial_pos, std::istream::beg);
13369 return !!(source_->rdstate() & std::istream::badbit);
13375 return !!(source_->rdstate() & std::istream::eofbit);
13379 explicit operator bool() const noexcept
13382 source_->rdstate() & (std::istream::badbit | std::istream::eofbit));
13388 return eof() || source_->peek() == std::istream::traits_type::eof();
13399 static_cast<char *
>(dest),
static_cast<std::streamsize
>(num));
13400 return static_cast<size_t>(source_->gcount());
13412 constexpr operator const char32_t &()
const noexcept
13423 static_assert(std::is_trivial_v<utf8_codepoint>);
13424 static_assert(std::is_standard_layout_v<utf8_codepoint>);
13438# if !TOML_EXCEPTIONS
13441 virtual optional<parse_error> &&
error() noexcept = 0;
13448# if TOML_EXCEPTIONS
13449# define utf8_reader_error(...) throw parse_error(__VA_ARGS__)
13450# define utf8_reader_return_after_error(...) static_assert(true)
13451# define utf8_reader_error_check(...) static_assert(true)
13453# define utf8_reader_error(...) err_.emplace(__VA_ARGS__)
13454# define utf8_reader_return_after_error(...) return __VA_ARGS__
13455# define utf8_reader_error_check(...) \
13458 if TOML_UNLIKELY (err_) \
13459 return __VA_ARGS__; \
13464# if defined(__APPLE__) || defined(__MINGW32__) || defined(__MINGW64__)
13465# define TOML_OVERALIGNED
13467# define TOML_OVERALIGNED alignas(32)
13470 template <
typename T>
13474 static constexpr size_t block_capacity = 32;
13475 utf8_byte_stream<T> stream_;
13478 impl::utf8_decoder decoder_;
13479 struct currently_decoding_t
13483 } currently_decoding_;
13485 struct codepoints_t
13494# if !TOML_EXCEPTIONS
13495 optional<parse_error> err_;
13503 size_t raw_bytes_read;
13509 raw_bytes_read = stream_(raw_bytes, block_capacity);
13511# if TOML_EXCEPTIONS
13516 raw_bytes_read = stream_(raw_bytes, block_capacity);
13518 catch (
const std::exception &exc)
13520 throw parse_error{exc.what(), next_pos_, source_path_};
13525 "An unspecified error occurred", next_pos_, source_path_};
13538 if (decoder_.needs_more_input())
13540 "Encountered EOF during incomplete utf-8 code point sequence",
13547 "Reading from the underlying stream failed - zero bytes read",
13555 std::memset(&codepoints_, 0,
sizeof(codepoints_));
13558 const auto calc_positions = [&]()
noexcept
13560 for (
size_t i = 0; i < codepoints_.count; i++)
13562 auto &cp = codepoints_.buffer[i];
13563 cp.position = next_pos_;
13568 next_pos_.column = source_index{1};
13571 next_pos_.column++;
13576 const auto ascii_fast_path = !decoder_.needs_more_input() &&
13577 impl::is_ascii(raw_bytes, raw_bytes_read);
13580 if (ascii_fast_path)
13583 currently_decoding_.count = {};
13585 codepoints_.count = raw_bytes_read;
13586 for (
size_t i = 0; i < codepoints_.count; i++)
13588 auto &cp = codepoints_.buffer[i];
13589 cp.value =
static_cast<char32_t>(raw_bytes[i]);
13590 cp.bytes[0] = raw_bytes[i];
13601 return codepoints_.count
13602 ? codepoints_.buffer[codepoints_.count - 1u].position
13606 for (
size_t i = 0; i < raw_bytes_read; i++)
13608 decoder_(
static_cast<uint8_t
>(raw_bytes[i]));
13613 "Encountered invalid utf-8 sequence", error_pos(), source_path_);
13617 currently_decoding_.bytes[currently_decoding_.count++] = raw_bytes[i];
13619 if (decoder_.has_code_point())
13621 auto &cp = codepoints_.buffer[codepoints_.count++];
13623 cp.value = decoder_.codepoint;
13624 cp.count = currently_decoding_.count;
13626 cp.bytes, currently_decoding_.bytes, currently_decoding_.count);
13627 currently_decoding_.count = {};
13633 "Encountered overlong utf-8 sequence", error_pos(), source_path_);
13637 if TOML_UNLIKELY (decoder_.needs_more_input() && stream_.eof())
13641 "Encountered EOF during incomplete utf-8 code point sequence",
13656 "An I/O error occurred while reading from the underlying stream",
13666 template <
typename U,
typename String = std::
string_view>
13670 {})
noexcept(std::is_nothrow_constructible_v<utf8_byte_stream<T>, U &&>)
13671 : stream_{static_cast<U &&>(source)}
13673 currently_decoding_.count = {};
13675 codepoints_.current = {};
13676 codepoints_.count = {};
13678 if (!source_path.empty())
13679 source_path_ = std::make_shared<const std::string>(
13680 static_cast<String &&
>(source_path));
13686 return source_path_;
13695 if (codepoints_.current == codepoints_.count)
13706 return &codepoints_.buffer[codepoints_.current++];
13712 return stream_.peek_eof();
13715# if !TOML_EXCEPTIONS
13718 optional<parse_error> &&
error() noexcept final
13720 return std::move(err_);
13726 template <
typename Char>
13729 template <
typename Char>
13732 template <
typename Char>
13735 template <
typename Char>
13739# if TOML_EXCEPTIONS
13740# define utf8_buffered_reader_error_check(...) static_assert(true)
13742# define utf8_buffered_reader_error_check(...) \
13745 if TOML_UNLIKELY (reader_.error()) \
13746 return __VA_ARGS__; \
13757 static constexpr size_t history_buffer_size =
13765 const utf8_codepoint *head_ = {};
13766 size_t negative_offset_ = {};
13778 return reader_.source_path();
13786 if (negative_offset_)
13788 negative_offset_--;
13791 if (!negative_offset_)
13796 return history_.buffer +
13797 ((history_.first + history_.count - negative_offset_) %
13798 history_buffer_size);
13804 head_ = reader_.read_next();
13810 history_.buffer[history_.count++] = *head_;
13813 [(history_.first++ + history_buffer_size) % history_buffer_size] =
13816 head_ = reader_.read_next();
13831 negative_offset_ +=
count;
13833 return negative_offset_
13834 ? history_.buffer +
13835 ((history_.first + history_.count - negative_offset_) %
13836 history_buffer_size)
13843 return reader_.peek_eof();
13846# if !TOML_EXCEPTIONS
13851 return reader_.error();
13859# if TOML_EXCEPTIONS
13860# define TOML_RETURNS_BY_THROWING [[noreturn]]
13862# define TOML_RETURNS_BY_THROWING
13867 template <
typename...
T>
13869 char32_t codepoint,
T... vals)
noexcept
13871 static_assert((std::is_same_v<char32_t, T> && ...));
13872 return ((codepoint == vals) || ...);
13875 template <u
int64_t>
13876 struct parse_integer_traits;
13878 struct parse_integer_traits<2>
13889 struct parse_integer_traits<8>
13900 struct parse_integer_traits<10>
13909 struct parse_integer_traits<16>
13912 static constexpr auto is_digit = impl::is_hexadecimal_digit;
13922 std::string_view
to_sv(node_type val)
noexcept
13924 return impl::node_type_friendly_names[impl::unwrap_enum(val)];
13929 std::string_view
to_sv(
const std::string &str)
noexcept
13931 return std::string_view{str};
13938 using namespace std::string_view_literals;
13940 return val ?
"true"sv :
"false"sv;
13947 if (cp.value <= U
'\x1F')
13948 return impl::control_char_escapes[cp.value];
13949 else if (cp.value == U
'\x7F')
13950 return "\\u007F"sv;
13952 return std::string_view{cp.bytes, cp.count};
13969 template <
typename T>
13972 char *&write_pos,
char *const buf_end, const
T &arg) noexcept
13977 using arg_type = impl::remove_cvref<T>;
13980 if constexpr (std::is_same_v<arg_type, std::string_view>)
13982 const auto max_chars =
static_cast<size_t>(buf_end - write_pos);
13983 const auto len = max_chars < arg.length() ? max_chars : arg.length();
13984 std::memcpy(write_pos, arg.data(), len);
13989 else if constexpr (std::is_same_v<arg_type, double>)
13991# if TOML_FLOAT_CHARCONV
13992 const auto result = std::to_chars(write_pos, buf_end, arg);
13993 write_pos = result.ptr;
13995 std::ostringstream ss;
13996 ss.imbue(std::locale::classic());
13997 ss.precision(std::numeric_limits<arg_type>::max_digits10);
14004 else if constexpr (impl::is_one_of<arg_type, int64_t, uint64_t>)
14006# if TOML_INT_CHARCONV
14007 const auto result = std::to_chars(write_pos, buf_end, arg);
14008 write_pos = result.ptr;
14010 std::ostringstream ss;
14011 ss.imbue(std::locale::classic());
14013 std::conditional_t<std::is_signed_v<arg_type>, int64_t, uint64_t>;
14014 ss << static_cast<cast_type>(arg);
14020 else if constexpr (std::is_same_v<arg_type, escaped_codepoint>)
14022 if (arg.cp.value <= U
'\x7F')
14026 auto val =
static_cast<uint_least32_t
>(arg.cp.value);
14027 const auto digits = val > 0xFFFFu ? 8u : 4u;
14028 constexpr auto mask = uint_least32_t{0xFu};
14029 char buf[10] = {
'\\', digits > 4 ?
'U' :
'u'};
14030 for (
auto i = 2u + digits; i-- > 2u;)
14032 const auto hexdig = val & mask;
14033 buf[i] =
static_cast<char>(
14034 hexdig >= 0xAu ? (
'A' + (hexdig - 0xAu)) : (
'0' + hexdig));
14037 concatenate(write_pos, buf_end, std::string_view{buf, digits + 2u});
14042 else if constexpr (std::is_floating_point_v<arg_type>)
14043 concatenate(write_pos, buf_end,
static_cast<double>(arg));
14046 else if constexpr (
14047 std::is_arithmetic_v<arg_type> && std::is_integral_v<arg_type>)
14050 std::conditional_t<std::is_unsigned_v<arg_type>, uint64_t, int64_t>;
14051 concatenate(write_pos, buf_end,
static_cast<cast_type
>(arg));
14057 impl::always_false<T>,
14058 "concatenate() inputs are limited to std::string_views, integers, "
14059 "floats, and escaped_codepoint");
14079 template <
typename T>
14091# if TOML_EXCEPTIONS
14092 throw parse_error{
buf,
pos, source_path};
14094 return parse_error{
14111 std::string_view ¤t_scope,
14112 std::string_view new_scope) noexcept
14125# define push_parse_scope_2(scope, line) \
14126 parse_scope ps_##line(current_scope, scope)
14127# define push_parse_scope_1(scope, line) push_parse_scope_2(scope, line)
14128# define push_parse_scope(scope) push_parse_scope_1(scope, __LINE__)
14157 return std::string_view{
14164 return (*
this)[
segments.size() - 1u];
14236# define is_eof() !cp
14237# define assert_not_eof() TOML_ASSERT_ASSUME(cp != nullptr)
14238# define return_if_eof(...) \
14241 if TOML_UNLIKELY (is_eof()) \
14242 return __VA_ARGS__; \
14245# if TOML_EXCEPTIONS
14246# define is_error() false
14247# define return_after_error(...) TOML_UNREACHABLE
14248# define assert_not_error() static_assert(true)
14249# define return_if_error(...) static_assert(true)
14250# define return_if_error_or_eof(...) return_if_eof(__VA_ARGS__)
14252# define is_error() !!err
14253# define return_after_error(...) return __VA_ARGS__
14254# define assert_not_error() TOML_ASSERT(!is_error())
14255# define return_if_error(...) \
14258 if TOML_UNLIKELY (is_error()) \
14259 return __VA_ARGS__; \
14261# define return_if_error_or_eof(...) \
14264 if TOML_UNLIKELY (is_eof() || is_error()) \
14265 return __VA_ARGS__; \
14269# if defined(TOML_BREAK_AT_PARSE_ERRORS) && TOML_BREAK_AT_PARSE_ERRORS
14270# if defined(__has_builtin)
14271# if __has_builtin(__builtin_debugtrap)
14272# define parse_error_break() __builtin_debugtrap()
14273# elif __has_builtin(__debugbreak)
14274# define parse_error_break() __debugbreak()
14277# ifndef parse_error_break
14278# if TOML_MSVC || TOML_ICC
14279# define parse_error_break() __debugbreak()
14281# define parse_error_break() TOML_ASSERT(false)
14285# define parse_error_break() static_assert(true)
14288# define set_error_and_return(ret, ...) \
14292 set_error(__VA_ARGS__); \
14293 return_after_error(ret); \
14296# define set_error_and_return_default(...) \
14297 set_error_and_return({}, __VA_ARGS__)
14299# define set_error_and_return_if_eof(...) \
14302 if TOML_UNLIKELY (is_eof()) \
14303 set_error_and_return(__VA_ARGS__, "encountered end-of-file"sv); \
14306# define advance_and_return_if_error(...) \
14309 assert_not_eof(); \
14311 return_if_error(__VA_ARGS__); \
14314# define advance_and_return_if_error_or_eof(...) \
14317 assert_not_eof(); \
14319 return_if_error(__VA_ARGS__); \
14320 set_error_and_return_if_eof(__VA_ARGS__); \
14338 std::vector<table *> implicit_tables;
14339 std::vector<table *> dotted_key_tables;
14340 std::vector<table *> open_inline_tables;
14341 std::vector<array *> table_arrays;
14343 std::string string_buffer;
14344 std::string recording_buffer;
14345 bool recording =
false, recording_whitespace =
true;
14346 std::string_view current_scope;
14347 size_t nested_values = {};
14348# if !TOML_EXCEPTIONS
14349 mutable optional<parse_error> err;
14354 current_position(source_index fallback_offset = 0)
const noexcept
14357 return cp->position;
14360 static_cast<source_index
>(prev_pos.column + fallback_offset)};
14363 template <
typename...
T>
14367 static_assert(
sizeof...(T) > 0);
14371 (builder.
append(reason), ...);
14375# if TOML_EXCEPTIONS
14376 builder.
finish(
pos, reader.source_path());
14378 err.emplace(builder.
finish(
pos, reader.source_path()));
14382 template <
typename...
T>
14385 set_error_at(current_position(1), reason...);
14388 void go_back(
size_t count = 1)
noexcept
14393 cp = reader.step_back(
count);
14394 prev_pos = cp->position;
14402 prev_pos = cp->position;
14403 cp = reader.read_next();
14405# if !TOML_EXCEPTIONS
14406 if (reader.error())
14408 err = std::move(reader.error());
14413 if (recording && !
is_eof())
14415 if (recording_whitespace || !is_whitespace(*cp))
14416 recording_buffer.append(cp->bytes, cp->count);
14420 void start_recording(
bool include_current =
true)
noexcept
14425 recording_whitespace =
true;
14426 recording_buffer.clear();
14427 if (include_current && !
is_eof())
14428 recording_buffer.append(cp->bytes, cp->count);
14431 void stop_recording(
size_t pop_bytes = 0)
noexcept
14438 if (pop_bytes >= recording_buffer.length())
14439 recording_buffer.clear();
14440 else if (pop_bytes == 1u)
14441 recording_buffer.pop_back();
14443 recording_buffer.erase(
14444 recording_buffer.begin() +
14445 static_cast<ptrdiff_t>(recording_buffer.length() - pop_bytes),
14446 recording_buffer.end());
14450 bool consume_leading_whitespace()
14454 bool consumed =
false;
14455 while (!
is_eof() && is_horizontal_whitespace(*cp))
14467 bool consume_line_break()
14473 R
"(vertical tabs '\v' and form-feeds '\f' are not legal line breaks in TOML)"sv);
14484 "expected '\\n' after '\\r', saw '"sv,
14488 else if (*cp != U
'\n')
14495 bool consume_rest_of_line()
14501 if (is_ascii_vertical_whitespace(*cp))
14502 return consume_line_break();
14511 bool consume_comment()
14524 if (consume_line_break())
14528# if TOML_LANG_AT_LEAST(1, 0, 0)
14533 "control characters other than TAB (U+0009) are explicitly prohibited in comments"sv);
14538 "unicode surrogates (U+D800 to U+DFFF) are explicitly prohibited in comments"sv);
14548 bool consume_expected_sequence(std::u32string_view seq)
14563 template <
typename T>
14570 for (
size_t i = 0; i < len; i++)
14573 if (!is_decimal_digit(*cp))
14576 digits[i] =
static_cast<T>(*cp - U
'0');
14582 template <
typename T>
14584 consume_variable_length_digit_sequence(
T *buffer,
size_t max_len)
14591 for (; i < max_len; i++)
14593 if (
is_eof() || !is_decimal_digit(*cp))
14596 buffer[i] =
static_cast<T>(*cp - U
'0');
14604 std::string_view parse_basic_string(
bool multi_line)
14617 consume_line_break();
14622 auto &str = string_buffer;
14624 bool escaped =
false;
14625 bool skipping_whitespace =
false;
14633 if (multi_line && is_whitespace(*cp))
14635 consume_leading_whitespace();
14639 "line-ending backslashes must be the last non-whitespace character on the line"sv);
14641 skipping_whitespace =
true;
14646 bool skip_escaped_codepoint =
true;
14673# if TOML_LANG_UNRELEASED
14680 "escape sequence '\\e' is not supported in TOML 1.0.0 and earlier"sv);
14683# if TOML_LANG_UNRELEASED
14689 "escape sequence '\\x' is not supported in TOML 1.0.0 and earlier"sv);
14699 skip_escaped_codepoint =
false;
14701 uint32_t place_value =
14705 uint32_t sequence_value{};
14706 while (place_value)
14712 "expected hex digit, saw '"sv,
to_sv(*cp),
"'"sv);
14714 sequence_value += place_value * hex_to_dec(*cp);
14715 place_value /= 16u;
14721 "unicode surrogates (U+D800 - U+DFFF) are explicitly prohibited"sv);
14724 "values greater than U+10FFFF are invalid"sv);
14726 if (sequence_value < 0x80)
14728 str +=
static_cast<char>(sequence_value);
14730 else if (sequence_value < 0x800u)
14732 str +=
static_cast<char>((sequence_value >> 6) | 0xC0u);
14733 str +=
static_cast<char>((sequence_value & 0x3Fu) | 0x80u);
14735 else if (sequence_value < 0x10000u)
14737 str +=
static_cast<char>((sequence_value >> 12) | 0xE0u);
14738 str +=
static_cast<char>(((sequence_value >> 6) & 0x3Fu) | 0x80u);
14739 str +=
static_cast<char>((sequence_value & 0x3Fu) | 0x80u);
14741 else if (sequence_value < 0x110000u)
14743 str +=
static_cast<char>((sequence_value >> 18) | 0xF0u);
14745 static_cast<char>(((sequence_value >> 12) & 0x3Fu) | 0x80u);
14746 str +=
static_cast<char>(((sequence_value >> 6) & 0x3Fu) | 0x80u);
14747 str +=
static_cast<char>((sequence_value & 0x3Fu) | 0x80u);
14756 "unknown escape sequence '\\"sv,
to_sv(*cp),
"'"sv);
14759 if (skip_escaped_codepoint)
14769 size_t lookaheads = {};
14770 size_t consecutive_delimiters = 1;
14775 if (!
is_eof() && *cp == U
'"')
14776 consecutive_delimiters++;
14779 }
while (lookaheads < 4u);
14781 switch (consecutive_delimiters)
14786 skipping_whitespace =
false;
14791 str.append(
"\"\""sv);
14792 skipping_whitespace =
false;
14806 str.append(
"\"\""sv);
14822 else if (*cp == U
'\\')
14825 skipping_whitespace =
false;
14831 if (multi_line && is_ascii_vertical_whitespace(*cp))
14833 consume_line_break();
14835 if (!skipping_whitespace)
14843 "unescaped control characters other than TAB (U+0009) are explicitly prohibited"sv);
14845# if TOML_LANG_AT_LEAST(1, 0, 0)
14850 "unescaped unicode surrogates (U+D800 to U+DFFF) are explicitly prohibited"sv);
14855 if (!skipping_whitespace || !is_horizontal_whitespace(*cp))
14857 skipping_whitespace =
false;
14858 str.append(cp->bytes, cp->count);
14862 str.append(cp->bytes, cp->count);
14873 std::string_view parse_literal_string(
bool multi_line)
14886 consume_line_break();
14891 auto &str = string_buffer;
14902 size_t lookaheads = {};
14903 size_t consecutive_delimiters = 1;
14908 if (!
is_eof() && *cp == U
'\'')
14909 consecutive_delimiters++;
14912 }
while (lookaheads < 4u);
14914 switch (consecutive_delimiters)
14923 str.append(
"''"sv);
14937 str.append(
"''"sv);
14953 if (multi_line && is_ascii_vertical_whitespace(*cp))
14955 consume_line_break();
14964 "control characters other than TAB (U+0009) are explicitly prohibited"sv);
14966# if TOML_LANG_AT_LEAST(1, 0, 0)
14971 "unicode surrogates (U+D800 - U+DFFF) are explicitly prohibited"sv);
14974 str.append(cp->bytes, cp->count);
14991 const auto first = cp->value;
14993 const auto second = cp->value;
14995 const auto third = cp ? cp->value : U
'\0';
15001 if (second == first)
15009 else if (first == second && first == third)
15012 first == U
'\'' ? parse_literal_string(
true)
15013 : parse_basic_string(
true),
15025 first == U
'\'' ? parse_literal_string(
false)
15026 : parse_basic_string(
false),
15033 std::string_view parse_bare_key_segment()
15039 string_buffer.clear();
15043 if (!is_bare_key_character(*cp))
15046 string_buffer.append(cp->bytes, cp->count);
15050 return string_buffer;
15055 bool parse_boolean()
15062 start_recording(
true);
15063 auto result = is_match(*cp, U
't', U
'T');
15064 if (!consume_expected_sequence(result ? U
"true"sv : U
"false"sv))
15069 to_sv(recording_buffer),
15073 if (cp && !is_value_terminator(*cp))
15075 "expected value-terminator, saw '"sv,
to_sv(*cp),
"'"sv);
15082 double parse_inf_or_nan()
15089 start_recording(
true);
15090 const bool negative = *cp == U
'-';
15091 if (negative || *cp == U
'+')
15094 const bool inf = is_match(*cp, U
'i', U
'I');
15095 if (!consume_expected_sequence(inf ? U
"inf"sv : U
"nan"sv))
15098 inf ?
"inf"sv :
"nan"sv,
15100 to_sv(recording_buffer),
15104 if (cp && !is_value_terminator(*cp))
15106 "expected value-terminator, saw '"sv,
to_sv(*cp),
"'"sv);
15108 return inf ? (negative ? -std::numeric_limits<double>::infinity()
15109 : std::numeric_limits<double>::infinity())
15110 : std::numeric_limits<double>::quiet_NaN();
15120 is_match(*cp, U
'+', U
'-', U
'.') || is_decimal_digit(*cp));
15124 const int sign = *cp == U
'-' ? -1 : 1;
15125 if (is_match(*cp, U
'+', U
'-'))
15130 size_t length = {};
15132 bool seen_decimal =
false, seen_exponent =
false;
15133 char first_integer_part =
'\0';
15134 while (!
is_eof() && !is_value_terminator(*cp))
15138 if (!prev || !is_decimal_digit(*prev))
15140 "underscores may only follow digits"sv);
15146 else if TOML_UNLIKELY (prev && *prev == U
'_' && !is_decimal_digit(*cp))
15148 "underscores must be followed by digits"sv);
15151 "exceeds length limit of "sv,
15154 (seen_exponent ?
""sv :
" (consider using exponent notation)"sv));
15155 else if (*cp == U
'.')
15160 if (!first_integer_part)
15164 else if (seen_exponent)
15166 "expected exponent decimal digit or sign, saw '.'"sv);
15171 else if (seen_decimal)
15173 "expected decimal digit or exponent, saw '.'"sv);
15175 seen_decimal =
true;
15177 else if (is_match(*cp, U
'e', U
'E'))
15179 if (prev && !is_decimal_digit(*prev))
15181 "expected decimal digit, saw '"sv,
to_sv(*cp),
"'"sv);
15184 else if (seen_exponent)
15186 "expected decimal digit, saw '"sv,
to_sv(*cp),
"'"sv);
15188 seen_decimal =
true;
15189 seen_exponent =
true;
15191 else if (is_match(*cp, U
'+', U
'-'))
15194 if (!seen_exponent)
15196 "expected decimal digit or '.', saw '"sv,
to_sv(*cp),
"'"sv);
15199 else if (!is_match(*prev, U
'e', U
'E'))
15201 "expected exponent digit, saw '"sv,
to_sv(*cp),
"'"sv);
15203 else if (is_decimal_digit(*cp))
15207 if (!first_integer_part)
15208 first_integer_part =
static_cast<char>(cp->bytes[0]);
15209 else if (first_integer_part ==
'0')
15215 "expected decimal digit, saw '"sv,
to_sv(*cp),
"'"sv);
15217 chars[length++] =
static_cast<char>(cp->bytes[0]);
15229 "underscores must be followed by digits"sv);
15231 else if (is_match(*prev, U
'e', U
'E', U
'+', U
'-', U
'.'))
15235 "expected decimal digit, saw '"sv,
to_sv(*cp),
"'"sv);
15241# if TOML_FLOAT_CHARCONV
15243 auto fc_result = std::from_chars(chars, chars + length, result);
15244 switch (fc_result.ec)
15248 return result * sign;
15250 case std::errc::invalid_argument:
15253 std::string_view{chars, length},
15254 "' could not be interpreted as a value"sv);
15257 case std::errc::result_out_of_range:
15260 std::string_view{chars, length},
15261 "' is not representable in 64 bits"sv);
15266 "an unspecified error occurred while trying to interpret '"sv,
15267 std::string_view{chars, length},
15273 std::stringstream ss;
15274 ss.imbue(std::locale::classic());
15275 ss.write(chars,
static_cast<std::streamsize
>(length));
15276 if ((ss >> result))
15277 return result * sign;
15281 std::string_view{chars, length},
15282 "' could not be interpreted as a value"sv);
15289 double parse_hex_float()
15296# if TOML_LANG_UNRELEASED
15299 const int sign = *cp == U
'-' ? -1 : 1;
15300 if (is_match(*cp, U
'+', U
'-'))
15306 " expected '0', saw '"sv,
to_sv(*cp),
"'"sv);
15310 if (!is_match(*cp, U
'x', U
'X'))
15312 "expected 'x' or 'X', saw '"sv,
to_sv(*cp),
"'"sv);
15324 fragment fragments[] = {
15329 fragment *current_fragment = fragments;
15331 int exponent_sign = 1;
15332 while (!
is_eof() && !is_value_terminator(*cp))
15336 if (!prev || !is_hexadecimal_digit(*prev))
15338 "underscores may only follow digits"sv);
15344 else if (prev && *prev == U
'_' && !is_hexadecimal_digit(*cp))
15346 "underscores must be followed by digits"sv);
15347 else if (*cp == U
'.')
15350 if (current_fragment == fragments + 2)
15352 "expected exponent digit or sign, saw '.'"sv);
15355 else if (current_fragment == fragments + 1)
15357 "expected hexadecimal digit or exponent, saw '.'"sv);
15360 current_fragment++;
15362 else if (is_match(*cp, U
'p', U
'P'))
15365 if (current_fragment == fragments + 2)
15367 "expected exponent digit or sign, saw '"sv,
to_sv(*cp),
"'"sv);
15370 else if (fragments[0].length == 0u && fragments[1].length == 0u)
15372 "expected hexadecimal digit, saw '"sv,
to_sv(*cp),
"'"sv);
15375 current_fragment = fragments + 2;
15377 else if (is_match(*cp, U
'+', U
'-'))
15380 if (current_fragment != fragments + 2)
15382 "expected hexadecimal digit or '.', saw '"sv,
to_sv(*cp),
"'"sv);
15385 else if (!is_match(*prev, U
'p', U
'P'))
15387 "expected exponent digit, saw '"sv,
to_sv(*cp),
"'"sv);
15390 exponent_sign = *cp == U
'-' ? -1 : 1;
15392 else if (current_fragment < fragments + 2 && !is_hexadecimal_digit(*cp))
15394 "expected hexadecimal digit or '.', saw '"sv,
to_sv(*cp),
"'"sv);
15395 else if (current_fragment == fragments + 2 && !is_decimal_digit(*cp))
15397 "expected exponent digit or sign, saw '"sv,
to_sv(*cp),
"'"sv);
15398 else if (current_fragment->length ==
sizeof(fragment::chars))
15400 "fragment exceeeds maximum length of "sv,
15401 sizeof(fragment::chars),
15404 current_fragment->chars[current_fragment->length++] =
15405 static_cast<char>(cp->bytes[0]);
15412 if (current_fragment != fragments + 2 || current_fragment->length == 0u)
15417 else if (prev && *prev == U
'_')
15421 "underscores must be followed by digits"sv);
15425 for (
int fragment_idx = 0; fragment_idx < 3; fragment_idx++)
15427 auto &f = fragments[fragment_idx];
15428 const uint32_t
base = fragment_idx == 2 ? 10u : 16u;
15431 const char *c = f.chars;
15433 while (f.length && *c ==
'0')
15444 for (
size_t i = 0; i < f.length - 1u; i++)
15450 val += place * hex_to_dec(*c);
15452 val += place *
static_cast<uint32_t
>(*c -
'0');
15453 if (fragment_idx == 1)
15458 f.value =
static_cast<double>(val);
15461 if (fragment_idx == 1)
15468 return (fragments[0].
value + fragments[1].
value) *
15469 pow(2.0, fragments[2].
value * exponent_sign) * sign;
15474 "hexadecimal floating-point values are not supported "
15475 "in TOML 1.0.0 and earlier"sv);
15480 template <u
int64_t base>
15485 using traits = parse_integer_traits<base>;
15488 [[maybe_unused]] int64_t sign = 1;
15489 if constexpr (traits::is_signed)
15491 sign = *cp == U
'-' ? -1 : 1;
15492 if (is_match(*cp, U
'+', U
'-'))
15496 if constexpr (
base == 10)
15498 if (!traits::is_digit(*cp))
15500 "expected expected digit or sign, saw '"sv,
to_sv(*cp),
"'"sv);
15507 "expected '0', saw '"sv,
to_sv(*cp),
"'"sv);
15511 if (*cp != traits::prefix_codepoint)
15513 "expected '"sv, traits::prefix,
"', saw '"sv,
to_sv(*cp),
"'"sv);
15516 if (!traits::is_digit(*cp))
15518 "expected digit, saw '"sv,
to_sv(*cp),
"'"sv);
15523 size_t length = {};
15525 while (!
is_eof() && !is_value_terminator(*cp))
15529 if (!prev || !traits::is_digit(*prev))
15531 "underscores may only follow digits"sv);
15537 else if TOML_UNLIKELY (prev && *prev == U
'_' && !traits::is_digit(*cp))
15539 "underscores must be followed by digits"sv);
15542 "expected digit, saw '"sv,
to_sv(*cp),
"'"sv);
15545 "exceeds length limit of "sv,
sizeof(digits),
" digits"sv);
15547 digits[length++] =
static_cast<char>(cp->bytes[0]);
15554 if (prev && *prev == U
'_')
15558 "underscores must be followed by digits"sv);
15566 if constexpr (
base == 16)
15567 result =
static_cast<int64_t
>(hex_to_dec(digits[0]));
15569 result =
static_cast<int64_t
>(digits[0] -
'0');
15571 if constexpr (traits::is_signed)
15578 const char *end = digits + length;
15579 const char *msd = digits;
15580 if constexpr (
base != 10)
15582 while (msd < end && *msd ==
'0')
15596 if TOML_UNLIKELY (
static_cast<size_t>(end - msd) > traits::max_digits)
15599 traits::full_prefix,
15600 std::string_view{digits, length},
15601 "' is not representable as a signed 64-bit integer"sv);
15605 uint64_t result = {};
15607 uint64_t
power = 1;
15608 while (--end >= msd)
15610 if constexpr (
base == 16)
15611 result +=
power * hex_to_dec(*end);
15613 result +=
power *
static_cast<uint64_t
>(*end -
'0');
15620 static constexpr auto i64_max =
15621 static_cast<uint64_t
>((std::numeric_limits<int64_t>::max)());
15625 traits::full_prefix,
15626 std::string_view{digits, length},
15627 "' is not representable as a signed 64-bit integer"sv);
15629 if constexpr (traits::is_signed)
15633 return (std::numeric_limits<int64_t>::min)();
15635 return static_cast<int64_t
>(result) * sign;
15638 return static_cast<int64_t
>(result);
15644 date parse_date(
bool part_of_datetime =
false)
15652 uint32_t digits[4];
15653 if (!consume_digit_sequence(digits, 4u))
15655 "expected 4-digit year, saw '"sv,
to_sv(cp),
"'"sv);
15657 digits[3] + digits[2] * 10u + digits[1] * 100u + digits[0] * 1000u;
15658 const auto is_leap_year =
15659 (year % 4u == 0u) && ((year % 100u != 0u) || (year % 400u == 0u));
15665 "expected '-', saw '"sv,
to_sv(*cp),
"'"sv);
15669 if (!consume_digit_sequence(digits, 2u))
15671 "expected 2-digit month, saw '"sv,
to_sv(cp),
"'"sv);
15672 const auto month = digits[1] + digits[0] * 10u;
15673 if (month == 0u || month > 12u)
15675 "expected month between 1 and 12 (inclusive), saw "sv, month);
15676 const auto max_days_in_month =
15678 ? (is_leap_year ? 29u : 28u)
15679 : (month == 4u || month == 6u || month == 9u || month == 11u ? 30u
15686 "expected '-', saw '"sv,
to_sv(*cp),
"'"sv);
15690 if (!consume_digit_sequence(digits, 2u))
15692 "expected 2-digit day, saw '"sv,
to_sv(cp),
"'"sv);
15693 const auto day = digits[1] + digits[0] * 10u;
15694 if (day == 0u || day > max_days_in_month)
15696 "expected day between 1 and "sv,
15698 " (inclusive), saw "sv,
15701 if (!part_of_datetime && !
is_eof() && !is_value_terminator(*cp))
15703 "expected value-terminator, saw '"sv,
to_sv(*cp),
"'"sv);
15705 return {year, month, day};
15710 time parse_time(
bool part_of_datetime =
false)
15717 static constexpr size_t max_digits =
15720 uint32_t digits[max_digits];
15723 if (!consume_digit_sequence(digits, 2u))
15725 "expected 2-digit hour, saw '"sv,
to_sv(cp),
"'"sv);
15726 const auto hour = digits[1] + digits[0] * 10u;
15729 "expected hour between 0 to 59 (inclusive), saw "sv, hour);
15735 "expected ':', saw '"sv,
to_sv(*cp),
"'"sv);
15739 if (!consume_digit_sequence(digits, 2u))
15741 "expected 2-digit minute, saw '"sv,
to_sv(cp),
"'"sv);
15742 const auto minute = digits[1] + digits[0] * 10u;
15745 "expected minute between 0 and 59 (inclusive), saw "sv, minute);
15746 auto time = toml::time{hour, minute};
15753 is_eof() || is_value_terminator(*cp) ||
15754 (part_of_datetime && is_match(*cp, U
'+', U
'-', U
'Z', U
'z')))
15761 "expected ':', saw '"sv,
to_sv(*cp),
"'"sv);
15765 if (!consume_digit_sequence(digits, 2u))
15767 "expected 2-digit second, saw '"sv,
to_sv(cp),
"'"sv);
15768 const auto second = digits[1] + digits[0] * 10u;
15771 "expected second between 0 and 59 (inclusive), saw "sv, second);
15772 time.second =
static_cast<decltype(
time.second)
>(second);
15776 is_eof() || is_value_terminator(*cp) ||
15777 (part_of_datetime && is_match(*cp, U
'+', U
'-', U
'Z', U
'z')))
15781 "expected '.', saw '"sv,
to_sv(*cp),
"'"sv);
15785 size_t digit_count =
15786 consume_variable_length_digit_sequence(digits, max_digits);
15791 "expected fractional digits, saw '"sv,
to_sv(*cp),
"'"sv);
15795 if (digit_count == max_digits && is_decimal_digit(*cp))
15797 "fractional component exceeds maximum precision of "sv, max_digits);
15798 else if (!part_of_datetime && !is_value_terminator(*cp))
15800 "expected value-terminator, saw '"sv,
to_sv(*cp),
"'"sv);
15802 uint32_t
value = 0u;
15803 uint32_t place = 1u;
15804 for (
auto i = impl::min<size_t>(digit_count, 9u); i-- > 0u;)
15806 value += digits[i] * place;
15809 for (
auto i = digit_count; i < 9u; i++)
15825 auto date = parse_date(
true);
15829 if (!is_match(*cp, U
' ', U
'T', U
't'))
15831 "expected space, 'T' or 't', saw '"sv,
to_sv(*cp),
"'"sv);
15835 auto time = parse_time(
true);
15839 if (
is_eof() || is_value_terminator(*cp))
15840 return {date,
time};
15844 if (is_match(*cp, U
'Z', U
'z'))
15848 else if (is_match(*cp, U
'+', U
'-'))
15853 int sign = *cp == U
'-' ? -1 : 1;
15858 if (!consume_digit_sequence(digits, 2u))
15860 "expected 2-digit hour, saw '"sv,
to_sv(cp),
"'"sv);
15861 const auto hour = digits[1] + digits[0] * 10;
15864 "expected hour between 0 and 23 (inclusive), saw "sv, hour);
15870 "expected ':', saw '"sv,
to_sv(*cp),
"'"sv);
15874 if (!consume_digit_sequence(digits, 2u))
15876 "expected 2-digit minute, saw '"sv,
to_sv(cp),
"'"sv);
15877 const auto minute = digits[1] + digits[0] * 10;
15880 "expected minute between 0 and 59 (inclusive), saw "sv, minute);
15882 static_cast<decltype(offset.minutes)
>((hour * 60 + minute) * sign);
15885 if (!
is_eof() && !is_value_terminator(*cp))
15887 "expected value-terminator, saw '"sv,
to_sv(*cp),
"'"sv);
15889 return {date,
time, offset};
15893 node_ptr parse_array();
15896 node_ptr parse_inline_table();
15899 node_ptr parse_value_known_prefixes()
15910 return parse_array();
15914 return parse_inline_table();
15924 return node_ptr{
new value{parse_string().value}};
15928 const auto cp_upper =
static_cast<uint_least32_t
>(cp->value) & ~0x20u;
15931 if (cp_upper == 70u || cp_upper == 84u)
15932 return node_ptr{
new value{parse_boolean()}};
15935 else if (cp_upper == 73u || cp_upper == 78u)
15936 return node_ptr{
new value{parse_inf_or_nan()}};
15946 node_ptr parse_value()
15956 "exceeded maximum nested value depth of "sv,
15958 " (TOML_MAX_NESTED_VALUES)"sv);
15967 else if (*cp == U
'_')
15970 const auto begin_pos = cp->position;
15982 val = parse_value_known_prefixes();
16000 has_colon = 1 << 8,
16002 has_minus = 1 << 10,
16004 begins_sign = 1 << 12,
16005 begins_digit = 1 << 13,
16006 begins_zero = 1 << 14,
16007 signs_msk = has_plus | has_minus,
16008 bdigit_msk = has_digits | begins_digit,
16009 bzero_msk = bdigit_msk | begins_zero,
16012 const auto has_any = [&](
auto t)
noexcept
16013 {
return (traits & t) != has_nothing; };
16014 const auto has_none = [&](
auto t)
noexcept
16015 {
return (traits & t) == has_nothing; };
16016 const auto add_trait = [&](
auto t)
noexcept
16021 if (is_decimal_digit(*cp))
16023 add_trait(begins_digit);
16025 add_trait(begins_zero);
16027 else if (is_match(*cp, U
'+', U
'-'))
16028 add_trait(begins_sign);
16034 size_t char_count = {}, advance_count = {};
16035 bool eof_while_scanning =
false;
16044 if (
const auto c = **cp; c != U
'_')
16046 chars[char_count++] = c;
16048 if (is_decimal_digit(c))
16049 add_trait(has_digits);
16050 else if (is_ascii_letter(c))
16053 (c >= U
'a' && c <= U
'z') || (c >= U
'A' && c <= U
'Z'));
16054 switch (
static_cast<char32_t>(c | 32u))
16057 if (char_count == 2u && has_any(begins_zero))
16065 has_b | has_o | has_p | has_t | has_x | has_z |
16067 (has_none(has_plus | has_minus) || has_any(begins_sign)))
16072 if (char_count == 2u && has_any(begins_zero))
16077 if (has_any(has_x))
16083 (char_count == 2u && has_any(begins_zero)) ||
16084 (char_count == 3u && has_any(begins_sign) &&
16097 else if (c <= U
':')
16103 add_trait(has_plus);
16106 add_trait(has_minus);
16109 add_trait(has_dot);
16112 add_trait(has_colon);
16120 eof_while_scanning =
is_eof();
16121 }
while (advance_count <
16123 !
is_eof() && !is_value_terminator(*cp));
16131 && (traits | begins_zero) == (bzero_msk | has_minus)
16132 && chars[4] == U
'-'
16133 && chars[7] == U
'-'
16137 const auto pre_advance_count = advance_count;
16138 const auto pre_scan_traits = traits;
16139 chars[char_count++] = *cp;
16142 const auto backpedal = [&]()
noexcept
16144 go_back(advance_count - pre_advance_count);
16145 advance_count = pre_advance_count;
16146 traits = pre_scan_traits;
16153 if (
is_eof() || !is_decimal_digit(*cp))
16157 chars[char_count++] = *cp;
16165 if (char_count == 12u)
16171 go_back(advance_count);
16175 if (char_count == 1u)
16177 if (has_any(begins_digit))
16179 val.reset(
new value{
static_cast<int64_t
>(chars[0] - U
'0')});
16187 eof_while_scanning ?
"encountered end-of-file"sv
16188 :
"could not determine value type"sv);
16198 if (has_any(has_p))
16199 val.reset(
new value{parse_hex_float()});
16200 else if (has_any(has_x | has_o | has_b))
16204 if (has_any(has_x))
16206 i = parse_integer<16>();
16207 flags = value_flags::format_as_hexadecimal;
16209 else if (has_any(has_o))
16211 i = parse_integer<8>();
16212 flags = value_flags::format_as_octal;
16216 i = parse_integer<2>();
16217 flags = value_flags::format_as_binary;
16221 val.reset(
new value{i});
16222 val->ref_cast<int64_t>().flags(flags);
16224 else if (has_any(has_e) || (has_any(begins_digit) && chars[1] == U
'.'))
16226 else if (has_any(begins_sign))
16229 if (char_count == 2u && has_any(has_digits))
16231 val.reset(
new value{
16232 static_cast<int64_t
>(chars[1] - U
'0') *
16233 (chars[0] == U
'-' ? -1LL : 1LL)});
16240 if (is_decimal_digit(chars[1]) && chars[2] == U
'.')
16244 else if (is_match(chars[1], U
'i', U
'n', U
'I', U
'N'))
16245 val.reset(
new value{parse_inf_or_nan()});
16256 switch (unwrap_enum(traits))
16260 case bzero_msk | has_b:
16261 val.reset(
new value{parse_integer<2>()});
16262 val->ref_cast<int64_t>().flags(value_flags::format_as_binary);
16267 case bzero_msk | has_o:
16268 val.reset(
new value{parse_integer<8>()});
16269 val->ref_cast<int64_t>().flags(value_flags::format_as_octal);
16281 case begins_sign | has_digits | has_minus:
16283 case begins_sign | has_digits | has_plus:
16290 static constexpr size_t max_numeric_value_length =
16293 !eof_while_scanning && advance_count > max_numeric_value_length)
16295 "numeric value too long to identify type - cannot exceed "sv,
16296 max_numeric_value_length,
16299 val.reset(
new value{parse_integer<10>()});
16305 case bzero_msk | has_x:
16306 val.reset(
new value{parse_integer<16>()});
16307 val->ref_cast<int64_t>().flags(value_flags::format_as_hexadecimal);
16318 case bzero_msk | has_e:
16320 case bzero_msk | has_e | has_minus:
16322 case bzero_msk | has_e | has_plus:
16324 case bzero_msk | has_dot:
16326 case bzero_msk | has_dot | has_e:
16328 case bzero_msk | has_dot | has_e | has_minus:
16330 case bzero_msk | has_dot | has_e | has_plus:
16339 case bdigit_msk | has_e:
16341 case bdigit_msk | has_e | has_minus:
16343 case bdigit_msk | has_e | has_plus:
16345 case bdigit_msk | has_dot:
16347 case bdigit_msk | has_dot | has_e:
16349 case bdigit_msk | has_dot | has_e | has_minus:
16351 case bdigit_msk | has_dot | has_e | has_plus:
16359 case begins_sign | has_digits | has_e | has_plus:
16361 case begins_sign | has_digits | has_dot | has_plus:
16363 case begins_sign | has_digits | has_dot | has_e | has_plus:
16365 case begins_sign | has_digits | has_dot | has_e | signs_msk:
16373 case begins_sign | has_digits | has_e | has_minus:
16375 case begins_sign | has_digits | has_e | signs_msk:
16377 case begins_sign | has_digits | has_dot | has_minus:
16379 case begins_sign | has_digits | has_dot | has_e | has_minus:
16387 case bzero_msk | has_x | has_p:
16389 case bzero_msk | has_x | has_p | has_minus:
16391 case bzero_msk | has_x | has_p | has_plus:
16399 case begins_sign | has_digits | has_x | has_p | has_minus:
16401 case begins_sign | has_digits | has_x | has_p | has_plus:
16403 case begins_sign | has_digits | has_x | has_p | signs_msk:
16408 case bzero_msk | has_x | has_dot | has_p:
16410 case bzero_msk | has_x | has_dot | has_p | has_minus:
16412 case bzero_msk | has_x | has_dot | has_p | has_plus:
16420 case begins_sign | has_digits | has_x | has_dot | has_p | has_minus:
16422 case begins_sign | has_digits | has_x | has_dot | has_p | has_plus:
16424 case begins_sign | has_digits | has_x | has_dot | has_p | signs_msk:
16425 val.reset(
new value{parse_hex_float()});
16432 case bzero_msk | has_colon:
16434 case bzero_msk | has_colon | has_dot:
16436 case bdigit_msk | has_colon:
16438 case bdigit_msk | has_colon | has_dot:
16439 val.reset(
new value{parse_time()});
16444 case bzero_msk | has_minus:
16446 case bdigit_msk | has_minus:
16447 val.reset(
new value{parse_date()});
16463 case bzero_msk | has_minus | has_colon | has_t:
16465 case bzero_msk | signs_msk | has_colon | has_t:
16467 case bdigit_msk | has_minus | has_colon | has_t:
16469 case bdigit_msk | signs_msk | has_colon | has_t:
16477 case bzero_msk | has_minus | has_colon | has_dot | has_t:
16479 case bzero_msk | signs_msk | has_colon | has_dot | has_t:
16481 case bdigit_msk | has_minus | has_colon | has_dot | has_t:
16483 case bdigit_msk | signs_msk | has_colon | has_dot | has_t:
16491 case bzero_msk | has_minus | has_colon | has_z | has_t:
16493 case bzero_msk | has_minus | has_colon | has_dot | has_z | has_t:
16495 case bdigit_msk | has_minus | has_colon | has_z | has_t:
16497 case bdigit_msk | has_minus | has_colon | has_dot | has_z | has_t:
16498 val.reset(
new value{parse_date_time()});
16505 set_error_at(begin_pos,
"could not determine value type"sv);
16509 val->source_ = {begin_pos, current_position(1), reader.source_path()};
16519 is_bare_key_character(*cp) || is_string_delimiter(*cp));
16522 key_buffer.clear();
16523 recording_whitespace =
false;
16527 std::string_view key_segment;
16528 const auto key_begin = current_position();
16531 if (is_bare_key_character(*cp))
16532 key_segment = parse_bare_key_segment();
16535 else if (is_string_delimiter(*cp))
16537 const auto begin_pos = cp->position;
16539 recording_whitespace =
true;
16541 recording_whitespace =
false;
16548 "multi-line strings are prohibited in "sv,
16549 key_buffer.empty() ?
""sv :
"dotted "sv,
16554 key_segment = str.
value;
16560 "expected bare key starting character or string delimiter, saw '"sv,
16564 const auto key_end = current_position();
16567 consume_leading_whitespace();
16570 key_buffer.push_back(key_segment, key_begin, key_end);
16573 if (
is_eof() || *cp != U
'.')
16578 consume_leading_whitespace();
16587 key make_key(
size_t segment_index)
const
16592 key_buffer[segment_index],
16594 key_buffer.starts[segment_index],
16595 key_buffer.ends[segment_index],
16596 root.source().path}};
16601 table *parse_table_header()
16610 bool is_arr =
false;
16618 const bool had_leading_whitespace = consume_leading_whitespace();
16624 if (had_leading_whitespace)
16626 "[[array-of-table]] brackets must be contiguous (i.e. [ [ this ] ] is prohibited)"sv);
16632 consume_leading_whitespace();
16639 "tables with blank bare keys are explicitly prohibited"sv);
16644 stop_recording(1u);
16648 consume_leading_whitespace();
16655 "expected ']', saw '"sv,
to_sv(*cp),
"'"sv);
16661 "expected ']', saw '"sv,
to_sv(*cp),
"'"sv);
16664 header_end_pos = current_position(1);
16667 consume_leading_whitespace();
16668 if (!
is_eof() && !consume_comment() && !consume_line_break())
16670 "expected a comment or whitespace, saw '"sv,
to_sv(cp),
"'"sv);
16675 table *parent = &root;
16676 for (
size_t i = 0, e = key_buffer.size() - 1u; i < e; i++)
16678 const std::string_view segment = key_buffer[i];
16682 if (pit != parent->
end() && pit->first == segment)
16684 node &p = pit->second;
16686 if (
auto tbl = p.as_table())
16690 tbl->is_inline() &&
16692 open_inline_tables.begin(), open_inline_tables.end(), tbl))
16694 "cannot insert '"sv,
16695 to_sv(recording_buffer),
16696 "' into existing inline table"sv);
16700 else if (
auto arr = p.as_array();
16702 impl::find(table_arrays.begin(), table_arrays.end(), arr))
16708 parent = &arr->
back().ref_cast<
table>();
16712 if (!is_arr && p.type() == node_type::table)
16714 "cannot redefine existing table '"sv,
16715 to_sv(recording_buffer),
16719 "cannot redefine existing "sv,
16722 to_sv(recording_buffer),
16724 is_arr ?
"array-of-tables"sv :
"table"sv);
16731 pit = parent->emplace_hint<
table>(pit, make_key(i));
16733 p.source_ = {header_begin_pos, header_end_pos, reader.source_path()};
16735 implicit_tables.push_back(&p);
16740 const auto last_segment = key_buffer.back();
16747 if (it != parent->
end() && it->first == last_segment)
16749 node &matching_node = it->second;
16750 if (
auto arr = matching_node.as_array();
16752 impl::find(table_arrays.begin(), table_arrays.end(), arr))
16756 header_begin_pos, header_end_pos, reader.source_path()};
16760 else if (
auto tbl = matching_node.as_table();
16761 !is_arr && tbl && !implicit_tables.empty())
16764 impl::find(implicit_tables.begin(), implicit_tables.end(), tbl);
16770 for (
auto &[_, child] : *tbl)
16772 if (!child.is_table() && !child.is_array_of_tables())
16782 implicit_tables.erase(
16783 implicit_tables.cbegin() + (found - implicit_tables.data()));
16784 tbl->source_.begin = header_begin_pos;
16785 tbl->source_.end = header_end_pos;
16792 if (!is_arr && matching_node.type() == node_type::table)
16796 "cannot redefine existing table '"sv,
16797 to_sv(recording_buffer),
16805 "cannot redefine existing "sv,
16806 to_sv(matching_node.type()),
16808 to_sv(recording_buffer),
16810 is_arr ?
"array-of-tables"sv :
"table"sv);
16818 auto last_key = make_key(key_buffer.size() - 1u);
16824 it = parent->emplace_hint<
array>(it, std::move(last_key));
16825 array &tbl_arr = it->second.ref_cast<
array>();
16827 tbl_arr.source_ = {
16828 header_begin_pos, header_end_pos, reader.source_path()};
16832 header_begin_pos, header_end_pos, reader.source_path()};
16839 it = parent->emplace_hint<
table>(it, std::move(last_key));
16842 header_begin_pos, header_end_pos, reader.source_path()};
16849 bool parse_key_value_pair_and_insert(
table *tbl)
16854 is_string_delimiter(*cp) || is_bare_key_character(*cp));
16860 stop_recording(1u);
16865 consume_leading_whitespace();
16871 "expected '=', saw '"sv,
to_sv(*cp),
"'"sv);
16875 consume_leading_whitespace();
16880 if (is_value_terminator(*cp))
16882 "expected value, saw '"sv,
to_sv(*cp),
"'"sv);
16886 if (key_buffer.size() > 1u)
16888 for (
size_t i = 0; i < key_buffer.size() - 1u; i++)
16890 const std::string_view segment = key_buffer[i];
16894 if (pit != tbl->
end() && pit->first == segment)
16896 table *p = pit->second.as_table();
16902 dotted_key_tables.begin(), dotted_key_tables.end(), p) ||
16903 impl::find(implicit_tables.begin(), implicit_tables.end(), p)))
16906 key_buffer.starts[i],
16907 "cannot redefine existing "sv,
16908 to_sv(pit->second.type()),
16909 " as dotted key-value pair"sv);
16919 pit = tbl->emplace_hint<
table>(pit, make_key(i));
16921 p.source_ = pit->first.source();
16923 dotted_key_tables.push_back(&p);
16930 const std::string_view last_segment = key_buffer.back();
16932 if (it != tbl->
end() && it->first == last_segment)
16935 "cannot redefine existing "sv,
16936 to_sv(it->second.type()),
16938 to_sv(recording_buffer),
16945 auto last_key = make_key(key_buffer.size() - 1u);
16948 node_ptr val = parse_value();
16951 tbl->emplace_hint<node_ptr>(it, std::move(last_key), std::move(val));
16955 void parse_document()
16961 table *current_table = &root;
16969 consume_leading_whitespace() || consume_line_break() ||
16977 current_table = parse_table_header();
16982 else if (is_bare_key_character(*cp) || is_string_delimiter(*cp))
16986 parse_key_value_pair_and_insert(current_table);
16990 consume_leading_whitespace();
16992 if (!
is_eof() && !consume_comment() && !consume_line_break())
16994 "expected a comment or whitespace, saw '"sv,
to_sv(cp),
"'"sv);
16999 "expected keys, tables, whitespace or comments, saw '"sv,
17004 auto eof_pos = current_position(1);
17005 root.source_.end = eof_pos;
17007 current_table && current_table != &root &&
17008 current_table->source_.
end <= current_table->source_.
begin)
17009 current_table->source_.
end = eof_pos;
17012 static void update_region_ends(node &nde)
noexcept
17014 const auto type = nde.type();
17015 if (type > node_type::array)
17018 if (type == node_type::table)
17020 auto &tbl = nde.ref_cast<
table>();
17027 auto end = nde.source_.end;
17028 for (
auto &&[k, v] : tbl)
17031 update_region_ends(v);
17032 if (end < v.source_.end)
17033 end = v.source_.end;
17038 auto &arr = nde.ref_cast<
array>();
17039 auto end = nde.source_.end;
17040 for (
auto &&v : arr)
17042 update_region_ends(v);
17043 if (end < v.source_.end)
17044 end = v.source_.end;
17046 nde.source_.end = end;
17054 root.source_ = {prev_pos, prev_pos, reader.source_path()};
17056 if (!reader.peek_eof())
17058 cp = reader.read_next();
17060# if !TOML_EXCEPTIONS
17061 if (reader.error())
17063 err = std::move(reader.error());
17072 update_region_ends(root);
17078# if TOML_EXCEPTIONS
17080 return {std::move(root)};
17094 node_ptr parser::parse_array()
17104 node_ptr arr_ptr{
new array{}};
17112 parse_type prev = parse_type::none;
17116 while (consume_leading_whitespace() || consume_line_break() ||
17124 if (prev == parse_type::val)
17126 prev = parse_type::comma;
17131 "expected value or closing ']', saw comma"sv);
17135 else if (*cp == U
']')
17144 if (prev == parse_type::val)
17147 "expected comma or closing ']', saw '"sv,
to_sv(*cp),
"'"sv);
17150 prev = parse_type::val;
17152 auto val = parse_value();
17166 node_ptr parser::parse_inline_table()
17176 node_ptr tbl_ptr{
new table{}};
17177 table &tbl = tbl_ptr->ref_cast<table>();
17179 table_vector_scope table_scope{open_inline_tables, tbl};
17187 parse_type prev = parse_type::none;
17193 while (consume_leading_whitespace() || consume_line_break() ||
17199 while (consume_leading_whitespace())
17208 if (prev == parse_type::kvp)
17210 prev = parse_type::comma;
17215 "expected key-value pair or closing '}', saw comma"sv);
17219 else if (*cp == U
'}')
17224 if (prev == parse_type::comma)
17227 "expected key-value pair, saw closing '}' (dangling comma)"sv);
17236 else if (is_string_delimiter(*cp) || is_bare_key_character(*cp))
17238 if (prev == parse_type::kvp)
17240 "expected comma or closing '}', saw '"sv,
to_sv(*cp),
"'"sv);
17243 prev = parse_type::kvp;
17244 parse_key_value_pair_and_insert(&tbl);
17250 "expected key or closing '}', saw '"sv,
to_sv(*cp),
"'"sv);
17261# undef TOML_RETURNS_BY_THROWING
17262# undef advance_and_return_if_error
17263# undef advance_and_return_if_error_or_eof
17264# undef assert_not_eof
17265# undef assert_not_error
17268# undef parse_error_break
17269# undef push_parse_scope
17270# undef push_parse_scope_1
17271# undef push_parse_scope_2
17272# undef return_after_error
17273# undef return_if_eof
17274# undef return_if_error
17275# undef return_if_error_or_eof
17276# undef set_error_and_return
17277# undef set_error_and_return_default
17278# undef set_error_and_return_if_eof
17279# undef utf8_buffered_reader_error_check
17280# undef utf8_reader_error
17281# undef utf8_reader_error_check
17282# undef utf8_reader_return_after_error
17290 return impl::parser{std::move(reader)};
17295 parse_result do_parse_file(std::string_view file_path)
17297# if TOML_EXCEPTIONS
17298# define TOML_PARSE_FILE_ERROR(msg, path) \
17299 throw parse_error( \
17301 source_position{}, \
17302 std::make_shared<const std::string>(std::move(path)))
17304# define TOML_PARSE_FILE_ERROR(msg, path) \
17305 return parse_result(parse_error( \
17307 source_position{}, \
17308 std::make_shared<const std::string>(std::move(path))))
17311 std::string file_path_str(file_path);
17314 std::ifstream file;
17316 file.rdbuf()->pubsetbuf(file_buffer,
sizeof(file_buffer));
17319 impl::widen(file_path_str).c_str(),
17320 std::ifstream::in | std::ifstream::binary | std::ifstream::ate);
17324 std::ifstream::in | std::ifstream::binary | std::ifstream::ate);
17326 if (!file.is_open())
17328 "File could not be opened for reading", file_path_str);
17331 const auto file_size = file.tellg();
17332 if (file_size == -1)
17334 file.seekg(0, std::ifstream::beg);
17337 constexpr auto large_file_threshold = 1024 * 1024 * 2;
17338 if (file_size <= large_file_threshold)
17340 std::vector<char> file_data;
17341 file_data.resize(
static_cast<size_t>(file_size));
17342 file.read(file_data.data(),
static_cast<std::streamsize
>(file_size));
17344 std::string_view{file_data.data(), file_data.size()},
17345 std::move(file_path_str));
17350 return parse(file, std::move(file_path_str));
17352# undef TOML_PARSE_FILE_ERROR
17363 std::string_view doc, std::string_view source_path)
17365 return TOML_ANON_NAMESPACE::do_parse(
17366 TOML_ANON_NAMESPACE::utf8_reader{doc, source_path});
17371 std::string_view doc, std::string && source_path)
17373 return TOML_ANON_NAMESPACE::do_parse(
17374 TOML_ANON_NAMESPACE::utf8_reader{doc, std::move(source_path)});
17379 std::istream & doc, std::string_view source_path)
17381 return TOML_ANON_NAMESPACE::do_parse(
17382 TOML_ANON_NAMESPACE::utf8_reader{doc, source_path});
17387 std::istream & doc, std::string && source_path)
17389 return TOML_ANON_NAMESPACE::do_parse(
17390 TOML_ANON_NAMESPACE::utf8_reader{doc, std::move(source_path)});
17396 return TOML_ANON_NAMESPACE::do_parse_file(file_path);
17403 std::u8string_view doc, std::string_view source_path)
17405 return TOML_ANON_NAMESPACE::do_parse(
17406 TOML_ANON_NAMESPACE::utf8_reader{doc, source_path});
17411 std::u8string_view doc, std::string && source_path)
17413 return TOML_ANON_NAMESPACE::do_parse(
17414 TOML_ANON_NAMESPACE::utf8_reader{doc, std::move(source_path)});
17420 std::string file_path_str;
17421 file_path_str.resize(file_path.length());
17422 memcpy(file_path_str.data(), file_path.data(), file_path.length());
17423 return TOML_ANON_NAMESPACE::do_parse_file(file_path_str);
17428# if TOML_ENABLE_WINDOWS_COMPAT
17432 std::string_view doc, std::wstring_view source_path)
17434 return TOML_ANON_NAMESPACE::do_parse(
17435 TOML_ANON_NAMESPACE::utf8_reader{doc, impl::narrow(source_path)});
17440 std::istream & doc, std::wstring_view source_path)
17442 return TOML_ANON_NAMESPACE::do_parse(
17443 TOML_ANON_NAMESPACE::utf8_reader{doc, impl::narrow(source_path)});
17449 return TOML_ANON_NAMESPACE::do_parse_file(impl::narrow(file_path));
17454# if TOML_HAS_CHAR8 && TOML_ENABLE_WINDOWS_COMPAT
17458 std::u8string_view doc, std::wstring_view source_path)
17460 return TOML_ANON_NAMESPACE::do_parse(
17461 TOML_ANON_NAMESPACE::utf8_reader{doc, impl::narrow(source_path)});
17470# undef TOML_OVERALIGNED
17473# pragma pop_macro("min")
17474# pragma pop_macro("max")
17476# pragma inline_recursion(off)
17485# if TOML_ENABLE_FORMATTERS
17490# pragma inline_recursion(on)
17492# pragma push_macro("min")
17493# pragma push_macro("max")
17503 line_breaks = 1u << 0,
17505 control_chars = 1u << 2,
17506 single_quotes = 1u << 3,
17507 non_bare = 1u << 4,
17508 non_ascii = 1u << 5,
17510 all = (non_ascii << 1u) - 1u
17516 const node *source_node,
17518 const formatter_constants &constants,
17520# if TOML_ENABLE_PARSER && !TOML_EXCEPTIONS
17521 : source_{source_pr && *source_pr ? &source_pr->table() : source_node},
17522 result_{source_pr},
17524 : source_{source_pr ? source_pr : source_node},
17526 constants_{&constants},
17531 config_.
flags = (config_.
flags | constants_->mandatory_flags) &
17532 ~constants_->ignored_flags;
17534 indent_columns_ = {};
17535 for (
auto c : config_.
indent)
17536 indent_columns_ += c ==
'\t' ? 4u : 1u;
17539 config_.
flags & (format_flags::allow_binary_integers |
17540 format_flags::allow_octal_integers |
17541 format_flags::allow_hexadecimal_integers);
17548 naked_newline_ =
true;
17561 if (!naked_newline_ || force)
17564 naked_newline_ =
true;
17571 for (
int i = 0; i < indent_; i++)
17574 naked_newline_ =
false;
17582 naked_newline_ =
false;
17589 naked_newline_ =
false;
17594 std::string_view str,
17595 bool allow_multi_line,
17597 bool allow_literal_whitespace)
17606 formatted_string_traits traits = {};
17609 traits |= formatted_string_traits::non_bare;
17613 if (
is_ascii(str.data(), str.length()))
17620 traits |= formatted_string_traits::line_breaks;
17623 traits |= formatted_string_traits::tabs;
17626 traits |= formatted_string_traits::single_quotes;
17631 traits |= formatted_string_traits::control_chars;
17633 if (!is_ascii_bare_key_character(
static_cast<char32_t>(c)))
17634 traits |= formatted_string_traits::non_bare;
17639 static constexpr auto all_ascii_traits =
17640 formatted_string_traits::all & ~formatted_string_traits::non_ascii;
17641 if (traits == all_ascii_traits)
17649 traits |= formatted_string_traits::non_ascii;
17650 utf8_decoder decoder;
17654 const auto bad_unicode = [&]()
noexcept
17656 traits &= ~formatted_string_traits::line_breaks;
17657 traits |= formatted_string_traits::control_chars |
17658 formatted_string_traits::non_bare;
17659 unicode_allowed =
false;
17672 if (!decoder.has_code_point())
17675 switch (decoder.codepoint)
17678 traits |= formatted_string_traits::line_breaks;
17681 traits |= formatted_string_traits::tabs;
17684 traits |= formatted_string_traits::single_quotes;
17689 is_control_character(decoder.codepoint) ||
17690 is_non_ascii_vertical_whitespace(decoder.codepoint))
17691 traits |= formatted_string_traits::control_chars;
17693 if (!is_bare_key_character(decoder.codepoint))
17694 traits |= formatted_string_traits::non_bare;
17700 if (decoder.needs_more_input())
17706 traits & (formatted_string_traits::line_breaks |
17707 formatted_string_traits::tabs |
17708 formatted_string_traits::single_quotes)))
17709 traits |= formatted_string_traits::non_bare;
17714 !(traits & formatted_string_traits::non_bare) &&
17715 (!(traits & formatted_string_traits::non_ascii) || unicode_allowed))
17720 const auto real_tabs_allowed =
17724 const auto multi_line = allow_literal_whitespace
17725 && allow_multi_line
17728 !!(traits & formatted_string_traits::line_breaks);
17731 const auto literal =
17733 && !(traits & formatted_string_traits::control_chars)
17734 && (!(traits & formatted_string_traits::single_quotes) || multi_line)
17735 && (!(traits & formatted_string_traits::tabs) || real_tabs_allowed)
17736 && (!(traits & formatted_string_traits::line_breaks) || multi_line)
17737 && (!(traits & formatted_string_traits::non_ascii) || unicode_allowed);
17742 const auto quot = multi_line ? R
"(''')"sv : R"(')"sv;
17753 if (!(traits & formatted_string_traits::non_ascii))
17791 utf8_decoder decoder;
17792 const char *cp_start = str.data();
17793 const char *cp_end = cp_start;
17800 if (decoder.error())
17802 while (cp_start != cp_end)
17807 static_cast<uint8_t
>(*cp_start),
17808 value_flags::format_as_hexadecimal,
17816 if (!decoder.has_code_point())
17819 switch (decoder.codepoint)
17843 decoder.codepoint)]);
17847 decoder.codepoint > U
'\x7F' &&
17848 (!unicode_allowed ||
17849 is_non_ascii_vertical_whitespace(decoder.codepoint)))
17851 if (
static_cast<uint_least32_t
>(decoder.codepoint) > 0xFFFFu)
17856 static_cast<uint_least32_t
>(decoder.codepoint),
17857 value_flags::format_as_hexadecimal,
17865 static_cast<uint_least32_t
>(decoder.codepoint),
17866 value_flags::format_as_hexadecimal,
17874 *stream_, cp_start,
static_cast<size_t>(cp_end - cp_start));
17894 naked_newline_ =
false;
17896 if (*val >= 0 && !!int_format_mask_)
17898 static constexpr auto value_flags_mask =
17899 value_flags::format_as_binary | value_flags::format_as_octal |
17900 value_flags::format_as_hexadecimal;
17902 const auto fmt = val.flags() & value_flags_mask;
17905 case value_flags::format_as_binary:
17906 if (!!(int_format_mask_ & format_flags::allow_binary_integers))
17914 case value_flags::format_as_octal:
17915 if (!!(int_format_mask_ & format_flags::allow_octal_integers))
17923 case value_flags::format_as_hexadecimal:
17924 if (!!(int_format_mask_ & format_flags::allow_hexadecimal_integers))
17944 const std::string_view *inf_nan =
nullptr;
17947 case fp_class::neg_inf:
17948 inf_nan = &constants_->float_neg_inf;
17950 case fp_class::pos_inf:
17951 inf_nan = &constants_->float_pos_inf;
17953 case fp_class::nan:
17954 inf_nan = &constants_->float_nan;
17961 !!(config_.flags & format_flags::relaxed_float_precision));
17969 if (!!(config_.flags & format_flags::quote_infinities_and_nans))
17975 naked_newline_ =
false;
17987 if (!!(config_.flags & format_flags::quote_dates_and_times))
17992 naked_newline_ =
false;
17998 if (!!(config_.flags & format_flags::quote_dates_and_times))
18003 naked_newline_ =
false;
18009 if (!!(config_.flags & format_flags::quote_dates_and_times))
18014 naked_newline_ =
false;
18023 case node_type::string:
18026 case node_type::integer:
18029 case node_type::floating_point:
18032 case node_type::boolean:
18035 case node_type::date:
18038 case node_type::time:
18041 case node_type::date_time:
18049# if TOML_ENABLE_PARSER && !TOML_EXCEPTIONS
18054 if (result_ && !(*result_))
18056 stream() << result_->error();
18076# pragma pop_macro("min")
18077# pragma pop_macro("max")
18079# pragma inline_recursion(off)
18088# if TOML_ENABLE_FORMATTERS
18093# pragma inline_recursion(on)
18095# pragma push_macro("min")
18096# pragma push_macro("max")
18106 size_t toml_formatter_count_inline_columns(
18107 const node &node,
size_t line_wrap_cols)
noexcept
18109 switch (node.type())
18111 case node_type::table:
18113 auto &tbl = *
reinterpret_cast<const table *
>(&node);
18116 size_t weight = 3u;
18117 for (
auto &&[k, v] : tbl)
18119 weight += k.length() +
18120 toml_formatter_count_inline_columns(v, line_wrap_cols) +
18122 if (weight >= line_wrap_cols)
18128 case node_type::array:
18130 auto &arr = *
reinterpret_cast<const array *
>(&node);
18133 size_t weight = 3u;
18134 for (
auto &elem : arr)
18136 weight += toml_formatter_count_inline_columns(elem, line_wrap_cols) +
18138 if (weight >= line_wrap_cols)
18144 case node_type::string:
18149 return str.length() + 2u;
18152 case node_type::integer:
18154 auto val = (*
reinterpret_cast<const value<int64_t> *
>(&node)).get();
18157 size_t weight = {};
18163 return weight +
static_cast<size_t>(
log10(
static_cast<double>(val))) + 1u;
18166 case node_type::floating_point:
18168 auto val = (*
reinterpret_cast<const value<double> *
>(&node)).get();
18171 size_t weight = 2u;
18177 return weight +
static_cast<size_t>(
log10(val)) + 1u;
18180 case node_type::boolean:
18182 case node_type::date:
18184 case node_type::time:
18186 case node_type::date_time:
18188 case node_type::none:
18198 bool toml_formatter_forces_multiline(
18200 size_t line_wrap_cols,
18201 size_t starting_column_bias)
noexcept
18203 return (toml_formatter_count_inline_columns(node, line_wrap_cols) +
18204 starting_column_bias) >= line_wrap_cols;
18212 void toml_formatter::print_pending_table_separator()
18214 if (pending_table_separator_)
18216 print_newline(
true);
18217 print_newline(
true);
18218 pending_table_separator_ =
false;
18223 void toml_formatter::print(
const key &k)
18225 print_string(k.str(),
false,
true,
false);
18229 void toml_formatter::print_inline(
const table &tbl)
18233 print_unformatted(
"{}"sv);
18237 print_unformatted(
"{ "sv);
18239 bool first =
false;
18240 for (
auto &&[k, v] : tbl)
18243 print_unformatted(
", "sv);
18248 print_unformatted(
"="sv);
18250 print_unformatted(
" = "sv);
18252 const auto type = v.type();
18256 case node_type::table:
18257 print_inline(*
reinterpret_cast<const table *
>(&v));
18259 case node_type::array:
18260 print(*
reinterpret_cast<const array *
>(&v));
18263 print_value(v, type);
18267 print_unformatted(
" }"sv);
18271 void toml_formatter::print(
const array &arr)
18275 print_unformatted(
"[]"sv);
18279 const auto original_indent = indent();
18280 const auto multiline = TOML_ANON_NAMESPACE::toml_formatter_forces_multiline(
18284 static_cast<size_t>(original_indent < 0 ? 0 : original_indent));
18286 print_unformatted(
"["sv);
18290 if (original_indent < 0)
18296 print_unformatted(
' ');
18298 for (
size_t i = 0; i < arr.
size(); i++)
18302 print_unformatted(
',');
18304 print_unformatted(
' ');
18309 print_newline(
true);
18314 const auto type = v.type();
18318 case node_type::table:
18319 print_inline(*
reinterpret_cast<const table *
>(&v));
18321 case node_type::array:
18322 print(*
reinterpret_cast<const array *
>(&v));
18325 print_value(v, type);
18330 indent(original_indent);
18331 print_newline(
true);
18335 print_unformatted(
' ');
18337 print_unformatted(
"]"sv);
18341 void toml_formatter::print(
const table &tbl)
18343 static constexpr auto is_non_inline_array_of_tables =
18344 [](
const node &n)
noexcept
18350 return !
reinterpret_cast<const table *
>(&(*arr)[0])->is_inline();
18354 for (
auto &&[k, v] : tbl)
18356 const auto type = v.type();
18358 (type == node_type::table &&
18359 !
reinterpret_cast<const table *
>(&v)->is_inline()) ||
18360 (type == node_type::array && is_non_inline_array_of_tables(v)))
18363 pending_table_separator_ =
true;
18368 print_unformatted(
"="sv);
18370 print_unformatted(
" = "sv);
18374 case node_type::table:
18375 print_inline(*
reinterpret_cast<const table *
>(&v));
18377 case node_type::array:
18378 print(*
reinterpret_cast<const array *
>(&v));
18381 print_value(v, type);
18385 const auto print_key_path = [&]()
18388 for (
const auto k : key_path_)
18391 print_unformatted(
'.');
18397 for (
auto &&[k, v] : tbl)
18399 const auto type = v.type();
18401 type != node_type::table ||
18402 reinterpret_cast<const table *
>(&v)->is_inline())
18404 auto &child_tbl = *
reinterpret_cast<const table *
>(&v);
18408 size_t child_value_count{};
18409 size_t child_table_count{};
18410 size_t child_table_array_count{};
18411 for (
auto &&[child_k, child_v] : child_tbl)
18414 const auto child_type = child_v.type();
18416 switch (child_type)
18418 case node_type::table:
18419 if (
reinterpret_cast<const table *
>(&child_v)->is_inline())
18420 child_value_count++;
18422 child_table_count++;
18425 case node_type::array:
18426 if (is_non_inline_array_of_tables(child_v))
18427 child_table_array_count++;
18429 child_value_count++;
18433 child_value_count++;
18436 bool skip_self =
false;
18438 child_value_count == 0u &&
18439 (child_table_count > 0u || child_table_array_count > 0u))
18442 key_path_.push_back(&k);
18446 print_pending_table_separator();
18450 print_unformatted(
"["sv);
18452 print_unformatted(
"]"sv);
18453 pending_table_separator_ =
true;
18458 key_path_.pop_back();
18464 for (
auto &&[k, v] : tbl)
18466 if (!is_non_inline_array_of_tables(v))
18468 auto &arr = *
reinterpret_cast<const array *
>(&v);
18472 key_path_.push_back(&k);
18474 for (
size_t i = 0; i < arr.
size(); i++)
18476 print_pending_table_separator();
18478 print_unformatted(
"[["sv);
18480 print_unformatted(
"]]"sv);
18481 pending_table_separator_ =
true;
18482 print(*
reinterpret_cast<const table *
>(&arr[i]));
18485 key_path_.pop_back();
18492 void toml_formatter::print()
18494 if (dump_failed_parse_result())
18497 switch (
auto source_type = source().
type())
18499 case node_type::table:
18501 auto &tbl = *
reinterpret_cast<const table *
>(&source());
18502 if (tbl.is_inline())
18512 case node_type::array:
18513 print(*
reinterpret_cast<const array *
>(&source()));
18517 print_value(source(), source_type);
18524# pragma pop_macro("min")
18525# pragma pop_macro("max")
18527# pragma inline_recursion(off)
18536# if TOML_ENABLE_FORMATTERS
18541# pragma inline_recursion(on)
18543# pragma push_macro("min")
18544# pragma push_macro("max")
18552 void json_formatter::print(
const toml::table &tbl)
18556 print_unformatted(
"{}"sv);
18560 print_unformatted(
'{');
18564 bool first =
false;
18565 for (
auto &&[k, v] : tbl)
18568 print_unformatted(
',');
18570 print_newline(
true);
18573 print_string(k.str(),
false);
18575 print_unformatted(
":"sv);
18577 print_unformatted(
" : "sv);
18579 const auto type = v.type();
18583 case node_type::table:
18584 print(*
reinterpret_cast<const table *
>(&v));
18586 case node_type::array:
18587 print(*
reinterpret_cast<const array *
>(&v));
18590 print_value(v, type);
18595 print_newline(
true);
18598 print_unformatted(
'}');
18602 void json_formatter::print(
const toml::array &arr)
18606 print_unformatted(
"[]"sv);
18610 print_unformatted(
'[');
18613 for (
size_t i = 0; i < arr.size(); i++)
18616 print_unformatted(
',');
18617 print_newline(
true);
18621 const auto type = v.type();
18625 case node_type::table:
18626 print(*
reinterpret_cast<const table *
>(&v));
18628 case node_type::array:
18629 print(*
reinterpret_cast<const array *
>(&v));
18632 print_value(v, type);
18637 print_newline(
true);
18639 print_unformatted(
']');
18643 void json_formatter::print()
18645 if (dump_failed_parse_result())
18648 switch (
auto source_type = source().
type())
18650 case node_type::table:
18651 print(*
reinterpret_cast<const table *
>(&source()));
18653 case node_type::array:
18654 print(*
reinterpret_cast<const array *
>(&source()));
18657 print_value(source(), source_type);
18664# pragma pop_macro("min")
18665# pragma pop_macro("max")
18667# pragma inline_recursion(off)
18676# if TOML_ENABLE_FORMATTERS
18681# pragma inline_recursion(on)
18683# pragma push_macro("min")
18684# pragma push_macro("max")
18700 bool contains_newline =
false;
18701 for (
auto c = str->c_str(), e = str->c_str() + str->length();
18702 c < e && !contains_newline;
18704 contains_newline = *c ==
'\n';
18706 if (contains_newline)
18708 print_unformatted(
"|-"sv);
18712 auto line_end = str->c_str() - 1u;
18713 const auto end = str->c_str() + str->length();
18714 while (line_end != end)
18716 auto line_start = line_end + 1u;
18717 line_end = line_start;
18718 for (; line_end !=
end && *line_end !=
'\n'; line_end++)
18721 if TOML_LIKELY (line_start != line_end || line_end != end)
18725 print_unformatted(std::string_view{
18726 line_start,
static_cast<size_t>(line_end - line_start)});
18733 print_string(*str,
false,
true);
18737 void yaml_formatter::print(
const toml::table &tbl,
bool parent_is_array)
18741 print_unformatted(
"{}"sv);
18747 for (
auto &&[k, v] : tbl)
18749 if (!parent_is_array)
18754 parent_is_array =
false;
18756 print_string(k.str(),
false,
true);
18758 print_unformatted(
":"sv);
18760 print_unformatted(
": "sv);
18762 const auto type = v.type();
18766 case node_type::table:
18767 print(*
reinterpret_cast<const table *
>(&v));
18769 case node_type::array:
18770 print(*
reinterpret_cast<const array *
>(&v));
18772 case node_type::string:
18776 print_value(v, type);
18784 void yaml_formatter::print(
const toml::array &arr,
bool parent_is_array)
18788 print_unformatted(
"[]"sv);
18794 for (
auto &&v : arr)
18796 if (!parent_is_array)
18801 parent_is_array =
false;
18803 print_unformatted(
"- "sv);
18805 const auto type = v.type();
18809 case node_type::table:
18810 print(*
reinterpret_cast<const table *
>(&v),
true);
18812 case node_type::array:
18813 print(*
reinterpret_cast<const array *
>(&v),
true);
18815 case node_type::string:
18819 print_value(v, type);
18827 void yaml_formatter::print()
18829 if (dump_failed_parse_result())
18832 switch (
auto source_type = source().
type())
18834 case node_type::table:
18836 print(*
reinterpret_cast<const table *
>(&source()));
18839 case node_type::array:
18840 print(*
reinterpret_cast<const array *
>(&source()));
18843 case node_type::string:
18849 print_value(source(), source_type);
18856# pragma pop_macro("min")
18857# pragma pop_macro("max")
18859# pragma inline_recursion(off)
18871#if TOML_UNDEF_MACROS
18872# undef TOML_ABI_NAMESPACE_BOOL
18873# undef TOML_ABI_NAMESPACE_END
18874# undef TOML_ABI_NAMESPACE_START
18875# undef TOML_ABI_NAMESPACES
18876# undef TOML_ABSTRACT_INTERFACE
18877# undef TOML_ALWAYS_INLINE
18878# undef TOML_ANON_NAMESPACE
18879# undef TOML_ANON_NAMESPACE_END
18880# undef TOML_ANON_NAMESPACE_START
18881# undef TOML_ARCH_AMD64
18882# undef TOML_ARCH_ARM
18883# undef TOML_ARCH_ARM32
18884# undef TOML_ARCH_ARM64
18885# undef TOML_ARCH_BITNESS
18886# undef TOML_ARCH_ITANIUM
18887# undef TOML_ARCH_X64
18888# undef TOML_ARCH_X86
18890# undef TOML_ASSERT_ASSUME
18892# undef TOML_ASYMMETRICAL_EQUALITY_OPS
18895# undef TOML_CLANG_VERSION
18896# undef TOML_CLOSED_ENUM
18897# undef TOML_CLOSED_FLAGS_ENUM
18898# undef TOML_COMPILER_HAS_EXCEPTIONS
18899# undef TOML_COMPILER_HAS_RTTI
18901# undef TOML_CONST_GETTER
18902# undef TOML_CONST_INLINE_GETTER
18903# undef TOML_CONSTRAINED_TEMPLATE
18905# undef TOML_DECLSPEC
18906# undef TOML_DELETE_DEFAULTS
18907# undef TOML_DISABLE_ARITHMETIC_WARNINGS
18908# undef TOML_DISABLE_CODE_ANALYSIS_WARNINGS
18909# undef TOML_DISABLE_SPAM_WARNINGS
18910# undef TOML_DISABLE_SPAM_WARNINGS_CLANG_10
18911# undef TOML_DISABLE_SPAM_WARNINGS_CLANG_11
18912# undef TOML_DISABLE_SUGGEST_ATTR_WARNINGS
18913# undef TOML_DISABLE_SWITCH_WARNINGS
18914# undef TOML_DISABLE_WARNINGS
18915# undef TOML_DOXYGEN
18916# undef TOML_EMPTY_BASES
18917# undef TOML_ENABLE_IF
18918# undef TOML_ENABLE_WARNINGS
18919# undef TOML_EVAL_BOOL_0
18920# undef TOML_EVAL_BOOL_1
18921# undef TOML_EXTERNAL_LINKAGE
18922# undef TOML_FLAGS_ENUM
18923# undef TOML_FLOAT_CHARCONV
18924# undef TOML_FLOAT128
18925# undef TOML_FLOAT16_DIG
18926# undef TOML_FLOAT16_LIMITS_SET
18927# undef TOML_FLOAT16_MANT_DIG
18928# undef TOML_FLOAT16_MAX_10_EXP
18929# undef TOML_FLOAT16_MAX_EXP
18930# undef TOML_FLOAT16_MIN_10_EXP
18931# undef TOML_FLOAT16_MIN_EXP
18933# undef TOML_GCC_LIKE
18934# undef TOML_HAS_ATTR
18935# undef TOML_HAS_BUILTIN
18936# undef TOML_HAS_CHAR8
18937# undef TOML_HAS_CPP_ATTR
18938# undef TOML_HAS_CUSTOM_OPTIONAL_TYPE
18939# undef TOML_HAS_FEATURE
18940# undef TOML_HAS_INCLUDE
18941# undef TOML_HAS_SSE2
18942# undef TOML_HAS_SSE4_1
18943# undef TOML_HIDDEN_CONSTRAINT
18946# undef TOML_IMPL_NAMESPACE_END
18947# undef TOML_IMPL_NAMESPACE_START
18948# undef TOML_IMPLEMENTATION
18949# undef TOML_INCLUDE_WINDOWS_H
18950# undef TOML_INLINE_GETTER
18951# undef TOML_INT_CHARCONV
18953# undef TOML_INTELLISENSE
18954# undef TOML_INTERNAL_LINKAGE
18955# undef TOML_LANG_AT_LEAST
18956# undef TOML_LANG_EFFECTIVE_VERSION
18957# undef TOML_LANG_HIGHER_THAN
18958# undef TOML_LANG_UNRELEASED
18959# undef TOML_LAUNDER
18960# undef TOML_LIFETIME_HOOKS
18962# undef TOML_LIKELY_CASE
18964# undef TOML_MAKE_FLAGS
18965# undef TOML_MAKE_FLAGS_
18966# undef TOML_MAKE_FLAGS_1
18967# undef TOML_MAKE_FLAGS_2
18968# undef TOML_MAKE_STRING
18969# undef TOML_MAKE_STRING_1
18970# undef TOML_MAKE_VERSION
18972# undef TOML_MSVC_LIKE
18973# undef TOML_NAMESPACE
18974# undef TOML_NEVER_INLINE
18975# undef TOML_NODISCARD
18976# undef TOML_NODISCARD_CTOR
18978# undef TOML_OPEN_ENUM
18979# undef TOML_OPEN_FLAGS_ENUM
18980# undef TOML_PARSER_TYPENAME
18981# undef TOML_POP_WARNINGS
18982# undef TOML_PRAGMA_CLANG
18983# undef TOML_PRAGMA_CLANG_GE_10
18984# undef TOML_PRAGMA_CLANG_GE_11
18985# undef TOML_PRAGMA_CLANG_GE_8
18986# undef TOML_PRAGMA_CLANG_GE_9
18987# undef TOML_PRAGMA_GCC
18988# undef TOML_PRAGMA_ICC
18989# undef TOML_PRAGMA_MSVC
18991# undef TOML_PURE_GETTER
18992# undef TOML_PURE_INLINE_GETTER
18993# undef TOML_PUSH_WARNINGS
18994# undef TOML_REQUIRES
18995# undef TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN
18996# undef TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_MESSAGE
18997# undef TOML_SA_LIST_BEG
18998# undef TOML_SA_LIST_END
18999# undef TOML_SA_LIST_NEW
19000# undef TOML_SA_LIST_NXT
19001# undef TOML_SA_LIST_SEP
19002# undef TOML_SA_NATIVE_VALUE_TYPE_LIST
19003# undef TOML_SA_NEWLINE
19004# undef TOML_SA_NODE_TYPE_LIST
19005# undef TOML_SA_UNWRAPPED_NODE_TYPE_LIST
19006# undef TOML_SA_VALUE_EXACT_FUNC_MESSAGE
19007# undef TOML_SA_VALUE_FUNC_MESSAGE
19008# undef TOML_SA_VALUE_MESSAGE_CONST_CHAR8
19009# undef TOML_SA_VALUE_MESSAGE_U8STRING_VIEW
19010# undef TOML_SA_VALUE_MESSAGE_WSTRING
19011# undef TOML_SIMPLE_STATIC_ASSERT_MESSAGES
19012# undef TOML_TRIVIAL_ABI
19013# undef TOML_UINT128
19015# undef TOML_UNLIKELY
19016# undef TOML_UNLIKELY_CASE
19017# undef TOML_UNREACHABLE
19019# undef TOML_WINDOWS
static const twodig_t base
Definition bigint.cpp:28
#define error(x)
Definition bigint.cpp:16
BigInt operator+(const BigInt &lhs, const BigInt &rhs)
Definition bigint.hh:341
BigInt operator*(const BigInt &lhs, const BigInt &rhs)
Definition bigint.hh:349
bool operator<(const BigInt &lhs, const BigInt &rhs)
Definition bigint.hh:406
bool operator>(const BigInt &lhs, const BigInt &rhs)
Definition bigint.hh:410
BigInt operator-(const BigInt &lhs, const BigInt &rhs)
Definition bigint.hh:345
bool operator!=(const BigInt &lhs, const BigInt &rhs)
Definition bigint.hh:426
bool operator<=(const BigInt &lhs, const BigInt &rhs)
Definition bigint.hh:414
bool operator==(const BigInt &lhs, const BigInt &rhs)
Definition bigint.hh:422
bool operator>=(const BigInt &lhs, const BigInt &rhs)
Definition bigint.hh:418
@ none
Definition builtin_names.h:35
static void parse_float(llvm::SmallVectorImpl< char > &src, BigInt &significand, BigInt &exponent)
Definition clang_c_convert_literals.cpp:96
TOML_NODISCARD_CTOR parse_error(std::string &&desc, source_region &&src) noexcept
Definition toml.hpp:9661
TOML_NODISCARD_CTOR parse_error(std::string &&desc, const source_region &src) noexcept
Definition toml.hpp:9667
friend std::ostream & operator<<(std::ostream &lhs, const parse_error &rhs)
Definition toml.hpp:9699
TOML_NODISCARD const source_region & source() const noexcept
Definition toml.hpp:9694
TOML_NODISCARD_CTOR parse_error(std::string &&desc, const source_position &position, const source_path_ptr &path={}) noexcept
Definition toml.hpp:9673
TOML_NODISCARD std::string_view description() const noexcept
Definition toml.hpp:9684
iterator emplace(const_iterator pos, Args &&...args)
Definition toml.hpp:7437
TOML_NODISCARD iterator begin() noexcept
Definition toml.hpp:6987
TOML_CONST_INLINE_GETTER table * as_table() noexcept final
Definition toml.hpp:6801
TOML_PURE_INLINE_GETTER node * get(size_t index) noexcept
Definition toml.hpp:6909
TOML_PURE_GETTER bool is_homogeneous() const noexcept
Definition toml.hpp:6716
TOML_EXPORTED_MEMBER_FUNCTION void reserve(size_t new_capacity)
TOML_NODISCARD friend bool operator==(const array &lhs, const std::initializer_list< T > &rhs) noexcept
Definition toml.hpp:7567
TOML_CONST_INLINE_GETTER bool is_boolean() const noexcept final
Definition toml.hpp:6777
TOML_CONST_INLINE_GETTER bool is_array() const noexcept final
Definition toml.hpp:6735
TOML_CONST_INLINE_GETTER bool is_date_time() const noexcept final
Definition toml.hpp:6795
TOML_NODISCARD friend bool operator==(const array &lhs, const std::vector< T > &rhs) noexcept
Definition toml.hpp:7579
TOML_CONSTRAINED_TEMPLATE((sizeof...(ElemTypes) > 0||!std::is_same_v< impl::remove_cvref< ElemType >, array >), typename ElemType, typename... ElemTypes) TOML_NODISCARD_CTOR explicit array(ElemType &&val
TOML_EXPORTED_MEMBER_FUNCTION ~array() noexcept
TOML_EXPORTED_MEMBER_FUNCTION array & operator=(array &&rhs) noexcept
TOML_CONST_INLINE_GETTER toml::value< double > * as_floating_point() noexcept final
Definition toml.hpp:6825
TOML_CONST_INLINE_GETTER const toml::value< bool > * as_boolean() const noexcept final
Definition toml.hpp:6885
TOML_NODISCARD iterator end() noexcept
Definition toml.hpp:7005
const array & for_each(Func &&visitor) const &noexcept(for_each_is_nothrow< Func &&, const array & >::value)
Definition toml.hpp:7233
TOML_CONST_INLINE_GETTER bool is_string() const noexcept final
Definition toml.hpp:6753
TOML_NODISCARD const_iterator cbegin() const noexcept
Definition toml.hpp:6999
TOML_CONST_INLINE_GETTER toml::value< std::string > * as_string() noexcept final
Definition toml.hpp:6813
TOML_NODISCARD node & back() noexcept
Definition toml.hpp:6971
array && prune(bool recursive=true) &&noexcept
Definition toml.hpp:7322
TOML_NODISCARD size_t capacity() const noexcept
Definition toml.hpp:7268
iterator insert(const_iterator pos, size_t count, ElemType &&val, value_flags flags=preserve_source_value_flags)
Definition toml.hpp:7350
TOML_NODISCARD friend bool operator!=(const array &lhs, const array &rhs) noexcept
Definition toml.hpp:7560
TOML_CONST_INLINE_GETTER bool is_floating_point() const noexcept final
Definition toml.hpp:6765
TOML_CONST_INLINE_GETTER toml::value< bool > * as_boolean() noexcept final
Definition toml.hpp:6831
TOML_PURE_INLINE_GETTER const node * get(size_t index) const noexcept
Definition toml.hpp:6915
TOML_EXPORTED_MEMBER_FUNCTION iterator erase(const_iterator pos) noexcept
TOML_ASYMMETRICAL_EQUALITY_OPS(const array &, const std::vector< T > &, template< typename T >)
array && for_each(Func &&visitor) &&noexcept(for_each_is_nothrow< Func &&, array && >::value)
Definition toml.hpp:7225
TOML_ASYMMETRICAL_EQUALITY_OPS(const array &, const std::initializer_list< T > &, template< typename T >)
TOML_NODISCARD const node & operator[](size_t index) const noexcept
Definition toml.hpp:6943
TOML_NODISCARD const_iterator cend() const noexcept
Definition toml.hpp:7017
TOML_EXPORTED_MEMBER_FUNCTION void pop_back() noexcept
TOML_CONST_INLINE_GETTER const toml::value< time > * as_time() const noexcept final
Definition toml.hpp:6897
TOML_CONST_INLINE_GETTER bool is_time() const noexcept final
Definition toml.hpp:6789
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION node & at(size_t index)
TOML_CONST_INLINE_GETTER const toml::value< date_time > * as_date_time() const noexcept final
Definition toml.hpp:6903
TOML_CONST_INLINE_GETTER bool is_integer() const noexcept final
Definition toml.hpp:6759
TOML_EXPORTED_MEMBER_FUNCTION array & prune(bool recursive=true) &noexcept
array && flatten() &&
Definition toml.hpp:7314
TOML_EXPORTED_MEMBER_FUNCTION void clear() noexcept
TOML_CONST_INLINE_GETTER toml::value< int64_t > * as_integer() noexcept final
Definition toml.hpp:6819
TOML_PURE_GETTER bool is_array_of_tables() const noexcept final
Definition toml.hpp:6741
TOML_NODISCARD const_iterator begin() const noexcept
Definition toml.hpp:6993
TOML_NODISCARD const_iterator end() const noexcept
Definition toml.hpp:7011
TOML_CONST_INLINE_GETTER const array * as_array() const noexcept final
Definition toml.hpp:6861
iterator insert(const_iterator pos, std::initializer_list< ElemType > ilist, value_flags flags=preserve_source_value_flags)
Definition toml.hpp:7428
const array && for_each(Func &&visitor) const &&noexcept(for_each_is_nothrow< Func &&, const array && >::value)
Definition toml.hpp:7241
TOML_EXPORTED_MEMBER_FUNCTION iterator erase(const_iterator first, const_iterator last) noexcept
TOML_EXPORTED_MEMBER_FUNCTION void truncate(size_t new_size)
node & reference
Definition toml.hpp:6657
TOML_NODISCARD friend bool operator==(const array &lhs, const array &rhs) noexcept
Definition toml.hpp:7554
TOML_CONST_INLINE_GETTER toml::value< date_time > * as_date_time() noexcept final
Definition toml.hpp:6849
TOML_CONST_INLINE_GETTER node_type type() const noexcept final
Definition toml.hpp:6697
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION bool is_homogeneous(node_type ntype, const node *&first_nonmatch) const noexcept final
TOML_CONST_INLINE_GETTER const table * as_table() const noexcept final
Definition toml.hpp:6855
array & for_each(Func &&visitor) &noexcept(for_each_is_nothrow< Func &&, array & >::value)
Definition toml.hpp:7217
TOML_CONST_INLINE_GETTER bool is_value() const noexcept final
Definition toml.hpp:6747
TOML_NODISCARD node & operator[](size_t index) noexcept
Definition toml.hpp:6937
TOML_NODISCARD bool empty() const noexcept
Definition toml.hpp:7250
decltype(auto) emplace_back(Args &&...args)
Definition toml.hpp:7485
TOML_NODISCARD size_t max_size() const noexcept
Definition toml.hpp:7262
size_t size_type
Definition toml.hpp:6655
TOML_CONST_INLINE_GETTER const toml::value< double > * as_floating_point() const noexcept final
Definition toml.hpp:6879
TOML_CONST_INLINE_GETTER const toml::value< int64_t > * as_integer() const noexcept final
Definition toml.hpp:6873
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION bool is_homogeneous(node_type ntype, node *&first_nonmatch) noexcept final
TOML_PURE_GETTER TOML_EXPORTED_MEMBER_FUNCTION bool is_homogeneous(node_type ntype) const noexcept final
TOML_CONST_INLINE_GETTER const toml::value< std::string > * as_string() const noexcept final
Definition toml.hpp:6867
TOML_CONST_INLINE_GETTER toml::value< time > * as_time() noexcept final
Definition toml.hpp:6843
ptrdiff_t difference_type
Definition toml.hpp:6656
TOML_NODISCARD const node & at(size_t index) const
Definition toml.hpp:6953
void resize(size_t new_size, ElemType &&default_init_val, value_flags default_init_flags=preserve_source_value_flags)
Definition toml.hpp:7283
TOML_NODISCARD node & front() noexcept
Definition toml.hpp:6959
TOML_EXPORTED_MEMBER_FUNCTION array & flatten() &
ElemTypes && vals
Definition toml.hpp:6683
iterator replace(const_iterator pos, ElemType &&val, value_flags flags=preserve_source_value_flags)
Definition toml.hpp:7458
TOML_CONST_INLINE_GETTER const toml::value< date > * as_date() const noexcept final
Definition toml.hpp:6891
TOML_CONST_INLINE_GETTER toml::value< date > * as_date() noexcept final
Definition toml.hpp:6837
friend std::ostream & operator<<(std::ostream &lhs, const array &rhs)
Definition toml.hpp:7591
array_iterator iterator
Definition toml.hpp:6982
TOML_CONST_INLINE_GETTER bool is_number() const noexcept final
Definition toml.hpp:6771
const_array_iterator const_iterator
Definition toml.hpp:6984
iterator insert(const_iterator pos, Iter first, Iter last, value_flags flags=preserve_source_value_flags)
Definition toml.hpp:7384
TOML_CONST_INLINE_GETTER array * as_array() noexcept final
Definition toml.hpp:6807
TOML_NODISCARD impl::wrap_node< ElemType > * get_as(size_t index) noexcept
Definition toml.hpp:6921
TOML_EXPORTED_MEMBER_FUNCTION void shrink_to_fit()
TOML_NODISCARD_CTOR TOML_EXPORTED_MEMBER_FUNCTION array() noexcept
TOML_NODISCARD const node & front() const noexcept
Definition toml.hpp:6965
TOML_NODISCARD const node & back() const noexcept
Definition toml.hpp:6977
TOML_NODISCARD size_t size() const noexcept
Definition toml.hpp:7256
iterator insert(const_iterator pos, ElemType &&val, value_flags flags=preserve_source_value_flags)
Definition toml.hpp:7334
node value_type
Definition toml.hpp:6654
TOML_CONST_INLINE_GETTER bool is_table() const noexcept final
Definition toml.hpp:6729
TOML_NODISCARD const impl::wrap_node< ElemType > * get_as(size_t index) const noexcept
Definition toml.hpp:6930
const node & const_reference
Definition toml.hpp:6658
TOML_CONST_INLINE_GETTER bool is_date() const noexcept final
Definition toml.hpp:6783
void push_back(ElemType &&val, value_flags flags=preserve_source_value_flags)
Definition toml.hpp:7479
TOML_NODISCARD toml::table && table() &&noexcept
Definition toml.hpp:9866
TOML_NODISCARD toml::table & table() &noexcept
Definition toml.hpp:9859
TOML_NODISCARD node_view< const node > operator[](const toml::path &path) const noexcept
Definition toml.hpp:10023
TOML_NODISCARD node_view< node > at_path(std::string_view path) noexcept
Definition toml.hpp:9977
TOML_NODISCARD node_view< node > at_path(const toml::path &path) noexcept
Definition toml.hpp:9989
TOML_NODISCARD const toml::table & table() const &noexcept
Definition toml.hpp:9873
TOML_NODISCARD const_table_iterator begin() const noexcept
Definition toml.hpp:9947
TOML_NODISCARD bool failed() const noexcept
Definition toml.hpp:9847
friend std::ostream & operator<<(std::ostream &os, const parse_result &result)
Definition toml.hpp:10059
TOML_NODISCARD_CTOR parse_result(parse_result &&res) noexcept
Definition toml.hpp:9801
TOML_NODISCARD node_view< const node > at_path(const toml::path &path) const noexcept
Definition toml.hpp:9995
TOML_NODISCARD table_iterator end() noexcept
Definition toml.hpp:9959
~parse_result() noexcept
Definition toml.hpp:9835
TOML_NODISCARD_CTOR parse_result(toml::table &&tbl) noexcept
Definition toml.hpp:9787
table_iterator iterator
Definition toml.hpp:9936
TOML_NODISCARD table_iterator begin() noexcept
Definition toml.hpp:9941
const_table_iterator const_iterator
Definition toml.hpp:9938
parse_result & operator=(parse_result &&rhs) noexcept
Definition toml.hpp:9812
TOML_NODISCARD_CTOR parse_result() noexcept
Definition toml.hpp:9779
TOML_NODISCARD node_view< node > operator[](std::string_view key) noexcept
Definition toml.hpp:10029
TOML_NODISCARD const_table_iterator end() const noexcept
Definition toml.hpp:9965
TOML_NODISCARD node_view< const node > operator[](std::string_view key) const noexcept
Definition toml.hpp:10035
TOML_NODISCARD_CTOR parse_result(parse_error &&err) noexcept
Definition toml.hpp:9794
TOML_NODISCARD const_table_iterator cend() const noexcept
Definition toml.hpp:9971
TOML_NODISCARD node_view< node > operator[](const toml::path &path) noexcept
Definition toml.hpp:10017
TOML_NODISCARD parse_error && error() &&noexcept
Definition toml.hpp:9905
TOML_NODISCARD const parse_error & error() const &noexcept
Definition toml.hpp:9912
TOML_NODISCARD node_view< const node > at_path(std::string_view path) const noexcept
Definition toml.hpp:9983
TOML_NODISCARD bool succeeded() const noexcept
Definition toml.hpp:9841
TOML_NODISCARD parse_error & error() &noexcept
Definition toml.hpp:9898
TOML_NODISCARD const_table_iterator cbegin() const noexcept
Definition toml.hpp:9953
parser(utf8_reader_interface &&reader_)
Definition toml.hpp:17051
TOML_NODISCARD_CTOR TOML_EXPORTED_MEMBER_FUNCTION path_component()
TOML_EXPORTED_MEMBER_FUNCTION path_component & operator=(const path_component &rhs)
TOML_NODISCARD_CTOR TOML_EXPORTED_MEMBER_FUNCTION path_component(const path_component &pc)
TOML_PURE_GETTER const std::string & key() const noexcept
Definition toml.hpp:3351
TOML_PURE_INLINE_GETTER friend bool operator==(const path_component &lhs, const path_component &rhs) noexcept
Definition toml.hpp:3371
~path_component() noexcept
Definition toml.hpp:3332
TOML_PURE_INLINE_GETTER friend bool operator!=(const path_component &lhs, const path_component &rhs) noexcept
Definition toml.hpp:3378
TOML_EXPORTED_MEMBER_FUNCTION path_component & operator=(std::string_view new_key)
TOML_EXPORTED_MEMBER_FUNCTION path_component & operator=(size_t new_index) noexcept
TOML_PURE_GETTER size_t index() const noexcept
Definition toml.hpp:3338
TOML_NODISCARD_CTOR TOML_EXPORTED_MEMBER_FUNCTION path_component(size_t index) noexcept
TOML_NODISCARD_CTOR TOML_EXPORTED_MEMBER_FUNCTION path_component(std::string_view key)
TOML_PURE_INLINE_GETTER path_component_type type() const noexcept
Definition toml.hpp:3364
TOML_NODISCARD_CTOR TOML_EXPORTED_MEMBER_FUNCTION path_component(path_component &&pc) noexcept
TOML_EXPORTED_MEMBER_FUNCTION path_component & operator=(path_component &&rhs) noexcept
TOML_NODISCARD TOML_ALWAYS_INLINE friend bool operator!=(std::string_view lhs, const path &rhs)
Definition toml.hpp:3666
TOML_EXPORTED_MEMBER_FUNCTION void clear() noexcept
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION path parent() const
TOML_EXPORTED_MEMBER_FUNCTION path & truncate(size_t n)
TOML_PURE_INLINE_GETTER friend bool operator!=(const path &lhs, const path &rhs) noexcept
Definition toml.hpp:3638
TOML_NODISCARD TOML_ALWAYS_INLINE friend bool operator!=(const path &lhs, std::string_view rhs)
Definition toml.hpp:3659
std::vector< path_component >::const_iterator const_iterator
Definition toml.hpp:3705
TOML_PURE_INLINE_GETTER friend bool operator==(const path &lhs, const path &rhs) noexcept
Definition toml.hpp:3632
TOML_PURE_INLINE_GETTER const path_component & operator[](size_t index) const noexcept
Definition toml.hpp:3446
TOML_ALWAYS_INLINE friend std::ostream & operator<<(std::ostream &os, const path &rhs)
Definition toml.hpp:3599
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION path truncated(size_t n) const
TOML_PURE_INLINE_GETTER iterator end() noexcept
Definition toml.hpp:3714
TOML_ALWAYS_INLINE path & append(std::string_view str)
Definition toml.hpp:3523
TOML_EXPORTED_MEMBER_FUNCTION path & prepend(path &&)
std::vector< path_component >::iterator iterator
Definition toml.hpp:3703
TOML_NODISCARD friend path operator+(const path &lhs, std::string_view rhs)
Definition toml.hpp:3563
TOML_PURE_INLINE_GETTER size_t size() const noexcept
Definition toml.hpp:3421
TOML_NODISCARD friend path operator+(std::string_view lhs, const path &rhs)
Definition toml.hpp:3571
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION std::string str() const
TOML_EXPORTED_MEMBER_FUNCTION path & operator+=(path &&)
TOML_NODISCARD_CTOR path() noexcept=default
TOML_PURE_INLINE_GETTER iterator begin() noexcept
Definition toml.hpp:3708
TOML_PURE_INLINE_GETTER const_iterator begin() const noexcept
Definition toml.hpp:3720
path & operator=(path &&) noexcept=default
TOML_PURE_INLINE_GETTER path_component & operator[](size_t index) noexcept
Definition toml.hpp:3439
TOML_EXPORTED_MEMBER_FUNCTION path & prepend(std::string_view)
TOML_ALWAYS_INLINE path & append(const path &p)
Definition toml.hpp:3511
TOML_EXPORTED_MEMBER_FUNCTION path & prepend(const path &)
TOML_PURE_INLINE_GETTER const_iterator end() const noexcept
Definition toml.hpp:3726
TOML_NODISCARD TOML_ALWAYS_INLINE friend bool operator==(std::string_view lhs, const path &rhs)
Definition toml.hpp:3652
TOML_PURE_INLINE_GETTER const_iterator cbegin() const noexcept
Definition toml.hpp:3732
TOML_EXPORTED_MEMBER_FUNCTION path & operator+=(const path &)
TOML_PURE_INLINE_GETTER bool empty() const noexcept
Definition toml.hpp:3433
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION path leaf(size_t n=1) const
TOML_ALWAYS_INLINE path & assign(const path &p)
Definition toml.hpp:3467
TOML_PURE_INLINE_GETTER const_iterator cend() const noexcept
Definition toml.hpp:3738
TOML_NODISCARD friend path operator+(const path &lhs, const path &rhs)
Definition toml.hpp:3555
TOML_EXPORTED_MEMBER_FUNCTION path & operator+=(std::string_view)
TOML_ALWAYS_INLINE path & assign(path &&p) noexcept
Definition toml.hpp:3473
TOML_ALWAYS_INLINE path & append(path &&p)
Definition toml.hpp:3517
path & operator=(const path &)=default
TOML_ALWAYS_INLINE path & assign(std::string_view str)
Definition toml.hpp:3479
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION path subpath(const_iterator start, const_iterator end) const
TOML_NODISCARD TOML_ALWAYS_INLINE friend bool operator==(const path &lhs, std::string_view rhs)
Definition toml.hpp:3645
table_iterator & operator=(const table_iterator &rhs) noexcept
Definition toml.hpp:7969
table_iterator & operator--() noexcept
Definition toml.hpp:7999
table_proxy_pair< IsConst > value_type
Definition toml.hpp:7976
TOML_NODISCARD_CTOR table_iterator(const table_iterator &other) noexcept
Definition toml.hpp:7964
table_iterator & operator++() noexcept
Definition toml.hpp:7984
TOML_NODISCARD_CTOR table_iterator(const table_iterator< false > &other) noexcept
Definition toml.hpp:7958
TOML_PURE_INLINE_GETTER friend bool operator==(const table_iterator &lhs, const table_iterator &rhs) noexcept
Definition toml.hpp:8041
TOML_NODISCARD_CTOR table_iterator() noexcept=default
table_iterator operator++(int) noexcept
Definition toml.hpp:7991
typename std::iterator_traits< map_iterator >::iterator_category iterator_category
Definition toml.hpp:7981
value_type * pointer
Definition toml.hpp:7978
table_iterator operator--(int) noexcept
Definition toml.hpp:8006
TOML_PURE_INLINE_GETTER pointer operator->() const noexcept
Definition toml.hpp:8021
typename std::iterator_traits< map_iterator >::difference_type difference_type
Definition toml.hpp:7979
TOML_NODISCARD_CTOR table_iterator(const_map_iterator iter) noexcept
Definition toml.hpp:7951
TOML_PURE_INLINE_GETTER friend bool operator!=(const table_iterator &lhs, const table_iterator &rhs) noexcept
Definition toml.hpp:8048
value_type & reference
Definition toml.hpp:7977
TOML_PURE_INLINE_GETTER reference operator*() const noexcept
Definition toml.hpp:8015
friend class table_iterator
Definition toml.hpp:7911
TOML_PURE_INLINE_GETTER const_iterator begin() const noexcept
Definition toml.hpp:8445
TOML_EXPORTED_MEMBER_FUNCTION table & prune(bool recursive=true) &noexcept
TOML_UNREACHABLE
Definition toml.hpp:8901
KeyType && key
Definition toml.hpp:8829
TOML_CONST_INLINE_GETTER bool is_date_time() const noexcept final
Definition toml.hpp:8222
TOML_NODISCARD const node & at(std::string_view key) const
Definition toml.hpp:8413
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION node & at(std::string_view key)
TOML_CONST_INLINE_GETTER bool is_string() const noexcept final
Definition toml.hpp:8180
TOML_PURE_INLINE_GETTER const node * get(std::string_view key) const noexcept
Definition toml.hpp:8351
TOML_CONST_INLINE_GETTER const toml::value< std::string > * as_string() const noexcept final
Definition toml.hpp:8294
TOML_CONST_INLINE_GETTER bool is_number() const noexcept final
Definition toml.hpp:8198
TOML_NODISCARD_CTOR TOML_EXPORTED_MEMBER_FUNCTION table() noexcept
iterator erase(const_iterator pos) noexcept
Definition toml.hpp:8781
table && for_each(Func &&visitor) &&noexcept(for_each_is_nothrow< Func &&, table && >::value)
Definition toml.hpp:8653
TOML_CONST_INLINE_GETTER const toml::value< double > * as_floating_point() const noexcept final
Definition toml.hpp:8306
TOML_CONST_INLINE_GETTER toml::value< bool > * as_boolean() noexcept final
Definition toml.hpp:8258
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION bool is_homogeneous(node_type ntype, const node *&first_nonmatch) const noexcept final
TOML_PURE_GETTER TOML_EXPORTED_MEMBER_FUNCTION node * get(std::string_view key) noexcept
TOML_CONST_INLINE_GETTER const toml::value< int64_t > * as_integer() const noexcept final
Definition toml.hpp:8300
table & for_each(Func &&visitor) &noexcept(for_each_is_nothrow< Func &&, table & >::value)
Definition toml.hpp:8645
TOML_PURE_INLINE_GETTER bool empty() const noexcept
Definition toml.hpp:8678
TOML_CONST_INLINE_GETTER const toml::value< time > * as_time() const noexcept final
Definition toml.hpp:8324
TOML_PURE_GETTER bool contains(std::string_view key) const noexcept
Definition toml.hpp:8738
Iter value_flags flags
Definition toml.hpp:8958
const table && for_each(Func &&visitor) const &&noexcept(for_each_is_nothrow< Func &&, const table && >::value)
Definition toml.hpp:8669
TOML_CONST_INLINE_GETTER bool is_array() const noexcept final
Definition toml.hpp:8162
TOML_CONST_INLINE_GETTER node_type type() const noexcept final
Definition toml.hpp:8124
TOML_CONSTRAINED_TEMPLATE((!is_key_or_convertible< Iter > &&!impl::is_wide_string< Iter >), typename Iter) void insert(Iter begin
TOML_CONST_INLINE_GETTER array * as_array() noexcept final
Definition toml.hpp:8234
iterator erase(const_iterator begin, const_iterator end) noexcept
Definition toml.hpp:8786
TOML_PURE_GETTER bool is_homogeneous() const noexcept
Definition toml.hpp:8143
toml::const_table_iterator const_iterator
Definition toml.hpp:8436
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION bool is_homogeneous(node_type ntype, node *&first_nonmatch) noexcept final
TOML_EXPORTED_MEMBER_FUNCTION table & operator=(table &&rhs) noexcept
map_iterator ipos
Definition toml.hpp:8871
TOML_EXPORTED_MEMBER_FUNCTION size_t erase(std::string_view key) noexcept
TOML_PURE_GETTER impl::wrap_node< T > * get_as(std::string_view key) noexcept
Definition toml.hpp:8376
TOML_EXPORTED_MEMBER_FUNCTION void clear() noexcept
toml::table_iterator iterator
Definition toml.hpp:8434
TOML_NODISCARD node_view< node > operator[](std::string_view key) noexcept
Definition toml.hpp:9082
impl::remove_cvref< ValueType > raw_value_type
Definition toml.hpp:8837
TOML_CONSTRAINED_TEMPLATE((is_key_or_convertible< KeyType && >||impl::is_wide_string< KeyType >), typename ValueType=void, typename KeyType, typename... ValueArgs) std
Definition toml.hpp:9024
TOML_PURE_GETTER const_iterator lower_bound(std::string_view key) const noexcept
Definition toml.hpp:8702
TOML_PURE_GETTER TOML_EXPORTED_MEMBER_FUNCTION bool is_homogeneous(node_type ntype) const noexcept final
TOML_CONST_INLINE_GETTER table * as_table() noexcept final
Definition toml.hpp:8228
TOML_EXPORTED_MEMBER_FUNCTION table & operator=(const table &)
TOML_CONST_INLINE_GETTER toml::value< time > * as_time() noexcept final
Definition toml.hpp:8270
TOML_PURE_INLINE_GETTER const_iterator end() const noexcept
Definition toml.hpp:8463
TOML_CONST_INLINE_GETTER const toml::value< date_time > * as_date_time() const noexcept final
Definition toml.hpp:8330
TOML_PURE_INLINE_GETTER iterator begin() noexcept
Definition toml.hpp:8439
TOML_NODISCARD node_view< const node > operator[](std::string_view key) const noexcept
Definition toml.hpp:9088
TOML_CONST_INLINE_GETTER bool is_table() const noexcept final
Definition toml.hpp:8156
TOML_EXPORTED_MEMBER_FUNCTION ~table() noexcept
TOML_CONST_INLINE_GETTER bool is_value() const noexcept final
Definition toml.hpp:8174
TOML_NODISCARD friend bool operator==(const table &lhs, const table &rhs) noexcept
Definition toml.hpp:9116
TOML_CONST_INLINE_GETTER const table * as_table() const noexcept final
Definition toml.hpp:8282
friend std::ostream & operator<<(std::ostream &lhs, const table &rhs)
Definition toml.hpp:9129
TOML_CONST_INLINE_GETTER bool is_boolean() const noexcept final
Definition toml.hpp:8204
TOML_CONSTRAINED_TEMPLATE((is_key_or_convertible< KeyType && >||impl::is_wide_string< KeyType >), typename KeyType, typename ValueType) std
Definition toml.hpp:8904
TOML_PURE_GETTER TOML_EXPORTED_MEMBER_FUNCTION const_iterator find(std::string_view key) const noexcept
TOML_PURE_GETTER TOML_EXPORTED_MEMBER_FUNCTION iterator find(std::string_view key) noexcept
TOML_CONST_INLINE_GETTER toml::value< int64_t > * as_integer() noexcept final
Definition toml.hpp:8246
Iter end
Definition toml.hpp:8957
const table & for_each(Func &&visitor) const &noexcept(for_each_is_nothrow< Func &&, const table & >::value)
Definition toml.hpp:8661
table && prune(bool recursive=true) &&noexcept
Definition toml.hpp:8810
TOML_CONST_INLINE_GETTER bool is_floating_point() const noexcept final
Definition toml.hpp:8192
TOML_PURE_INLINE_GETTER const_iterator cbegin() const noexcept
Definition toml.hpp:8451
TOML_CONST_INLINE_GETTER bool is_date() const noexcept final
Definition toml.hpp:8210
TOML_PURE_INLINE_GETTER iterator end() noexcept
Definition toml.hpp:8457
TOML_CONST_INLINE_GETTER toml::value< date > * as_date() noexcept final
Definition toml.hpp:8264
TOML_CONSTRAINED_TEMPLATE((is_key_or_convertible< KeyType && >||impl::is_wide_string< KeyType >), typename ValueType=void, typename KeyType, typename... ValueArgs) iterator emplace_hint(const_iterator hint
TOML_PURE_INLINE_GETTER bool is_inline() const noexcept
Definition toml.hpp:8336
TOML_CONST_INLINE_GETTER const array * as_array() const noexcept final
Definition toml.hpp:8288
TOML_PURE_GETTER const impl::wrap_node< T > * get_as(std::string_view key) const noexcept
Definition toml.hpp:8384
std::conditional_t< std::is_void_v< raw_value_type >, impl::emplaced_type_of< ValueArgs &&... >, raw_value_type > value_type
Definition toml.hpp:8838
KeyType ValueArgs && args
Definition toml.hpp:8830
TOML_NODISCARD friend bool operator!=(const table &lhs, const table &rhs) noexcept
Definition toml.hpp:9122
TOML_CONST_INLINE_GETTER const toml::value< date > * as_date() const noexcept final
Definition toml.hpp:8318
impl::remove_cvref< impl::unwrap_node< value_type > > unwrapped_type
Definition toml.hpp:8861
TOML_CONST_INLINE_GETTER toml::value< double > * as_floating_point() noexcept final
Definition toml.hpp:8252
TOML_PURE_GETTER iterator lower_bound(std::string_view key) noexcept
Definition toml.hpp:8696
TOML_CONST_INLINE_GETTER toml::value< date_time > * as_date_time() noexcept final
Definition toml.hpp:8276
TOML_PURE_GETTER bool is_array_of_tables() const noexcept final
Definition toml.hpp:8168
TOML_CONST_INLINE_GETTER bool is_integer() const noexcept final
Definition toml.hpp:8186
TOML_CONST_INLINE_GETTER const toml::value< bool > * as_boolean() const noexcept final
Definition toml.hpp:8312
void is_inline(bool val) noexcept
Definition toml.hpp:8341
TOML_PURE_INLINE_GETTER const_iterator cend() const noexcept
Definition toml.hpp:8469
TOML_CONST_INLINE_GETTER bool is_time() const noexcept final
Definition toml.hpp:8216
TOML_CONST_INLINE_GETTER toml::value< std::string > * as_string() noexcept final
Definition toml.hpp:8240
Iter value_flags bool insert_or_assign(KeyType &&key, ValueType &&val, value_flags flags=preserve_source_value_flags)
Definition toml.hpp:8975
iterator erase(iterator pos) noexcept
Definition toml.hpp:8776
TOML_PURE_INLINE_GETTER size_t size() const noexcept
Definition toml.hpp:8684
Definition toml.hpp:13752
utf8_codepoint buffer[history_buffer_size]
Definition toml.hpp:13762
TOML_PURE_INLINE_GETTER const source_path_ptr & source_path() const noexcept
Definition toml.hpp:13776
TOML_NODISCARD const utf8_codepoint * read_next() noexcept(!TOML_COMPILER_HAS_EXCEPTIONS)
Definition toml.hpp:13782
size_t count
Definition toml.hpp:13763
TOML_NODISCARD bool peek_eof() const noexcept(!TOML_COMPILER_HAS_EXCEPTIONS)
Definition toml.hpp:13841
TOML_NODISCARD const utf8_codepoint * step_back(size_t count) noexcept
Definition toml.hpp:13824
size_t first
Definition toml.hpp:13763
TOML_NODISCARD optional< parse_error > && error() noexcept
Definition toml.hpp:13849
static constexpr size_t max_history_length
Definition toml.hpp:13754
TOML_NODISCARD_CTOR utf8_buffered_reader(utf8_reader_interface &reader) noexcept
Definition toml.hpp:13770
TOML_PURE_INLINE_GETTER constexpr bool peek_eof() const noexcept
Definition toml.hpp:13321
TOML_NODISCARD_CTOR constexpr utf8_byte_stream(std::basic_string_view< Char > sv) noexcept
Definition toml.hpp:13291
TOML_CONST_INLINE_GETTER constexpr bool error() const noexcept
Definition toml.hpp:13303
TOML_PURE_INLINE_GETTER constexpr bool eof() const noexcept
Definition toml.hpp:13309
TOML_PURE_INLINE_GETTER bool eof() const noexcept
Definition toml.hpp:13373
TOML_NODISCARD_CTOR utf8_byte_stream(std::istream &stream) noexcept(!TOML_COMPILER_HAS_EXCEPTIONS)
Definition toml.hpp:13347
TOML_NODISCARD size_t operator()(void *dest, size_t num) noexcept(!TOML_COMPILER_HAS_EXCEPTIONS)
Definition toml.hpp:13394
TOML_NODISCARD bool peek_eof() const noexcept(!TOML_COMPILER_HAS_EXCEPTIONS)
Definition toml.hpp:13386
TOML_PURE_INLINE_GETTER bool error() const noexcept
Definition toml.hpp:13367
Definition toml.hpp:13472
TOML_NODISCARD_CTOR utf8_reader(U &&source, String &&source_path={}) noexcept(std::is_nothrow_constructible_v< utf8_byte_stream< T >, U && >)
Definition toml.hpp:13667
TOML_NODISCARD optional< parse_error > && error() noexcept final
Definition toml.hpp:13718
TOML_PURE_INLINE_GETTER const source_path_ptr & source_path() const noexcept final
Definition toml.hpp:13684
TOML_NODISCARD bool peek_eof() const noexcept(!TOML_COMPILER_HAS_EXCEPTIONS) final
Definition toml.hpp:13710
TOML_NODISCARD const utf8_codepoint * read_next() noexcept(!TOML_COMPILER_HAS_EXCEPTIONS) final
Definition toml.hpp:13691
configt config
Definition config.cpp:8
@ other
Definition converter_compare.cpp:887
int count
Definition cuda.h:51
#define N
Definition exp2f.c:23
#define T
Definition exp2f.c:24
#define C
Definition exp2f.c:25
std::ostream & operator<<(std::ostream &out, const interval_templatet< T > &i)
Definition interval_template.h:800
guard2tc & operator-=(guard2tc &g1, const guard2tc &g2)
Definition irep2_guard.cpp:334
#define CHAR_BIT
Definition limits.h:11
literalt pos(literalt a)
Definition literal.h:130
double log10(double x)
Definition log10.c:35
#define A
Definition logf.c:22
float e
Definition cmath.py:18
Any equal(Any a, Any b)
Definition numpy.py:362
list[Any] array(list[Any] data)
Definition numpy.py:15
list[float] empty(int shape)
Definition numpy.py:29
int U
Definition re.py:251
Definition exception.cpp:51
interval at(const std::string &function, double x)
The results at x, a single value where every implementation is exact.
Definition transcendental.cpp:239
double nan(const char *x)
Definition nan.c:3
double pow(double x, double y)
Definition pow.c:52
static __inline__ __device__ bool all(bool cond)
Definition sm_atomic_functions.h:548
void * value
Definition solidity_mapping.c:2
uint256_t key
Definition solidity_mapping.c:1
unsigned stack_budget_guardt< Tag >::depth
Definition stack_budget.h:72
#define true
Definition stdbool.h:11
#define false
Definition stdbool.h:10
#define bool
Definition stdbool.h:9
long int ptrdiff_t
Definition stddef.h:30
unsigned int size_t
Definition stddef.h:47
short wchar_t
Definition stddef.h:36
int memcmp(const void *s1, const void *s2, size_t n)
Definition string.c:412
void * memcpy(void *__ESBMC_restrict dst, const void *__ESBMC_restrict src, size_t n)
node_ptr value
Definition toml.hpp:6586
TOML_NODISCARD_CTOR array_init_elem(T &&val, value_flags flags=preserve_source_value_flags)
Definition toml.hpp:6590
std::add_const_t< Dest > type
Definition toml.hpp:1788
std::add_cv_t< Dest > type
Definition toml.hpp:1800
std::add_volatile_t< Dest > type
Definition toml.hpp:1794
Dest type
Definition toml.hpp:1782
std::add_lvalue_reference_t< Dest > type
Definition toml.hpp:1765
std::add_rvalue_reference_t< Dest > type
Definition toml.hpp:1771
Dest type
Definition toml.hpp:1759
TOML_NODISCARD_CTOR constexpr date_time(const toml::date &d) noexcept
Definition toml.hpp:3057
toml::date date
Definition toml.hpp:3041
TOML_PURE_INLINE_GETTER friend constexpr bool operator>(const date_time &lhs, const date_time &rhs) noexcept
Definition toml.hpp:3123
TOML_PURE_INLINE_GETTER friend constexpr bool operator!=(const date_time &lhs, const date_time &rhs) noexcept
Definition toml.hpp:3094
TOML_PURE_GETTER friend constexpr bool operator==(const date_time &lhs, const date_time &rhs) noexcept
Definition toml.hpp:3085
TOML_PURE_GETTER friend constexpr bool operator<(const date_time &lhs, const date_time &rhs) noexcept
Definition toml.hpp:3101
TOML_PURE_GETTER friend constexpr bool operator<=(const date_time &lhs, const date_time &rhs) noexcept
Definition toml.hpp:3112
TOML_NODISCARD_CTOR date_time() noexcept=default
TOML_PURE_INLINE_GETTER constexpr bool is_local() const noexcept
Definition toml.hpp:3078
TOML_PURE_INLINE_GETTER friend constexpr bool operator>=(const date_time &lhs, const date_time &rhs) noexcept
Definition toml.hpp:3130
friend std::ostream & operator<<(std::ostream &lhs, const date_time &rhs)
Definition toml.hpp:3135
TOML_NODISCARD_CTOR constexpr date_time(const toml::date &d, const toml::time &t, const toml::time_offset &off) noexcept
Definition toml.hpp:3069
optional< toml::time_offset > offset
Definition toml.hpp:3045
TOML_NODISCARD_CTOR constexpr date_time(const toml::time &t) noexcept
Definition toml.hpp:3063
static constexpr auto type
Definition toml.hpp:1840
static constexpr bool can_represent_native
Definition toml.hpp:1838
static constexpr bool is_losslessly_convertible_to_native
Definition toml.hpp:1837
void native_type
Definition toml.hpp:1835
static constexpr bool can_partially_represent_native
Definition toml.hpp:1839
static constexpr bool is_native
Definition toml.hpp:1836
Definition toml.hpp:14181
~depth_counter_scope() noexcept
Definition toml.hpp:14191
size_t & depth_
Definition toml.hpp:14182
TOML_DELETE_DEFAULTS(depth_counter_scope)
TOML_NODISCARD_CTOR depth_counter_scope(size_t &depth) noexcept
Definition toml.hpp:14185
std::conditional_t< is_one_of< T, node, node_view< node >, node_view< const node > >, void, typename inserted_type_of_< T >::type > type
Definition toml.hpp:6317
typename emplaced_type_of_< remove_cvref< T > >::type type
Definition toml.hpp:6326
void type
Definition toml.hpp:6311
Definition toml.hpp:14064
void append(const T &arg) noexcept
Definition toml.hpp:14080
char buf[buf_size]
Definition toml.hpp:14066
static constexpr std::size_t buf_size
Definition toml.hpp:14065
TOML_NODISCARD_CTOR error_builder(std::string_view scope) noexcept
Definition toml.hpp:14072
TOML_DELETE_DEFAULTS(error_builder)
TOML_RETURNS_BY_THROWING auto finish(const source_position &pos, const source_path_ptr &source_path) const
Definition toml.hpp:14087
char *const max_write_pos
Definition toml.hpp:14068
char * write_pos
Definition toml.hpp:14067
Definition toml.hpp:13965
const utf8_codepoint & cp
Definition toml.hpp:13966
static constexpr int bits
Definition toml.hpp:2022
static constexpr bool is_losslessly_convertible_to_native
Definition toml.hpp:2026
double native_type
Definition toml.hpp:2018
static constexpr bool can_represent_native
Definition toml.hpp:2031
static constexpr bool is_signed
Definition toml.hpp:2020
static constexpr int digits10
Definition toml.hpp:2024
static constexpr auto type
Definition toml.hpp:2017
static constexpr bool is_native
Definition toml.hpp:2019
static constexpr int digits
Definition toml.hpp:2023
static constexpr bool can_partially_represent_native
Definition toml.hpp:2034
void type
Definition toml.hpp:6298
typename inserted_type_of_< remove_cvref< T > >::type type
Definition toml.hpp:6292
T value
Definition toml.hpp:1705
static constexpr T max
Definition toml.hpp:1892
static constexpr T min
Definition toml.hpp:1890
static constexpr auto type
Definition toml.hpp:1903
static constexpr bool is_signed
Definition toml.hpp:1901
static constexpr bool is_native
Definition toml.hpp:1899
int64_t native_type
Definition toml.hpp:1898
static constexpr bool can_partially_represent_native
Definition toml.hpp:1904
TOML_NODISCARD static TOML_ALWAYS_INLINE U && make(U &&val) noexcept
Definition toml.hpp:5118
static constexpr bool is_native
Definition toml.hpp:2206
static constexpr bool is_losslessly_convertible_to_native
Definition toml.hpp:2207
static constexpr bool can_partially_represent_native
Definition toml.hpp:2209
static constexpr auto type
Definition toml.hpp:2210
T native_type
Definition toml.hpp:2205
static constexpr bool can_represent_native
Definition toml.hpp:2208
static constexpr auto value
Definition toml.hpp:2349
static constexpr auto value
Definition toml.hpp:2344
static constexpr auto value
Definition toml.hpp:2354
static constexpr auto value
Definition toml.hpp:2339
std::add_const_t< T > type
Definition toml.hpp:2321
std::add_volatile_t< std::add_const_t< T > > type
Definition toml.hpp:2331
T type
Definition toml.hpp:2316
std::add_volatile_t< T > type
Definition toml.hpp:2326
T type
Definition toml.hpp:2311
value< bool > type
Definition toml.hpp:2287
std::add_const_t< typename node_wrapper< T >::type > type
Definition toml.hpp:2256
std::add_const_t< std::add_volatile_t< typename node_wrapper< T >::type > > type
Definition toml.hpp:2266
value< date > type
Definition toml.hpp:2292
value< date_time > type
Definition toml.hpp:2302
value< double > type
Definition toml.hpp:2282
value< int64_t > type
Definition toml.hpp:2277
value< std::string > type
Definition toml.hpp:2272
value< time > type
Definition toml.hpp:2297
std::add_volatile_t< typename node_wrapper< T >::type > type
Definition toml.hpp:2261
T type
Definition toml.hpp:2251
static constexpr auto full_prefix
Definition toml.hpp:13906
static constexpr auto scope_qualifier
Definition toml.hpp:13902
static constexpr auto is_signed
Definition toml.hpp:13904
static constexpr auto is_digit
Definition toml.hpp:13903
static constexpr auto max_digits
Definition toml.hpp:13905
static constexpr auto max_digits
Definition toml.hpp:13914
static constexpr auto is_signed
Definition toml.hpp:13913
static constexpr auto full_prefix
Definition toml.hpp:13917
static constexpr auto scope_qualifier
Definition toml.hpp:13911
static constexpr auto prefix
Definition toml.hpp:13916
static constexpr auto is_digit
Definition toml.hpp:13912
static constexpr auto prefix_codepoint
Definition toml.hpp:13915
static constexpr auto prefix
Definition toml.hpp:13885
static constexpr auto full_prefix
Definition toml.hpp:13886
static constexpr auto is_digit
Definition toml.hpp:13881
static constexpr auto prefix_codepoint
Definition toml.hpp:13884
static constexpr auto is_signed
Definition toml.hpp:13882
static constexpr auto scope_qualifier
Definition toml.hpp:13880
static constexpr auto max_digits
Definition toml.hpp:13883
static constexpr auto max_digits
Definition toml.hpp:13894
static constexpr auto prefix_codepoint
Definition toml.hpp:13895
static constexpr auto is_signed
Definition toml.hpp:13893
static constexpr auto prefix
Definition toml.hpp:13896
static constexpr auto is_digit
Definition toml.hpp:13892
static constexpr auto scope_qualifier
Definition toml.hpp:13891
static constexpr auto full_prefix
Definition toml.hpp:13897
Definition toml.hpp:14131
TOML_PURE_INLINE_GETTER size_t size() const noexcept
Definition toml.hpp:14174
std::vector< std::pair< size_t, size_t > > segments
Definition toml.hpp:14133
std::vector< source_position > starts
Definition toml.hpp:14134
std::vector< source_position > ends
Definition toml.hpp:14135
TOML_PURE_INLINE_GETTER std::string_view back() const noexcept
Definition toml.hpp:14162
void clear() noexcept
Definition toml.hpp:14137
void push_back(std::string_view segment, source_position b, source_position e)
Definition toml.hpp:14146
TOML_PURE_INLINE_GETTER bool empty() const noexcept
Definition toml.hpp:14168
std::string buffer
Definition toml.hpp:14132
TOML_PURE_INLINE_GETTER std::string_view operator[](size_t i) const noexcept
Definition toml.hpp:14155
TOML_DELETE_DEFAULTS(parse_scope)
std::string_view parent_
Definition toml.hpp:14107
~parse_scope() noexcept
Definition toml.hpp:14118
TOML_NODISCARD_CTOR parse_scope(std::string_view ¤t_scope, std::string_view new_scope) noexcept
Definition toml.hpp:14110
std::string_view & storage_
Definition toml.hpp:14106
Definition toml.hpp:14200
std::string_view value
Definition toml.hpp:14201
bool was_multi_line
Definition toml.hpp:14202
static constexpr bool can_represent_native
Definition toml.hpp:1921
int64_t native_type
Definition toml.hpp:1916
static constexpr bool is_losslessly_convertible_to_native
Definition toml.hpp:1917
TOML_PURE_GETTER friend constexpr bool operator>=(const source_position &lhs, const source_position &rhs) noexcept
Definition toml.hpp:2744
TOML_PURE_INLINE_GETTER friend constexpr bool operator!=(const source_position &lhs, const source_position &rhs) noexcept
Definition toml.hpp:2707
source_index line
Definition toml.hpp:2686
source_index column
Definition toml.hpp:2688
TOML_PURE_GETTER friend constexpr bool operator==(const source_position &lhs, const source_position &rhs) noexcept
Definition toml.hpp:2699
TOML_PURE_GETTER friend constexpr bool operator>(const source_position &lhs, const source_position &rhs) noexcept
Definition toml.hpp:2737
source_path_ptr path
Definition toml.hpp:2763
friend std::ostream & operator<<(std::ostream &lhs, const source_region &rhs)
Definition toml.hpp:2777
source_position end
Definition toml.hpp:2761
source_position begin
Definition toml.hpp:2759
static constexpr auto type
Definition toml.hpp:2107
static constexpr bool is_native
Definition toml.hpp:2101
static constexpr bool is_losslessly_convertible_to_native
Definition toml.hpp:2102
static constexpr bool can_partially_represent_native
Definition toml.hpp:2106
std::string native_type
Definition toml.hpp:2100
static constexpr bool can_represent_native
Definition toml.hpp:2103
node_ptr value
Definition toml.hpp:8057
TOML_NODISCARD_CTOR table_init_pair(K &&k, V &&v, value_flags flags=preserve_source_value_flags)
Definition toml.hpp:8060
toml::key key
Definition toml.hpp:8056
std::vector< table * > & tables
Definition toml.hpp:14207
~table_vector_scope() noexcept
Definition toml.hpp:14216
TOML_DELETE_DEFAULTS(table_vector_scope)
TOML_NODISCARD_CTOR table_vector_scope(std::vector< table * > &tables_, table &tbl)
Definition toml.hpp:14210
TOML_PURE_INLINE_GETTER friend constexpr bool operator<=(time_offset lhs, time_offset rhs) noexcept
Definition toml.hpp:3013
friend std::ostream & operator<<(std::ostream &lhs, const time_offset &rhs)
Definition toml.hpp:3030
TOML_PURE_INLINE_GETTER friend constexpr bool operator>(time_offset lhs, time_offset rhs) noexcept
Definition toml.hpp:3019
TOML_PURE_INLINE_GETTER friend constexpr bool operator<(time_offset lhs, time_offset rhs) noexcept
Definition toml.hpp:3007
TOML_PURE_INLINE_GETTER friend constexpr bool operator>=(time_offset lhs, time_offset rhs) noexcept
Definition toml.hpp:3025
int16_t minutes
Definition toml.hpp:2976
TOML_PURE_INLINE_GETTER friend constexpr bool operator==(time_offset lhs, time_offset rhs) noexcept
Definition toml.hpp:2995
M m noexcept
Definition toml.hpp:2988
TOML_PURE_INLINE_GETTER friend constexpr bool operator!=(time_offset lhs, time_offset rhs) noexcept
Definition toml.hpp:3001
M m M(h) *impl
Definition toml.hpp:2988
TOML_NODISCARD_CTOR time_offset() noexcept=default
TOML_CONSTRAINED_TEMPLATE((impl::all_integral< H, M >), typename H, typename M) TOML_NODISCARD_CTOR const expr time_offset(H h
uint8_t minute
Definition toml.hpp:2893
TOML_CONSTRAINED_TEMPLATE((impl::all_integral< H, M, S, NS >), typename H, typename M, typename S=uint8_t, typename NS=uint32_t) TOML_NODISCARD_CTOR const expr time(H h
M S s
Definition toml.hpp:2909
M m
Definition toml.hpp:2909
uint32_t nanosecond
Definition toml.hpp:2897
uint8_t hour
Definition toml.hpp:2891
uint8_t second
Definition toml.hpp:2895
TOML_NODISCARD_CTOR time() noexcept=default
T type
Definition toml.hpp:1826
std::underlying_type_t< T > type
Definition toml.hpp:1821
static constexpr bool is_losslessly_convertible_to_native
Definition toml.hpp:1909
static constexpr bool can_represent_native
Definition toml.hpp:1911
Definition toml.hpp:13405
TOML_PURE_INLINE_GETTER constexpr const char32_t & operator*() const noexcept
Definition toml.hpp:13418
source_position position
Definition toml.hpp:13409
char32_t value
Definition toml.hpp:13406
size_t count
Definition toml.hpp:13408
char bytes[4]
Definition toml.hpp:13407
Definition toml.hpp:13427
virtual TOML_NODISCARD optional< parse_error > && error() noexcept=0
virtual TOML_NODISCARD const source_path_ptr & source_path() const noexcept=0
virtual ~utf8_reader_interface() noexcept=default
virtual TOML_NODISCARD bool peek_eof() const noexcept(!TOML_COMPILER_HAS_EXCEPTIONS)=0
virtual TOML_NODISCARD const utf8_codepoint * read_next() noexcept(!TOML_COMPILER_HAS_EXCEPTIONS)=0
value_traits< underlying_type< T > > type
Definition toml.hpp:1858
default_value_traits type
Definition toml.hpp:1851
enum TOML_OPEN_FLAGS_ENUM format_as_hexadecimal
Definition toml.hpp:1672
typename underlying_type_< T >::type underlying_type
Definition toml.hpp:1829
#define TOML_ANON_NAMESPACE_END
Definition toml.hpp:1262
#define TOML_PARSER_TYPENAME
Definition toml.hpp:1617
#define TOML_UNUSED(...)
Definition toml.hpp:661
#define TOML_NODISCARD_CTOR
Definition toml.hpp:498
toml_formatter default_formatter
Definition toml.hpp:1712
constexpr bool is_constructible_or_convertible
Definition toml.hpp:2361
constexpr bool is_native
Definition toml.hpp:2234
enum TOML_OPEN_FLAGS_ENUM value_flags
Definition toml.hpp:1666
constexpr size_t charconv_buffer_length< int16_t >
Definition toml.hpp:10891
#define TOML_TRIVIAL_ABI
Definition toml.hpp:478
#define TOML_DISABLE_ARITHMETIC_WARNINGS
Definition toml.hpp:922
#define TOML_HAS_CUSTOM_OPTIONAL_TYPE
Definition toml.hpp:1085
constexpr size_t charconv_buffer_length< uint8_t >
Definition toml.hpp:10903
#define TOML_LIFETIME_HOOKS
Definition toml.hpp:1130
#define POXY_IMPLEMENTATION_DETAIL(...)
Definition toml.hpp:688
constexpr bool value_retrieval_is_nothrow
Definition toml.hpp:1743
#define TOML_UNLIKELY(...)
Definition toml.hpp:596
#define TOML_ABI_NAMESPACE_BOOL(cond, T, F)
Definition toml.hpp:1248
#define TOML_SA_LIST_BEG
Definition toml.hpp:1293
#define TOML_SA_UNWRAPPED_NODE_TYPE_LIST
Definition toml.hpp:1322
constexpr bool is_number
Definition toml.hpp:2394
#define TOML_EMPTY_BASES
Definition toml.hpp:470
#define TOML_RETURNS_BY_THROWING
Definition toml.hpp:13862
#define TOML_LIKELY(...)
Definition toml.hpp:583
enum TOML_OPEN_FLAGS_ENUM format_as_octal
Definition toml.hpp:1671
enum TOML_CLOSED_FLAGS_ENUM allow_multi_line_strings
Definition toml.hpp:1686
enum TOML_CLOSED_FLAGS_ENUM quote_dates_and_times
Definition toml.hpp:1683
#define TOML_PUSH_WARNINGS
Definition toml.hpp:907
#define TOML_CONSTRAINED_TEMPLATE(condition,...)
Definition toml.hpp:1187
#define TOML_SA_NODE_TYPE_LIST
Definition toml.hpp:1310
#define TOML_CALLCONV
Definition toml.hpp:1104
TOML_PURE_GETTER fp_class fpclassify(const double &val) noexcept
Definition toml.hpp:2455
constexpr node_type node_type_of
Definition toml.hpp:2357
#define TOML_ABI_NAMESPACE_END
Definition toml.hpp:1249
enum TOML_CLOSED_FLAGS_ENUM allow_unicode_strings
Definition toml.hpp:1688
#define TOML_NEVER_INLINE
Definition toml.hpp:461
#define TOML_INTERNAL_LINKAGE
Definition toml.hpp:1265
TOML_PURE_GETTER auto find(Iterator start, Iterator end, const T &needle) noexcept -> decltype(&(*start))
Definition toml.hpp:2480
typename value_traits< T >::native_type native_type_of
Definition toml.hpp:2232
#define set_error_and_return_if_eof(...)
Definition toml.hpp:14299
constexpr size_t charconv_buffer_length< int64_t >
Definition toml.hpp:10899
std::common_type_t< std::make_signed_t< T >... > common_signed_type
Definition toml.hpp:1722
#define TOML_CLOSED_ENUM
Definition toml.hpp:615
#define TOML_EXPORTED_CLASS
Definition toml.hpp:1005
constexpr bool is_boolean
Definition toml.hpp:2397
enum TOML_CLOSED_FLAGS_ENUM allow_real_tabs_in_strings
Definition toml.hpp:1687
TOML_EXPORTED_FREE_FUNCTION void TOML_CALLCONV print_to_stream(std::ostream &, std::string_view)
#define TOML_UNLIKELY_CASE
Definition toml.hpp:599
constexpr bool is_floating_point
Definition toml.hpp:2389
constexpr bool is_date
Definition toml.hpp:2402
constexpr bool can_partially_represent_native
Definition toml.hpp:2239
constexpr bool is_key
Definition toml.hpp:7856
#define TOML_EXTERNAL_LINKAGE
Definition toml.hpp:1264
TOML_NODISCARD node_ptr make_node(T &&val, value_flags flags=preserve_source_value_flags)
Definition toml.hpp:6302
#define TOML_UNREACHABLE
Definition toml.hpp:572
typename node_wrapper< std::remove_reference_t< T > >::type wrap_node
Definition toml.hpp:2305
#define set_error_and_return_default(...)
Definition toml.hpp:14296
#define TOML_DISABLE_WARNINGS
Definition toml.hpp:928
TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION parse_result TOML_CALLCONV parse_file(std::string_view file_path)
Definition toml.hpp:17394
#define TOML_NODISCARD
Definition toml.hpp:489
enum TOML_CLOSED_FLAGS_ENUM allow_octal_integers
Definition toml.hpp:1690
#define TOML_ANON_NAMESPACE_START
Definition toml.hpp:1261
#define TOML_LAUNDER(x)
Definition toml.hpp:1364
#define TOML_DISABLE_SWITCH_WARNINGS
Definition toml.hpp:913
TOML_PURE_GETTER bool is_ascii(const char *str, size_t len) noexcept
typename copy_cv_< Dest, Src >::type copy_cv
Definition toml.hpp:1777
enum TOML_CLOSED_FLAGS_ENUM allow_binary_integers
Definition toml.hpp:1689
constexpr bool is_string
Definition toml.hpp:2379
POXY_IMPLEMENTATION_DETAIL(impl::array_iterator< true >) const_array_iterator
Definition toml.hpp:6603
#define return_if_error_or_eof(...)
Definition toml.hpp:14261
#define is_error()
Definition toml.hpp:14252
#define TOML_CONST_GETTER
Definition toml.hpp:538
#define TOML_LANG_UNRELEASED
Definition toml.hpp:1233
#define TOML_SA_LIST_END
Definition toml.hpp:1294
#define TOML_DISABLE_SUGGEST_ATTR_WARNINGS
Definition toml.hpp:916
constexpr std::string_view control_char_escapes[]
Definition toml.hpp:1559
TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION parse_result TOML_CALLCONV parse(std::string_view doc, std::string_view source_path={})
Definition toml.hpp:17362
TOML_INTERNAL_LINKAGE void print_floating_point_to_stream(std::ostream &stream, T val, value_flags format, bool relaxed_precision)
Definition toml.hpp:11028
#define TOML_COMPILER_HAS_EXCEPTIONS
Definition toml.hpp:373
constexpr bool is_array
Definition toml.hpp:2373
constexpr bool first_is_same
Definition toml.hpp:1814
#define TOML_ENV_MESSAGE
Definition toml.hpp:1462
constexpr size_t charconv_buffer_length< uint16_t >
Definition toml.hpp:10906
#define TOML_OVERALIGNED
Definition toml.hpp:13467
constexpr bool all_integral
Definition toml.hpp:1728
#define utf8_reader_error(...)
Definition toml.hpp:13453
utf8_reader(std::basic_string_view< Char >, std::string_view) -> utf8_reader< std::basic_string_view< Char > >
TOML_PURE_GETTER TOML_INTERNAL_LINKAGE std::string_view to_sv(node_type val) noexcept
Definition toml.hpp:13922
enum TOML_CLOSED_FLAGS_ENUM quote_infinities_and_nans
Definition toml.hpp:1684
constexpr bool is_chronological
Definition toml.hpp:2417
constexpr bool is_date_time
Definition toml.hpp:2412
enum TOML_CLOSED_FLAGS_ENUM allow_hexadecimal_integers
Definition toml.hpp:1691
#define TOML_PARSE_FILE_ERROR(msg, path)
constexpr bool is_one_of
Definition toml.hpp:1725
constexpr size_t charconv_buffer_length< int8_t >
Definition toml.hpp:10888
typename emplaced_type_of_< remove_cvref< T >... >::type emplaced_type_of
Definition toml.hpp:6330
#define TOML_EXPORTED_STATIC_FUNCTION
Definition toml.hpp:1011
#define TOML_POP_WARNINGS
Definition toml.hpp:925
#define return_if_error(...)
Definition toml.hpp:14255
enum TOML_CLOSED_FLAGS_ENUM allow_literal_strings
Definition toml.hpp:1685
TOML_NODISCARD bool TOML_CALLCONV parse_path(std::string_view, void *, parse_path_callback< std::string_view >, parse_path_callback< size_t >)
constexpr bool is_integer
Definition toml.hpp:2384
#define TOML_ASSERT(expr)
Definition toml.hpp:1143
TOML_CONST_GETTER optional< T > node_integer_cast(int64_t val) noexcept
Definition toml.hpp:5197
constexpr bool is_losslessly_convertible_to_native
Definition toml.hpp:2242
#define return_after_error(...)
Definition toml.hpp:14253
TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION node_view< const node > TOML_CALLCONV at_path(const node &root, std::string_view path) noexcept
std::shared_ptr< const std::string > source_path_ptr
Definition toml.hpp:2682
constexpr bool always_false
Definition toml.hpp:1811
#define TOML_EXCEPTIONS
Definition toml.hpp:1099
#define TOML_PURE_GETTER
Definition toml.hpp:527
enum TOML_CLOSED_FLAGS_ENUM terse_key_value_pairs
Definition toml.hpp:1696
#define TOML_ENABLE_WINDOWS_COMPAT
Definition toml.hpp:1069
constexpr bool is_natively_one_of
Definition toml.hpp:2245
#define TOML_ABI_NAMESPACE_START(name)
Definition toml.hpp:1247
#define TOML_LIKELY_CASE
Definition toml.hpp:586
#define push_parse_scope(scope)
Definition toml.hpp:14128
constexpr bool is_cvref
Definition toml.hpp:1731
#define utf8_reader_error_check(...)
Definition toml.hpp:13455
constexpr size_t charconv_buffer_length< uint32_t >
Definition toml.hpp:10910
#define TOML_ASSERT_ASSUME(expr)
Definition toml.hpp:1148
#define TOML_NAMESPACE_START
Definition toml.hpp:1244
#define TOML_MAX_NESTED_VALUES
Definition toml.hpp:1112
#define assert_not_error()
Definition toml.hpp:14254
constexpr size_t charconv_buffer_length< int32_t >
Definition toml.hpp:10895
#define TOML_OPEN_FLAGS_ENUM
Definition toml.hpp:619
#define advance_and_return_if_error_or_eof(...)
Definition toml.hpp:14314
constexpr bool is_container
Definition toml.hpp:2376
constexpr size_t charconv_buffer_length< uint64_t >
Definition toml.hpp:10914
#define TOML_PRAGMA_CLANG(decl)
Definition toml.hpp:398
#define TOML_NAMESPACE_END
Definition toml.hpp:1245
#define TOML_SA_LIST_NEW
Definition toml.hpp:1295
#define TOML_SA_LIST_NXT
Definition toml.hpp:1296
#define TOML_CLOSED_FLAGS_ENUM
Definition toml.hpp:620
constexpr value_flags preserve_source_value_flags
Definition toml.hpp:1676
#define TOML_HIDDEN_CONSTRAINT(condition,...)
Definition toml.hpp:1190
#define TOML_ATTR(...)
Definition toml.hpp:355
enum TOML_CLOSED_FLAGS_ENUM relaxed_float_precision
Definition toml.hpp:1695
#define TOML_PURE_INLINE_GETTER
Definition toml.hpp:532
enum TOML_OPEN_FLAGS_ENUM format_as_binary
Definition toml.hpp:1670
#define TOML_ALWAYS_INLINE
Definition toml.hpp:445
#define TOML_IMPL_NAMESPACE_END
Definition toml.hpp:1259
constexpr bool is_node_view
Definition toml.hpp:2430
#define TOML_DISABLE_SPAM_WARNINGS
Definition toml.hpp:919
enum TOML_CLOSED_FLAGS_ENUM format_flags
Definition toml.hpp:1680
#define TOML_EXPORTED_FREE_FUNCTION
Definition toml.hpp:1014
#define parse_error_break()
Definition toml.hpp:14285
#define utf8_buffered_reader_error_check(...)
Definition toml.hpp:13742
node_view(const T &) -> node_view< const node >
#define TOML_IMPL_NAMESPACE_START
Definition toml.hpp:1258
#define is_eof()
Definition toml.hpp:14236
#define TOML_ASYMMETRICAL_EQUALITY_OPS(LHS, RHS,...)
Definition toml.hpp:669
#define TOML_SA_VALUE_FUNC_MESSAGE(type_arg)
Definition toml.hpp:5073
#define advance_and_return_if_error(...)
Definition toml.hpp:14306
POXY_IMPLEMENTATION_DETAIL(impl::table_iterator< true >) const_table_iterator
Definition toml.hpp:8076
constexpr size_t charconv_buffer_length< double >
Definition toml.hpp:10921
#define assert_not_eof()
Definition toml.hpp:14237
#define TOML_CONST_INLINE_GETTER
Definition toml.hpp:543
#define TOML_ENABLE_WARNINGS
Definition toml.hpp:931
constexpr bool can_represent_native
Definition toml.hpp:2236
constexpr bool is_node
Definition toml.hpp:2425
TOML_INTERNAL_LINKAGE constexpr auto utf8_byte_order_mark
Definition toml.hpp:13278
value(T) -> value< impl::native_type_of< impl::remove_cvref< T > > >
constexpr size_t charconv_buffer_length< float >
Definition toml.hpp:10918
std::basic_ostream< Char > & operator<<(std::basic_ostream< Char > &lhs, node_type rhs)
Definition toml.hpp:1648
copy_ref< copy_ref< copy_cv< std::remove_reference_t< Dest >, std::remove_reference_t< Src > >, Dest >, Src > copy_cvref
Definition toml.hpp:1804
#define TOML_EXPORTED_MEMBER_FUNCTION
Definition toml.hpp:1008
TOML_INTERNAL_LINKAGE void print_integer_to_stream(std::ostream &stream, T val, value_flags format={}, size_t min_digits=0)
Definition toml.hpp:10924
enum TOML_CLOSED_FLAGS_ENUM indent_sub_tables
Definition toml.hpp:1692
#define TOML_SA_NATIVE_VALUE_TYPE_LIST
Definition toml.hpp:1300
constexpr bool is_time
Definition toml.hpp:2407
#define TOML_NVCC_WORKAROUND
Definition toml.hpp:3827
typename node_unwrapper< std::remove_reference_t< T > >::type unwrap_node
Definition toml.hpp:2334
TOML_PURE_INLINE_GETTER constexpr const T & min(const T &a, const T &b) noexcept
Definition toml.hpp:2491
enum TOML_CLOSED_FLAGS_ENUM indentation
Definition toml.hpp:1694
inserter(T &&) -> inserter< T && >
constexpr bool is_key_or_convertible
Definition toml.hpp:7860
#define TOML_MAKE_FLAGS(T)
Definition toml.hpp:659
#define TOML_SA_VALUE_EXACT_FUNC_MESSAGE(type_arg)
Definition toml.hpp:5054
enum TOML_CLOSED_FLAGS_ENUM indent_array_elements
Definition toml.hpp:1693
#define TOML_SA_LIST_SEP
Definition toml.hpp:1292
TOML_INTERNAL_LINKAGE void concatenate(char *&write_pos, char *const buf_end, const T &arg) noexcept
Definition toml.hpp:13971
constexpr std::string_view node_type_friendly_names[]
Definition toml.hpp:1595
constexpr bool is_wide_string
Definition toml.hpp:1735
#define utf8_reader_return_after_error(...)
Definition toml.hpp:13454
#define TOML_ASSUME(expr)
Definition toml.hpp:560
constexpr bool is_value
Definition toml.hpp:2421
typename copy_ref_< Dest, Src >::type copy_ref
Definition toml.hpp:1754
void print_to_stream_bookended(std::ostream &stream, const T &val, const U &bookend)
Definition toml.hpp:2646
#define TOML_ABSTRACT_INTERFACE
Definition toml.hpp:467