From fae8e07faae285837110d68f4efb48bbe4e9de27 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sun, 18 Jun 2017 08:11:27 +0200 Subject: [PATCH] Removed dependency of boost::string_ref if USE_STANDALONE_ASIO is defined --- client_http.hpp | 12 ++++++------ server_http.hpp | 2 -- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/client_http.hpp b/client_http.hpp index fc2adf8..73c4fd1 100644 --- a/client_http.hpp +++ b/client_http.hpp @@ -7,7 +7,6 @@ #include #include -#include #include #include @@ -20,17 +19,18 @@ namespace SimpleWeb { using errc = std::errc; using system_error = std::system_error; namespace make_error_code = std; + using string_view = const std::string&; // TODO c++17: use std::string_view } #else #include -#include -#include +#include namespace SimpleWeb { namespace asio = boost::asio; using error_code = boost::system::error_code; namespace errc = boost::system::errc; using system_error = boost::system::system_error; namespace make_error_code = boost::system::errc; + using string_view = boost::string_ref; } #endif @@ -155,7 +155,7 @@ namespace SimpleWeb { } /// Synchronous request. The io_service is run within this function. - std::shared_ptr request(const std::string& method, const std::string& path=std::string("/"), boost::string_ref content="", const Header& header=Header()) { + std::shared_ptr request(const std::string& method, const std::string& path=std::string("/"), string_view content="", const Header& header=Header()) { auto session=std::make_shared(io_service, get_connection(), create_request_header(method, path, header)); std::shared_ptr response; session->callback=[this, &response, session](const error_code &ec) { @@ -215,7 +215,7 @@ namespace SimpleWeb { /// Asynchronous request where setting and/or running Client's io_service is required. /// The request callback is not run if the calling Client object has been destroyed. - void request(const std::string &method, const std::string &path, boost::string_ref content, const Header& header, + void request(const std::string &method, const std::string &path, string_view content, const Header& header, std::function, const error_code&)> &&request_callback_) { auto session=std::make_shared(io_service, get_connection(), create_request_header(method, path, header)); auto request_callback=std::make_shared, const error_code&)>>(std::move(request_callback_)); @@ -246,7 +246,7 @@ namespace SimpleWeb { /// Asynchronous request where setting and/or running Client's io_service is required. /// The request callback is not run if the calling Client object has been destroyed. - void request(const std::string &method, const std::string &path, boost::string_ref content, + void request(const std::string &method, const std::string &path, string_view content, std::function, const error_code&)> &&request_callback) { request(method, path, content, Header(), std::move(request_callback)); } diff --git a/server_http.hpp b/server_http.hpp index 45a9a16..eb5f0d4 100644 --- a/server_http.hpp +++ b/server_http.hpp @@ -18,8 +18,6 @@ namespace SimpleWeb { } #else #include -#include -#include namespace SimpleWeb { namespace asio = boost::asio; using error_code = boost::system::error_code;