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

Function main

test/transform_replace.cpp:363–781  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

361}
362
363int main()
364{
365
366// detail_attr_search_repack_shim
367{
368 using namespace bp::literals;
369
370 {
371 std::string str = "";
372 auto parser = bp::string("XYZ");
373
374 // Follows body of attr_search_impl() that constructs a custom parser
375 // from the given one.
376 auto first = bp::detail::text::detail::begin(str);
377 auto const last = bp::detail::text::detail::end(str);
378 auto match_first = first;
379 auto match_last = first;
380 auto before = [&match_first](auto & ctx) {
381 match_first = _where(ctx).begin();
382 };
383 auto after = [&match_last](auto & ctx) {
384 match_last = _where(ctx).begin();
385 };
386 auto const search_parser =
387 bp::omit[*(bp::char_ - parser)] >>
388 -bp::lexeme[bp::eps[before] >> bp::skip[parser] >> bp::eps[after]];
389
390 auto result = bp::prefix_parse(
391 first, last, search_parser, bp::ws, bp::trace::off);
392 static_assert(std::is_same_v<
393 decltype(result),
394 std::optional<std::optional<std::string>>>);
395 static_assert(std::is_same_v<
396 decltype(bp::prefix_parse(
397 first, last, search_parser, bp::ws, bp::trace::off)),
398 std::optional<std::optional<std::string>>>);
399 }
400 {
401 std::string str = "";
402 auto parser = bp::string("XYZ");
403 bp::detail::attr_search_impl(str, parser, bp::ws, bp::trace::off);
404 }
405 {
406 std::string str = "";
407 auto result = bp::detail::attr_search_repack_shim(
408 str, bp::string("XYZ"), bp::ws, bp::trace::off);
409 auto subrng = bp::get(result, 0_c);
410 BOOST_TEST(subrng.begin() == std::begin(str));
411 BOOST_TEST(subrng.end() == std::begin(str));
412 auto result_str = bp::get(result, 1_c);
413 BOOST_TEST(result_str == "");
414 }
415 {
416 char const str[] = "not here";
417 auto result = bp::detail::attr_search_repack_shim(
418 str, bp::string("XYZ"), bp::ws, bp::trace::off);
419 auto subrng = bp::get(result, 0_c);
420 BOOST_TEST(subrng.begin() == std::end(str));

Callers

nothing calls this directly

Calls 11

_whereFunction · 0.85
prefix_parseFunction · 0.85
attr_search_implFunction · 0.85
attr_search_repack_shimFunction · 0.85
null_termFunction · 0.85
stringClass · 0.50
beginFunction · 0.50
endFunction · 0.50
getFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected