RESTinio
common_types.hpp
Go to the documentation of this file.
1 /*
2  restinio
3 */
4 
9 #pragma once
10 
11 #include <cstdint>
12 
14 
15 namespace restinio
16 {
17 
19 
25 enum class request_handling_status_t : std::uint8_t
26 {
28  accepted,
29 
31  rejected
32 };
33 
38 request_accepted() noexcept
39 {
41 }
42 
44 request_rejected() noexcept
45 {
47 }
49 
51 using request_id_t = unsigned int;
52 
54 enum class response_parts_attr_t : std::uint8_t
55 {
57  not_final_parts,
60 };
61 
62 inline std::ostream &
63 operator << ( std::ostream & o, response_parts_attr_t attr )
64 {
65  if( response_parts_attr_t::not_final_parts == attr )
66  o << "not_final_parts";
67  else
68  o << "final_parts";
69 
70  return o;
71 }
72 
74 enum class response_connection_attr_t : std::uint8_t
75 {
77  connection_keepalive,
80 };
81 
82 inline std::ostream &
83 operator << ( std::ostream & o, response_connection_attr_t attr )
84 {
85  if( response_connection_attr_t::connection_keepalive == attr )
86  o << "connection_keepalive";
87  else
88  o << "connection_close";
89 
90  return o;
91 }
92 
94 response_connection_attr( bool should_keep_alive )
95 {
96  if( should_keep_alive )
97  return response_connection_attr_t::connection_keepalive;
98 
100 }
101 
104 {
106  response_parts_attr_t response_parts,
107  response_connection_attr_t response_connection ) noexcept
108  : m_response_parts{ response_parts }
109  , m_response_connection{ response_connection }
110  {}
111 
114 };
115 
116 inline std::ostream &
117 operator << ( std::ostream & o, const response_output_flags_t & flags )
118 {
119  return o << "{ " << flags.m_response_parts << ", "
120  << flags.m_response_connection << " }";
121 }
122 
123 //
124 // nullable_pointer_t
125 //
134 template< typename T >
136 
137 //
138 // not_null_pointer_t
139 //
149 template< typename T >
151 
155 using connection_id_t = std::uint64_t;
156 
158 using endpoint_t = asio_ns::ip::tcp::endpoint;
159 
160 } /* namespace restinio */
161 
restinio::response_parts_attr_t::not_final_parts
@ not_final_parts
Intermediate parts (more parts of response to follow).
restinio::operator<<
std::ostream & operator<<(std::ostream &o, response_parts_attr_t attr)
Definition: common_types.hpp:63
restinio::response_parts_attr_t
response_parts_attr_t
Attribute for parts.
Definition: common_types.hpp:55
restinio::endpoint_t
asio_ns::ip::tcp::endpoint endpoint_t
An alias for endpoint type from Asio.
Definition: common_types.hpp:158
asio_include.hpp
restinio::response_connection_attr_t::connection_close
@ connection_close
This response says to close connection.
restinio::connection_id_t
std::uint64_t connection_id_t
Type for ID of connection.
Definition: common_types.hpp:155
restinio::response_connection_attr
response_connection_attr_t response_connection_attr(bool should_keep_alive)
Definition: common_types.hpp:94
restinio::request_handling_status_t
request_handling_status_t
Request handling status.
Definition: common_types.hpp:26
restinio::response_output_flags_t::m_response_connection
response_connection_attr_t m_response_connection
Definition: common_types.hpp:113
restinio::not_null_pointer_t
T * not_null_pointer_t
Type for pointer that is not null by design.
Definition: common_types.hpp:150
restinio::response_connection_attr_t
response_connection_attr_t
Attribute for parts.
Definition: common_types.hpp:75
restinio::request_handling_status_t::accepted
@ accepted
Request accepted for handling.
restinio::nullable_pointer_t
T * nullable_pointer_t
Type for pointer that can be nullptr.
Definition: common_types.hpp:135
restinio
Definition: asio_include.hpp:21
restinio::response_output_flags_t
Response output flags for buffers commited to response-coordinator.
Definition: common_types.hpp:104
restinio::request_accepted
constexpr request_handling_status_t request_accepted() noexcept
Definition: common_types.hpp:38
restinio::request_id_t
unsigned int request_id_t
Request id in scope of single connection.
Definition: common_types.hpp:51
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:105
restinio::response_output_flags_t::m_response_parts
response_parts_attr_t m_response_parts
Definition: common_types.hpp:112
restinio::request_rejected
constexpr request_handling_status_t request_rejected() noexcept
Definition: common_types.hpp:44
restinio::status_code::accepted
constexpr http_status_code_t accepted
Definition: http_headers.hpp:2045