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

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext
parser::write_some (5 of 6 overloads)

Parse a buffer containing a complete JSON.

Synopsis
std::size_t
write_some(
    char const* data,
    std::size_t size);
Description

This function parses a complete JSON contained in the specified character buffer. Additional characters past the end of the complete JSON are ignored. The function returns the actual number of characters parsed, which may be less than the size of the input. This allows parsing of a buffer containing multiple individual JSONs or containing different protocol data:

Example
parser p;                                       // construct a parser
size_t n = p.write_some( "[1,2,3] null" );      // parse a complete JSON
assert( n == 8 );                               // only some characters consumed
value jv = p.release();                         // take ownership of the value
Complexity

Linear in size.

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.

Return Value

The number of characters consumed from the buffer.

Parameters

Name

Description

data

A pointer to a buffer of size characters to parse.

size

The number of characters pointed to by data.

Exceptions

Type

Thrown On

system_error

Thrown on error.


PrevUpHomeNext