nlohmann::detail::parser< BasicJsonType, InputAdapterType > Class Template Reference

syntax analysis More...

`#include <json.hpp>`

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...
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, InputAdapterType >
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< 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...
const bool | allow_exceptions = true
| whether to throw exceptions in case of errors 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 10708 of file json.hpp.

## Member Typedef Documentation

## lexer_t

template<typename BasicJsonType , typename InputAdapterType >

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

private

Definition at line 10714 of file json.hpp.

## number_float_t

template<typename BasicJsonType , typename InputAdapterType >

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

private

Definition at line 10712 of file json.hpp.

## number_integer_t

template<typename BasicJsonType , typename InputAdapterType >

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

private

Definition at line 10710 of file json.hpp.

## number_unsigned_t

template<typename BasicJsonType , typename InputAdapterType >

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

private

Definition at line 10711 of file json.hpp.

## string_t

template<typename BasicJsonType , typename InputAdapterType >

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

private

Definition at line 10713 of file json.hpp.

## token_type

template<typename BasicJsonType , typename InputAdapterType >

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

private

Definition at line 10715 of file json.hpp.

## Constructor & Destructor Documentation

## parser()

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`
| ) |  |

inline explicit

a parser reading from an input adapter

Definition at line 10719 of file json.hpp.

## Member Function Documentation

## accept()

template<typename BasicJsonType , typename InputAdapterType >

bool nlohmann::detail::parser< BasicJsonType, InputAdapterType >::accept | ( | const bool | strict = `true` | ) |

inline

public accept interface

Parameters

  [in] | strict | whether to expect the last token to be EOF

Returns
  whether the input is a proper JSON text

Definition at line 10801 of file json.hpp.

References JSON_HEDLEY_NON_NULL, and nlohmann::detail::strict.

## exception_message()

template<typename BasicJsonType , typename InputAdapterType >

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

inline private

Definition at line 11107 of file json.hpp.

References nlohmann::detail::string.

## get_token()

template<typename BasicJsonType , typename InputAdapterType >

token_type nlohmann::detail::parser< BasicJsonType, InputAdapterType >::get_token | ( |  | ) |

inline private

get next token from lexer

Definition at line 11102 of file json.hpp.

## parse()

template<typename BasicJsonType , typename InputAdapterType >

void nlohmann::detail::parser< BasicJsonType, InputAdapterType >::parse | ( | const bool | strict,
|  | BasicJsonType & | result
| ) |  |

inline

public parser interface

Parameters

  [in] | strict | whether to expect the last token to be EOF
  [in,out] | result | parsed JSON value

Exceptions

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

Definition at line 10741 of file json.hpp.

References nlohmann::detail::parse_error::create(), nlohmann::detail::discarded, nlohmann::detail::json_sax_dom_parser< BasicJsonType >::is_errored(), nlohmann::detail::json_sax_dom_callback_parser< BasicJsonType >::is_errored(), nlohmann::detail::json_sax_dom_parser< BasicJsonType >::parse_error(), and nlohmann::detail::json_sax_dom_callback_parser< BasicJsonType >::parse_error().

## sax_parse()

template<typename BasicJsonType , typename InputAdapterType >
template<typename SAX >

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

inline

Definition at line 10809 of file json.hpp.

References nlohmann::detail::parse_error::create(), JSON_HEDLEY_NON_NULL, nlohmann::detail::strict, and nlohmann::detail::void().

## sax_parse_internal()

template<typename BasicJsonType , typename InputAdapterType >
template<typename SAX >

bool nlohmann::detail::parser< BasicJsonType, InputAdapterType >::sax_parse_internal | ( | SAX * | sax | ) |

inline private

Definition at line 10828 of file json.hpp.

References nlohmann::detail::parse_error::create(), nlohmann::detail::out_of_range::create(), JSON_ASSERT, JSON_HEDLEY_LIKELY, and JSON_HEDLEY_UNLIKELY.

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

## callback

template<typename BasicJsonType , typename InputAdapterType >

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

private

callback function

Definition at line 11138 of file json.hpp.

## last_token

template<typename BasicJsonType , typename InputAdapterType >

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

private

the type of the last read token

Definition at line 11140 of file json.hpp.

## m_lexer

template<typename BasicJsonType , typename InputAdapterType >

lexer_t nlohmann::detail::parser< BasicJsonType, InputAdapterType >::m_lexer

private

the lexer

Definition at line 11142 of file json.hpp.

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

- json.hpp