common_types.hpp
Go to the documentation of this file.
/*
restinio
*/
#pragma once
#include <cstdint>
#include <restinio/asio_include.hpp>
namespace restinio
{
enum class request_handling_status_t : std::uint8_t
{
accepted,
rejected,
not_handled
};
RESTINIO_NODISCARD
constexpr request_handling_status_t
request_accepted() noexcept
{
return request_handling_status_t::accepted;
}
RESTINIO_NODISCARD
constexpr request_handling_status_t
request_rejected() noexcept
{
return request_handling_status_t::rejected;
}
RESTINIO_NODISCARD
constexpr request_handling_status_t
request_not_handled() noexcept
{
return request_handling_status_t::not_handled;
}
using request_id_t = unsigned int;
enum class response_parts_attr_t : std::uint8_t
{
not_final_parts,
final_parts
};
inline std::ostream &
operator << ( std::ostream & o, response_parts_attr_t attr )
{
if( response_parts_attr_t::not_final_parts == attr )
o << "not_final_parts";
else
o << "final_parts";
return o;
}
enum class response_connection_attr_t : std::uint8_t
{
connection_keepalive,
connection_close
};
inline std::ostream &
operator << ( std::ostream & o, response_connection_attr_t attr )
{
if( response_connection_attr_t::connection_keepalive == attr )
o << "connection_keepalive";
else
o << "connection_close";
return o;
}
inline response_connection_attr_t
response_connection_attr( bool should_keep_alive )
{
if( should_keep_alive )
return response_connection_attr_t::connection_keepalive;
return response_connection_attr_t::connection_close;
}
struct response_output_flags_t
{
response_output_flags_t(
response_parts_attr_t response_parts,
response_connection_attr_t response_connection ) noexcept
: m_response_parts{ response_parts }
, m_response_connection{ response_connection }
{}
response_parts_attr_t m_response_parts;
response_connection_attr_t m_response_connection;
};
inline std::ostream &
operator << ( std::ostream & o, const response_output_flags_t & flags )
{
return o << "{ " << flags.m_response_parts << ", "
<< flags.m_response_connection << " }";
}
//
// nullable_pointer_t
//
template< typename T >
using nullable_pointer_t = T*;
//
// not_null_pointer_t
//
template< typename T >
using not_null_pointer_t = T*;
using connection_id_t = std::uint64_t;
using endpoint_t = asio_ns::ip::tcp::endpoint;
} /* namespace restinio */
asio_include.hpp
RESTINIO_NODISCARD
#define RESTINIO_NODISCARD
Definition: compiler_features.hpp:33
restinio
Definition: asio_include.hpp:21
restinio::request_not_handled
RESTINIO_NODISCARD constexpr request_handling_status_t request_not_handled() noexcept
Definition: common_types.hpp:63
restinio::nullable_pointer_t
T * nullable_pointer_t
Type for pointer that can be nullptr.
Definition: common_types.hpp:154
restinio::request_rejected
RESTINIO_NODISCARD constexpr request_handling_status_t request_rejected() noexcept
Definition: common_types.hpp:53
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::operator<<
std::ostream & operator<<(std::ostream &o, response_parts_attr_t attr)
Definition: common_types.hpp:82
restinio::request_id_t
unsigned int request_id_t
Request id in scope of single connection.
Definition: common_types.hpp:70
restinio::response_connection_attr
response_connection_attr_t response_connection_attr(bool should_keep_alive)
Definition: common_types.hpp:113
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.
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....
restinio::request_handling_status_t::rejected
@ rejected
Request wasn't accepted for handling.
restinio::endpoint_t
asio_ns::ip::tcp::endpoint endpoint_t
An alias for endpoint type from Asio.
Definition: common_types.hpp:177
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.
restinio::response_connection_attr_t::connection_keepalive
@ connection_keepalive
This response says to keep connection.
restinio::request_accepted
RESTINIO_NODISCARD constexpr request_handling_status_t request_accepted() noexcept
Definition: common_types.hpp:46
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).
restinio::response_parts_attr_t::not_final_parts
@ not_final_parts
Intermediate parts (more parts of response to follow).
restinio::connection_id_t
std::uint64_t connection_id_t
Type for ID of connection.
Definition: common_types.hpp:174
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