From d575534471044125256f1e03e150a8810aa304be Mon Sep 17 00:00:00 2001 From: Francois Chabot Date: Thu, 28 May 2020 12:13:43 -0400 Subject: [PATCH] brought back the from_*(ptr, len) syntax with a deprecation warning --- include/nlohmann/json.hpp | 49 ++++++++++++++++++++++++++++++++ single_include/nlohmann/json.hpp | 49 ++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 4cc329f9..bc0eda00 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -6639,6 +6639,7 @@ class basic_json return result; } + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, parse(ptr, ptr + len)) JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json parse(detail::span_input_adapter&& i, const parser_callback_t cb = nullptr, @@ -6661,6 +6662,8 @@ class basic_json return parser(detail::input_adapter(std::move(first), std::move(last))).accept(true); } + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, accept(ptr, ptr + len)) + JSON_HEDLEY_WARN_UNUSED_RESULT static bool accept(detail::span_input_adapter&& i) { return parser(i.get()).accept(true); @@ -6728,6 +6731,7 @@ class basic_json } template + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, sax_parse(ptr, ptr + len, ...)) JSON_HEDLEY_NON_NULL(2) static bool sax_parse(detail::span_input_adapter&& i, SAX* sax, input_format_t format = input_format_t::json, @@ -7403,6 +7407,18 @@ class basic_json return res ? result : basic_json(value_t::discarded); } + template + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json from_cbor(const T* ptr, std::size_t len, + const bool strict = true, + const bool allow_exceptions = true) + { + return from_cbor(ptr, ptr + len, strict, allow_exceptions); + } + + + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(detail::span_input_adapter&& i, const bool strict = true, @@ -7531,6 +7547,17 @@ class basic_json } + template + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json from_msgpack(const T* ptr, std::size_t len, + const bool strict = true, + const bool allow_exceptions = true) + { + return from_msgpack(ptr, ptr + len, strict, allow_exceptions); + } + + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(detail::span_input_adapter&& i, const bool strict = true, @@ -7634,7 +7661,18 @@ class basic_json return res ? result : basic_json(value_t::discarded); } + template + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json from_ubjson(const T* ptr, std::size_t len, + const bool strict = true, + const bool allow_exceptions = true) + { + return from_ubjson(ptr, ptr + len, strict, allow_exceptions); + } + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(detail::span_input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -7736,6 +7774,17 @@ class basic_json return res ? result : basic_json(value_t::discarded); } + template + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len)) + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json from_bson(const T* ptr, std::size_t len, + const bool strict = true, + const bool allow_exceptions = true) + { + return from_bson(ptr, ptr + len, strict, allow_exceptions); + } + + JSON_HEDLEY_DEPRECATED(3.8.0, from_bson(ptr, ptr + len)) JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(detail::span_input_adapter&& i, const bool strict = true, diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 8c007588..0421302c 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -22402,6 +22402,7 @@ class basic_json return result; } + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, parse(ptr, ptr + len)) JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json parse(detail::span_input_adapter&& i, const parser_callback_t cb = nullptr, @@ -22424,6 +22425,8 @@ class basic_json return parser(detail::input_adapter(std::move(first), std::move(last))).accept(true); } + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, accept(ptr, ptr + len)) + JSON_HEDLEY_WARN_UNUSED_RESULT static bool accept(detail::span_input_adapter&& i) { return parser(i.get()).accept(true); @@ -22491,6 +22494,7 @@ class basic_json } template + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, sax_parse(ptr, ptr + len, ...)) JSON_HEDLEY_NON_NULL(2) static bool sax_parse(detail::span_input_adapter&& i, SAX* sax, input_format_t format = input_format_t::json, @@ -23166,6 +23170,18 @@ class basic_json return res ? result : basic_json(value_t::discarded); } + template + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json from_cbor(const T* ptr, std::size_t len, + const bool strict = true, + const bool allow_exceptions = true) + { + return from_cbor(ptr, ptr + len, strict, allow_exceptions); + } + + + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(detail::span_input_adapter&& i, const bool strict = true, @@ -23294,6 +23310,17 @@ class basic_json } + template + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json from_msgpack(const T* ptr, std::size_t len, + const bool strict = true, + const bool allow_exceptions = true) + { + return from_msgpack(ptr, ptr + len, strict, allow_exceptions); + } + + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(detail::span_input_adapter&& i, const bool strict = true, @@ -23397,7 +23424,18 @@ class basic_json return res ? result : basic_json(value_t::discarded); } + template + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json from_ubjson(const T* ptr, std::size_t len, + const bool strict = true, + const bool allow_exceptions = true) + { + return from_ubjson(ptr, ptr + len, strict, allow_exceptions); + } + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(detail::span_input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -23499,6 +23537,17 @@ class basic_json return res ? result : basic_json(value_t::discarded); } + template + JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len)) + JSON_HEDLEY_WARN_UNUSED_RESULT + static basic_json from_bson(const T* ptr, std::size_t len, + const bool strict = true, + const bool allow_exceptions = true) + { + return from_bson(ptr, ptr + len, strict, allow_exceptions); + } + + JSON_HEDLEY_DEPRECATED(3.8.0, from_bson(ptr, ptr + len)) JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(detail::span_input_adapter&& i, const bool strict = true,