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

Method sax_parse_internal

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

Source from the content-addressed store, hash-verified

7181 private:
7182 template <typename SAX>
7183 bool sax_parse_internal(SAX* sax)
7184 {
7185 // stack to remember the hierarchy of structured values we are parsing
7186 // true = array; false = object
7187 std::vector<bool> states;
7188 // value to avoid a goto (see comment where set to true)
7189 bool skip_to_state_evaluation = false;
7190
7191 while (true)
7192 {
7193 if (not skip_to_state_evaluation)
7194 {
7195 // invariant: get_token() was called before each iteration
7196 switch (last_token)
7197 {
7198 case token_type::begin_object:
7199 {
7200 if (JSON_UNLIKELY(not sax->start_object(std::size_t(-1))))
7201 {
7202 return false;
7203 }
7204
7205 // closing } -> we are done
7206 if (get_token() == token_type::end_object)
7207 {
7208 if (JSON_UNLIKELY(not sax->end_object()))
7209 {
7210 return false;
7211 }
7212 break;
7213 }
7214
7215 // parse key
7216 if (JSON_UNLIKELY(last_token != token_type::value_string))
7217 {
7218 return sax->parse_error(m_lexer.get_position(),
7219 m_lexer.get_token_string(),
7220 parse_error::create(101, m_lexer.get_position(),
7221 exception_message(token_type::value_string, "object key")));
7222 }
7223 if (JSON_UNLIKELY(not sax->key(m_lexer.get_string())))
7224 {
7225 return false;
7226 }
7227
7228 // parse separator (:)
7229 if (JSON_UNLIKELY(get_token() != token_type::name_separator))
7230 {
7231 return sax->parse_error(m_lexer.get_position(),
7232 m_lexer.get_token_string(),
7233 parse_error::create(101, m_lexer.get_position(),
7234 exception_message(token_type::name_separator, "object separator")));
7235 }
7236
7237 // remember we are now inside an object
7238 states.push_back(false);
7239
7240 // parse values

Callers

nothing calls this directly

Calls 15

get_positionMethod · 0.80
get_stringMethod · 0.80
get_number_floatMethod · 0.80
get_number_integerMethod · 0.80
get_number_unsignedMethod · 0.80
pop_backMethod · 0.80
createFunction · 0.70
start_objectMethod · 0.45
end_objectMethod · 0.45
parse_errorMethod · 0.45
get_token_stringMethod · 0.45
keyMethod · 0.45

Tested by

no test coverage detected