// Copyright (C) 2020 T. Zachary Laine // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef JSON_FWD_HPP #define JSON_FWD_HPP #include #include #include namespace json { struct value; enum class value_kind { null, boolean, number, string, object, array }; struct null_t { bool operator==(null_t) const noexcept { return true; } bool operator!=(null_t) const noexcept { return false; } bool operator<(null_t) const noexcept { return false; } }; using array = std::vector; using object = std::unordered_map; namespace detail { template struct get_result { using type = T; }; template<> struct get_result { using type = array const &; }; template<> struct get_result { using type = array &; }; template<> struct get_result { using type = object const &; }; template<> struct get_result { using type = object &; }; template using get_result_t = typename get_result::type; } template detail::get_result_t get(value const & v) noexcept; template detail::get_result_t get(value & v) noexcept; std::size_t hash_append(std::size_t seed, value const & v); std::size_t hash_append(std::size_t seed, array const & v); std::size_t hash_append(std::size_t seed, object const & v); namespace detail { template struct get_impl; } } namespace std { template<> struct hash { using argument_type = json::value; using result_type = size_t; result_type operator()(argument_type const & v) const noexcept; }; template<> struct hash { using argument_type = json::object; using result_type = size_t; result_type operator()(argument_type const & o) const noexcept; }; template<> struct hash { using argument_type = json::array; using result_type = size_t; result_type operator()(argument_type const & a) const noexcept; }; } #endif