aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authoripknHama <ipknhama@gmail.com>2015-02-20 11:47:51 +0900
committeripknHama <ipknhama@gmail.com>2015-02-20 11:50:34 +0900
commit0a7c9973496d73da87fb4e88de5a267c6d589da5 (patch)
tree55cdb92a87917b2700bdc10408a5c7a411a055cd /include
parent02f81f7eaa9b4428b33c471a020c43b2f647b91c (diff)
downloadcrow-0a7c9973496d73da87fb4e88de5a267c6d589da5.tar.gz
crow-0a7c9973496d73da87fb4e88de5a267c6d589da5.zip
working on VS2013 support
* wrap constexpr * add run-time version of get_parameter_tag
Diffstat (limited to 'include')
-rw-r--r--include/common.h3
-rw-r--r--include/utility.h43
2 files changed, 27 insertions, 19 deletions
diff --git a/include/common.h b/include/common.h
index 619f4d5..8808d6a 100644
--- a/include/common.h
+++ b/include/common.h
@@ -109,6 +109,7 @@ namespace crow
}
}
+#ifndef CROW_MSVC_WORKAROUND
constexpr crow::HTTPMethod operator "" _method(const char* str, size_t len)
{
return
@@ -122,4 +123,4 @@ constexpr crow::HTTPMethod operator "" _method(const char* str, size_t len)
crow::black_magic::is_equ_p(str, "TRACE", 5) ? crow::HTTPMethod::TRACE :
throw std::runtime_error("invalid http method");
};
-
+#endif
diff --git a/include/utility.h b/include/utility.h
index 65d4cf8..d1dda06 100644
--- a/include/utility.h
+++ b/include/utility.h
@@ -4,11 +4,14 @@
#include <stdexcept>
#include <tuple>
#include <type_traits>
+#include <cstring>
+#include <functional>
namespace crow
{
namespace black_magic
{
+#ifndef CROW_MSVC_WORKAROUND
struct OutOfRange
{
OutOfRange(unsigned pos, unsigned length) {}
@@ -44,15 +47,6 @@ namespace crow
}
};
- unsigned find_closing_tag_runtime(const char* s, unsigned p)
- {
- return
- s[p] == 0
- ? throw std::runtime_error("unmatched tag <") :
- s[p] == '>'
- ? p : find_closing_tag_runtime(s, p+1);
- }
-
constexpr unsigned find_closing_tag(const_str s, unsigned p)
{
return s[p] == '>' ? p : find_closing_tag(s, p+1);
@@ -124,7 +118,7 @@ namespace crow
{
return is_equ_n(s, i, "<path>", 0, 6);
}
-
+#endif
template <typename T>
struct paramater_tag
{
@@ -184,28 +178,38 @@ struct paramater_tag<t> \
return is_paramter_tag_compatible(a/6, b/6);
}
- constexpr uint64_t get_parameter_tag_runtime(const char* s, unsigned p = 0)
+ unsigned find_closing_tag_runtime(const char* s, unsigned p)
+ {
+ return
+ s[p] == 0
+ ? throw std::runtime_error("unmatched tag <") :
+ s[p] == '>'
+ ? p : find_closing_tag_runtime(s, p + 1);
+ }
+
+ uint64_t get_parameter_tag_runtime(const char* s, unsigned p = 0)
{
return
s[p] == 0
? 0 :
s[p] == '<' ? (
- strncmp(s+p, "<int>", 5) == 0
+ std::strncmp(s+p, "<int>", 5) == 0
? get_parameter_tag_runtime(s, find_closing_tag_runtime(s, p)) * 6 + 1 :
- strncmp(s+p, "<uint>", 6) == 0
+ std::strncmp(s+p, "<uint>", 6) == 0
? get_parameter_tag_runtime(s, find_closing_tag_runtime(s, p)) * 6 + 2 :
- (strncmp(s+p, "<float>", 7) == 0 ||
- strncmp(s+p, "<double>", 8) == 0)
+ (std::strncmp(s+p, "<float>", 7) == 0 ||
+ std::strncmp(s+p, "<double>", 8) == 0)
? get_parameter_tag_runtime(s, find_closing_tag_runtime(s, p)) * 6 + 3 :
- (strncmp(s+p, "<str>", 5) == 0 ||
- strncmp(s+p, "<string>", 8) == 0)
+ (std::strncmp(s+p, "<str>", 5) == 0 ||
+ std::strncmp(s+p, "<string>", 8) == 0)
? get_parameter_tag_runtime(s, find_closing_tag_runtime(s, p)) * 6 + 4 :
- strncmp(s+p, "<path>", 6) == 0
+ std::strncmp(s+p, "<path>", 6) == 0
? get_parameter_tag_runtime(s, find_closing_tag_runtime(s, p)) * 6 + 5 :
throw std::runtime_error("invalid parameter type")
) :
get_parameter_tag_runtime(s, p+1);
}
+#ifndef CROW_MSVC_WORKAROUND
constexpr uint64_t get_parameter_tag(const_str s, unsigned p = 0)
{
return
@@ -226,6 +230,7 @@ struct paramater_tag<t> \
) :
get_parameter_tag(s, p+1);
}
+#endif
template <typename ... T>
struct S
@@ -448,6 +453,7 @@ template <typename F, typename Set>
template<typename T>
struct function_traits;
+#ifndef CROW_MSVC_WORKAROUND
template<typename T>
struct function_traits : public function_traits<decltype(&T::operator())>
{
@@ -458,6 +464,7 @@ template <typename F, typename Set>
using arg = typename parent_t::template arg<i>;
};
+#endif
template<typename ClassType, typename R, typename ...Args>
struct function_traits<R(ClassType::*)(Args...) const>