| 959 | template<class Handler> |
| 960 | template<bool StackEmpty_, bool IsKey_> |
| 961 | const char* |
| 962 | basic_parser<Handler>:: |
| 963 | parse_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 | |
| 993 | do_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); |
nothing calls this directly
no test coverage detected