From c94ed1c9ab52645b68ddfb42c5efc4a6f2222096 Mon Sep 17 00:00:00 2001 From: kamchatka-volcano Date: Sun, 14 Jul 2024 16:19:01 +0500 Subject: [PATCH] -wip refactoring 2 --- CMakeLists.txt | 6 +++++- examples/example_client.cpp | 2 -- examples/example_client_in_processor.cpp | 2 -- examples/example_guestbook.cpp | 1 - examples/example_hello_world.cpp | 2 -- examples/example_request_processor.cpp | 2 -- examples/example_response_dispatching_asio_task.cpp | 2 -- examples/example_response_wait_future.cpp | 2 -- examples/example_route_context.cpp | 1 - examples/example_route_matcher.cpp | 1 - examples/example_route_params.cpp | 1 - .../example_route_params_user_defined_types.cpp | 1 - examples/example_router.cpp | 1 - examples/example_timer.cpp | 2 -- include/asyncgi/asyncgi.h | 4 ++++ include/asyncgi/asyncgi_fwd.h | 13 +++++++++---- 16 files changed, 18 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1dd3ec8..83cdd91 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,4 +105,8 @@ endif() if (ASYNCGI_USE_BOOST_ASIO) target_compile_definitions(asyncgi PUBLIC "ASYNCGI_USE_BOOST_ASIO") -endif() \ No newline at end of file +endif() + +if (ASYNCGI_DISABLE_GLOBAL_HTTP_NAMESPACE) + target_compile_definitions(asyncgi PUBLIC "ASYNCGI_DISABLE_GLOBAL_HTTP_NAMESPACE") +endif () \ No newline at end of file diff --git a/examples/example_client.cpp b/examples/example_client.cpp index f24c5b5..0200140 100644 --- a/examples/example_client.cpp +++ b/examples/example_client.cpp @@ -1,8 +1,6 @@ #include #include -using namespace asyncgi; - int main() { auto io = asyncgi::IO{}; diff --git a/examples/example_client_in_processor.cpp b/examples/example_client_in_processor.cpp index 9c4b2c9..545cc55 100644 --- a/examples/example_client_in_processor.cpp +++ b/examples/example_client_in_processor.cpp @@ -1,7 +1,5 @@ #include -namespace http = asyncgi::http; - struct RequestPage{ void operator()(const http::Request&, asyncgi::Responder& responder) { diff --git a/examples/example_guestbook.cpp b/examples/example_guestbook.cpp index dda044c..9ff5023 100644 --- a/examples/example_guestbook.cpp +++ b/examples/example_guestbook.cpp @@ -3,7 +3,6 @@ #include #include -namespace http = asyncgi::http; using namespace std::string_literals; enum class AccessRole { diff --git a/examples/example_hello_world.cpp b/examples/example_hello_world.cpp index 665a9f4..dc21b6f 100644 --- a/examples/example_hello_world.cpp +++ b/examples/example_hello_world.cpp @@ -1,7 +1,5 @@ #include -namespace http = asyncgi::http; - int main() { auto io = asyncgi::IO{}; diff --git a/examples/example_request_processor.cpp b/examples/example_request_processor.cpp index 6d6ccd3..0f90d46 100644 --- a/examples/example_request_processor.cpp +++ b/examples/example_request_processor.cpp @@ -1,7 +1,5 @@ #include -namespace http = asyncgi::http; - http::Response guestBookPage(const http::Request& request) { if (request.path() == "/") diff --git a/examples/example_response_dispatching_asio_task.cpp b/examples/example_response_dispatching_asio_task.cpp index be080ce..af05d63 100644 --- a/examples/example_response_dispatching_asio_task.cpp +++ b/examples/example_response_dispatching_asio_task.cpp @@ -6,8 +6,6 @@ namespace asio = boost::asio; #include #endif -namespace http = asyncgi::http; - struct DelayedPage { void operator()(const http::Request&, asyncgi::Responder& responder) { diff --git a/examples/example_response_wait_future.cpp b/examples/example_response_wait_future.cpp index b0515af..2bd9112 100644 --- a/examples/example_response_wait_future.cpp +++ b/examples/example_response_wait_future.cpp @@ -1,8 +1,6 @@ #include #include -using namespace asyncgi; - struct DelayedPage{ void operator()(const http::Request&, asyncgi::Responder& responder) { diff --git a/examples/example_route_context.cpp b/examples/example_route_context.cpp index 1794e17..45d5202 100644 --- a/examples/example_route_context.cpp +++ b/examples/example_route_context.cpp @@ -2,7 +2,6 @@ #include #include -namespace http = asyncgi::http; using namespace std::string_literals; enum class AccessRole { diff --git a/examples/example_route_matcher.cpp b/examples/example_route_matcher.cpp index 2e38199..b73424d 100644 --- a/examples/example_route_matcher.cpp +++ b/examples/example_route_matcher.cpp @@ -2,7 +2,6 @@ #include #include -namespace http = asyncgi::http; using namespace std::string_literals; enum class AccessRole { diff --git a/examples/example_route_params.cpp b/examples/example_route_params.cpp index 8f5dded..df555dc 100644 --- a/examples/example_route_params.cpp +++ b/examples/example_route_params.cpp @@ -1,7 +1,6 @@ #include #include -using namespace asyncgi; using namespace std::string_literals; class GuestBookState { diff --git a/examples/example_route_params_user_defined_types.cpp b/examples/example_route_params_user_defined_types.cpp index de0341d..c784ff2 100644 --- a/examples/example_route_params_user_defined_types.cpp +++ b/examples/example_route_params_user_defined_types.cpp @@ -1,7 +1,6 @@ #include #include -using namespace asyncgi; using namespace std::string_literals; struct MessageNumber { diff --git a/examples/example_router.cpp b/examples/example_router.cpp index 1aaae33..235ce23 100644 --- a/examples/example_router.cpp +++ b/examples/example_router.cpp @@ -1,7 +1,6 @@ #include #include -namespace http = asyncgi::http; using namespace std::string_literals; class GuestBookState { diff --git a/examples/example_timer.cpp b/examples/example_timer.cpp index 54ba557..33c2c60 100644 --- a/examples/example_timer.cpp +++ b/examples/example_timer.cpp @@ -1,7 +1,5 @@ #include -namespace http = asyncgi::http; - struct Greeter{ Greeter(const int& secondsCounter) : secondsCounter_{&secondsCounter} diff --git a/include/asyncgi/asyncgi.h b/include/asyncgi/asyncgi.h index 30c94fb..50420d4 100755 --- a/include/asyncgi/asyncgi.h +++ b/include/asyncgi/asyncgi.h @@ -10,4 +10,8 @@ #include "server.h" #include "timer.h" +#ifndef ASYNCGI_DISABLE_GLOBAL_HTTP_NAMESPACE +namespace http = asyncgi::http; +#endif + #endif //ASYNCGI_H \ No newline at end of file diff --git a/include/asyncgi/asyncgi_fwd.h b/include/asyncgi/asyncgi_fwd.h index d5a84cd..73256e9 100644 --- a/include/asyncgi/asyncgi_fwd.h +++ b/include/asyncgi/asyncgi_fwd.h @@ -3,7 +3,6 @@ namespace asyncgi { class IO; -class Request; class Responder; class Server; class Client; @@ -13,13 +12,19 @@ class TaskContext; class Timer; namespace http { +class Request; class Response; -}; +}; //namespace http + namespace fastcgi { -struct Request; -struct Response; +class Request; +class Response; } //namespace fastcgi } //namespace asyncgi +#ifndef ASYNCGI_DISABLE_GLOBAL_HTTP_NAMESPACE +namespace http = asyncgi::http; +#endif + #endif //ASYNCGI_FWD_H \ No newline at end of file