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

Method parse_literal

include/boost/json/basic_parser_impl.hpp:790–871  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

788template<class Handler>
789template<class Literal>
790const char*
791basic_parser<Handler>::
792parse_literal(const char* p, Literal)
793{
794 using L = detail::literals;
795
796 std::size_t cur_lit;
797 std::size_t offset;
798
799 detail::const_stream_wrapper cs(p, end_);
800 BOOST_IF_CONSTEXPR( Literal::value != L::resume )
801 {
802 constexpr std::size_t index = literal_index(Literal::value);
803 constexpr char const* literal = detail::literal_strings[index];
804 constexpr std::size_t sz = detail::literal_sizes[index];
805
806 if(BOOST_JSON_LIKELY( cs.remain() >= sz ))
807 {
808 int const cmp = std::memcmp(cs.begin(), literal, sz);
809 if( cmp != 0 )
810 {
811 BOOST_STATIC_CONSTEXPR source_location loc = BOOST_CURRENT_LOCATION;
812 return fail(cs.begin(), error::syntax, &loc);
813 }
814
815 BOOST_IF_CONSTEXPR( Literal::value == L::null )
816 {
817 if(BOOST_JSON_UNLIKELY(
818 ! h_.on_null(ec_)))
819 return fail(cs.begin());
820 }
821 else BOOST_IF_CONSTEXPR( Literal::value == L::true_ )
822 {
823 if(BOOST_JSON_UNLIKELY(
824 ! h_.on_bool(true, ec_)))
825 return fail(cs.begin());
826 }
827 else BOOST_IF_CONSTEXPR( Literal::value == L::false_ )
828 {
829 if(BOOST_JSON_UNLIKELY(
830 ! h_.on_bool(false, ec_)))
831 return fail(cs.begin());
832 }
833 else BOOST_IF_CONSTEXPR( Literal::value == L::infinity )
834 {
835 if(BOOST_JSON_UNLIKELY(
836 ! h_.on_double(
837 std::numeric_limits<double>::infinity(),
838 string_view(literal, sz),
839 ec_)))
840 return fail(cs.begin());
841 }
842 else BOOST_IF_CONSTEXPR( Literal::value == L::neg_infinity )
843 {
844 if(BOOST_JSON_UNLIKELY(
845 ! h_.on_double(
846 -std::numeric_limits<double>::infinity(),
847 string_view(literal, sz),

Callers

nothing calls this directly

Calls 8

literal_indexFunction · 0.85
string_viewClass · 0.85
BOOST_IF_CONSTEXPRFunction · 0.70
remainMethod · 0.45
beginMethod · 0.45
on_nullMethod · 0.45
on_boolMethod · 0.45
on_doubleMethod · 0.45

Tested by

no test coverage detected