A Discrete-Event Network Simulator
API
nlohmann::detail::parser< BasicJsonType, InputAdapterType > Class Template Reference

syntax analysis More...

#include "json.h"

+ Collaboration diagram for nlohmann::detail::parser< BasicJsonType, InputAdapterType >:

Public Member Functions

 parser (InputAdapterType &&adapter, const parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool skip_comments=false)
 a parser reading from an input adapter More...
 
 parser (InputAdapterType &&adapter, const parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool skip_comments=false)
 a parser reading from an input adapter More...
 
bool accept (const bool strict=true)
 public accept interface More...
 
bool accept (const bool strict=true)
 public accept interface More...
 
void parse (const bool strict, BasicJsonType &result)
 public parser interface More...
 
void parse (const bool strict, BasicJsonType &result)
 public parser interface More...
 
template<typename SAX >
bool sax_parse (SAX *sax, const bool strict=true)
 
template<typename SAX >
bool sax_parse (SAX *sax, const bool strict=true)
 

Private Types

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

Private Member Functions

std::string exception_message (const token_type expected, const std::string &context)
 
std::string exception_message (const token_type expected, const std::string &context)
 
token_type get_token ()
 get next token from lexer More...
 
token_type get_token ()
 get next token from lexer More...
 
template<typename SAX >
bool sax_parse_internal (SAX *sax)
 
template<typename SAX >
bool sax_parse_internal (SAX *sax)
 

Private Attributes

const bool allow_exceptions = true
 whether to throw exceptions in case of errors More...
 
const parser_callback_t< BasicJsonType > callback = nullptr
 callback function 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, typename InputAdapterType>
class nlohmann::detail::parser< BasicJsonType, InputAdapterType >

syntax analysis

This class implements a recursive descent parser.

Definition at line 10232 of file json.h.

Member Typedef Documentation

◆ lexer_t [1/2]

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

Definition at line 10238 of file json.h.

◆ lexer_t [2/2]

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

Definition at line 10238 of file json.h.

◆ number_float_t [1/2]

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

Definition at line 10236 of file json.h.

◆ number_float_t [2/2]

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

Definition at line 10236 of file json.h.

◆ number_integer_t [1/2]

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

Definition at line 10234 of file json.h.

◆ number_integer_t [2/2]

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

Definition at line 10234 of file json.h.

◆ number_unsigned_t [1/2]

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

Definition at line 10235 of file json.h.

◆ number_unsigned_t [2/2]

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

Definition at line 10235 of file json.h.

◆ string_t [1/2]

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

Definition at line 10237 of file json.h.

◆ string_t [2/2]

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

Definition at line 10237 of file json.h.

◆ token_type [1/2]

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

Definition at line 10239 of file json.h.

◆ token_type [2/2]

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

Definition at line 10239 of file json.h.

Constructor & Destructor Documentation

◆ parser() [1/2]

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

a parser reading from an input adapter

Definition at line 10243 of file json.h.

References nlohmann::detail::parser< BasicJsonType, InputAdapterType >::get_token().

+ Here is the call graph for this function:

◆ parser() [2/2]

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

a parser reading from an input adapter

Definition at line 10243 of file json.h.

References nlohmann::detail::parser< BasicJsonType, InputAdapterType >::get_token().

+ Here is the call graph for this function:

Member Function Documentation

◆ accept() [1/2]

template<typename BasicJsonType , typename InputAdapterType >
bool nlohmann::detail::parser< BasicJsonType, InputAdapterType >::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 10326 of file json.h.

References nlohmann::detail::parser< BasicJsonType, InputAdapterType >::sax_parse(), and nlohmann::detail::strict.

+ Here is the call graph for this function:

◆ accept() [2/2]

template<typename BasicJsonType , typename InputAdapterType >
bool nlohmann::detail::parser< BasicJsonType, InputAdapterType >::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 10326 of file json.h.

References nlohmann::detail::parser< BasicJsonType, InputAdapterType >::sax_parse(), and nlohmann::detail::strict.

+ Here is the call graph for this function:

◆ exception_message() [1/2]

template<typename BasicJsonType , typename InputAdapterType >
std::string nlohmann::detail::parser< BasicJsonType, InputAdapterType >::exception_message ( const token_type  expected,
const std::string &  context 
)
inlineprivate

◆ exception_message() [2/2]

template<typename BasicJsonType , typename InputAdapterType >
std::string nlohmann::detail::parser< BasicJsonType, InputAdapterType >::exception_message ( const token_type  expected,
const std::string &  context 
)
inlineprivate

◆ get_token() [1/2]

◆ get_token() [2/2]

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

◆ parse() [1/2]

◆ parse() [2/2]

template<typename BasicJsonType , typename InputAdapterType >
void nlohmann::detail::parser< BasicJsonType, InputAdapterType >::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 10265 of file json.h.

References nlohmann::detail::parser< BasicJsonType, InputAdapterType >::allow_exceptions, nlohmann::detail::parser< BasicJsonType, InputAdapterType >::callback, nlohmann::detail::parse_error::create(), nlohmann::detail::discarded, nlohmann::detail::parser< BasicJsonType, InputAdapterType >::exception_message(), nlohmann::detail::parser< BasicJsonType, InputAdapterType >::get_token(), nlohmann::detail::parser< BasicJsonType, InputAdapterType >::m_lexer, nlohmann::detail::parser< BasicJsonType, InputAdapterType >::sax_parse_internal(), and nlohmann::detail::strict.

+ Here is the call graph for this function:

◆ sax_parse() [1/2]

template<typename BasicJsonType , typename InputAdapterType >
template<typename SAX >
bool nlohmann::detail::parser< BasicJsonType, InputAdapterType >::sax_parse ( SAX *  sax,
const bool  strict = true 
)
inline

◆ sax_parse() [2/2]

template<typename BasicJsonType , typename InputAdapterType >
template<typename SAX >
bool nlohmann::detail::parser< BasicJsonType, InputAdapterType >::sax_parse ( SAX *  sax,
const bool  strict = true 
)
inline

◆ sax_parse_internal() [1/2]

◆ sax_parse_internal() [2/2]

Member Data Documentation

◆ allow_exceptions

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

whether to throw exceptions in case of errors

Definition at line 10678 of file json.h.

Referenced by nlohmann::detail::parser< BasicJsonType, InputAdapterType >::parse().

◆ callback

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

callback function

Definition at line 10672 of file json.h.

Referenced by nlohmann::detail::parser< BasicJsonType, InputAdapterType >::parse().

◆ last_token

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

◆ m_lexer


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