MCPcopy Create free account
hub / github.com/Mixaill/FakePDB / sax_parse_internal

Method sax_parse_internal

src_cpp/include/nlohmann/json.hpp:10285–10564  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

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

Tested by

no test coverage detected