TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ parse()

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

11089 {
11090 if (callback)
11091 {
11092 json_sax_dom_callback_parser<BasicJsonType> sdp(result, callback, allow_exceptions);
11093 sax_parse_internal(&sdp);
11094
11095 // in strict mode, input must be completely read
11096 if (strict && (get_token() != token_type::end_of_input))
11097 {
11098 sdp.parse_error(m_lexer.get_position(),
11101 exception_message(token_type::end_of_input, "value"), BasicJsonType()));
11102 }
11103
11104 // in case of an error, return discarded value
11105 if (sdp.is_errored())
11106 {
11107 result = value_t::discarded;
11108 return;
11109 }
11110
11111 // set top-level value to null if it was discarded by the callback
11112 // function
11113 if (result.is_discarded())
11114 {
11115 result = nullptr;
11116 }
11117 }
11118
11119 else
11120 {
11121 json_sax_dom_parser<BasicJsonType> sdp(result, allow_exceptions);
11122 sax_parse_internal(&sdp);
11123
11124 // in strict mode, input must be completely read
11125 if (strict && (get_token() != token_type::end_of_input))
11126 {
11127 sdp.parse_error(m_lexer.get_position(),
11129 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), BasicJsonType()));
11130 }
11131
11132 // in case of an error, return discarded value
11133 if (sdp.is_errored())
11134 {
11135 result = value_t::discarded;
11136 return;
11137 }
11138 }
11139
11140 result.assert_invariant();
11141 }
constexpr position_t get_position() const noexcept
return position of last read token
Definition: json.hpp:8045
std::string get_token_string() const
return the last read token (for errors only).
Definition: json.hpp:8053
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, const BasicJsonType &context)
create a parse error exception
Definition: json.hpp:2800
lexer_t m_lexer
the lexer
Definition: json.hpp:11506
token_type get_token()
get next token from lexer
Definition: json.hpp:11465
const parser_callback_t< BasicJsonType > callback
callback function
Definition: json.hpp:11502
const bool allow_exceptions
whether to throw exceptions in case of errors
Definition: json.hpp:11508
@ discarded
discarded by the parser callback function