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

Method parse_array

include/boost/json/basic_parser_impl.hpp:1867–1974  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1865 bool AllowTrailing_,
1866 bool AllowBadUTF8_*/>
1867const char*
1868basic_parser<Handler>::
1869parse_array(const char* p,
1870 std::integral_constant<bool, StackEmpty_> stack_empty,
1871 std::integral_constant<bool, AllowComments_> allow_comments,
1872 /*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing,
1873 /*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
1874 bool allow_bad_utf16)
1875{
1876 detail::const_stream_wrapper cs(p, end_);
1877 std::size_t size;
1878 if(! stack_empty && ! st_.empty())
1879 {
1880 // resume
1881 state st;
1882 st_.pop(st);
1883 st_.pop(size);
1884 switch(st)
1885 {
1886 default: BOOST_JSON_UNREACHABLE();
1887 case state::arr1: goto do_arr1;
1888 case state::arr2: goto do_arr2;
1889 case state::arr3: goto do_arr3;
1890 case state::arr4: goto do_arr4;
1891 case state::arr5: goto do_arr5;
1892 case state::arr6: goto do_arr6;
1893 }
1894 }
1895 BOOST_ASSERT(*cs == '[');
1896 size = 0;
1897 if(BOOST_JSON_UNLIKELY(! depth_))
1898 {
1899 BOOST_STATIC_CONSTEXPR source_location loc = BOOST_CURRENT_LOCATION;
1900 return fail(cs.begin(), error::too_deep, &loc);
1901 }
1902 --depth_;
1903 if(BOOST_JSON_UNLIKELY(
1904 ! h_.on_array_begin(ec_)))
1905 return fail(cs.begin());
1906 ++cs;
1907 // array:
1908 // '[' *ws ']'
1909 // '[' *ws value *ws *[ ',' *ws value *ws ] ']'
1910do_arr1:
1911 cs = detail::count_whitespace(cs.begin(), cs.end());
1912 if(BOOST_JSON_UNLIKELY(! cs))
1913 return maybe_suspend(cs.begin(), state::arr1, size);
1914 if(BOOST_JSON_LIKELY(*cs != ']'))
1915 {
1916loop:
1917 if(allow_comments && *cs == '/')
1918 {
1919do_arr2:
1920 cs = parse_comment(cs.begin(), stack_empty, std::false_type());
1921 if(BOOST_JSON_UNLIKELY(incomplete(cs)))
1922 return suspend_or_fail(state::arr2, size);
1923 goto do_arr1;
1924 }

Callers

nothing calls this directly

Calls 8

count_whitespaceFunction · 0.85
parse_valueFunction · 0.85
popMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45
on_array_beginMethod · 0.45
endMethod · 0.45
on_array_endMethod · 0.45

Tested by

no test coverage detected