Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
nlohmann::detail::parser< BasicJsonType > Class Template Reference

syntax analysis More...

#include <json.hpp>

Public Types

enum  parse_event_t : uint8_t {
  parse_event_t::object_start, parse_event_t::object_end, parse_event_t::array_start, parse_event_t::array_end,
  parse_event_t::key, parse_event_t::value
}
 
using parser_callback_t = std::function< bool(int depth, parse_event_t event, BasicJsonType &parsed)>
 

Public Member Functions

bool accept (const bool strict=true)
 public accept interface More...
 
void parse (const bool strict, BasicJsonType &result)
 public parser interface More...
 
 parser (detail::input_adapter_t adapter, const parser_callback_t cb=nullptr, const bool allow_exceptions_=true)
 a parser reading from an input adapter More...
 

Private Types

using lexer_t = lexer< BasicJsonType >
 
using number_float_t = typename BasicJsonType::number_float_t
 
using number_integer_t = typename BasicJsonType::number_integer_t
 
using number_unsigned_t = typename BasicJsonType::number_unsigned_t
 
using string_t = typename BasicJsonType::string_t
 
using token_type = typename lexer_t::token_type
 

Private Member Functions

bool accept_internal ()
 the actual acceptor More...
 
bool expect (token_type t)
 
token_type get_token ()
 get next token from lexer More...
 
void parse_internal (bool keep, BasicJsonType &result)
 the actual parser More...
 
void throw_exception () const
 

Private Attributes

const bool allow_exceptions = true
 whether to throw exceptions in case of errors More...
 
const parser_callback_t callback = nullptr
 callback function More...
 
int depth = 0
 current level of recursion More...
 
bool errored = false
 whether a syntax error occurred More...
 
token_type expected = token_type::uninitialized
 possible reason for the syntax error More...
 
token_type last_token = token_type::uninitialized
 the type of the last read token More...
 
lexer_t m_lexer
 the lexer More...
 

Detailed Description

template<typename BasicJsonType>
class nlohmann::detail::parser< BasicJsonType >

syntax analysis

This class implements a recursive decent parser.

Definition at line 3154 of file json.hpp.

Member Typedef Documentation

template<typename BasicJsonType >
using nlohmann::detail::parser< BasicJsonType >::lexer_t = lexer<BasicJsonType>
private

Definition at line 3160 of file json.hpp.

template<typename BasicJsonType >
using nlohmann::detail::parser< BasicJsonType >::number_float_t = typename BasicJsonType::number_float_t
private

Definition at line 3158 of file json.hpp.

template<typename BasicJsonType >
using nlohmann::detail::parser< BasicJsonType >::number_integer_t = typename BasicJsonType::number_integer_t
private

Definition at line 3156 of file json.hpp.

template<typename BasicJsonType >
using nlohmann::detail::parser< BasicJsonType >::number_unsigned_t = typename BasicJsonType::number_unsigned_t
private

Definition at line 3157 of file json.hpp.

template<typename BasicJsonType >
using nlohmann::detail::parser< BasicJsonType >::parser_callback_t = std::function<bool(int depth, parse_event_t event, BasicJsonType& parsed)>

Definition at line 3181 of file json.hpp.

template<typename BasicJsonType >
using nlohmann::detail::parser< BasicJsonType >::string_t = typename BasicJsonType::string_t
private

Definition at line 3159 of file json.hpp.

template<typename BasicJsonType >
using nlohmann::detail::parser< BasicJsonType >::token_type = typename lexer_t::token_type
private

Definition at line 3161 of file json.hpp.

Member Enumeration Documentation

template<typename BasicJsonType >
enum nlohmann::detail::parser::parse_event_t : uint8_t
strong
Enumerator
object_start 

the parser read { and started to process a JSON object

object_end 

the parser read } and finished processing a JSON object

array_start 

the parser read [ and started to process a JSON array

array_end 

the parser read ] and finished processing a JSON array

key 

the parser read a key of a value in an object

value 

the parser finished reading a JSON value

Definition at line 3164 of file json.hpp.

