drogon
C++14/17-based HTTP application framework
Toggle main menu visibility
Loading...
Searching...
No Matches
FunctionTraits.h
1
14
15
#pragma once
16
#include <exception>
17
#include <string>
18
#include <tuple>
19
#include <type_traits>
20
21
namespace
drogon
22
{
23
namespace
orm
24
{
25
class
Result
;
26
class
DrogonDbException
;
27
28
namespace
internal
29
{
30
template
<
typename
>
31
struct
FunctionTraits
;
32
33
template
<>
34
struct
FunctionTraits
<void (*)()>
35
{
36
using
result_type = void;
37
template
<std::
size_t
Index>
38
using
argument = void;
39
static
const
std::size_t arity = 0;
40
41
static
const
bool
isSqlCallback =
false
;
42
static
const
bool
isExceptCallback =
false
;
43
};
44
45
// functor,lambda
46
template
<
typename
Function>
47
struct
FunctionTraits
48
:
public
FunctionTraits
<
49
decltype(&std::remove_reference<Function>::type::operator())>
50
{
51
};
52
53
template
<
typename
ClassType,
typename
ReturnType,
typename
... Arguments>
54
struct
FunctionTraits
<ReturnType (ClassType::*)(Arguments...) const>
55
:
FunctionTraits
<ReturnType (*)(Arguments...)>
56
{
57
};
58
59
template
<
typename
ClassType,
typename
ReturnType,
typename
... Arguments>
60
struct
FunctionTraits
<ReturnType (ClassType::*)(Arguments...)>
61
:
FunctionTraits
<ReturnType (*)(Arguments...)>
62
{
63
};
64
65
template
<>
66
struct
FunctionTraits
<void (*)(
const
Result
&)>
67
:
public
FunctionTraits
<void (*)()>
68
{
69
static
const
bool
isSqlCallback =
true
;
70
static
const
bool
isStepResultCallback =
false
;
71
static
const
bool
isExceptCallback =
false
;
72
};
73
74
template
<>
75
struct
FunctionTraits
<void (*)(
const
DrogonDbException
&)>
76
:
public
FunctionTraits
<void (*)()>
77
{
78
static
const
bool
isExceptCallback =
true
;
79
static
const
bool
isSqlCallback =
false
;
80
static
const
bool
isStepResultCallback =
false
;
81
static
const
bool
isPtr =
false
;
82
};
83
84
template
<>
85
struct
FunctionTraits
<void (*)(
const
std::exception_ptr &)>
86
:
public
FunctionTraits
<void (*)()>
87
{
88
static
const
bool
isExceptCallback =
true
;
89
static
const
bool
isSqlCallback =
false
;
90
static
const
bool
isStepResultCallback =
false
;
91
static
const
bool
isPtr =
true
;
92
};
93
94
template
<
typename
ReturnType,
typename
... Arguments>
95
struct
FunctionTraits
<ReturnType (*)(
bool
, Arguments...)>
96
:
FunctionTraits
<ReturnType (*)(Arguments...)>
97
{
98
static
const
bool
isSqlCallback =
true
;
99
static
const
bool
isStepResultCallback =
true
;
100
};
101
102
template
<
typename
ReturnType,
typename
... Arguments>
103
struct
FunctionTraits
<ReturnType (*)(Arguments...)>
104
{
105
using
result_type = ReturnType;
106
107
template
<std::
size_t
Index>
108
using
argument =
109
typename
std::tuple_element<Index, std::tuple<Arguments...>>::type;
110
111
static
const
std::size_t arity =
sizeof
...(Arguments);
112
113
static
const
bool
isSqlCallback =
true
;
114
static
const
bool
isStepResultCallback =
true
;
115
static
const
bool
isExceptCallback =
false
;
116
static
const
bool
isPtr =
false
;
117
};
118
}
// namespace internal
119
}
// namespace orm
120
}
// namespace drogon
drogon::orm::DrogonDbException
Mixin base class to identify drogon-db-specific exception types.
Definition
Exception.h:51
drogon::orm::Result
Result set containing data returned by a query or command.
Definition
Result.h:58
drogon
Drogon Test is a minimal effort test framework developed because the major C++ test frameworks doesn'...
Definition
Attribute.h:23
drogon::orm::internal::FunctionTraits
Definition
FunctionTraits.h:50
orm_lib
inc
drogon
orm
FunctionTraits.h
Generated by
1.17.0