#include <jsoncons_ext/ubjson/ubjson_cursor.hpp>
template<
class Src=jsoncons::binary_stream_source,
class Allocator=std::allocator<char>>
class basic_ubjson_cursor;
A pull parser for reporting UBJSON parse events. A typical application will
repeatedly process the current()
event and call the next()
function to advance to the next event, until done()
returns true
.
basic_ubjson_cursor
is noncopyable and nonmoveable.
Typedefs for common sources are provided:
Type | Definition |
---|---|
ubjson_stream_cursor | basic_ubjson_cursorjsoncons::binary_stream_source |
ubjson_bytes_cursor | basic_ubjson_cursorjsoncons::bytes_source |
template <class Source>
basic_ubjson_cursor(Source&& source); // (1)
template <class Source>
basic_ubjson_cursor(Source&& source,
std::function<bool(const staj_event&, const ser_context&)> filter); // (2)
template <class Source>
basic_ubjson_cursor(Source&& source, std::error_code& ec); // (3)
template <class Source>
basic_ubjson_cursor(Source&& source,
std::function<bool(const staj_event&, const ser_context&)> filter,
std::error_code& ec); // (4)
Constructor3 (1)-(2) read from a buffer or stream source and throw a ser_error if a parsing error is encountered while processing the initial event.
Constructor3 (3)-(4) read from a buffer or stream source and set ec
if a parsing error is encountered while processing the initial event.
Note: It is the programmer's responsibility to ensure that basic_ubjson_cursor
does not outlive any source passed in the constuctor,
as basic_ubjson_cursor
holds a pointer to but does not own this object.
source
- a value from which a source_type
is constructible.
bool done() const override;
Checks if there are no more events.
const staj_event& current() const override;
Returns the current staj_event.
void read(json_content_handler& handler) override
Feeds the current and succeeding staj events through the provided handler, until the handler indicates to stop. If a parsing error is encountered, throws a ser_error.
void read(json_content_handler& handler, std::error_code& ec) override
Feeds the current and succeeding staj events through the provided
handler, until the handler indicates
to stop. If a parsing error is encountered, sets ec
.
void next() override;
Advances to the next event. If a parsing error is encountered, throws a ser_error.
void next(std::error_code& ec) override;
Advances to the next event. If a parsing error is encountered, sets ec
.
const ser_context& context() const override;
Returns the current context