MCPcopy Create free account
hub / github.com/boostorg/parser / bool_parser

Class bool_parser

include/boost/parser/parser.hpp:8203–8268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8201#ifndef BOOST_PARSER_DOXYGEN
8202
8203 struct bool_parser
8204 {
8205 template<
8206 typename Iter,
8207 typename Sentinel,
8208 typename Context,
8209 typename SkipParser>
8210 bool call(
8211 Iter & first,
8212 Sentinel last,
8213 Context const & context,
8214 SkipParser const & skip,
8215 detail::flags flags,
8216 bool & success) const
8217 {
8218 bool retval{};
8219 call(first, last, context, skip, flags, success, retval);
8220 return retval;
8221 }
8222
8223 template<
8224 typename Iter,
8225 typename Sentinel,
8226 typename Context,
8227 typename SkipParser,
8228 typename Attribute>
8229 void call(
8230 Iter & first,
8231 Sentinel last,
8232 Context const & context,
8233 SkipParser const & skip,
8234 detail::flags flags,
8235 bool & success,
8236 Attribute & retval) const
8237 {
8238#if BOOST_PARSER_DO_TRACE
8239 [[maybe_unused]] auto _ = detail::scoped_trace(
8240 *this, first, last, context, flags, retval);
8241#endif
8242
8243 auto compare =
8244 [no_case = context.no_case_depth_](char32_t a, char32_t b) {
8245 if (no_case && 0x41 <= b && b < 0x5b)
8246 b += 0x20;
8247 return a == b;
8248 };
8249
8250 // The lambda quiets a signed/unsigned mismatch warning when
8251 // comparing the chars here to code points.
8252 char const t[] = "true";
8253 if (detail::mismatch(t, t + 4, first, last, compare).first ==
8254 t + 4) {
8255 std::advance(first, 4);
8256 detail::assign(retval, true);
8257 return;
8258 }
8259 char const f[] = "false";
8260 if (detail::mismatch(f, f + 5, first, last, compare).first ==

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected