Skip to content

Commit

Permalink
read_more_command
Browse files Browse the repository at this point in the history
  • Loading branch information
danielaparker committed Nov 6, 2024
1 parent d8d15e1 commit 3d57996
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 6 additions & 4 deletions include/jsoncons/json_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};

Expand Down Expand Up @@ -2311,16 +2312,17 @@ 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;
}
local_input_end = end_input_;
sb = input_ptr_;
goto string_u1;
//return;
}

escape:
Expand Down
9 changes: 6 additions & 3 deletions include/jsoncons/json_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -297,6 +299,7 @@ namespace jsoncons {
}
}*/
}
return success;
}

void read_next()
Expand Down

0 comments on commit 3d57996

Please sign in to comment.