mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
Removed FunctionTraits.h.
This commit is contained in:
parent
18f1bc2496
commit
bb1f871478
@ -1,142 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* FunctionTraits.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
|
||||
namespace drogon {
|
||||
class HttpRequest;
|
||||
class HttpResponse;
|
||||
using HttpRequestPtr = std::shared_ptr<HttpRequest>;
|
||||
using HttpResponsePtr = std::shared_ptr<HttpResponse>;
|
||||
|
||||
namespace internal {
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct resumable_type : std::false_type {
|
||||
};
|
||||
|
||||
template <typename>
|
||||
struct FunctionTraits;
|
||||
|
||||
// functor,lambda,std::function...
|
||||
template <typename Function>
|
||||
struct FunctionTraits : public FunctionTraits<decltype(
|
||||
&std::remove_reference<Function>::type::operator())> {
|
||||
static const bool isClassFunction = false;
|
||||
static const bool isDrObjectClass = false;
|
||||
using class_type = void;
|
||||
static const std::string name() {
|
||||
return std::string("Functor");
|
||||
}
|
||||
};
|
||||
|
||||
// class instance method of const object
|
||||
template <typename ClassType, typename ReturnType, typename... Arguments>
|
||||
struct FunctionTraits<ReturnType (ClassType::*)(Arguments...) const>
|
||||
: FunctionTraits<ReturnType (*)(Arguments...)> {
|
||||
static const bool isClassFunction = true;
|
||||
static const bool isDrObjectClass =
|
||||
std::is_base_of<DrObject<ClassType>, ClassType>::value;
|
||||
using class_type = ClassType;
|
||||
static const std::string name() {
|
||||
return std::string("Class Function");
|
||||
}
|
||||
};
|
||||
|
||||
// class instance method of non-const object
|
||||
template <typename ClassType, typename ReturnType, typename... Arguments>
|
||||
struct FunctionTraits<ReturnType (ClassType::*)(Arguments...)>
|
||||
: FunctionTraits<ReturnType (*)(Arguments...)> {
|
||||
static const bool isClassFunction = true;
|
||||
static const bool isDrObjectClass =
|
||||
std::is_base_of<DrObject<ClassType>, ClassType>::value;
|
||||
using class_type = ClassType;
|
||||
static const std::string name() {
|
||||
return std::string("Class Function");
|
||||
}
|
||||
};
|
||||
|
||||
// normal function for HTTP handling
|
||||
template <typename ReturnType, typename... Arguments>
|
||||
struct FunctionTraits<
|
||||
ReturnType (*)(const HttpRequestPtr &req,
|
||||
std::function<void(const HttpResponsePtr &)> &&callback,
|
||||
Arguments...)> : FunctionTraits<ReturnType (*)(Arguments...)> {
|
||||
static const bool isHTTPFunction = !resumable_type<ReturnType>::value;
|
||||
static const bool isCoroutine = false;
|
||||
using class_type = void;
|
||||
using first_param_type = HttpRequestPtr;
|
||||
using return_type = ReturnType;
|
||||
};
|
||||
|
||||
template <typename ReturnType, typename... Arguments>
|
||||
struct FunctionTraits<
|
||||
ReturnType (*)(HttpRequestPtr &req,
|
||||
std::function<void(const HttpResponsePtr &)> &&callback,
|
||||
Arguments...)> : FunctionTraits<ReturnType (*)(Arguments...)> {
|
||||
static const bool isHTTPFunction = false;
|
||||
using class_type = void;
|
||||
};
|
||||
|
||||
template <typename ReturnType, typename... Arguments>
|
||||
struct FunctionTraits<
|
||||
ReturnType (*)(HttpRequestPtr &&req,
|
||||
std::function<void(const HttpResponsePtr &)> &&callback,
|
||||
Arguments...)> : FunctionTraits<ReturnType (*)(Arguments...)> {
|
||||
static const bool isHTTPFunction = false;
|
||||
using class_type = void;
|
||||
};
|
||||
|
||||
// normal function for HTTP handling
|
||||
template <typename T, typename ReturnType, typename... Arguments>
|
||||
struct FunctionTraits<
|
||||
ReturnType (*)(T &&customReq,
|
||||
std::function<void(const HttpResponsePtr &)> &&callback,
|
||||
Arguments...)> : FunctionTraits<ReturnType (*)(Arguments...)> {
|
||||
static const bool isHTTPFunction = !resumable_type<ReturnType>::value;
|
||||
static const bool isCoroutine = false;
|
||||
using class_type = void;
|
||||
using first_param_type = T;
|
||||
using return_type = ReturnType;
|
||||
};
|
||||
|
||||
// normal function
|
||||
template <typename ReturnType, typename... Arguments>
|
||||
struct FunctionTraits<ReturnType (*)(Arguments...)> {
|
||||
using result_type = ReturnType;
|
||||
|
||||
template <std::size_t Index>
|
||||
using argument =
|
||||
typename std::tuple_element<Index, std::tuple<Arguments...> >::type;
|
||||
|
||||
static const std::size_t arity = sizeof...(Arguments);
|
||||
using class_type = void;
|
||||
using return_type = ReturnType;
|
||||
static const bool isHTTPFunction = false;
|
||||
static const bool isClassFunction = false;
|
||||
static const bool isDrObjectClass = false;
|
||||
static const bool isCoroutine = false;
|
||||
static const std::string name() {
|
||||
return std::string("Normal or Static Function");
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace drogon
|
Loading…
Reference in New Issue
Block a user