Constructor & Destructor Documentation

template<typename BasicJsonType >
nlohmann::detail::parser< BasicJsonType >::parser ( detail::input_adapter_t  adapter,
const parser_callback_t  cb = nullptr,
const bool  allow_exceptions_ = true 
)
inlineexplicit

a parser reading from an input adapter

Definition at line 3184 of file json.hpp.

Member Function Documentation

template<typename BasicJsonType >
bool nlohmann::detail::parser< BasicJsonType >::accept ( const bool  strict = true)
inline

public accept interface

Parameters
[in]strictwhether to expect the last token to be EOF
Returns
whether the input is a proper JSON text

Definition at line 3236 of file json.hpp.

template<typename BasicJsonType >
bool nlohmann::detail::parser< BasicJsonType >::accept_internal ( )
inlineprivate

the actual acceptor

Invariant
1. The last token is not yet processed. Therefore, the caller of this function must make sure a token has been read.
  1. When this function returns, the last token is processed. That is, the last read character was already considered.

This invariant makes sure that no token needs to be "unput".

Definition at line 3546 of file json.hpp.

template<typename BasicJsonType >
bool nlohmann::detail::parser< BasicJsonType >::expect ( token_type  t)
inlineprivate
Exceptions
parse_error.101if expected token did not occur

Definition at line 3658 of file json.hpp.

template<typename BasicJsonType >
token_type nlohmann::detail::parser< BasicJsonType >::get_token ( )
inlineprivate

get next token from lexer

Definition at line 3650 of file json.hpp.

template<typename BasicJsonType >
void nlohmann::detail::parser< BasicJsonType >::parse ( const bool  strict,
BasicJsonType &  result 
)
inline

public parser interface

Parameters
[in]strictwhether to expect the last token to be EOF
[in,out]resultparsed JSON value
Exceptions
parse_error.101in case of an unexpected token
parse_error.102if to_unicode fails or surrogate error
parse_error.103if to_unicode fails

Definition at line 3200 of file json.hpp.

template<typename BasicJsonType >
void nlohmann::detail::parser< BasicJsonType >::parse_internal ( bool  keep,
BasicJsonType &  result 
)
inlineprivate

the actual parser

Exceptions
parse_error.101in case of an unexpected token
parse_error.102if to_unicode fails or surrogate error
parse_error.103if to_unicode fails

Definition at line 3257 of file json.hpp.

template<typename BasicJsonType >
void nlohmann::detail::parser< BasicJsonType >::throw_exception ( ) const
inlineprivate

Definition at line 3677 of file json.hpp.

Member Data Documentation

template<typename BasicJsonType >
const bool nlohmann::detail::parser< BasicJsonType >::allow_exceptions = true
private

whether to throw exceptions in case of errors

Definition at line 3712 of file json.hpp.

template<typename BasicJsonType >
const parser_callback_t nlohmann::detail::parser< BasicJsonType >::callback = nullptr
private

callback function

Definition at line 3702 of file json.hpp.

template<typename BasicJsonType >
int nlohmann::detail::parser< BasicJsonType >::depth = 0
private

current level of recursion

Definition at line 3700 of file json.hpp.

template<typename BasicJsonType >
bool nlohmann::detail::parser< BasicJsonType >::errored = false
private

whether a syntax error occurred

Definition at line 3708 of file json.hpp.

template<typename BasicJsonType >
token_type nlohmann::detail::parser< BasicJsonType >::expected = token_type::uninitialized
private

possible reason for the syntax error

Definition at line 3710 of file json.hpp.

template<typename BasicJsonType >
token_type nlohmann::detail::parser< BasicJsonType >::last_token = token_type::uninitialized
private

the type of the last read token

Definition at line 3704 of file json.hpp.

template<typename BasicJsonType >
lexer_t nlohmann::detail::parser< BasicJsonType >::m_lexer
private

the lexer

Definition at line 3706 of file json.hpp.


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


json_transport
Author(s): Paul Bovbel
autogenerated on Thu Jun 13 2019 19:12:24