MCPcopy Create free account
hub / github.com/PeterFWS/Structure-PLP-SLAM / parse

Method parse

3rd/json/include/nlohmann/json.hpp:7096–7149  ·  view source on GitHub ↗

! @brief public parser interface @param[in] strict whether to expect the last token to be EOF @param[in,out] result parsed JSON value @throw parse_error.101 in case of an unexpected token @throw parse_error.102 if to_unicode fails or surrogate error @throw parse_error.103 if to_unicode fails */

Source from the content-addressed store, hash-verified

7094 @throw parse_error.103 if to_unicode fails
7095 */
7096 void parse(const bool strict, BasicJsonType& result)
7097 {
7098 if (callback)
7099 {
7100 json_sax_dom_callback_parser<BasicJsonType> sdp(result, callback, allow_exceptions);
7101 sax_parse_internal(&sdp);
7102 result.assert_invariant();
7103
7104 // in strict mode, input must be completely read
7105 if (strict and (get_token() != token_type::end_of_input))
7106 {
7107 sdp.parse_error(m_lexer.get_position(),
7108 m_lexer.get_token_string(),
7109 parse_error::create(101, m_lexer.get_position(),
7110 exception_message(token_type::end_of_input, "value")));
7111 }
7112
7113 // in case of an error, return discarded value
7114 if (sdp.is_errored())
7115 {
7116 result = value_t::discarded;
7117 return;
7118 }
7119
7120 // set top-level value to null if it was discarded by the callback
7121 // function
7122 if (result.is_discarded())
7123 {
7124 result = nullptr;
7125 }
7126 }
7127 else
7128 {
7129 json_sax_dom_parser<BasicJsonType> sdp(result, allow_exceptions);
7130 sax_parse_internal(&sdp);
7131 result.assert_invariant();
7132
7133 // in strict mode, input must be completely read
7134 if (strict and (get_token() != token_type::end_of_input))
7135 {
7136 sdp.parse_error(m_lexer.get_position(),
7137 m_lexer.get_token_string(),
7138 parse_error::create(101, m_lexer.get_position(),
7139 exception_message(token_type::end_of_input, "value")));
7140 }
7141
7142 // in case of an error, return discarded value
7143 if (sdp.is_errored())
7144 {
7145 result = value_t::discarded;
7146 return;
7147 }
7148 }
7149 }
7150
7151 /*!
7152 @brief public accept interface

Callers 3

basic_json parseFunction · 0.45
parseFunction · 0.45
json.hppFile · 0.45

Calls 5

get_positionMethod · 0.80
createFunction · 0.70
parse_errorMethod · 0.45
get_token_stringMethod · 0.45
is_erroredMethod · 0.45

Tested by

no test coverage detected