roar
Loading...
Searching...
No Matches
void_body.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <boost/beast/http/message.hpp>
4
5#include <cstdint>
6
7namespace Roar
8{
13 {
14 public:
15 struct Void
16 {};
18 using const_buffers_type = boost::asio::const_buffer;
19
20 class reader
21 {
22 public:
23 template <bool isRequest, class Fields>
24 reader(boost::beast::http::header<isRequest, Fields>&, value_type&);
25 void init(boost::optional<std::uint64_t> const&, boost::beast::error_code& ec);
26 template <class ConstBufferSequence>
27 std::size_t put(ConstBufferSequence const& buffers, boost::beast::error_code& ec);
28 void finish(boost::beast::error_code& ec);
29 };
30 class writer
31 {
32 public:
33 template <bool isRequest, class Fields>
34 writer(boost::beast::http::header<isRequest, Fields>&, value_type&);
35 void init(boost::beast::error_code& ec);
36 boost::optional<std::pair<const_buffers_type, bool>> get(boost::beast::error_code& ec);
37 };
38
39 static std::uint64_t size(value_type const&)
40 {
41 return 0;
42 }
43 };
44
45 template <bool isRequest, class Fields>
46 inline VoidBody::reader::reader(boost::beast::http::header<isRequest, Fields>&, value_type&)
47 {}
48 inline void VoidBody::reader::init(boost::optional<std::uint64_t> const&, boost::beast::error_code& ec)
49 {
50 ec = {};
51 }
52 template <class ConstBufferSequence>
53 inline std::size_t VoidBody::reader::put(ConstBufferSequence const& buffers, boost::beast::error_code& ec)
54 {
55 ec = {};
56 std::size_t writtenAmount = 0;
57 for (auto it = boost::asio::buffer_sequence_begin(buffers); it != boost::asio::buffer_sequence_end(buffers);
58 ++it)
59 {
60 writtenAmount += it->size();
61 }
62 return writtenAmount;
63 }
64 inline void VoidBody::reader::finish(boost::beast::error_code& ec)
65 {
66 ec = {};
67 }
68
69 template <bool isRequest, class Fields>
70 inline VoidBody::writer::writer(boost::beast::http::header<isRequest, Fields>&, value_type&)
71 {}
72 inline void VoidBody::writer::init(boost::beast::error_code& ec)
73 {
74 ec = {};
75 }
76 inline boost::optional<std::pair<VoidBody::const_buffers_type, bool>>
77 VoidBody::writer::get(boost::beast::error_code& ec)
78 {
79 ec = {};
80 return boost::none;
81 }
82}
Definition void_body.hpp:21
void init(boost::optional< std::uint64_t > const &, boost::beast::error_code &ec)
Definition void_body.hpp:48
void finish(boost::beast::error_code &ec)
Definition void_body.hpp:64
reader(boost::beast::http::header< isRequest, Fields > &, value_type &)
Definition void_body.hpp:46
std::size_t put(ConstBufferSequence const &buffers, boost::beast::error_code &ec)
Definition void_body.hpp:53
Definition void_body.hpp:31
writer(boost::beast::http::header< isRequest, Fields > &, value_type &)
Definition void_body.hpp:70
void init(boost::beast::error_code &ec)
Definition void_body.hpp:72
boost::optional< std::pair< const_buffers_type, bool > > get(boost::beast::error_code &ec)
Definition void_body.hpp:77
This body is for reading into nothing.
Definition void_body.hpp:13
boost::asio::const_buffer const_buffers_type
Definition void_body.hpp:18
static std::uint64_t size(value_type const &)
Definition void_body.hpp:39
Definition authorization.hpp:10
Definition void_body.hpp:16