RESTinio
Toggle main menu visibility
Loading...
Searching...
No Matches
restinio
common_types.hpp
Go to the documentation of this file.
1
/*
2
restinio
3
*/
4
5
/*!
6
Restinio common types.
7
*/
8
9
#
pragma
once
10
11
#
include
<
cstdint
>
12
13
#
include
<
restinio
/
asio_include
.
hpp
>
14
15
namespace
restinio
16
{
17
18
//! Request handling status.
19
/*!
20
If handler handles request it must return accepted.
21
22
If handler refuses to handle request
23
it must return rejected.
24
*/
25
enum
class
request_handling_status_t
:
std
::
uint8_t
26
{
27
//! Request accepted for handling.
28
accepted
,
29
30
//! Request wasn't accepted for handling.
31
rejected
,
32
33
//! The request wasn't handled. If there is another handler to
34
//! be tried it should be tried. Otherwise the request has to
35
//! be rejected.
36
//!
37
//! @since v.0.6.13.
38
not_handled
39
};
40
41
//! @name Helper funcs for working with request_handling_status_t
42
//! \see request_handling_status_t.
43
///@{
44
[[
nodiscard
]]
45
constexpr
request_handling_status_t
46
request_accepted
()
noexcept
47
{
48
return
request_handling_status_t
::
accepted
;
49
}
50
51
[[
nodiscard
]]
52
constexpr
request_handling_status_t
53
request_rejected
()
noexcept
54
{
55
return
request_handling_status_t
::
rejected
;
56
}
57
58
/*!
59
* @since v.0.6.13
60
*/
61
[[
nodiscard
]]
62
constexpr
request_handling_status_t
63
request_not_handled
()
noexcept
64
{
65
return
request_handling_status_t
::
not_handled
;
66
}
67
///@}
68
69
//! Request id in scope of single connection.
70
using
request_id_t
=
unsigned
int
;
71
72
//! Attribute for parts.
73
enum
class
response_parts_attr_t
:
std
::
uint8_t
74
{
75
//! Intermediate parts (more parts of response to follow).
76
not_final_parts
,
77
//! Final parts (response ands with these parts).
78
final_parts
79
};
80
81
inline
std::ostream &
82
operator << ( std::ostream & o,
response_parts_attr_t
attr )
83
{
84
if
(
response_parts_attr_t
::
not_final_parts
== attr )
85
o <<
"not_final_parts"
;
86
else
87
o <<
"final_parts"
;
88
89
return
o;
90
}
91
92
//! Attribute for parts.
93
enum
class
response_connection_attr_t
:
std
::
uint8_t
94
{
95
//! This response says to keep connection.
96
connection_keepalive
,
97
//! This response says to close connection.
98
connection_close
99
};
100
101
inline
std::ostream &
102
operator << ( std::ostream & o,
response_connection_attr_t
attr )
103
{
104
if
(
response_connection_attr_t
::
connection_keepalive
== attr )
105
o <<
"connection_keepalive"
;
106
else
107
o <<
"connection_close"
;
108
109
return
o;
110
}
111
112
inline
response_connection_attr_t
113
response_connection_attr
(
bool
should_keep_alive )
114
{
115
if
( should_keep_alive )
116
return
response_connection_attr_t
::
connection_keepalive
;
117
118
return
response_connection_attr_t
::
connection_close
;
119
}
120
121
//! Response output flags for buffers commited to response-coordinator
122
struct
response_output_flags_t
123
{
124
response_output_flags_t
(
125
response_parts_attr_t
response_parts,
126
response_connection_attr_t
response_connection )
noexcept
127
:
m_response_parts
{ response_parts }
128
,
m_response_connection
{ response_connection }
129
{}
130
131
response_parts_attr_t
m_response_parts
;
132
response_connection_attr_t
m_response_connection
;
133
};
134
135
inline
std::ostream &
136
operator << ( std::ostream & o,
const
response_output_flags_t
& flags )
137
{
138
return
o <<
"{ "
<< flags
.
m_response_parts
<<
", "
139
<< flags
.
m_response_connection
<<
" }"
;
140
}
141
142
//
143
// nullable_pointer_t
144
//
145
/*!
146
* @brief Type for pointer that can be nullptr.
147
*
148
* This type is used in methods which return raw pointers. It indicates
149
* that returned value should be checked for nullptr.
150
*
151
* @since v.0.4.9
152
*/
153
template
<
typename
T >
154
using
nullable_pointer_t
= T*;
155
156
//
157
// not_null_pointer_t
158
//
159
/*!
160
* @brief Type for pointer that is not null by design.
161
*
162
* @note
163
* There is no any compile-time or run-time checks for a value of the pointer.
164
* It is just a flag that we don't expect a nullptr here by design.
165
*
166
* @since v.0.4.9
167
*/
168
template
<
typename
T >
169
using
not_null_pointer_t
= T*;
170
171
/*!
172
* @brief Type for ID of connection.
173
*/
174
using
connection_id_t
= std::
uint64_t
;
175
176
//! An alias for endpoint type from Asio.
177
using
endpoint_t
= asio_ns::ip::tcp::endpoint;
178
179
}
/* namespace restinio */
restinio
Definition
sendfile_operation_default.ipp:12
restinio::endpoint_t
asio_ns::ip::tcp::endpoint endpoint_t
An alias for endpoint type from Asio.
Definition
common_types.hpp:177
restinio::request_id_t
unsigned int request_id_t
Request id in scope of single connection.
Definition
common_types.hpp:70
restinio::not_null_pointer_t
T * not_null_pointer_t
Type for pointer that is not null by design.
Definition
common_types.hpp:169
restinio::request_not_handled
constexpr request_handling_status_t request_not_handled() noexcept
Definition
common_types.hpp:63
restinio::response_connection_attr
response_connection_attr_t response_connection_attr(bool should_keep_alive)
Definition
common_types.hpp:113
restinio::nullable_pointer_t
T * nullable_pointer_t
Type for pointer that can be nullptr.
Definition
common_types.hpp:154
restinio::request_accepted
constexpr request_handling_status_t request_accepted() noexcept
Definition
common_types.hpp:46
restinio::request_handling_status_t
request_handling_status_t
Request handling status.
Definition
common_types.hpp:26
restinio::request_handling_status_t::accepted
@ accepted
Request accepted for handling.
Definition
common_types.hpp:28
restinio::request_handling_status_t::not_handled
@ not_handled
The request wasn't handled. If there is another handler to be tried it should be tried....
Definition
common_types.hpp:38
restinio::request_handling_status_t::rejected
@ rejected
Request wasn't accepted for handling.
Definition
common_types.hpp:31
restinio::request_rejected
constexpr request_handling_status_t request_rejected() noexcept
Definition
common_types.hpp:53
restinio::connection_id_t
std::uint64_t connection_id_t
Type for ID of connection.
Definition
common_types.hpp:174
restinio::response_connection_attr_t
response_connection_attr_t
Attribute for parts.
Definition
common_types.hpp:94
restinio::response_connection_attr_t::connection_close
@ connection_close
This response says to close connection.
Definition
common_types.hpp:98
restinio::response_connection_attr_t::connection_keepalive
@ connection_keepalive
This response says to keep connection.
Definition
common_types.hpp:96
restinio::response_parts_attr_t
response_parts_attr_t
Attribute for parts.
Definition
common_types.hpp:74
restinio::response_parts_attr_t::final_parts
@ final_parts
Final parts (response ands with these parts).
Definition
common_types.hpp:78
restinio::response_parts_attr_t::not_final_parts
@ not_final_parts
Intermediate parts (more parts of response to follow).
Definition
common_types.hpp:76
restinio::response_output_flags_t
Response output flags for buffers commited to response-coordinator.
Definition
common_types.hpp:123
restinio::response_output_flags_t::m_response_connection
response_connection_attr_t m_response_connection
Definition
common_types.hpp:132
restinio::response_output_flags_t::m_response_parts
response_parts_attr_t m_response_parts
Definition
common_types.hpp:131
restinio::response_output_flags_t::response_output_flags_t
response_output_flags_t(response_parts_attr_t response_parts, response_connection_attr_t response_connection) noexcept
Definition
common_types.hpp:124
Generated by
1.17.0