Skip to content

Commit a10bdb1

Browse files
committed
Add static fields and message containers
1 parent 3798695 commit a10bdb1

32 files changed

Lines changed: 2594 additions & 666 deletions

include/boost/http_proto.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
#include <boost/http_proto/serializer.hpp>
3939
#include <boost/http_proto/sink.hpp>
4040
#include <boost/http_proto/source.hpp>
41+
#include <boost/http_proto/static_fields.hpp>
42+
#include <boost/http_proto/static_request.hpp>
43+
#include <boost/http_proto/static_response.hpp>
4144
#include <boost/http_proto/status.hpp>
4245
#include <boost/http_proto/string_body.hpp>
4346
#include <boost/http_proto/version.hpp>

include/boost/http_proto/detail/header.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ struct empty
4646

4747
struct header
4848
{
49-
// this field lookup table is
50-
// stored at the end of the
51-
// allocated buffer, in
52-
// reverse order.
49+
// +------------+-----------+--------------+------------------------------+
50+
// | start-line | headers | free space | entry[count-1] ... entry[0] |
51+
// +------------+-----------+--------------+------------------------------+
52+
// ^ ^ ^ ^
53+
// buf buf+prefix buf+size buf+cap
54+
5355
struct entry
5456
{
5557
offset_type np; // name pos

include/boost/http_proto/detail/impl/workspace.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct workspace::any
3030
};
3131

3232
template<class U>
33-
struct alignas(alignof(::max_align_t))
33+
struct alignas(::max_align_t)
3434
workspace::any_impl : any
3535
{
3636
U u;
@@ -117,7 +117,7 @@ push_array(
117117
std::size_t n,
118118
T const& t)
119119
{
120-
struct alignas(alignof(::max_align_t))
120+
struct alignas(::max_align_t)
121121
U : any
122122
{
123123
std::size_t n_ = 0;

include/boost/http_proto/detail/sv.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace detail {
2121
namespace string_literals {
2222
inline
2323
core::string_view
24-
operator"" _sv(
24+
operator""_sv(
2525
char const* p,
2626
std::size_t n) noexcept
2727
{

include/boost/http_proto/fields_base.hpp

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,43 +37,90 @@ class fields_base
3737
: public virtual fields_view_base
3838
{
3939
detail::header h_;
40+
bool static_storage = false;
4041

4142
class op_t;
43+
class prefix_op_t
44+
{
45+
fields_base& self_;
46+
offset_type new_prefix_;
47+
char* buf_ = nullptr;
48+
49+
public:
50+
prefix_op_t(
51+
fields_base& self,
52+
std::size_t new_prefix,
53+
core::string_view* s0 = nullptr,
54+
core::string_view* s1 = nullptr);
55+
56+
~prefix_op_t();
57+
};
58+
4259
using entry =
4360
detail::header::entry;
4461
using table =
4562
detail::header::table;
4663

4764
friend class fields;
65+
template<std::size_t>
66+
friend class static_fields;
67+
friend class request_base;
4868
friend class request;
69+
template<std::size_t>
70+
friend class static_request;
71+
friend class response_base;
4972
friend class response;
73+
template<std::size_t>
74+
friend class static_response;
5075
friend class serializer;
5176
friend class message_base;
5277
friend struct detail::header;
5378
friend struct detail::prefix_op;
5479

80+
BOOST_HTTP_PROTO_DECL
81+
explicit
82+
fields_base(
83+
detail::kind) noexcept;
84+
5585
BOOST_HTTP_PROTO_DECL
5686
fields_base(
5787
detail::kind,
58-
std::size_t size);
88+
char*,
89+
std::size_t) noexcept;
5990

6091
BOOST_HTTP_PROTO_DECL
6192
fields_base(
6293
detail::kind,
63-
std::size_t size,
64-
std::size_t max_size);
94+
std::size_t);
6595

6696
BOOST_HTTP_PROTO_DECL
67-
explicit
6897
fields_base(
69-
detail::kind) noexcept;
98+
detail::kind,
99+
std::size_t,
100+
std::size_t);
70101

71102
BOOST_HTTP_PROTO_DECL
72103
fields_base(
73104
detail::kind,
74105
core::string_view);
75106

76-
fields_base(detail::header const&);
107+
BOOST_HTTP_PROTO_DECL
108+
fields_base(
109+
detail::kind,
110+
char*,
111+
std::size_t,
112+
core::string_view);
113+
114+
BOOST_HTTP_PROTO_DECL
115+
explicit
116+
fields_base(
117+
detail::header const&);
118+
119+
BOOST_HTTP_PROTO_DECL
120+
fields_base(
121+
detail::header const&,
122+
char*,
123+
std::size_t);
77124

78125
public:
79126
/** Destructor

include/boost/http_proto/fields_view.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class BOOST_SYMBOL_VISIBLE
2424
: public fields_view_base
2525
{
2626
friend class fields;
27+
template<std::size_t>
28+
friend class static_fields;
2729

2830
#ifndef BOOST_HTTP_PROTO_DOCS
2931
protected:

include/boost/http_proto/fields_view_base.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,21 @@ class fields_view_base
3232
detail::header const* ph_;
3333

3434
friend class fields;
35+
template<std::size_t>
36+
friend class static_fields;
3537
friend class fields_base;
3638
friend class fields_view;
3739
friend class message_base;
3840
friend class message_view_base;
41+
friend class request_base;
3942
friend class request;
43+
template<std::size_t>
44+
friend class static_request;
4045
friend class request_view;
46+
friend class response_base;
4147
friend class response;
48+
template<std::size_t>
49+
friend class static_response;
4250
friend class response_view;
4351
friend class serializer;
4452

include/boost/http_proto/message_base.hpp

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class message_base
2525
: public fields_base
2626
, public message_view_base
2727
{
28-
friend class request;
29-
friend class response;
28+
friend class request_base;
29+
friend class response_base;
3030

3131
explicit
3232
message_base(
@@ -37,6 +37,16 @@ class message_base
3737
{
3838
}
3939

40+
message_base(
41+
detail::kind k,
42+
char* storage,
43+
std::size_t storage_size) noexcept
44+
: fields_view_base(&this->fields_base::h_)
45+
, fields_base(
46+
k, storage, storage_size)
47+
{
48+
}
49+
4050
message_base(
4151
detail::kind k,
4252
std::size_t storage_size)
@@ -67,15 +77,37 @@ class message_base
6777
{
6878
}
6979

80+
message_base(
81+
detail::kind k,
82+
char* storage,
83+
std::size_t storage_size,
84+
core::string_view s)
85+
: fields_view_base(
86+
&this->fields_base::h_)
87+
, fields_base(
88+
k, storage, storage_size, s)
89+
{
90+
}
91+
7092
explicit
7193
message_base(
72-
detail::header const& ph) noexcept
94+
detail::header const& ph)
7395
: fields_view_base(
7496
&this->fields_base::h_)
7597
, fields_base(ph)
7698
{
7799
}
78100

101+
message_base(
102+
detail::header const& ph,
103+
char* storage,
104+
std::size_t storage_size)
105+
: fields_view_base(
106+
&this->fields_base::h_)
107+
, fields_base(ph, storage, storage_size)
108+
{
109+
}
110+
79111
public:
80112
//--------------------------------------------
81113
//

0 commit comments

Comments
 (0)