MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / sax_parse_internal

Method sax_parse_internal

Source/Utils/json.hpp:10283–10562  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10281 template<typename SAX>
10282 JSON_HEDLEY_NON_NULL(2)
10283 bool sax_parse_internal(SAX* sax)
10284 {
10285 // stack to remember the hierarchy of structured values we are parsing
10286 // true = array; false = object
10287 std::vector<bool> states;
10288 // value to avoid a goto (see comment where set to true)
10289 bool skip_to_state_evaluation = false;
10290
10291 while (true)
10292 {
10293 if (!skip_to_state_evaluation)
10294 {
10295 // invariant: get_token() was called before each iteration
10296 switch (last_token)
10297 {
10298 case token_type::begin_object:
10299 {
10300 if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1))))
10301 {
10302 return false;
10303 }
10304
10305 // closing } -> we are done
10306 if (get_token() == token_type::end_object)
10307 {
10308 if (JSON_HEDLEY_UNLIKELY(!sax->end_object()))
10309 {
10310 return false;
10311 }
10312 break;
10313 }
10314
10315 // parse key
10316 if (JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string))
10317 {
10318 return sax->parse_error(m_lexer.get_position(),
10319 m_lexer.get_token_string(),
10320 parse_error::create(101, m_lexer.get_position(),
10321 exception_message(token_type::value_string, "object key")));
10322 }
10323 if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string())))
10324 {
10325 return false;
10326 }
10327
10328 // parse separator (:)
10329 if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator))
10330 {
10331 return sax->parse_error(m_lexer.get_position(),
10332 m_lexer.get_token_string(),
10333 parse_error::create(101, m_lexer.get_position(),
10334 exception_message(token_type::name_separator, "object separator")));
10335 }
10336
10337 // remember we are now inside an object
10338 states.push_back(false);
10339
10340 // parse values

Callers

nothing calls this directly

Calls 15

createFunction · 0.85
get_token_stringMethod · 0.80
get_stringMethod · 0.80
pop_backMethod · 0.80
start_objectMethod · 0.45
end_objectMethod · 0.45
parse_errorMethod · 0.45
keyMethod · 0.45
push_backMethod · 0.45
start_arrayMethod · 0.45
end_arrayMethod · 0.45
number_floatMethod · 0.45

Tested by

no test coverage detected