MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / parse

Method parse

external/json/json.hpp:4888–4941  ·  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

4886 @throw parse_error.103 if to_unicode fails
4887 */
4888 void parse(const bool strict, BasicJsonType& result)
4889 {
4890 if (callback)
4891 {
4892 json_sax_dom_callback_parser<BasicJsonType> sdp(result, callback, allow_exceptions);
4893 sax_parse_internal(&sdp);
4894 result.assert_invariant();
4895
4896 // in strict mode, input must be completely read
4897 if (strict and (get_token() != token_type::end_of_input))
4898 {
4899 sdp.parse_error(m_lexer.get_position(),
4900 m_lexer.get_token_string(),
4901 parse_error::create(101, m_lexer.get_position(),
4902 exception_message(token_type::end_of_input, "value")));
4903 }
4904
4905 // in case of an error, return discarded value
4906 if (sdp.is_errored())
4907 {
4908 result = value_t::discarded;
4909 return;
4910 }
4911
4912 // set top-level value to null if it was discarded by the callback
4913 // function
4914 if (result.is_discarded())
4915 {
4916 result = nullptr;
4917 }
4918 }
4919 else
4920 {
4921 json_sax_dom_parser<BasicJsonType> sdp(result, allow_exceptions);
4922 sax_parse_internal(&sdp);
4923 result.assert_invariant();
4924
4925 // in strict mode, input must be completely read
4926 if (strict and (get_token() != token_type::end_of_input))
4927 {
4928 sdp.parse_error(m_lexer.get_position(),
4929 m_lexer.get_token_string(),
4930 parse_error::create(101, m_lexer.get_position(),
4931 exception_message(token_type::end_of_input, "value")));
4932 }
4933
4934 // in case of an error, return discarded value
4935 if (sdp.is_errored())
4936 {
4937 result = value_t::discarded;
4938 return;
4939 }
4940 }
4941 }
4942
4943 /*!
4944 @brief public accept interface

Callers 2

parseFunction · 0.45
json.hppFile · 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