Fix examples for clang-tidy, clang-format

This commit is contained in:
sha512sum 2024-07-06 22:02:42 +00:00
parent 2cd8bbdb60
commit 0f5d7f182b
3 changed files with 24 additions and 16 deletions

View file

@ -1,8 +1,7 @@
#include <cserver/components/cli/manager.hpp> #include <cserver/components/cli/manager.hpp>
#include <cserver/components/cli/struct.hpp> #include <cserver/components/cli/struct.hpp>
#include <cserver/server/server/server.hpp>
#include <cserver/server/handlers/http_handler_base.hpp> #include <cserver/server/handlers/http_handler_base.hpp>
#include <cserver/server/server/server.hpp>
struct SomeStruct { struct SomeStruct {
static_assert(utempl::OpenStruct<SomeStruct>()); static_assert(utempl::OpenStruct<SomeStruct>());
@ -19,17 +18,16 @@ struct SomeOtherComponent : public cserver::server::handlers::HttpHandlerBaseWit
static constexpr utempl::ConstexprString kName = "name"; static constexpr utempl::ConstexprString kName = "name";
static constexpr utempl::ConstexprString kHandlerManagerName = "server"; static constexpr utempl::ConstexprString kHandlerManagerName = "server";
SomeComponent& some; SomeComponent& some;
inline constexpr SomeOtherComponent(auto& context) : explicit constexpr SomeOtherComponent(auto& context) :
HttpHandlerBaseWithAdder(context), HttpHandlerBaseWithAdder(context), some(context.template FindComponent<"component">()) {};
some(context.template FindComponent<"component">()) {};
inline auto HandleRequestThrow(const cserver::server::http::HttpRequest&) -> cserver::Task<cserver::server::http::HttpResponse> { inline auto HandleRequestThrow(const cserver::server::http::HttpRequest&) -> cserver::Task<cserver::server::http::HttpResponse> {
co_return cserver::server::http::HttpResponse{.body = this->some.field}; co_return cserver::server::http::HttpResponse{.body = this->some.field};
}; };
}; };
// clang-format off
// NOLINTBEGIN
auto main(int argc, const char** argv) -> int { auto main(int argc, const char** argv) -> int {
cserver::ServiceContextBuilder{} cserver::ServiceContextBuilder{}
.AppendConfigParam<"threads", 8>() .AppendConfigParam<"threads", 8>()
@ -47,3 +45,5 @@ auto main(int argc, const char** argv) -> int {
.Sort() .Sort()
.Run(argc, argv); .Run(argc, argv);
}; };
// NOLINTEND
// clang-format on

View file

@ -1,19 +1,21 @@
#include <cserver/server/server/server.hpp>
#include <cserver/engine/basic/task_processor.hpp> #include <cserver/engine/basic/task_processor.hpp>
#include <cserver/server/handlers/http_handler_base.hpp> #include <cserver/server/handlers/http_handler_base.hpp>
#include <cserver/server/server/server.hpp>
struct SomeComponent : public cserver::server::handlers::HttpHandlerBaseWithAdder<SomeComponent> { struct SomeComponent : public cserver::server::handlers::HttpHandlerBaseWithAdder<SomeComponent> {
static constexpr utempl::ConstexprString kPath = "/v1/some/"; static constexpr utempl::ConstexprString kPath = "/v1/some/";
static constexpr utempl::ConstexprString kName = "name"; static constexpr utempl::ConstexprString kName = "name";
static constexpr utempl::ConstexprString kHandlerManagerName = "server"; static constexpr utempl::ConstexprString kHandlerManagerName = "server";
inline constexpr SomeComponent(auto& context) : explicit constexpr SomeComponent(auto& context) : HttpHandlerBaseWithAdder(context) {};
HttpHandlerBaseWithAdder(context) {};
inline auto HandleRequestThrow(const cserver::server::http::HttpRequest& request) -> cserver::Task<cserver::server::http::HttpResponse> { inline auto HandleRequestThrow(const cserver::server::http::HttpRequest& request) -> cserver::Task<cserver::server::http::HttpResponse> {
co_return cserver::server::http::HttpResponse{.body = request.url.data()}; co_return cserver::server::http::HttpResponse{.body = request.url.data()};
}; };
}; };
// clang-format off
// NOLINTBEGIN
auto main() -> int { auto main() -> int {
cserver::ServiceContextBuilder{} cserver::ServiceContextBuilder{}
.AppendConfigParam<"threads", 8>() .AppendConfigParam<"threads", 8>()
@ -28,3 +30,6 @@ auto main() -> int {
.Sort() .Sort()
.Run(); .Run();
}; };
// NOLINTEND
// clang-format on

View file

@ -1,6 +1,5 @@
#include <cserver/components/loggable_component_base.hpp> #include <cserver/components/loggable_component_base.hpp>
struct SomeComponent : cserver::ComponentBase { struct SomeComponent : cserver::ComponentBase {
static constexpr utempl::ConstexprString kName = "component"; static constexpr utempl::ConstexprString kName = "component";
using cserver::ComponentBase::ComponentBase; using cserver::ComponentBase::ComponentBase;
@ -10,7 +9,8 @@ struct SomeComponent : cserver::ComponentBase {
}; };
}; };
// clang-format off
// NOLINTBEGIN
auto main() -> int { auto main() -> int {
cserver::ServiceContextBuilder{} cserver::ServiceContextBuilder{}
.AppendConfigParam<"threads", 8>() .AppendConfigParam<"threads", 8>()
@ -21,3 +21,6 @@ auto main() -> int {
.Sort() .Sort()
.Run(); .Run();
}; };
// NOLINTEND
// clang-format on