// Glaze Library // For the license information refer to glaze.hpp #pragma once #ifndef GLZ_THROW_OR_ABORT #if __cpp_exceptions #define GLZ_THROW_OR_ABORT(EXC) (throw(EXC)) #else #define GLZ_THROW_OR_ABORT(EXC) (std::abort()) #endif #endif #ifndef GLZ_NOEXCEPT #if __cpp_exceptions #define GLZ_NOEXCEPT noexcept(false) #else #define GLZ_NOEXCEPT noexcept(true) #endif #endif #if __cpp_exceptions #include #endif namespace glz { inline void glaze_error([[maybe_unused]] const char* msg) GLZ_NOEXCEPT { GLZ_THROW_OR_ABORT(std::runtime_error(msg)); } } #include #include #include #include #include "glaze/containers/ordered_small_map.hpp" #include "glaze/core/context.hpp" #include "glaze/forward.hpp" #include "glaze/util/expected.hpp" #if defined(_MSC_VER) && !defined(__clang__) // Turn off broken MSVC warning for "declaration of 'v' hides previous local declaration" #pragma warning(push) #pragma warning(disable : 4456) #endif namespace glz { // Number storage mode for generic JSON types enum class num_mode { f64, // double only - fast, JavaScript-compatible (default) i64, // int64_t → double - signed integer precision u64 // uint64_t → int64_t → double - full integer range }; // Helper to determine variant type based on mode template struct generic_val_type; template struct generic_val_type { using type = std::variant; }; template struct generic_val_type { using type = std::variant; }; template struct generic_val_type { using type = std::variant; }; // Concept for map types usable with generic_json. // MapType must be a template taking a single type parameter (the mapped value type), // with std::string keys and support for heterogeneous lookup via std::string_view. template