From b2eb50afce0aff48c04f1842e5773a8e50b3a125 Mon Sep 17 00:00:00 2001 From: Wei Dong Date: Mon, 19 Dec 2016 11:27:19 -0500 Subject: [PATCH] make iequal_to & ihash template-independent. --- server_http.hpp | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/server_http.hpp b/server_http.hpp index f0cf9a12..515ef915 100644 --- a/server_http.hpp +++ b/server_http.hpp @@ -21,6 +21,26 @@ #endif namespace SimpleWeb { + class RequestBase { + public: + //Based on http://www.boost.org/doc/libs/1_60_0/doc/html/unordered/hash_equality.html + class iequal_to { + public: + bool operator()(const std::string &key1, const std::string &key2) const { + return boost::algorithm::iequals(key1, key2); + } + }; + class ihash { + public: + size_t operator()(const std::string &key) const { + std::size_t seed=0; + for(auto &c: key) + boost::hash_combine(seed, std::tolower(c)); + return seed; + } + }; + }; + template class Server; @@ -60,26 +80,10 @@ namespace SimpleWeb { Content(boost::asio::streambuf &streambuf): std::istream(&streambuf), streambuf(streambuf) {} }; - class Request { + class Request: public RequestBase { friend class ServerBase; friend class Server; - //Based on http://www.boost.org/doc/libs/1_60_0/doc/html/unordered/hash_equality.html - class iequal_to { - public: - bool operator()(const std::string &key1, const std::string &key2) const { - return boost::algorithm::iequals(key1, key2); - } - }; - class ihash { - public: - size_t operator()(const std::string &key) const { - std::size_t seed=0; - for(auto &c: key) - boost::hash_combine(seed, std::tolower(c)); - return seed; - } - }; public: std::string method, path, http_version;