diff options
| author | Rutger Broekhoff | 2026-08-29 12:01:42 +0200 |
|---|---|---|
| committer | Rutger Broekhoff | 2026-08-29 12:01:42 +0200 |
| commit | 52b3cd46c76fd4be18aeb8422a08a073484b9fad (patch) | |
| tree | b4f23957c096e6bce5369bb94a4e8e23de71761a /server/src/xml.cppm | |
| parent | 35878b76049b9c3e752480e9f298b7e2da6fdf1f (diff) | |
| download | routemon-52b3cd46c76fd4be18aeb8422a08a073484b9fad.tar.gz routemon-52b3cd46c76fd4be18aeb8422a08a073484b9fad.zip | |
More module implementation partition units
Diffstat (limited to 'server/src/xml.cppm')
| -rw-r--r-- | server/src/xml.cppm | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/server/src/xml.cppm b/server/src/xml.cppm index 4648047..ffaf159 100644 --- a/server/src/xml.cppm +++ b/server/src/xml.cppm | |||
| @@ -201,7 +201,8 @@ struct eof_event | |||
| 201 | 201 | ||
| 202 | using event = std::variant< | 202 | using event = std::variant< |
| 203 | start_element_event, end_element_event, character_data_event, | 203 | start_element_event, end_element_event, character_data_event, |
| 204 | processing_instructions_event, xml_decl_event, eof_event>; | 204 | processing_instructions_event, xml_decl_event, eof_event |
| 205 | >; | ||
| 205 | 206 | ||
| 206 | template <class T> | 207 | template <class T> |
| 207 | concept event_type = requires(event ev) { std::get<T>(ev); }; | 208 | concept event_type = requires(event ev) { std::get<T>(ev); }; |
| @@ -522,6 +523,7 @@ public: | |||
| 522 | } | 523 | } |
| 523 | constexpr auto await_resume() const noexcept -> void { return; } | 524 | constexpr auto await_resume() const noexcept -> void { return; } |
| 524 | }; | 525 | }; |
| 526 | |||
| 525 | if (this->continuation()) | 527 | if (this->continuation()) |
| 526 | { | 528 | { |
| 527 | return awaiter{this->continuation()}; | 529 | return awaiter{this->continuation()}; |
| @@ -548,16 +550,19 @@ public: | |||
| 548 | { | 550 | { |
| 549 | return !executor_->advance_flag(); | 551 | return !executor_->advance_flag(); |
| 550 | } | 552 | } |
| 553 | |||
| 551 | auto await_suspend(std::coroutine_handle<promise<T>> h) -> void | 554 | auto await_suspend(std::coroutine_handle<promise<T>> h) -> void |
| 552 | { | 555 | { |
| 553 | executor_->set_continuation(h.promise().base_handle()); | 556 | executor_->set_continuation(h.promise().base_handle()); |
| 554 | } | 557 | } |
| 558 | |||
| 555 | [[nodiscard]] auto await_resume() const -> event | 559 | [[nodiscard]] auto await_resume() const -> event |
| 556 | { | 560 | { |
| 557 | assert(executor_->event()); | 561 | assert(executor_->event()); |
| 558 | return executor_->event().value(); | 562 | return executor_->event().value(); |
| 559 | } | 563 | } |
| 560 | }; | 564 | }; |
| 565 | |||
| 561 | return awaiter{req.executor}; | 566 | return awaiter{req.executor}; |
| 562 | } | 567 | } |
| 563 | 568 | ||
| @@ -572,6 +577,7 @@ public: | |||
| 572 | { | 577 | { |
| 573 | return false; | 578 | return false; |
| 574 | } | 579 | } |
| 580 | |||
| 575 | auto await_suspend(std::coroutine_handle<promise<T>> h) | 581 | auto await_suspend(std::coroutine_handle<promise<T>> h) |
| 576 | -> std::coroutine_handle<> | 582 | -> std::coroutine_handle<> |
| 577 | { | 583 | { |
| @@ -580,6 +586,7 @@ public: | |||
| 580 | next_->set_continuation(h.promise().base_handle()); | 586 | next_->set_continuation(h.promise().base_handle()); |
| 581 | return next_->handle(); | 587 | return next_->handle(); |
| 582 | } | 588 | } |
| 589 | |||
| 583 | auto await_resume() -> U | 590 | auto await_resume() -> U |
| 584 | { | 591 | { |
| 585 | // Promise is still valid since coroutine frame is still alive | 592 | // Promise is still valid since coroutine frame is still alive |
| @@ -599,6 +606,7 @@ public: | |||
| 599 | } | 606 | } |
| 600 | } | 607 | } |
| 601 | }; | 608 | }; |
| 609 | |||
| 602 | return awaiter{util::not_null{&coro.promise()}}; | 610 | return awaiter{util::not_null{&coro.promise()}}; |
| 603 | } | 611 | } |
| 604 | }; | 612 | }; |
| @@ -717,14 +725,16 @@ auto expect_element( | |||
| 717 | co_await expect_end_element(e, want); | 725 | co_await expect_end_element(e, want); |
| 718 | co_await ignore_whitespace(e); | 726 | co_await ignore_whitespace(e); |
| 719 | co_return std::forward< | 727 | co_return std::forward< |
| 720 | parser_invoke_result_t<decltype(p), executor_ref, attribute_view>>(res); | 728 | parser_invoke_result_t<decltype(p), executor_ref, attribute_view> |
| 729 | >(res); | ||
| 721 | } | 730 | } |
| 722 | 731 | ||
| 723 | auto allow_element( | 732 | auto allow_element( |
| 724 | executor_ref e, qname_view want, | 733 | executor_ref e, qname_view want, |
| 725 | parser_invocable<executor_ref, attribute_view> auto p) | 734 | parser_invocable<executor_ref, attribute_view> auto p) |
| 726 | -> parser<std::optional< | 735 | -> parser<std::optional< |
| 727 | parser_invoke_result_t<decltype(p), executor_ref, attribute_view>>> | 736 | parser_invoke_result_t<decltype(p), executor_ref, attribute_view> |
| 737 | >> | ||
| 728 | { | 738 | { |
| 729 | co_await ignore_whitespace(e); | 739 | co_await ignore_whitespace(e); |
| 730 | if (auto mattrs = co_await allow_start_element(e, want)) | 740 | if (auto mattrs = co_await allow_start_element(e, want)) |
| @@ -734,8 +744,8 @@ auto allow_element( | |||
| 734 | co_await ignore_whitespace(e); | 744 | co_await ignore_whitespace(e); |
| 735 | co_return std::make_optional( | 745 | co_return std::make_optional( |
| 736 | std::forward< | 746 | std::forward< |
| 737 | parser_invoke_result_t<decltype(p), executor_ref, attribute_view>>( | 747 | parser_invoke_result_t<decltype(p), executor_ref, attribute_view> |
| 738 | res)); | 748 | >(res)); |
| 739 | } | 749 | } |
| 740 | co_return std::nullopt; | 750 | co_return std::nullopt; |
| 741 | } | 751 | } |
| @@ -744,7 +754,8 @@ auto allow_element( | |||
| 744 | executor_ref e, qname_view want, | 754 | executor_ref e, qname_view want, |
| 745 | parser_invocable<executor_ref, attribute_view> auto p) -> parser<bool> | 755 | parser_invocable<executor_ref, attribute_view> auto p) -> parser<bool> |
| 746 | requires std::is_void_v< | 756 | requires std::is_void_v< |
| 747 | parser_invoke_result_t<decltype(p), executor_ref, attribute_view>> | 757 | parser_invoke_result_t<decltype(p), executor_ref, attribute_view> |
| 758 | > | ||
| 748 | { | 759 | { |
| 749 | co_await ignore_whitespace(e); | 760 | co_await ignore_whitespace(e); |
| 750 | if (auto mattrs = co_await allow_start_element(e, want)) | 761 | if (auto mattrs = co_await allow_start_element(e, want)) |