diff --git a/Makefile b/Makefile index b07fb6b02..b8b746284 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,10 @@ .PHONY: pretty clean ChangeLog.md +SRCDIR = src +SRCS = ${SRCDIR}/json.hpp \ + ${SRCDIR}/json_fwd.hpp + +# main target all: @echo "ChangeLog.md - generate ChangeLog file" @echo "check - compile and execute test suite" @@ -218,10 +223,9 @@ pretty: --indent-col1-comments --pad-oper --pad-header --align-pointer=type \ --align-reference=type --add-brackets --convert-tabs --close-templates \ --lineend=linux --preserve-date --suffix=none --formatted \ - src/json.hpp test/src/*.cpp \ + $(SRCS) test/src/*.cpp \ benchmarks/src/benchmarks.cpp doc/examples/*.cpp - ########################################################################## # changelog ########################################################################## diff --git a/src/json.hpp b/src/json.hpp index a12fcbe3c..3768af0a9 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -36,7 +36,6 @@ SOFTWARE. #include // lconv, localeconv #include // isfinite, labs, ldexp, signbit #include // nullptr_t, ptrdiff_t, size_t -#include // int64_t, uint64_t #include // abort, strtod, strtof, strtold, strtoul, strtoll, strtoull #include // memcpy, strlen #include // forward_list @@ -47,15 +46,13 @@ SOFTWARE. #include // advance, begin, back_inserter, bidirectional_iterator_tag, distance, end, inserter, iterator, iterator_traits, next, random_access_iterator_tag, reverse_iterator #include // numeric_limits #include // locale -#include // map -#include // addressof, allocator, allocator_traits, unique_ptr #include // accumulate #include // stringstream -#include // getline, stoi, string, to_string #include // add_pointer, conditional, decay, enable_if, false_type, integral_constant, is_arithmetic, is_base_of, is_const, is_constructible, is_convertible, is_default_constructible, is_enum, is_floating_point, is_integral, is_nothrow_move_assignable, is_nothrow_move_constructible, is_pointer, is_reference, is_same, is_scalar, is_signed, remove_const, remove_cv, remove_pointer, remove_reference, true_type, underlying_type #include // declval, forward, make_pair, move, pair, swap #include // valarray -#include // vector + +#include "json_fwd.hpp" // exclude unsupported compilers #if defined(__clang__) @@ -124,20 +121,6 @@ SOFTWARE. */ namespace nlohmann { -template -struct adl_serializer; - -// forward declaration of basic_json (required to split the class) -template class ObjectType = std::map, - template class ArrayType = std::vector, - class StringType = std::string, class BooleanType = bool, - class NumberIntegerType = std::int64_t, - class NumberUnsignedType = std::uint64_t, - class NumberFloatType = double, - template class AllocatorType = std::allocator, - template class JSONSerializer = adl_serializer> -class basic_json; - // Ugly macros to avoid uglier copy-paste when specializing basic_json. They // may be removed in the future once the class is split. @@ -6896,14 +6879,6 @@ constexpr const auto& to_json = detail::static_const::value; constexpr const auto& from_json = detail::static_const::value; } - -/*! -@brief default JSONSerializer template argument - -This serializer ignores the template arguments and uses ADL -([argument-dependent lookup](http://en.cppreference.com/w/cpp/language/adl)) -for serialization. -*/ template struct adl_serializer { @@ -6940,17 +6915,6 @@ struct adl_serializer } }; -/*! -@brief JSON Pointer - -A JSON pointer defines a string syntax for identifying a specific value -within a JSON document. It can be used with functions `at` and -`operator[]`. Furthermore, JSON pointers are the base for JSON patches. - -@sa [RFC 6901](https://tools.ietf.org/html/rfc6901) - -@since version 2.0.0 -*/ class json_pointer { /// allow basic_json to access private members @@ -14411,20 +14375,6 @@ class basic_json /// @} }; -///////////// -// presets // -///////////// - -/*! -@brief default JSON class - -This type is the default specialization of the @ref basic_json class which -uses the standard template types. - -@since version 1.0.0 -*/ -using json = basic_json<>; - ////////////////// // json_pointer // ////////////////// diff --git a/src/json_fwd.hpp b/src/json_fwd.hpp new file mode 100644 index 000000000..a068da18e --- /dev/null +++ b/src/json_fwd.hpp @@ -0,0 +1,63 @@ +#ifndef NLOHMANN_JSON_FWD_HPP +#define NLOHMANN_JSON_FWD_HPP + +#include // int64_t, uint64_t +#include // map +#include // addressof, allocator, allocator_traits, unique_ptr +#include // getline, stoi, string, to_string +#include // vector + +/*! +@brief namespace for Niels Lohmann +@see https://github.com/nlohmann +@since version 1.0.0 +*/ +namespace nlohmann +{ +/*! +@brief default JSONSerializer template argument + +This serializer ignores the template arguments and uses ADL +([argument-dependent lookup](http://en.cppreference.com/w/cpp/language/adl)) +for serialization. +*/ +template +struct adl_serializer; + +template class ObjectType = + std::map, + template class ArrayType = std::vector, + class StringType = std::string, class BooleanType = bool, + class NumberIntegerType = std::int64_t, + class NumberUnsignedType = std::uint64_t, + class NumberFloatType = double, + template class AllocatorType = std::allocator, + template class JSONSerializer = + adl_serializer> +class basic_json; + +/*! +@brief JSON Pointer + +A JSON pointer defines a string syntax for identifying a specific value +within a JSON document. It can be used with functions `at` and +`operator[]`. Furthermore, JSON pointers are the base for JSON patches. + +@sa [RFC 6901](https://tools.ietf.org/html/rfc6901) + +@since version 2.0.0 +*/ +class json_pointer; + +/*! +@brief default JSON class + +This type is the default specialization of the @ref basic_json class which +uses the standard template types. + +@since version 1.0.0 +*/ +using json = basic_json<>; +} + +#endif