🚧 start BON8 parser

This commit is contained in:
Niels Lohmann
2021-09-11 22:46:49 +02:00
parent 627eefa5ad
commit e27c127068
4 changed files with 460 additions and 4 deletions
+30
View File
@@ -8211,6 +8211,36 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict);
return res ? result : basic_json(value_t::discarded);
}
template<typename InputType>
JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json from_bon8(InputType&& i,
const bool strict = true,
const bool allow_exceptions = true)
{
basic_json result;
detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
auto ia = detail::input_adapter(std::forward<InputType>(i));
const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::bon8, &sdp, strict);
return res ? result : basic_json(value_t::discarded);
}
/*!
@copydoc from_bon8(InputType&&, const bool, const bool)
*/
template<typename IteratorType>
JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json from_bon8(IteratorType first, IteratorType last,
const bool strict = true,
const bool allow_exceptions = true)
{
basic_json result;
detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
auto ia = detail::input_adapter(std::move(first), std::move(last));
const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::bon8, &sdp, strict);
return res ? result : basic_json(value_t::discarded);
}
/// @}
//////////////////////////