From b0d7600970d2fdb1eb6fff813c7336ea34d4e228 Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Fri, 28 Aug 2026 22:22:24 +0200 Subject: Indent tweaks --- server/src/xml.cppm | 140 ++++++++++++++++++++++++++-------------------------- 1 file changed, 70 insertions(+), 70 deletions(-) (limited to 'server/src/xml.cppm') diff --git a/server/src/xml.cppm b/server/src/xml.cppm index 0c319e6..4648047 100644 --- a/server/src/xml.cppm +++ b/server/src/xml.cppm @@ -66,7 +66,7 @@ public: }; inline explicit attribute_view_iterator( - std::string_view default_ns_uri, char const* const* attrs) + std::string_view default_ns_uri, char const* const* attrs) : default_ns_uri_{default_ns_uri}, attrs_{attrs} { } @@ -105,7 +105,7 @@ class attribute_view : std::ranges::view_base public: inline explicit attribute_view( - std::string_view default_ns_uri, char const** attrs) + std::string_view default_ns_uri, char const** attrs) : default_ns_uri_{default_ns_uri}, attrs_{const_cast(attrs)} { @@ -122,7 +122,7 @@ public: } inline auto lookup(qname_view want) - -> std::optional> + -> std::optional> { for (auto const& [name, v] : *this) { @@ -200,8 +200,8 @@ struct eof_event }; using event = std::variant< - start_element_event, end_element_event, character_data_event, - processing_instructions_event, xml_decl_event, eof_event>; + start_element_event, end_element_event, character_data_event, + processing_instructions_event, xml_decl_event, eof_event>; template concept event_type = requires(event ev) { std::get(ev); }; @@ -237,7 +237,7 @@ public: } [[nodiscard]] inline auto continuation() const - -> std::coroutine_handle + -> std::coroutine_handle { return continuation_; } @@ -285,11 +285,11 @@ class executor s != XML_STATUS_OK) { ex_ = std::make_exception_ptr( - std::runtime_error{"unexpected error when stopping XML parser"}); + std::runtime_error{"unexpected error when stopping XML parser"}); return; } ex_ = std::make_exception_ptr( - std::runtime_error{"parser did not consume entire XML document"}); + std::runtime_error{"parser did not consume entire XML document"}); return; } continuation_.resume(); @@ -302,74 +302,74 @@ class executor static auto handle_start_element(void* ctx, char const* name, char const** attrs) noexcept - -> void + -> void { auto qname = detail::split_name(name); static_cast(ctx)->try_handle_event( - start_element_event{ - .name = qname, - .attrs = attribute_view{qname.ns_uri, attrs}, - }); + start_element_event{ + .name = qname, + .attrs = attribute_view{qname.ns_uri, attrs}, + }); } static auto handle_end_element(void* ctx, char const* name) noexcept -> void { static_cast(ctx)->try_handle_event( - end_element_event{ - .name = detail::split_name(name), - }); + end_element_event{ + .name = detail::split_name(name), + }); } static auto handle_character_data(void* ctx, char const* s, int len) noexcept - -> void + -> void { static_cast(ctx)->try_handle_event( - character_data_event{ - .data = std::string_view{s, static_cast(len)}, - }); + character_data_event{ + .data = std::string_view{s, static_cast(len)}, + }); } static auto handle_processing_instructions( - void* ctx, char const* target, char const* data) noexcept -> void + void* ctx, char const* target, char const* data) noexcept -> void { static_cast(ctx)->try_handle_event( - processing_instructions_event{ - .target = util::lazy_zstring_view{target}, - .data = util::lazy_zstring_view{data}, - }); + processing_instructions_event{ + .target = util::lazy_zstring_view{target}, + .data = util::lazy_zstring_view{data}, + }); } static auto handle_external_entity_ref( - XML_Parser, char const* /* context */, char const* /* base */, - char const* /* system_id */, char const* /* public_id */) noexcept -> int + XML_Parser, char const* /* context */, char const* /* base */, + char const* /* system_id */, char const* /* public_id */) noexcept -> int { return XML_STATUS_ERROR; } static auto handle_start_namespace_decl( - void* ctx, char const* prefix, char const* uri) noexcept -> void + void* ctx, char const* prefix, char const* uri) noexcept -> void { if (prefix) { static_cast(ctx) - ->namespaces_[std::string_view{prefix}] - .emplace_back(uri); + ->namespaces_[std::string_view{prefix}] + .emplace_back(uri); } else { static_cast(ctx)->default_namespace_.push_back( - uri ? std::make_optional(uri) : std::nullopt); + uri ? std::make_optional(uri) : std::nullopt); } } static auto handle_end_namespace_decl(void* ctx, char const* prefix) noexcept - -> void + -> void { if (prefix) { static_cast(ctx) - ->namespaces_[std::string_view{prefix}] - .pop_back(); + ->namespaces_[std::string_view{prefix}] + .pop_back(); } else { @@ -378,16 +378,16 @@ class executor } static auto handle_xml_decl( - void* ctx, char const* version, char const* encoding, - int standalone) noexcept -> void + void* ctx, char const* version, char const* encoding, + int standalone) noexcept -> void { static_cast(ctx)->try_handle_event( - xml_decl_event{ - .version = util::lazy_zstring_view{version}, - .encoding = util::lazy_zstring_view{encoding}, - .standalone = - standalone < 0 ? std::nullopt : std::make_optional(standalone > 0), - }); + xml_decl_event{ + .version = util::lazy_zstring_view{version}, + .encoding = util::lazy_zstring_view{encoding}, + .standalone = standalone < 0 ? std::nullopt + : std::make_optional(standalone > 0), + }); } inline auto advance_flag() -> bool { return advance_; } @@ -431,7 +431,7 @@ public: inline auto event() const -> std::optional const& { return ev_; } inline auto resolve_namespace(std::string_view prefix) - -> std::optional + -> std::optional { if (auto it = namespaces_.find(prefix); it != namespaces_.end() && !it->second.empty()) @@ -573,7 +573,7 @@ public: return false; } auto await_suspend(std::coroutine_handle> h) - -> std::coroutine_handle<> + -> std::coroutine_handle<> { // Passed coroutine handle will be the same as // parser::handle_type::from_promise(*this) @@ -621,13 +621,13 @@ using parser_result_t = T::result_type; template concept parser_invocable = - std::invocable - && parser_of, unconstrained>; + std::invocable + && parser_of, unconstrained>; template requires parser_invocable using parser_invoke_result_t = - parser_result_t>; + parser_result_t>; template auto expect_event(executor_ref e) -> parser @@ -637,28 +637,28 @@ auto expect_event(executor_ref e) -> parser { auto pos = e->position(); throw std::runtime_error{std::format( - "at {}:{}: unexpected event type, have {}", pos.line, pos.col, - ev.index())}; + "at {}:{}: unexpected event type, have {}", pos.line, pos.col, + ev.index())}; } e->set_advance_flag(); co_return std::get(ev); } inline auto expect_start_element(executor_ref e, qname_view want) - -> parser + -> parser { auto ev = co_await expect_event(e); if (ev.name != want) { auto pos = e->position(); throw std::runtime_error{std::format( - "at {}:{}: unexpected element started", pos.line, pos.col)}; + "at {}:{}: unexpected element started", pos.line, pos.col)}; } co_return ev.attrs; } inline auto allow_start_element(executor_ref e, qname_view want) - -> parser> + -> parser> { auto ev = co_await current_event(e); if (auto const* pev = std::get_if(&ev)) @@ -707,9 +707,9 @@ inline auto ignore_whitespace(executor_ref e) -> parser } auto expect_element( - executor_ref e, qname_view want, - parser_invocable auto p) - -> parser> + executor_ref e, qname_view want, + parser_invocable auto p) + -> parser> { co_await ignore_whitespace(e); auto attrs = co_await expect_start_element(e, want); @@ -717,14 +717,14 @@ auto expect_element( co_await expect_end_element(e, want); co_await ignore_whitespace(e); co_return std::forward< - parser_invoke_result_t>(res); + parser_invoke_result_t>(res); } auto allow_element( - executor_ref e, qname_view want, - parser_invocable auto p) - -> parser>> + executor_ref e, qname_view want, + parser_invocable auto p) + -> parser>> { co_await ignore_whitespace(e); if (auto mattrs = co_await allow_start_element(e, want)) @@ -733,18 +733,18 @@ auto allow_element( co_await expect_end_element(e, want); co_await ignore_whitespace(e); co_return std::make_optional( - std::forward< - parser_invoke_result_t>( - res)); + std::forward< + parser_invoke_result_t>( + res)); } co_return std::nullopt; } auto allow_element( - executor_ref e, qname_view want, - parser_invocable auto p) -> parser + executor_ref e, qname_view want, + parser_invocable auto p) -> parser requires std::is_void_v< - parser_invoke_result_t> + parser_invoke_result_t> { co_await ignore_whitespace(e); if (auto mattrs = co_await allow_start_element(e, want)) @@ -759,7 +759,7 @@ auto allow_element( inline auto ignore_contents(executor_ref e, std::optional muntil = std::nullopt) - -> parser + -> parser { std::size_t depth = 0; while (true) @@ -791,7 +791,7 @@ ignore_contents(executor_ref e, std::optional muntil = std::nullopt) } } inline auto ignore_element_contents(executor_ref e, attribute_view) - -> parser + -> parser { co_await ignore_contents(e); } @@ -814,7 +814,7 @@ inline auto read_string(executor_ref e) -> parser } } inline auto read_string_contents(executor_ref e, attribute_view) - -> parser + -> parser { co_return co_await read_string(e); } @@ -823,7 +823,7 @@ template auto hohalo() { return []( - Args&&... args) -> std::invoke_result_t + Args&&... args) -> std::invoke_result_t { co_return co_await f(std::forward(args)...); }; } -- cgit v1.3