diff options
| author | Rutger Broekhoff | 2026-11-30 23:33:26 +0100 |
|---|---|---|
| committer | Rutger Broekhoff | 2026-11-30 23:33:26 +0100 |
| commit | 4a81c39d94b6877f7753896218467ff77b8d7f6f (patch) | |
| tree | f046f52f4f81e9951b7531d795c169a16e7e6e54 /server | |
| parent | 7bba7176194c4d1d9c7066f8eda7a94491d924e6 (diff) | |
| download | routemon-4a81c39d94b6877f7753896218467ff77b8d7f6f.tar.gz routemon-4a81c39d94b6877f7753896218467ff77b8d7f6f.zip | |
class -> typename
Diffstat (limited to 'server')
| -rw-r--r-- | server/src/config.cpp | 4 | ||||
| -rw-r--r-- | server/src/database/sqlite3.cppm | 6 | ||||
| -rw-r--r-- | server/src/geo/utm_multizonal.cppm | 4 | ||||
| -rw-r--r-- | server/src/http/core/client.cppm | 2 | ||||
| -rw-r--r-- | server/src/http/core/common.cppm | 10 | ||||
| -rw-r--r-- | server/src/http/core/server.cppm | 42 | ||||
| -rw-r--r-- | server/src/http/ext/hmac_openssl.cppm | 1 | ||||
| -rw-r--r-- | server/src/http/handler.cpp | 2 | ||||
| -rw-r--r-- | server/src/locale.cppm | 2 | ||||
| -rw-r--r-- | server/src/log.cppm | 8 | ||||
| -rw-r--r-- | server/src/time.cppm | 34 | ||||
| -rw-r--r-- | server/src/util.cppm | 14 | ||||
| -rw-r--r-- | server/src/xml.cppm | 28 |
13 files changed, 78 insertions, 79 deletions
diff --git a/server/src/config.cpp b/server/src/config.cpp index ec49aeb..4454781 100644 --- a/server/src/config.cpp +++ b/server/src/config.cpp | |||
| @@ -80,7 +80,7 @@ public: | |||
| 80 | } | 80 | } |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | template <class T> | 83 | template <typename T> |
| 84 | auto allow_at(std::string_view key) -> std::optional<T> | 84 | auto allow_at(std::string_view key) -> std::optional<T> |
| 85 | { | 85 | { |
| 86 | visited_.emplace(key); | 86 | visited_.emplace(key); |
| @@ -103,7 +103,7 @@ public: | |||
| 103 | } | 103 | } |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | template <class T> | 106 | template <typename T> |
| 107 | auto expect_at(std::string_view key) -> T | 107 | auto expect_at(std::string_view key) -> T |
| 108 | { | 108 | { |
| 109 | if (auto&& mv = allow_at<T>(key); mv) | 109 | if (auto&& mv = allow_at<T>(key); mv) |
diff --git a/server/src/database/sqlite3.cppm b/server/src/database/sqlite3.cppm index 2216109..61c3257 100644 --- a/server/src/database/sqlite3.cppm +++ b/server/src/database/sqlite3.cppm | |||
| @@ -12,18 +12,18 @@ extern "C" | |||
| 12 | 12 | ||
| 13 | namespace routemon::database::sqlite3 { | 13 | namespace routemon::database::sqlite3 { |
| 14 | 14 | ||
| 15 | template <class T, template <class U> concept C> | 15 | template <typename T, template <typename U> concept C> |
| 16 | concept optional_of = requires { | 16 | concept optional_of = requires { |
| 17 | typename T::value_type; | 17 | typename T::value_type; |
| 18 | requires std::same_as<T, std::optional<typename T::value_type>>; | 18 | requires std::same_as<T, std::optional<typename T::value_type>>; |
| 19 | requires C<typename T::value_type>; | 19 | requires C<typename T::value_type>; |
| 20 | }; | 20 | }; |
| 21 | 21 | ||
| 22 | template <class T> | 22 | template <typename T> |
| 23 | concept scannable_prim = std::same_as<T, std::string> || std::same_as<T, double> | 23 | concept scannable_prim = std::same_as<T, std::string> || std::same_as<T, double> |
| 24 | || std::same_as<T, std::int64_t>; | 24 | || std::same_as<T, std::int64_t>; |
| 25 | 25 | ||
| 26 | template <class T> | 26 | template <typename T> |
| 27 | concept scannable = scannable_prim<T> || optional_of<T, scannable_prim>; | 27 | concept scannable = scannable_prim<T> || optional_of<T, scannable_prim>; |
| 28 | 28 | ||
| 29 | class mutex_guard | 29 | class mutex_guard |
diff --git a/server/src/geo/utm_multizonal.cppm b/server/src/geo/utm_multizonal.cppm index 56c6481..8886375 100644 --- a/server/src/geo/utm_multizonal.cppm +++ b/server/src/geo/utm_multizonal.cppm | |||
| @@ -202,7 +202,7 @@ auto split_linestring_across_zones(utm::zonable_wgs84_linestring ls) | |||
| 202 | return splits; | 202 | return splits; |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | template <class T> | 205 | template <typename T> |
| 206 | class linestring_rtree | 206 | class linestring_rtree |
| 207 | { | 207 | { |
| 208 | public: | 208 | public: |
| @@ -265,7 +265,7 @@ public: | |||
| 265 | } | 265 | } |
| 266 | }; | 266 | }; |
| 267 | 267 | ||
| 268 | template <class T> | 268 | template <typename T> |
| 269 | class point_rtree | 269 | class point_rtree |
| 270 | { | 270 | { |
| 271 | public: | 271 | public: |
diff --git a/server/src/http/core/client.cppm b/server/src/http/core/client.cppm index ada4f03..2bf1137 100644 --- a/server/src/http/core/client.cppm +++ b/server/src/http/core/client.cppm | |||
| @@ -25,7 +25,7 @@ export class client | |||
| 25 | public: | 25 | public: |
| 26 | explicit client(net::io_context& ioc); | 26 | explicit client(net::io_context& ioc); |
| 27 | 27 | ||
| 28 | template <class ReqBody> | 28 | template <typename ReqBody> |
| 29 | auto do_request(bhttp::request<ReqBody>& req) | 29 | auto do_request(bhttp::request<ReqBody>& req) |
| 30 | -> bhttp::response<bhttp::dynamic_body> | 30 | -> bhttp::response<bhttp::dynamic_body> |
| 31 | { | 31 | { |
diff --git a/server/src/http/core/common.cppm b/server/src/http/core/common.cppm index e8fbe42..83d474f 100644 --- a/server/src/http/core/common.cppm +++ b/server/src/http/core/common.cppm | |||
| @@ -12,23 +12,23 @@ namespace boost::beast { | |||
| 12 | 12 | ||
| 13 | namespace concepts { | 13 | namespace concepts { |
| 14 | 14 | ||
| 15 | template <class T> | 15 | template <typename T> |
| 16 | concept buffers_generator = beast::is_buffers_generator<T>::value; | 16 | concept buffers_generator = beast::is_buffers_generator<T>::value; |
| 17 | 17 | ||
| 18 | template <class T> | 18 | template <typename T> |
| 19 | concept const_buffer_sequence = beast::is_const_buffer_sequence<T>::value; | 19 | concept const_buffer_sequence = beast::is_const_buffer_sequence<T>::value; |
| 20 | 20 | ||
| 21 | } // namespace concepts | 21 | } // namespace concepts |
| 22 | 22 | ||
| 23 | namespace http::concepts { | 23 | namespace http::concepts { |
| 24 | 24 | ||
| 25 | template <class T> | 25 | template <typename T> |
| 26 | concept fields = is_fields<T>::value; | 26 | concept fields = is_fields<T>::value; |
| 27 | 27 | ||
| 28 | template <class T> | 28 | template <typename T> |
| 29 | concept body = is_body<T>::value; | 29 | concept body = is_body<T>::value; |
| 30 | 30 | ||
| 31 | template <class T> | 31 | template <typename T> |
| 32 | concept body_reader = is_body_reader<T>::value; | 32 | concept body_reader = is_body_reader<T>::value; |
| 33 | 33 | ||
| 34 | } // namespace http::concepts | 34 | } // namespace http::concepts |
diff --git a/server/src/http/core/server.cppm b/server/src/http/core/server.cppm index dbef975..19eb1c4 100644 --- a/server/src/http/core/server.cppm +++ b/server/src/http/core/server.cppm | |||
| @@ -146,17 +146,17 @@ public: | |||
| 146 | }; | 146 | }; |
| 147 | static_assert(beast::concepts::buffers_generator<presponse>); | 147 | static_assert(beast::concepts::buffers_generator<presponse>); |
| 148 | 148 | ||
| 149 | template <class Ctx> | 149 | template <typename Ctx> |
| 150 | using next_handler_t = std::function<auto(Ctx)->net::awaitable<presponse>>; | 150 | using next_handler_t = std::function<auto(Ctx)->net::awaitable<presponse>>; |
| 151 | 151 | ||
| 152 | template <class OuterCtx, class InnerCtx> | 152 | template <typename OuterCtx, typename InnerCtx> |
| 153 | using middleware_t = | 153 | using middleware_t = |
| 154 | std::function<auto( | 154 | std::function<auto( |
| 155 | OuterCtx, bhttp::request_header<bhttp::fields>&, | 155 | OuterCtx, bhttp::request_header<bhttp::fields>&, |
| 156 | next_handler_t<InnerCtx>) | 156 | next_handler_t<InnerCtx>) |
| 157 | ->net::awaitable<presponse>>; | 157 | ->net::awaitable<presponse>>; |
| 158 | 158 | ||
| 159 | template <class Ctx> | 159 | template <typename Ctx> |
| 160 | auto id_middleware( | 160 | auto id_middleware( |
| 161 | Ctx ctx, bhttp::request_header<bhttp::fields>&, next_handler_t<Ctx> next) | 161 | Ctx ctx, bhttp::request_header<bhttp::fields>&, next_handler_t<Ctx> next) |
| 162 | -> net::awaitable<presponse> | 162 | -> net::awaitable<presponse> |
| @@ -170,14 +170,14 @@ struct base_ctx | |||
| 170 | trace::id trace_id; | 170 | trace::id trace_id; |
| 171 | }; | 171 | }; |
| 172 | 172 | ||
| 173 | template <class Ctx> | 173 | template <typename Ctx> |
| 174 | using basic_route_handler_fn_t = | 174 | using basic_route_handler_fn_t = |
| 175 | std::function<auto( | 175 | std::function<auto( |
| 176 | Ctx, readable_request, | 176 | Ctx, readable_request, |
| 177 | std::vector<std::string> const& matches) | 177 | std::vector<std::string> const& matches) |
| 178 | ->net::awaitable<presponse>>; | 178 | ->net::awaitable<presponse>>; |
| 179 | 179 | ||
| 180 | template <class Ctx> | 180 | template <typename Ctx> |
| 181 | auto cors_middleware(std::vector<std::string> const& allow_origins) | 181 | auto cors_middleware(std::vector<std::string> const& allow_origins) |
| 182 | -> middleware_t<Ctx, Ctx> | 182 | -> middleware_t<Ctx, Ctx> |
| 183 | { | 183 | { |
| @@ -199,7 +199,7 @@ auto cors_middleware(std::vector<std::string> const& allow_origins) | |||
| 199 | }; | 199 | }; |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | template <class Ctx> | 202 | template <typename Ctx> |
| 203 | auto expose_trace_id_middleware( | 203 | auto expose_trace_id_middleware( |
| 204 | Ctx ctx, bhttp::request_header<bhttp::fields>& req_hdr, | 204 | Ctx ctx, bhttp::request_header<bhttp::fields>& req_hdr, |
| 205 | next_handler_t<Ctx> next) -> net::awaitable<presponse> | 205 | next_handler_t<Ctx> next) -> net::awaitable<presponse> |
| @@ -214,7 +214,7 @@ auto expose_trace_id_middleware( | |||
| 214 | co_return std::move(prersp); | 214 | co_return std::move(prersp); |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | template <class Ctx> | 217 | template <typename Ctx> |
| 218 | auto expose_content_language_middleware( | 218 | auto expose_content_language_middleware( |
| 219 | Ctx ctx, bhttp::request_header<bhttp::fields>& req_hdr, | 219 | Ctx ctx, bhttp::request_header<bhttp::fields>& req_hdr, |
| 220 | next_handler_t<Ctx> next) -> net::awaitable<presponse> | 220 | next_handler_t<Ctx> next) -> net::awaitable<presponse> |
| @@ -297,17 +297,17 @@ auto read_empty_request(base_ctx const& ctx, readable_request&& r) -> net:: | |||
| 297 | co_return r.p->release(); | 297 | co_return r.p->release(); |
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | template <class InnerCtx> | 300 | template <typename InnerCtx> |
| 301 | struct routed_ctx : InnerCtx | 301 | struct routed_ctx : InnerCtx |
| 302 | { | 302 | { |
| 303 | verb_set route_methods; | 303 | verb_set route_methods; |
| 304 | boost::urls::url target; | 304 | boost::urls::url target; |
| 305 | }; | 305 | }; |
| 306 | 306 | ||
| 307 | template <class Ctx> | 307 | template <typename Ctx> |
| 308 | requires requires(Ctx ctx) { | 308 | requires requires(Ctx ctx) { |
| 309 | // Ctx must be derived from an instantiation of routed_ctx | 309 | // Ctx must be derived from an instantiation of routed_ctx |
| 310 | []<class InnerCtx>(routed_ctx<InnerCtx> const&) {}(ctx); | 310 | []<typename InnerCtx>(routed_ctx<InnerCtx> const&) {}(ctx); |
| 311 | } | 311 | } |
| 312 | auto default_options_handler( | 312 | auto default_options_handler( |
| 313 | Ctx const& ctx, readable_request r, std::vector<std::string> const&) | 313 | Ctx const& ctx, readable_request r, std::vector<std::string> const&) |
| @@ -343,7 +343,7 @@ auto default_options_handler( | |||
| 343 | auto global_options_handler(base_ctx const& ctx, readable_request r) | 343 | auto global_options_handler(base_ctx const& ctx, readable_request r) |
| 344 | -> net::awaitable<presponse>; | 344 | -> net::awaitable<presponse>; |
| 345 | 345 | ||
| 346 | template <class A, class B, class C> | 346 | template <typename A, typename B, typename C> |
| 347 | auto middleware_compose(middleware_t<A, B> ab, middleware_t<B, C> bc) | 347 | auto middleware_compose(middleware_t<A, B> ab, middleware_t<B, C> bc) |
| 348 | -> middleware_t<A, C> | 348 | -> middleware_t<A, C> |
| 349 | { | 349 | { |
| @@ -357,7 +357,7 @@ auto middleware_compose(middleware_t<A, B> ab, middleware_t<B, C> bc) | |||
| 357 | }; | 357 | }; |
| 358 | } | 358 | } |
| 359 | 359 | ||
| 360 | template <class A, class B> | 360 | template <typename A, typename B> |
| 361 | auto middleware_wrap_fn(middleware_t<A, B> ab, basic_route_handler_fn_t<B> fn) | 361 | auto middleware_wrap_fn(middleware_t<A, B> ab, basic_route_handler_fn_t<B> fn) |
| 362 | -> basic_route_handler_fn_t<A> | 362 | -> basic_route_handler_fn_t<A> |
| 363 | { | 363 | { |
| @@ -386,7 +386,7 @@ struct handler_map | |||
| 386 | V post = {}; | 386 | V post = {}; |
| 387 | V put = {}; | 387 | V put = {}; |
| 388 | 388 | ||
| 389 | template <class Self> | 389 | template <typename Self> |
| 390 | auto lookup(this Self&& self, supported_verb v) -> auto&& | 390 | auto lookup(this Self&& self, supported_verb v) -> auto&& |
| 391 | { | 391 | { |
| 392 | switch (v.value) | 392 | switch (v.value) |
| @@ -436,7 +436,7 @@ struct handler_map | |||
| 436 | } | 436 | } |
| 437 | }; | 437 | }; |
| 438 | 438 | ||
| 439 | template <class Ctx> | 439 | template <typename Ctx> |
| 440 | struct route_tree | 440 | struct route_tree |
| 441 | { | 441 | { |
| 442 | using leaves = handler_map<basic_route_handler_fn_t<Ctx>>; | 442 | using leaves = handler_map<basic_route_handler_fn_t<Ctx>>; |
| @@ -451,7 +451,7 @@ struct route_tree | |||
| 451 | std::variant<named_subtrees, wildcard_subtree> sub; | 451 | std::variant<named_subtrees, wildcard_subtree> sub; |
| 452 | }; | 452 | }; |
| 453 | 453 | ||
| 454 | template <class OuterCtx, class InnerCtx> | 454 | template <typename OuterCtx, typename InnerCtx> |
| 455 | auto middleware_wrap_tree( | 455 | auto middleware_wrap_tree( |
| 456 | middleware_t<OuterCtx, InnerCtx> mw, route_tree<InnerCtx> const& tree) | 456 | middleware_t<OuterCtx, InnerCtx> mw, route_tree<InnerCtx> const& tree) |
| 457 | -> route_tree<OuterCtx> | 457 | -> route_tree<OuterCtx> |
| @@ -479,15 +479,15 @@ auto middleware_wrap_tree( | |||
| 479 | return {.here = new_leaves, .sub = new_sub}; | 479 | return {.here = new_leaves, .sub = new_sub}; |
| 480 | } | 480 | } |
| 481 | 481 | ||
| 482 | template <class T> | 482 | template <typename T> |
| 483 | concept match_arg = std::constructible_from<T, std::string const&>; | 483 | concept match_arg = std::constructible_from<T, std::string const&>; |
| 484 | 484 | ||
| 485 | template <class Ctx, match_arg... MatchArgs> | 485 | template <typename Ctx, match_arg... MatchArgs> |
| 486 | using route_handler_fn_t = | 486 | using route_handler_fn_t = |
| 487 | std::function<auto(Ctx, readable_request, MatchArgs...) | 487 | std::function<auto(Ctx, readable_request, MatchArgs...) |
| 488 | ->net::awaitable<presponse>>; | 488 | ->net::awaitable<presponse>>; |
| 489 | 489 | ||
| 490 | template <class Ctx, match_arg... MatchArgs> | 490 | template <typename Ctx, match_arg... MatchArgs> |
| 491 | auto degen_route_handler(route_handler_fn_t<Ctx, MatchArgs...> fn) | 491 | auto degen_route_handler(route_handler_fn_t<Ctx, MatchArgs...> fn) |
| 492 | -> basic_route_handler_fn_t<Ctx> | 492 | -> basic_route_handler_fn_t<Ctx> |
| 493 | { | 493 | { |
| @@ -505,10 +505,10 @@ auto degen_route_handler(route_handler_fn_t<Ctx, MatchArgs...> fn) | |||
| 505 | }; | 505 | }; |
| 506 | } | 506 | } |
| 507 | 507 | ||
| 508 | template <class Ctx, match_arg... MatchArgs> | 508 | template <typename Ctx, match_arg... MatchArgs> |
| 509 | struct ctree : route_tree<Ctx> | 509 | struct ctree : route_tree<Ctx> |
| 510 | { | 510 | { |
| 511 | template <class OuterCtx> | 511 | template <typename OuterCtx> |
| 512 | auto wrap(middleware_t<OuterCtx, Ctx> mw) const | 512 | auto wrap(middleware_t<OuterCtx, Ctx> mw) const |
| 513 | -> ctree<OuterCtx, MatchArgs...> | 513 | -> ctree<OuterCtx, MatchArgs...> |
| 514 | { | 514 | { |
| @@ -516,7 +516,7 @@ struct ctree : route_tree<Ctx> | |||
| 516 | } | 516 | } |
| 517 | }; | 517 | }; |
| 518 | 518 | ||
| 519 | template <class Ctx, match_arg... MatchArgs> | 519 | template <typename Ctx, match_arg... MatchArgs> |
| 520 | struct dtree : handler_map<route_handler_fn_t<Ctx, MatchArgs...>> | 520 | struct dtree : handler_map<route_handler_fn_t<Ctx, MatchArgs...>> |
| 521 | { | 521 | { |
| 522 | [[nodiscard]] auto to_leaves() const -> typename route_tree<Ctx>::leaves | 522 | [[nodiscard]] auto to_leaves() const -> typename route_tree<Ctx>::leaves |
diff --git a/server/src/http/ext/hmac_openssl.cppm b/server/src/http/ext/hmac_openssl.cppm index b196094..a175406 100644 --- a/server/src/http/ext/hmac_openssl.cppm +++ b/server/src/http/ext/hmac_openssl.cppm | |||
| @@ -78,7 +78,6 @@ public: | |||
| 78 | ::EVP_MAC_free(mac_); | 78 | ::EVP_MAC_free(mac_); |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | // TODO: move to impl. unit. | ||
| 82 | auto init(boost::optional<std::uint64_t> n, beast::error_code& ec) noexcept | 81 | auto init(boost::optional<std::uint64_t> n, beast::error_code& ec) noexcept |
| 83 | -> void | 82 | -> void |
| 84 | { | 83 | { |
diff --git a/server/src/http/handler.cpp b/server/src/http/handler.cpp index d755c16..580e3f5 100644 --- a/server/src/http/handler.cpp +++ b/server/src/http/handler.cpp | |||
| @@ -325,7 +325,7 @@ handler::handler( | |||
| 325 | 325 | ||
| 326 | auto handler::make_routes() -> core::route_tree<core::routed_ctx<outer_ctx>> | 326 | auto handler::make_routes() -> core::route_tree<core::routed_ctx<outer_ctx>> |
| 327 | { | 327 | { |
| 328 | auto handler = [this]<class MemFn>(MemFn member) | 328 | auto handler = [this]<typename MemFn>(MemFn member) |
| 329 | { return std::bind_front(member, this); }; | 329 | { return std::bind_front(member, this); }; |
| 330 | 330 | ||
| 331 | return core::dtree<core::routed_ctx<outer_ctx>>{}.named_subtrees({ | 331 | return core::dtree<core::routed_ctx<outer_ctx>>{}.named_subtrees({ |
diff --git a/server/src/locale.cppm b/server/src/locale.cppm index 00a3d36..43e32c3 100644 --- a/server/src/locale.cppm +++ b/server/src/locale.cppm | |||
| @@ -20,7 +20,7 @@ using blocale::translate; | |||
| 20 | 20 | ||
| 21 | namespace routemon::locale { | 21 | namespace routemon::locale { |
| 22 | 22 | ||
| 23 | export template <class T> | 23 | export template <typename T> |
| 24 | concept locale_input_range = | 24 | concept locale_input_range = |
| 25 | std::ranges::input_range<T> | 25 | std::ranges::input_range<T> |
| 26 | && std:: | 26 | && std:: |
diff --git a/server/src/log.cppm b/server/src/log.cppm index 10c2d7a..22531d0 100644 --- a/server/src/log.cppm +++ b/server/src/log.cppm | |||
| @@ -48,25 +48,25 @@ public: | |||
| 48 | [[nodiscard]] auto with(std::string const& k, std::string_view v) const | 48 | [[nodiscard]] auto with(std::string const& k, std::string_view v) const |
| 49 | -> logger; | 49 | -> logger; |
| 50 | 50 | ||
| 51 | template <class... Args> | 51 | template <typename... Args> |
| 52 | auto debug(std::format_string<Args...> fmt, Args&&... args) -> logger& | 52 | auto debug(std::format_string<Args...> fmt, Args&&... args) -> logger& |
| 53 | { | 53 | { |
| 54 | return log_at(level::debug, fmt.get(), std::make_format_args(args...)); | 54 | return log_at(level::debug, fmt.get(), std::make_format_args(args...)); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | template <class... Args> | 57 | template <typename... Args> |
| 58 | auto info(std::format_string<Args...> fmt, Args&&... args) -> logger& | 58 | auto info(std::format_string<Args...> fmt, Args&&... args) -> logger& |
| 59 | { | 59 | { |
| 60 | return log_at(level::info, fmt.get(), std::make_format_args(args...)); | 60 | return log_at(level::info, fmt.get(), std::make_format_args(args...)); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | template <class... Args> | 63 | template <typename... Args> |
| 64 | auto warn(std::format_string<Args...> fmt, Args&&... args) -> logger& | 64 | auto warn(std::format_string<Args...> fmt, Args&&... args) -> logger& |
| 65 | { | 65 | { |
| 66 | return log_at(level::warn, fmt.get(), std::make_format_args(args...)); | 66 | return log_at(level::warn, fmt.get(), std::make_format_args(args...)); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | template <class... Args> | 69 | template <typename... Args> |
| 70 | auto error(std::format_string<Args...> fmt, Args&&... args) -> logger& | 70 | auto error(std::format_string<Args...> fmt, Args&&... args) -> logger& |
| 71 | { | 71 | { |
| 72 | return log_at(level::error, fmt.get(), std::make_format_args(args...)); | 72 | return log_at(level::error, fmt.get(), std::make_format_args(args...)); |
diff --git a/server/src/time.cppm b/server/src/time.cppm index 32df737..61f399b 100644 --- a/server/src/time.cppm +++ b/server/src/time.cppm | |||
| @@ -4,12 +4,12 @@ import std; | |||
| 4 | 4 | ||
| 5 | export namespace routemon::time { | 5 | export namespace routemon::time { |
| 6 | 6 | ||
| 7 | template <class Duration = std::chrono::utc_clock::duration> | 7 | template <typename Duration = std::chrono::utc_clock::duration> |
| 8 | using timestamp = std::chrono::time_point<std::chrono::utc_clock, Duration>; | 8 | using timestamp = std::chrono::time_point<std::chrono::utc_clock, Duration>; |
| 9 | 9 | ||
| 10 | auto iso8601_secs(timestamp<std::chrono::seconds> ts) -> std::string; | 10 | auto iso8601_secs(timestamp<std::chrono::seconds> ts) -> std::string; |
| 11 | 11 | ||
| 12 | template <class Duration> | 12 | template <typename Duration> |
| 13 | class period | 13 | class period |
| 14 | { | 14 | { |
| 15 | // Assuming [start, end). Unfortunately the DATEX II model is not | 15 | // Assuming [start, end). Unfortunately the DATEX II model is not |
| @@ -27,7 +27,7 @@ public: | |||
| 27 | [[nodiscard]] auto end() const -> timestamp<Duration>; | 27 | [[nodiscard]] auto end() const -> timestamp<Duration>; |
| 28 | }; | 28 | }; |
| 29 | 29 | ||
| 30 | template <class Duration> | 30 | template <typename Duration> |
| 31 | class period_seq | 31 | class period_seq |
| 32 | { | 32 | { |
| 33 | std::vector<period<Duration>> periods_; | 33 | std::vector<period<Duration>> periods_; |
| @@ -110,10 +110,10 @@ public: | |||
| 110 | [[nodiscard]] auto periods() const -> std::vector<period<Duration>> const&; | 110 | [[nodiscard]] auto periods() const -> std::vector<period<Duration>> const&; |
| 111 | }; | 111 | }; |
| 112 | 112 | ||
| 113 | template <class Duration> | 113 | template <typename Duration> |
| 114 | auto operator<<(std::ostream& os, period<Duration> const& p) -> std::ostream&; | 114 | auto operator<<(std::ostream& os, period<Duration> const& p) -> std::ostream&; |
| 115 | 115 | ||
| 116 | template <class Duration> | 116 | template <typename Duration> |
| 117 | auto operator<<(std::ostream& os, period_seq<Duration> const& ps) | 117 | auto operator<<(std::ostream& os, period_seq<Duration> const& ps) |
| 118 | -> std::ostream&; | 118 | -> std::ostream&; |
| 119 | 119 | ||
| @@ -121,7 +121,7 @@ auto operator<<(std::ostream& os, period_seq<Duration> const& ps) | |||
| 121 | 121 | ||
| 122 | namespace routemon::time { | 122 | namespace routemon::time { |
| 123 | 123 | ||
| 124 | template <class Duration> | 124 | template <typename Duration> |
| 125 | period<Duration>::period(timestamp<Duration> start, timestamp<Duration> end) | 125 | period<Duration>::period(timestamp<Duration> start, timestamp<Duration> end) |
| 126 | : start_{start}, end_{end} | 126 | : start_{start}, end_{end} |
| 127 | { | 127 | { |
| @@ -131,7 +131,7 @@ period<Duration>::period(timestamp<Duration> start, timestamp<Duration> end) | |||
| 131 | } | 131 | } |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | template <class Duration> | 134 | template <typename Duration> |
| 135 | auto period<Duration>::intersect(period other) const -> std::optional<period> | 135 | auto period<Duration>::intersect(period other) const -> std::optional<period> |
| 136 | { | 136 | { |
| 137 | auto const new_start = start_ < other.start() ? other.start() : start_; | 137 | auto const new_start = start_ < other.start() ? other.start() : start_; |
| @@ -140,7 +140,7 @@ auto period<Duration>::intersect(period other) const -> std::optional<period> | |||
| 140 | : std::nullopt; | 140 | : std::nullopt; |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | template <class Duration> | 143 | template <typename Duration> |
| 144 | auto period<Duration>::except(period other) const | 144 | auto period<Duration>::except(period other) const |
| 145 | -> std::pair<std::optional<period>, std::optional<period>> | 145 | -> std::pair<std::optional<period>, std::optional<period>> |
| 146 | { | 146 | { |
| @@ -156,19 +156,19 @@ auto period<Duration>::except(period other) const | |||
| 156 | return std::make_pair(before, after); | 156 | return std::make_pair(before, after); |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | template <class Duration> | 159 | template <typename Duration> |
| 160 | auto period<Duration>::start() const -> timestamp<Duration> | 160 | auto period<Duration>::start() const -> timestamp<Duration> |
| 161 | { | 161 | { |
| 162 | return start_; | 162 | return start_; |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | template <class Duration> | 165 | template <typename Duration> |
| 166 | auto period<Duration>::end() const -> timestamp<Duration> | 166 | auto period<Duration>::end() const -> timestamp<Duration> |
| 167 | { | 167 | { |
| 168 | return end_; | 168 | return end_; |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | template <class Duration> | 171 | template <typename Duration> |
| 172 | period_seq<Duration>::period_seq(std::vector<period<Duration>> periods) | 172 | period_seq<Duration>::period_seq(std::vector<period<Duration>> periods) |
| 173 | : periods_{std::move(periods)} | 173 | : periods_{std::move(periods)} |
| 174 | { | 174 | { |
| @@ -185,13 +185,13 @@ period_seq<Duration>::period_seq(std::vector<period<Duration>> periods) | |||
| 185 | } | 185 | } |
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | template <class Duration> | 188 | template <typename Duration> |
| 189 | period_seq<Duration>::period_seq(period<Duration> singleton) | 189 | period_seq<Duration>::period_seq(period<Duration> singleton) |
| 190 | : periods_{singleton} | 190 | : periods_{singleton} |
| 191 | { | 191 | { |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | template <class Duration> | 194 | template <typename Duration> |
| 195 | auto period_seq<Duration>::intersect(period_seq const& other) const | 195 | auto period_seq<Duration>::intersect(period_seq const& other) const |
| 196 | -> period_seq | 196 | -> period_seq |
| 197 | { | 197 | { |
| @@ -232,7 +232,7 @@ auto period_seq<Duration>::intersect(period_seq const& other) const | |||
| 232 | return period_seq{res}; | 232 | return period_seq{res}; |
| 233 | } | 233 | } |
| 234 | 234 | ||
| 235 | template <class Duration> | 235 | template <typename Duration> |
| 236 | auto period_seq<Duration>::except(period_seq const& other) const -> period_seq | 236 | auto period_seq<Duration>::except(period_seq const& other) const -> period_seq |
| 237 | { | 237 | { |
| 238 | // This code was pretty tricky to write, I wouldn't be surprised if it | 238 | // This code was pretty tricky to write, I wouldn't be surprised if it |
| @@ -281,20 +281,20 @@ auto period_seq<Duration>::except(period_seq const& other) const -> period_seq | |||
| 281 | return period_seq{res}; | 281 | return period_seq{res}; |
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | template <class Duration> | 284 | template <typename Duration> |
| 285 | auto period_seq<Duration>::periods() const | 285 | auto period_seq<Duration>::periods() const |
| 286 | -> std::vector<period<Duration>> const& | 286 | -> std::vector<period<Duration>> const& |
| 287 | { | 287 | { |
| 288 | return periods_; | 288 | return periods_; |
| 289 | } | 289 | } |
| 290 | 290 | ||
| 291 | template <class Duration> | 291 | template <typename Duration> |
| 292 | auto operator<<(std::ostream& os, period<Duration> const& p) -> std::ostream& | 292 | auto operator<<(std::ostream& os, period<Duration> const& p) -> std::ostream& |
| 293 | { | 293 | { |
| 294 | return os << "[" << p.start() << ", " << p.end() << ")"; | 294 | return os << "[" << p.start() << ", " << p.end() << ")"; |
| 295 | } | 295 | } |
| 296 | 296 | ||
| 297 | template <class Duration> | 297 | template <typename Duration> |
| 298 | auto operator<<(std::ostream& os, period_seq<Duration> const& ps) | 298 | auto operator<<(std::ostream& os, period_seq<Duration> const& ps) |
| 299 | -> std::ostream& | 299 | -> std::ostream& |
| 300 | { | 300 | { |
diff --git a/server/src/util.cppm b/server/src/util.cppm index 986e350..aedc120 100644 --- a/server/src/util.cppm +++ b/server/src/util.cppm | |||
| @@ -7,7 +7,7 @@ import std; | |||
| 7 | namespace routemon::util { | 7 | namespace routemon::util { |
| 8 | 8 | ||
| 9 | // For use with e.g. std::visit (on std::variant). | 9 | // For use with e.g. std::visit (on std::variant). |
| 10 | template <class... Ts> | 10 | template <typename... Ts> |
| 11 | struct overloaded : Ts... | 11 | struct overloaded : Ts... |
| 12 | { | 12 | { |
| 13 | using Ts::operator()...; | 13 | using Ts::operator()...; |
| @@ -48,7 +48,7 @@ constexpr auto parse_int(std::string_view s, int base = 10) noexcept | |||
| 48 | return x; | 48 | return x; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | template <class T> | 51 | template <typename T> |
| 52 | class aolist : public std::enable_shared_from_this<aolist<T>> | 52 | class aolist : public std::enable_shared_from_this<aolist<T>> |
| 53 | { | 53 | { |
| 54 | T v_; | 54 | T v_; |
| @@ -177,10 +177,10 @@ constexpr auto split_on(std::string_view s, char c) | |||
| 177 | return std::make_pair(s, std::nullopt); | 177 | return std::make_pair(s, std::nullopt); |
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | template <class T> | 180 | template <typename T> |
| 181 | class not_null; | 181 | class not_null; |
| 182 | 182 | ||
| 183 | template <class T> | 183 | template <typename T> |
| 184 | class not_null<T*> | 184 | class not_null<T*> |
| 185 | { | 185 | { |
| 186 | T* p_; | 186 | T* p_; |
| @@ -220,7 +220,7 @@ public: | |||
| 220 | 220 | ||
| 221 | auto operator->() const noexcept -> T* { return p_; } | 221 | auto operator->() const noexcept -> T* { return p_; } |
| 222 | }; | 222 | }; |
| 223 | template <class T> | 223 | template <typename T> |
| 224 | explicit not_null(T*) -> not_null<T*>; | 224 | explicit not_null(T*) -> not_null<T*>; |
| 225 | 225 | ||
| 226 | template <> | 226 | template <> |
| @@ -248,7 +248,7 @@ explicit not_null(lazy_zstring_view s) -> not_null<lazy_zstring_view>; | |||
| 248 | template <> | 248 | template <> |
| 249 | struct std::formatter<routemon::util::zstring_view, char> | 249 | struct std::formatter<routemon::util::zstring_view, char> |
| 250 | { | 250 | { |
| 251 | template <class ParseContext> | 251 | template <typename ParseContext> |
| 252 | constexpr auto parse(ParseContext& ctx) -> ParseContext::iterator | 252 | constexpr auto parse(ParseContext& ctx) -> ParseContext::iterator |
| 253 | { | 253 | { |
| 254 | auto it = ctx.begin(); | 254 | auto it = ctx.begin(); |
| @@ -259,7 +259,7 @@ struct std::formatter<routemon::util::zstring_view, char> | |||
| 259 | return it; | 259 | return it; |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | template <class FmtContext> | 262 | template <typename FmtContext> |
| 263 | auto format(routemon::util::zstring_view s, FmtContext& ctx) const | 263 | auto format(routemon::util::zstring_view s, FmtContext& ctx) const |
| 264 | -> FmtContext::iterator | 264 | -> FmtContext::iterator |
| 265 | { | 265 | { |
diff --git a/server/src/xml.cppm b/server/src/xml.cppm index 2d186da..783b192 100644 --- a/server/src/xml.cppm +++ b/server/src/xml.cppm | |||
| @@ -136,10 +136,10 @@ public: | |||
| 136 | }; | 136 | }; |
| 137 | static_assert(std::ranges::input_range<attribute_view>); | 137 | static_assert(std::ranges::input_range<attribute_view>); |
| 138 | 138 | ||
| 139 | template <class T> | 139 | template <typename T> |
| 140 | class promise; | 140 | class promise; |
| 141 | 141 | ||
| 142 | template <class T> | 142 | template <typename T> |
| 143 | struct [[clang::coro_await_elidable, clang::coro_return_type]] parser | 143 | struct [[clang::coro_await_elidable, clang::coro_return_type]] parser |
| 144 | { | 144 | { |
| 145 | using promise_type = promise<T>; | 145 | using promise_type = promise<T>; |
| @@ -204,7 +204,7 @@ using event = std::variant< | |||
| 204 | processing_instructions_event, xml_decl_event, eof_event | 204 | processing_instructions_event, xml_decl_event, eof_event |
| 205 | >; | 205 | >; |
| 206 | 206 | ||
| 207 | template <class T> | 207 | template <typename T> |
| 208 | concept event_type = requires(event ev) { std::get<T>(ev); }; | 208 | concept event_type = requires(event ev) { std::get<T>(ev); }; |
| 209 | 209 | ||
| 210 | class executor; | 210 | class executor; |
| @@ -403,7 +403,7 @@ class executor | |||
| 403 | return std::exchange(ex_, nullptr); | 403 | return std::exchange(ex_, nullptr); |
| 404 | } | 404 | } |
| 405 | 405 | ||
| 406 | template <class T> | 406 | template <typename T> |
| 407 | friend class promise; | 407 | friend class promise; |
| 408 | 408 | ||
| 409 | public: | 409 | public: |
| @@ -453,7 +453,7 @@ public: | |||
| 453 | auto end() -> void; | 453 | auto end() -> void; |
| 454 | }; | 454 | }; |
| 455 | 455 | ||
| 456 | template <class T> | 456 | template <typename T> |
| 457 | class promise_returnable : public promise_base | 457 | class promise_returnable : public promise_base |
| 458 | { | 458 | { |
| 459 | std::optional<T> returned_value_; | 459 | std::optional<T> returned_value_; |
| @@ -462,7 +462,7 @@ public: | |||
| 462 | using result_type = T; | 462 | using result_type = T; |
| 463 | using promise_base::promise_base; | 463 | using promise_base::promise_base; |
| 464 | 464 | ||
| 465 | template <class U> | 465 | template <typename U> |
| 466 | auto return_value(U&& v) -> void | 466 | auto return_value(U&& v) -> void |
| 467 | { | 467 | { |
| 468 | returned_value_.emplace(std::forward<U>(v)); | 468 | returned_value_.emplace(std::forward<U>(v)); |
| @@ -486,13 +486,13 @@ public: | |||
| 486 | auto return_void() -> void {} | 486 | auto return_void() -> void {} |
| 487 | }; | 487 | }; |
| 488 | 488 | ||
| 489 | template <class T> | 489 | template <typename T> |
| 490 | class promise : public promise_returnable<T> | 490 | class promise : public promise_returnable<T> |
| 491 | { | 491 | { |
| 492 | public: | 492 | public: |
| 493 | // Called with all the coroutine's arguments. | 493 | // Called with all the coroutine's arguments. |
| 494 | // Ignoring all but the first argument, which should be the executor. | 494 | // Ignoring all but the first argument, which should be the executor. |
| 495 | template <class... Args> | 495 | template <typename... Args> |
| 496 | explicit promise(executor_ref executor, Args&&...) | 496 | explicit promise(executor_ref executor, Args&&...) |
| 497 | : promise_returnable<T>{executor} | 497 | : promise_returnable<T>{executor} |
| 498 | { | 498 | { |
| @@ -566,7 +566,7 @@ public: | |||
| 566 | return awaiter{req.executor}; | 566 | return awaiter{req.executor}; |
| 567 | } | 567 | } |
| 568 | 568 | ||
| 569 | template <class U> | 569 | template <typename U> |
| 570 | auto await_transform(parser<U> const& coro) | 570 | auto await_transform(parser<U> const& coro) |
| 571 | { | 571 | { |
| 572 | struct [[clang::coro_await_elidable]] awaiter | 572 | struct [[clang::coro_await_elidable]] awaiter |
| @@ -614,10 +614,10 @@ public: | |||
| 614 | // Helpers for handling XML documents. Non-polymorphic functions | 614 | // Helpers for handling XML documents. Non-polymorphic functions |
| 615 | // should be marked inline to allow HALO across TU boundaries. | 615 | // should be marked inline to allow HALO across TU boundaries. |
| 616 | 616 | ||
| 617 | template <class T> | 617 | template <typename T> |
| 618 | concept unconstrained = true; | 618 | concept unconstrained = true; |
| 619 | 619 | ||
| 620 | template <class T, template <class U> concept C> | 620 | template <typename T, template <typename U> concept C> |
| 621 | concept parser_of = requires { | 621 | concept parser_of = requires { |
| 622 | typename T::result_type; | 622 | typename T::result_type; |
| 623 | requires std::same_as<parser<typename T::result_type>, T>; | 623 | requires std::same_as<parser<typename T::result_type>, T>; |
| @@ -627,12 +627,12 @@ concept parser_of = requires { | |||
| 627 | template <parser_of<unconstrained> T> | 627 | template <parser_of<unconstrained> T> |
| 628 | using parser_result_t = T::result_type; | 628 | using parser_result_t = T::result_type; |
| 629 | 629 | ||
| 630 | template <class T, class... Args> | 630 | template <typename T, typename... Args> |
| 631 | concept parser_invocable = | 631 | concept parser_invocable = |
| 632 | std::invocable<T, Args...> | 632 | std::invocable<T, Args...> |
| 633 | && parser_of<std::invoke_result_t<T, Args...>, unconstrained>; | 633 | && parser_of<std::invoke_result_t<T, Args...>, unconstrained>; |
| 634 | 634 | ||
| 635 | template <class Fn, class... Args> | 635 | template <typename Fn, typename... Args> |
| 636 | requires parser_invocable<Fn, Args...> | 636 | requires parser_invocable<Fn, Args...> |
| 637 | using parser_invoke_result_t = | 637 | using parser_invoke_result_t = |
| 638 | parser_result_t<std::invoke_result_t<Fn, Args...>>; | 638 | parser_result_t<std::invoke_result_t<Fn, Args...>>; |
| @@ -833,7 +833,7 @@ inline auto read_string_contents(executor_ref e, attribute_view) | |||
| 833 | template <auto f> | 833 | template <auto f> |
| 834 | auto hohalo() | 834 | auto hohalo() |
| 835 | { | 835 | { |
| 836 | return []<class... Args>( | 836 | return []<typename... Args>( |
| 837 | Args&&... args) -> std::invoke_result_t<decltype(f), Args...> | 837 | Args&&... args) -> std::invoke_result_t<decltype(f), Args...> |
| 838 | { co_return co_await f(std::forward<Args>(args)...); }; | 838 | { co_return co_await f(std::forward<Args>(args)...); }; |
| 839 | } | 839 | } |