diff --git a/CHANGELOG.md b/CHANGELOG.md index 33c7df6c..84946dda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/doc/5_06_serializer_buffers.qbk b/doc/5_06_serializer_buffers.qbk index 79587881..8e2446e3 100644 --- a/doc/5_06_serializer_buffers.qbk +++ b/doc/5_06_serializer_buffers.qbk @@ -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`] diff --git a/example/doc/http_examples.hpp b/example/doc/http_examples.hpp index 3e3526b2..7371e15d 100644 --- a/example/doc/http_examples.hpp +++ b/example/doc/http_examples.hpp @@ -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; } diff --git a/include/beast/http/impl/serializer.ipp b/include/beast/http/impl/serializer.ipp index ad304b2a..2f492cd3 100644 --- a/include/beast/http/impl/serializer.ipp +++ b/include/beast/http/impl/serializer.ipp @@ -50,7 +50,7 @@ template void serializer:: -get(error_code& ec, Visit&& visit) +next(error_code& ec, Visit&& visit) { using boost::asio::buffer_size; switch(s_) diff --git a/include/beast/http/impl/write.ipp b/include/beast/http/impl/write.ipp index a723bd0e..08a63a2b 100644 --- a/include/beast/http/impl/write.ipp +++ b/include/beast/http/impl/write.ipp @@ -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 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 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 f{os, sr}; do { - sr.get(ec, f); + sr.next(ec, f); if(os.fail()) break; if(ec == error::end_of_stream) diff --git a/include/beast/http/serializer.hpp b/include/beast/http/serializer.hpp index 7a593269..7069d31e 100644 --- a/include/beast/http/serializer.hpp +++ b/include/beast/http/serializer.hpp @@ -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 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); diff --git a/test/http/doc_snippets.cpp b/test/http/doc_snippets.cpp index 78e07ca0..82dd0e05 100644 --- a/test/http/doc_snippets.cpp +++ b/test/http/doc_snippets.cpp @@ -202,7 +202,7 @@ print_cxx14(message const& m) serializer 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 const& m) serializer sr{m}; do { - sr.get(ec, lambda{sr}); + sr.next(ec, lambda{sr}); } while(! ec && ! sr.is_done()); if(! ec) @@ -270,7 +270,7 @@ split_print_cxx14(message 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 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());