use abstract sax class in parser tests

This commit is contained in:
Théo DELRIEU 2018-08-16 10:52:33 +02:00
parent 9bbb133094
commit 38f8a51a8f
No known key found for this signature in database
GPG Key ID: 7D6E00D1DF01DEAF
3 changed files with 15 additions and 13 deletions

View File

@ -212,6 +212,7 @@ class basic_json
using initializer_list_t = std::initializer_list<detail::json_ref<basic_json>>;
using input_format_t = detail::input_format_t;
using json_sax_t = json_sax<basic_json>;
////////////////
// exceptions //

View File

@ -11078,6 +11078,7 @@ class basic_json
using initializer_list_t = std::initializer_list<detail::json_ref<basic_json>>;
using input_format_t = detail::input_format_t;
using json_sax_t = json_sax<basic_json>;
////////////////
// exceptions //

View File

@ -129,68 +129,68 @@ class SaxEventLogger
bool errored = false;
};
class SaxCountdown
class SaxCountdown : public nlohmann::json::json_sax_t
{
public:
explicit SaxCountdown(const int count) : events_left(count)
{}
bool null()
bool null() override
{
return events_left-- > 0;
}
bool boolean(bool)
bool boolean(bool) override
{
return events_left-- > 0;
}
bool number_integer(json::number_integer_t)
bool number_integer(json::number_integer_t) override
{
return events_left-- > 0;
}
bool number_unsigned(json::number_unsigned_t)
bool number_unsigned(json::number_unsigned_t) override
{
return events_left-- > 0;
}
bool number_float(json::number_float_t, const std::string&)
bool number_float(json::number_float_t, const std::string&) override
{
return events_left-- > 0;
}
bool string(std::string&)
bool string(std::string&) override
{
return events_left-- > 0;
}
bool start_object(std::size_t)
bool start_object(std::size_t) override
{
return events_left-- > 0;
}
bool key(std::string&)
bool key(std::string&) override
{
return events_left-- > 0;
}
bool end_object()
bool end_object() override
{
return events_left-- > 0;
}
bool start_array(std::size_t)
bool start_array(std::size_t) override
{
return events_left-- > 0;
}
bool end_array()
bool end_array() override
{
return events_left-- > 0;
}
bool parse_error(std::size_t, const std::string&, const json::exception&)
bool parse_error(std::size_t, const std::string&, const json::exception&) override
{
return false;
}