1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-28 12:02:00 +03:00

added a SAX parser #971

This commit is contained in:
Niels Lohmann
2018-02-24 18:04:07 +01:00
parent 8968adcd53
commit 374ebacc51
4 changed files with 854 additions and 3 deletions

View File

@ -1054,6 +1054,8 @@ class basic_json
*/
using parse_event_t = typename parser::parse_event_t;
using SAX = typename parser::SAX;
/*!
@brief per-element parser callback type
@ -5925,6 +5927,16 @@ class basic_json
return parser(i).accept(true);
}
static bool sax_parse(detail::input_adapter i, SAX* sax)
{
return parser(i, sax).sax_parse();
}
static bool sax_parse(detail::input_adapter& i, SAX* sax)
{
return parser(i, sax).sax_parse();
}
/*!
@brief deserialize from an iterator range with contiguous storage
@ -5994,6 +6006,15 @@ class basic_json
return parser(detail::input_adapter(first, last)).accept(true);
}
template<class IteratorType, typename std::enable_if<
std::is_base_of<
std::random_access_iterator_tag,
typename std::iterator_traits<IteratorType>::iterator_category>::value, int>::type = 0>
static bool sax_parse(IteratorType first, IteratorType last, SAX* sax)
{
return parser(detail::input_adapter(first, last), sax).sax_parse();
}
/*!
@brief deserialize from stream
@deprecated This stream operator is deprecated and will be removed in