Fixes #129: linking issues related to case_insensitive_equal and make_error_code

This commit is contained in:
eidheim 2017-06-10 15:03:27 +02:00
commit 83691c6e9a
3 changed files with 9 additions and 7 deletions

View file

@ -16,6 +16,7 @@ namespace SimpleWeb {
using error_code = std::error_code; using error_code = std::error_code;
using errc = std::errc; using errc = std::errc;
using system_error = std::system_error; using system_error = std::system_error;
namespace make_error_code = std;
} }
#else #else
#include <boost/asio.hpp> #include <boost/asio.hpp>
@ -27,13 +28,14 @@ namespace SimpleWeb {
using error_code = boost::system::error_code; using error_code = boost::system::error_code;
namespace errc = boost::system::errc; namespace errc = boost::system::errc;
using system_error = boost::system::system_error; using system_error = boost::system::system_error;
namespace make_error_code = boost::system::errc;
} }
#endif #endif
# ifndef CASE_INSENSITIVE_EQUAL_AND_HASH # ifndef CASE_INSENSITIVE_EQUAL_AND_HASH
# define CASE_INSENSITIVE_EQUAL_AND_HASH # define CASE_INSENSITIVE_EQUAL_AND_HASH
namespace SimpleWeb { namespace SimpleWeb {
bool case_insensitive_equal(const std::string &str1, const std::string &str2) { inline bool case_insensitive_equal(const std::string &str1, const std::string &str2) {
return str1.size() == str2.size() && return str1.size() == str2.size() &&
std::equal(str1.begin(), str1.end(), str2.begin(), [](char a, char b) { std::equal(str1.begin(), str1.end(), str2.begin(), [](char a, char b) {
return tolower(a) == tolower(b); return tolower(a) == tolower(b);

View file

@ -120,7 +120,7 @@ namespace SimpleWeb {
if (response->status_code.empty() || response->status_code.compare(0, 3, "200") != 0) { if (response->status_code.empty() || response->status_code.compare(0, 3, "200") != 0) {
std::lock_guard<std::mutex> lock(socket_mutex); std::lock_guard<std::mutex> lock(socket_mutex);
socket=nullptr; socket=nullptr;
throw make_error_code(errc::permission_denied); throw make_error_code::make_error_code(errc::permission_denied);
} }
} }

View file

@ -14,7 +14,7 @@
namespace SimpleWeb { namespace SimpleWeb {
using error_code = std::error_code; using error_code = std::error_code;
using errc = std::errc; using errc = std::errc;
error_code (&make_error_code)(errc) = std::make_error_code; namespace make_error_code = std;
} }
#else #else
#include <boost/asio.hpp> #include <boost/asio.hpp>
@ -24,14 +24,14 @@ namespace SimpleWeb {
namespace asio = boost::asio; namespace asio = boost::asio;
using error_code = boost::system::error_code; using error_code = boost::system::error_code;
namespace errc = boost::system::errc; namespace errc = boost::system::errc;
error_code (&make_error_code)(boost::system::errc::errc_t) = boost::system::errc::make_error_code; namespace make_error_code = boost::system::errc;
} }
#endif #endif
# ifndef CASE_INSENSITIVE_EQUAL_AND_HASH # ifndef CASE_INSENSITIVE_EQUAL_AND_HASH
# define CASE_INSENSITIVE_EQUAL_AND_HASH # define CASE_INSENSITIVE_EQUAL_AND_HASH
namespace SimpleWeb { namespace SimpleWeb {
bool case_insensitive_equal(const std::string &str1, const std::string &str2) { inline bool case_insensitive_equal(const std::string &str1, const std::string &str2) {
return str1.size() == str2.size() && return str1.size() == str2.size() &&
std::equal(str1.begin(), str1.end(), str2.begin(), [](char a, char b) { std::equal(str1.begin(), str1.end(), str2.begin(), [](char a, char b) {
return tolower(a) == tolower(b); return tolower(a) == tolower(b);
@ -339,7 +339,7 @@ namespace SimpleWeb {
} }
catch(const std::exception &e) { catch(const std::exception &e) {
if(on_error) if(on_error)
on_error(request, make_error_code(errc::protocol_error)); on_error(request, make_error_code::make_error_code(errc::protocol_error));
return; return;
} }
if(content_length>num_additional_bytes) { if(content_length>num_additional_bytes) {
@ -473,7 +473,7 @@ namespace SimpleWeb {
} }
catch(const std::exception &e) { catch(const std::exception &e) {
if(on_error) if(on_error)
on_error(request, make_error_code(errc::operation_canceled)); on_error(request, make_error_code::make_error_code(errc::operation_canceled));
return; return;
} }
} }