MCPcopy Create free account
hub / github.com/boostorg/json / parse_string

Method parse_string

include/boost/json/basic_parser_impl.hpp:961–1120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

959template<class Handler>
960template<bool StackEmpty_, bool IsKey_>
961const char*
962basic_parser<Handler>::
963parse_string(const char* p,
964 std::integral_constant<bool, StackEmpty_> stack_empty,
965 std::integral_constant<bool, IsKey_> is_key,
966 bool allow_bad_utf8,
967 bool allow_bad_utf16)
968{
969 detail::const_stream_wrapper cs(p, end_);
970 std::size_t total;
971 char const* start;
972 std::size_t size;
973 if(! stack_empty && ! st_.empty())
974 {
975 state st;
976 st_.pop(st);
977 st_.pop(total);
978 switch(st)
979 {
980 default: BOOST_JSON_UNREACHABLE();
981 case state::str2: goto do_str2;
982 case state::str8: goto do_str8;
983 case state::str1: break;
984 }
985 }
986 else
987 {
988 BOOST_ASSERT(*cs == '\x22'); // '"'
989 ++cs;
990 total = 0;
991 }
992
993do_str1:
994 start = cs.begin();
995 cs = allow_bad_utf8?
996 detail::count_valid<true>(cs.begin(), cs.end()):
997 detail::count_valid<false>(cs.begin(), cs.end());
998 size = cs.used(start);
999 if(is_key)
1000 {
1001 BOOST_ASSERT(total <= Handler::max_key_size);
1002 if(BOOST_JSON_UNLIKELY(size >
1003 Handler::max_key_size - total))
1004 {
1005 BOOST_STATIC_CONSTEXPR source_location loc
1006 = BOOST_CURRENT_LOCATION;
1007 return fail(cs.begin(), error::key_too_large, &loc);
1008 }
1009 }
1010 else
1011 {
1012 BOOST_ASSERT(total <= Handler::max_string_size);
1013 if(BOOST_JSON_UNLIKELY(size >
1014 Handler::max_string_size - total))
1015 {
1016 BOOST_STATIC_CONSTEXPR source_location loc
1017 = BOOST_CURRENT_LOCATION;
1018 return fail(cs.begin(), error::string_too_large, &loc);

Callers

nothing calls this directly

Calls 15

count_valid<false>Function · 0.85
popMethod · 0.80
saveMethod · 0.80
completeMethod · 0.80
neededMethod · 0.80
validMethod · 0.80
lengthMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
usedMethod · 0.45
on_key_partMethod · 0.45

Tested by

no test coverage detected