tetengo 1.9.2
A multipurpose library set
Loading...
Searching...
No Matches
tetengo::json::json_parser Class Reference

A JSON parser. More...

#include <json_parser.hpp>

Inheritance diagram for tetengo::json::json_parser:
Collaboration diagram for tetengo::json::json_parser:

Public Member Functions

 json_parser (std::unique_ptr< reader > &&p_reader, std::size_t buffer_capacity=default_buffer_capacity())
 Creates a JSON parser.
 ~json_parser ()
 Destroys the JSON parser.
bool has_next () const
 Returns true when the next element exists.
const element & peek () const
 Returns the current element.
void next ()
 Moves to the next element.

Static Public Member Functions

static std::size_t default_buffer_capacity ()
 Returns the default buffer capacity.

Detailed Description

A JSON parser.

Based on RFC 8259.

Constructor & Destructor Documentation

◆ json_parser()

tetengo::json::json_parser::json_parser ( std::unique_ptr< reader > && p_reader,
std::size_t buffer_capacity = default_buffer_capacity() )
explicit

Creates a JSON parser.

Parameters
p_readerA unique pointer to a reader.
buffer_capacityA buffer capacity.
Exceptions
std::invalid_argumentWhen p_reader is nullptr.

Member Function Documentation

◆ default_buffer_capacity()

std::size_t tetengo::json::json_parser::default_buffer_capacity ( )
staticnodiscard

Returns the default buffer capacity.

Returns
The default buffer capacity.

◆ has_next()

bool tetengo::json::json_parser::has_next ( ) const
nodiscard

Returns true when the next element exists.

Return values
trueWhen the next element exists.
falseOtherwise.

◆ next()

void tetengo::json::json_parser::next ( )

Moves to the next element.

Exceptions
std::logic_errorWhen the current position is beyond the termination point.

◆ peek()

const element & tetengo::json::json_parser::peek ( ) const
nodiscard

Returns the current element.

Returns
The current element.
Exceptions
std::logic_errorWhen the current position is beyond the termination point.

The documentation for this class was generated from the following file: