From 38f8a51a8f049a98936f0f3eeabdb1f6080e5f37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20DELRIEU?= Date: Thu, 16 Aug 2018 10:52:33 +0200 Subject: [PATCH] use abstract sax class in parser tests --- include/nlohmann/json.hpp | 1 + single_include/nlohmann/json.hpp | 1 + test/src/unit-class_parser.cpp | 26 +++++++++++++------------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 8c4cb159e..54638d72d 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -212,6 +212,7 @@ class basic_json using initializer_list_t = std::initializer_list>; using input_format_t = detail::input_format_t; + using json_sax_t = json_sax; //////////////// // exceptions // diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 6e6ef85d8..cbd1a34d7 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -11078,6 +11078,7 @@ class basic_json using initializer_list_t = std::initializer_list>; using input_format_t = detail::input_format_t; + using json_sax_t = json_sax; //////////////// // exceptions // diff --git a/test/src/unit-class_parser.cpp b/test/src/unit-class_parser.cpp index e08099da0..74abd472e 100644 --- a/test/src/unit-class_parser.cpp +++ b/test/src/unit-class_parser.cpp @@ -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; }