serializer::next replaces serializer::get (API Change):

Actions Required:

* Use serializer::next instead of serializer::get at call sites
This commit is contained in:
Vinnie Falco
2017-07-04 01:17:56 -07:00
parent b0e52dd246
commit f5ae60613f
7 changed files with 23 additions and 20 deletions

View File

@@ -8,12 +8,15 @@ HTTP:
API Changes:
* Refactor header and message constructors
* serializer::next replaces serializer::get
Actions Required:
* Evaluate each message constructor call site and
adjust the constructor argument list as needed.
* Use serializer::next instead of serializer::get at call sites
--------------------------------------------------------------------------------
Version 72:

View File

@@ -18,12 +18,12 @@ to produce buffers until all of the buffers have been generated. Then the
serializer is destroyed.
To obtain the serialized next buffer sequence, call
[link beast.ref.beast__http__serializer.get `serializer::get`].
[link beast.ref.beast__http__serializer.next `serializer::next`].
Then, call
[link beast.ref.beast__http__serializer.consume `serializer::consume`]
to indicate the number of bytes consumed. This updates the next
set of buffers to be returned, if any.
`serializer::get` takes an error code parameter and invokes a visitor
`serializer::next` takes an error code parameter and invokes a visitor
argument with the error code and buffer of unspecified type. In C++14
this is easily expressed with a generic lambda. The function
[link beast.ref.beast__http__serializer.is_done `serializer::is_done`]

View File

@@ -649,7 +649,7 @@ write_ostream(
// In C++14 we could use a generic lambda but since we want
// to require only C++11, the lambda is written out by hand.
// This function call retrieves the next serialized buffers.
sr.get(ec, lambda);
sr.next(ec, lambda);
if(ec)
return;
}

View File

@@ -50,7 +50,7 @@ template<bool isRequest, class Body,
template<class Visit>
void
serializer<isRequest, Body, Fields, ChunkDecorator>::
get(error_code& ec, Visit&& visit)
next(error_code& ec, Visit&& visit)
{
using boost::asio::buffer_size;
switch(s_)

View File

@@ -131,7 +131,7 @@ operator()()
return s_.get_io_service().post(
bind_handler(std::move(*this), ec, 0));
lambda f{*this};
sr_.get(ec, f);
sr_.next(ec, f);
if(ec)
{
BOOST_ASSERT(! f.invoked);
@@ -298,7 +298,7 @@ operator()(error_code ec,
}
lambda f{*this};
state_ = 2;
sr_.get(ec, f);
sr_.next(ec, f);
if(ec)
{
BOOST_ASSERT(! f.invoked);
@@ -328,7 +328,7 @@ operator()(error_code ec,
if(Predicate{}(sr_))
goto upcall;
lambda f{*this};
sr_.get(ec, f);
sr_.next(ec, f);
if(ec)
{
BOOST_ASSERT(! f.invoked);
@@ -540,7 +540,7 @@ write_some(SyncWriteStream& stream, serializer<
ec.assign(0, ec.category());
return;
}
sr.get(ec, f);
sr.next(ec, f);
if(ec)
return;
if(f.invoked)
@@ -615,7 +615,7 @@ write_header(SyncWriteStream& stream, serializer<
detail::write_lambda<SyncWriteStream> f{stream};
do
{
sr.get(ec, f);
sr.next(ec, f);
if(ec)
return;
BOOST_ASSERT(f.invoked);
@@ -686,7 +686,7 @@ write(SyncWriteStream& stream, serializer<
detail::write_lambda<SyncWriteStream> f{stream};
do
{
sr.get(ec, f);
sr.next(ec, f);
if(ec)
return;
if(f.invoked)
@@ -864,7 +864,7 @@ operator<<(std::ostream& os,
detail::write_ostream_lambda<decltype(sr)> f{os, sr};
do
{
sr.get(ec, f);
sr.next(ec, f);
if(os.fail())
break;
if(ec == error::end_of_stream)

View File

@@ -236,7 +236,7 @@ public:
The implementation guarantees that the message passed on
construction will not be accessed until the first call to
@ref get. This allows the message to be lazily created.
@ref next. This allows the message to be lazily created.
For example, if the header is filled in before serialization.
@param msg The message to serialize, which must remain valid
@@ -327,18 +327,18 @@ public:
void visit(error_code&, ConstBufferSequence const&);
@endcode
The function is not copied, if no error occurs it will be
invoked before the call to @ref get returns.
invoked before the call to @ref next returns.
*/
template<class Visit>
void
get(error_code& ec, Visit&& visit);
next(error_code& ec, Visit&& visit);
/** Consume buffer octets in the serialization.
This function should be called after one or more octets
contained in the buffers provided in the prior call
to @ref get have been used.
to @ref next have been used.
After a call to @ref consume, callers should check the
return value of @ref is_done to determine if the entire
@@ -346,7 +346,7 @@ public:
@param n The number of octets to consume. This number must
be greater than zero and no greater than the number of
octets in the buffers provided in the prior call to @ref get.
octets in the buffers provided in the prior call to @ref next.
*/
void
consume(std::size_t n);

View File

@@ -202,7 +202,7 @@ print_cxx14(message<isRequest, Body, Fields> const& m)
serializer<isRequest, Body, Fields> sr{m};
do
{
sr.get(ec,
sr.next(ec,
[&sr](error_code& ec, auto const& buffer)
{
ec.assign(0, ec.category());
@@ -246,7 +246,7 @@ print(message<isRequest, Body, Fields> const& m)
serializer<isRequest, Body, Fields> sr{m};
do
{
sr.get(ec, lambda<decltype(sr)>{sr});
sr.next(ec, lambda<decltype(sr)>{sr});
}
while(! ec && ! sr.is_done());
if(! ec)
@@ -270,7 +270,7 @@ split_print_cxx14(message<isRequest, Body, Fields> const& m)
std::cout << "Header:" << std::endl;
do
{
sr.get(ec,
sr.next(ec,
[&sr](error_code& ec, auto const& buffer)
{
ec.assign(0, ec.category());
@@ -284,7 +284,7 @@ split_print_cxx14(message<isRequest, Body, Fields> const& m)
std::cout << "Body:" << std::endl;
do
{
sr.get(ec,
sr.next(ec,
[&sr](error_code& ec, auto const& buffer)
{
ec.assign(0, ec.category());