MCPcopy Create free account
hub / github.com/LAStools/LAStools / parse

Method parse

src/json.hpp:12265–12317  ·  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

12263 @throw parse_error.103 if to_unicode fails
12264 */
12265 void parse(const bool strict, BasicJsonType& result)
12266 {
12267 if (callback)
12268 {
12269 json_sax_dom_callback_parser<BasicJsonType> sdp(result, callback, allow_exceptions);
12270 sax_parse_internal(&sdp);
12271
12272 // in strict mode, input must be completely read
12273 if (strict && (get_token() != token_type::end_of_input))
12274 {
12275 sdp.parse_error(m_lexer.get_position(),
12276 m_lexer.get_token_string(),
12277 parse_error::create(101, m_lexer.get_position(),
12278 exception_message(token_type::end_of_input, "value"), nullptr));
12279 }
12280
12281 // in case of an error, return discarded value
12282 if (sdp.is_errored())
12283 {
12284 result = value_t::discarded;
12285 return;
12286 }
12287
12288 // set top-level value to null if it was discarded by the callback
12289 // function
12290 if (result.is_discarded())
12291 {
12292 result = nullptr;
12293 }
12294 }
12295 else
12296 {
12297 json_sax_dom_parser<BasicJsonType> sdp(result, allow_exceptions);
12298 sax_parse_internal(&sdp);
12299
12300 // in strict mode, input must be completely read
12301 if (strict && (get_token() != token_type::end_of_input))
12302 {
12303 sdp.parse_error(m_lexer.get_position(),
12304 m_lexer.get_token_string(),
12305 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), nullptr));
12306 }
12307
12308 // in case of an error, return discarded value
12309 if (sdp.is_errored())
12310 {
12311 result = value_t::discarded;
12312 return;
12313 }
12314 }
12315
12316 result.assert_invariant();
12317 }
12318
12319 /*!
12320 @brief public accept interface

Callers 14

mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
basic_json parseFunction · 0.45
json.hppFile · 0.45
parseFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
runMethod · 0.45
mainFunction · 0.45
mainFunction · 0.45

Calls 4

createFunction · 0.85
get_token_stringMethod · 0.80
is_erroredMethod · 0.80
parse_errorMethod · 0.45

Tested by

no test coverage detected