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
basic_parser::write_some (2 of 2 overloads)

Parse some of an input string as JSON, incrementally.

Synopsis
std::size_t
write_some(
    bool more,
    char const* data,
    std::size_t size,
    std::error_code& ec);
Description

This function parses the JSON in the specified buffer, calling the handler to emit each SAX parsing event. The parse proceeds from the current state, which is at the beginning of a new JSON or in the middle of the current JSON if any characters were already parsed.

The characters in the buffer are processed starting from the beginning, until one of the following conditions is met:

The supplied buffer does not need to contain the entire JSON. Subsequent calls can provide more serialized data, allowing JSON to be processed incrementally. The end of the serialized JSON can be indicated by passing more = false.

Complexity

Linear in size.

Exception Safety

Basic guarantee. Calls to the handler 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 successfully parsed, which may be smaller than size.

Parameters

Name

Description

more

true if there are possibly more buffers in the current JSON, otherwise false.

data

A pointer to a buffer of size characters to parse.

size

The number of characters pointed to by data.

ec

Set to the error, if any occurred.


PrevUpHomeNext