CellModules
nlohmann::detail::parser< BasicJsonType > Class Template Reference

syntax analysis More...

#include <json.hpp>

Public Types

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

Public Member Functions

 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...
 
void parse (const bool strict, BasicJsonType &result)
 public parser interface More...
 
bool accept (const bool strict=true)
 public accept interface More...
 
template<typename SAX >
bool sax_parse (SAX *sax, const bool strict=true)
 

Private Types

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

Private Member Functions

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

Private Attributes

const parser_callback_t 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...
 
const bool allow_exceptions = true
 whether to throw exceptions in case of errors More...
 

Detailed Description

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

syntax analysis

This class implements a recursive decent parser.

Definition at line 7047 of file json.hpp.

Member Typedef Documentation

◆ lexer_t

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

Definition at line 7053 of file json.hpp.

◆ number_float_t

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

Definition at line 7051 of file json.hpp.

◆ number_integer_t

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

Definition at line 7049 of file json.hpp.

◆ number_unsigned_t

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

Definition at line 7050 of file json.hpp.

◆ parser_callback_t

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 7073 of file json.hpp.

◆ string_t

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

Definition at line 7052 of file json.hpp.

◆ token_type

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

Definition at line 7054 of file json.hpp.

Member Enumeration Documentation

◆ parse_event_t

template<typename BasicJsonType >
enum class 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 7057 of file json.hpp.

Constructor & Destructor Documentation

◆ parser()

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 7077 of file json.hpp.

Member Function Documentation

◆ accept()

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 7157 of file json.hpp.

◆ exception_message()

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

Definition at line 7470 of file json.hpp.

◆ get_token()

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

get next token from lexer

Definition at line 7465 of file json.hpp.

◆ parse()

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 7096 of file json.hpp.

◆ sax_parse()

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

Definition at line 7164 of file json.hpp.

◆ sax_parse_internal()

template<typename BasicJsonType >
template<typename SAX >
bool nlohmann::detail::parser< BasicJsonType >::sax_parse_internal ( SAX *  sax)
inlineprivate

Definition at line 7183 of file json.hpp.

Member Data Documentation

◆ allow_exceptions

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

whether to throw exceptions in case of errors

Definition at line 7507 of file json.hpp.

◆ callback

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

callback function

Definition at line 7501 of file json.hpp.

◆ last_token

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 7503 of file json.hpp.

◆ m_lexer

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

the lexer

Definition at line 7505 of file json.hpp.


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