From 0f5d7f182b9cd694cf7cc61f940bc8df8ce6357c Mon Sep 17 00:00:00 2001 From: sha512sum Date: Sat, 6 Jul 2024 22:02:42 +0000 Subject: [PATCH] Fix examples for clang-tidy, clang-format --- examples/src/cli.cpp | 16 ++++++++-------- examples/src/http.cpp | 17 +++++++++++------ examples/src/log.cpp | 7 +++++-- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/examples/src/cli.cpp b/examples/src/cli.cpp index 9a5b8cc..e3301a4 100644 --- a/examples/src/cli.cpp +++ b/examples/src/cli.cpp @@ -1,8 +1,7 @@ #include #include -#include #include - +#include struct SomeStruct { static_assert(utempl::OpenStruct()); @@ -19,17 +18,16 @@ struct SomeOtherComponent : public cserver::server::handlers::HttpHandlerBaseWit static constexpr utempl::ConstexprString kName = "name"; static constexpr utempl::ConstexprString kHandlerManagerName = "server"; SomeComponent& some; - inline constexpr SomeOtherComponent(auto& context) : - HttpHandlerBaseWithAdder(context), - some(context.template FindComponent<"component">()) {}; - + explicit constexpr SomeOtherComponent(auto& context) : + HttpHandlerBaseWithAdder(context), some(context.template FindComponent<"component">()) {}; + inline auto HandleRequestThrow(const cserver::server::http::HttpRequest&) -> cserver::Task { co_return cserver::server::http::HttpResponse{.body = this->some.field}; }; }; - - +// clang-format off +// NOLINTBEGIN auto main(int argc, const char** argv) -> int { cserver::ServiceContextBuilder{} .AppendConfigParam<"threads", 8>() @@ -47,3 +45,5 @@ auto main(int argc, const char** argv) -> int { .Sort() .Run(argc, argv); }; +// NOLINTEND +// clang-format on diff --git a/examples/src/http.cpp b/examples/src/http.cpp index dc393e0..d2e4d7c 100644 --- a/examples/src/http.cpp +++ b/examples/src/http.cpp @@ -1,19 +1,21 @@ -#include #include #include - +#include + struct SomeComponent : public cserver::server::handlers::HttpHandlerBaseWithAdder { static constexpr utempl::ConstexprString kPath = "/v1/some/"; static constexpr utempl::ConstexprString kName = "name"; static constexpr utempl::ConstexprString kHandlerManagerName = "server"; - inline constexpr SomeComponent(auto& context) : - HttpHandlerBaseWithAdder(context) {}; - + explicit constexpr SomeComponent(auto& context) : HttpHandlerBaseWithAdder(context) {}; + inline auto HandleRequestThrow(const cserver::server::http::HttpRequest& request) -> cserver::Task { co_return cserver::server::http::HttpResponse{.body = request.url.data()}; }; }; - + +// clang-format off +// NOLINTBEGIN + auto main() -> int { cserver::ServiceContextBuilder{} .AppendConfigParam<"threads", 8>() @@ -28,3 +30,6 @@ auto main() -> int { .Sort() .Run(); }; + +// NOLINTEND +// clang-format on diff --git a/examples/src/log.cpp b/examples/src/log.cpp index 8000096..f34f34d 100644 --- a/examples/src/log.cpp +++ b/examples/src/log.cpp @@ -1,6 +1,5 @@ #include - struct SomeComponent : cserver::ComponentBase { static constexpr utempl::ConstexprString kName = "component"; using cserver::ComponentBase::ComponentBase; @@ -10,7 +9,8 @@ struct SomeComponent : cserver::ComponentBase { }; }; - +// clang-format off +// NOLINTBEGIN auto main() -> int { cserver::ServiceContextBuilder{} .AppendConfigParam<"threads", 8>() @@ -21,3 +21,6 @@ auto main() -> int { .Sort() .Run(); }; + +// NOLINTEND +// clang-format on