MCPcopy Create free account
hub / github.com/bupticybee/TexasSolver / parse

Method parse

include/json.hpp:8733–8786  ·  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

8731 @throw parse_error.103 if to_unicode fails
8732 */
8733 void parse(const bool strict, BasicJsonType& result)
8734 {
8735 if (callback)
8736 {
8737 json_sax_dom_callback_parser<BasicJsonType> sdp(result, callback, allow_exceptions);
8738 sax_parse_internal(&sdp);
8739 result.assert_invariant();
8740
8741 // in strict mode, input must be completely read
8742 if (strict and (get_token() != token_type::end_of_input))
8743 {
8744 sdp.parse_error(m_lexer.get_position(),
8745 m_lexer.get_token_string(),
8746 parse_error::create(101, m_lexer.get_position(),
8747 exception_message(token_type::end_of_input, "value")));
8748 }
8749
8750 // in case of an error, return discarded value
8751 if (sdp.is_errored())
8752 {
8753 result = value_t::discarded;
8754 return;
8755 }
8756
8757 // set top-level value to null if it was discarded by the callback
8758 // function
8759 if (result.is_discarded())
8760 {
8761 result = nullptr;
8762 }
8763 }
8764 else
8765 {
8766 json_sax_dom_parser<BasicJsonType> sdp(result, allow_exceptions);
8767 sax_parse_internal(&sdp);
8768 result.assert_invariant();
8769
8770 // in strict mode, input must be completely read
8771 if (strict and (get_token() != token_type::end_of_input))
8772 {
8773 sdp.parse_error(m_lexer.get_position(),
8774 m_lexer.get_token_string(),
8775 parse_error::create(101, m_lexer.get_position(),
8776 exception_message(token_type::end_of_input, "value")));
8777 }
8778
8779 // in case of an error, return discarded value
8780 if (sdp.is_errored())
8781 {
8782 result = value_t::discarded;
8783 return;
8784 }
8785 }
8786 }
8787
8788 /*!
8789 @brief public accept interface

Callers 3

main_backupFunction · 0.45
json.hppFile · 0.45
parseFunction · 0.45

Calls 5

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

Tested by

no test coverage detected