MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / sax_parse_internal

Method sax_parse_internal

extern/json/json.hpp:12282–12560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12280 template<typename SAX>
12281 JSON_HEDLEY_NON_NULL(2)
12282 bool sax_parse_internal(SAX* sax)
12283 {
12284 // stack to remember the hierarchy of structured values we are parsing
12285 // true = array; false = object
12286 std::vector<bool> states;
12287 // value to avoid a goto (see comment where set to true)
12288 bool skip_to_state_evaluation = false;
12289
12290 while (true)
12291 {
12292 if (!skip_to_state_evaluation)
12293 {
12294 // invariant: get_token() was called before each iteration
12295 switch (last_token)
12296 {
12297 case token_type::begin_object:
12298 {
12299 if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast<std::size_t>(-1))))
12300 {
12301 return false;
12302 }
12303
12304 // closing } -> we are done
12305 if (get_token() == token_type::end_object)
12306 {
12307 if (JSON_HEDLEY_UNLIKELY(!sax->end_object()))
12308 {
12309 return false;
12310 }
12311 break;
12312 }
12313
12314 // parse key
12315 if (JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string))
12316 {
12317 return sax->parse_error(m_lexer.get_position(),
12318 m_lexer.get_token_string(),
12319 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), nullptr));
12320 }
12321 if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string())))
12322 {
12323 return false;
12324 }
12325
12326 // parse separator (:)
12327 if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator))
12328 {
12329 return sax->parse_error(m_lexer.get_position(),
12330 m_lexer.get_token_string(),
12331 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), nullptr));
12332 }
12333
12334 // remember we are now inside an object
12335 states.push_back(false);
12336
12337 // parse values
12338 get_token();
12339 continue;

Callers

nothing calls this directly

Calls 15

get_token_stringMethod · 0.80
get_stringMethod · 0.80
createFunction · 0.70
concatFunction · 0.70
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