From 3d57996a6705486a751b2e034ead8f24bff69957 Mon Sep 17 00:00:00 2001 From: Daniel Parker Date: Tue, 5 Nov 2024 20:14:07 -0500 Subject: [PATCH] read_more_command --- include/jsoncons/json_parser.hpp | 10 ++++++---- include/jsoncons/json_reader.hpp | 9 ++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/jsoncons/json_parser.hpp b/include/jsoncons/json_parser.hpp index 5dcaf91a1..f03453f6a 100644 --- a/include/jsoncons/json_parser.hpp +++ b/include/jsoncons/json_parser.hpp @@ -33,8 +33,9 @@ class read_more_command { public: virtual ~read_more_command() = default; - virtual void read_more(std::error_code& ec) + virtual bool read_more(std::error_code&) { + return false; } }; @@ -2311,8 +2312,10 @@ class basic_json_parser : public ser_context { string_buffer_.append(sb,input_ptr_-sb); position_ += (input_ptr_ - sb); - //state_ = json_parse_state::string; - more_command_->read_more(ec); + if (!more_command_->read_more(ec)) + { + return; + } if (ec) { return; @@ -2320,7 +2323,6 @@ class basic_json_parser : public ser_context local_input_end = end_input_; sb = input_ptr_; goto string_u1; - //return; } escape: diff --git a/include/jsoncons/json_reader.hpp b/include/jsoncons/json_reader.hpp index 35cd232c9..95aff3e51 100644 --- a/include/jsoncons/json_reader.hpp +++ b/include/jsoncons/json_reader.hpp @@ -267,18 +267,20 @@ namespace jsoncons { { } - virtual void read_more(std::error_code& ec) + virtual bool read_more(std::error_code& ec) { - std::cout << "UPDATE BUFFER\n"; + //std::cout << "UPDATE BUFFER\n"; + bool success = false; if (!parser_.stopped()) { if (parser_.source_exhausted()) { auto s = source_.read_buffer(ec); - if (ec) return; + if (ec) return false; if (s.size() > 0) { parser_.update(s.data(),s.size()); + success = true; } } /*bool eof = parser_.source_exhausted(); @@ -297,6 +299,7 @@ namespace jsoncons { } }*/ } + return success; } void read_next()