Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext
stream_parser::finish (2 of 3 overloads)

Indicate the end of JSON input.

Synopsis
void
finish(
    std::error_code& ec);
Description

This function is used to indicate that there are no more character buffers in the current JSON text being parsed. If the resulting JSON text is incomplete, the error is set to indicate a parsing failure.

Example

In the code below, finish is called to indicate there are no more digits in the resulting number:

stream_parser p;                                // construct a parser
p.write( "3." );                                // write the first part of the number
p.write( "14" );                                // write the second part of the number
assert( ! p.done() );                           // there could be more digits
p.finish();                                     // indicate the end of the JSON input
assert( p.done() );                             // now we are finished
value jv = p.release();                         // take ownership of the value
Complexity

Constant.

Exception Safety

Basic guarantee. Calls to memory_resource::allocate may throw. Upon error or exception, subsequent calls will fail until reset is called to parse a new JSON text.

Parameters

Name

Description

ec

Set to the error, if any occurred.


PrevUpHomeNext