mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 05:17:26 +02:00
@ -1,3 +1,9 @@
|
|||||||
|
Version 137:
|
||||||
|
|
||||||
|
* ConstBufferSequence mandates pointer equivalence
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
Version 136:
|
Version 136:
|
||||||
|
|
||||||
* Tidy up message doc image
|
* Tidy up message doc image
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
@ -67,19 +68,6 @@ struct is_chunk_extensions<T, beast::detail::void_t<decltype(
|
|||||||
*/
|
*/
|
||||||
class chunk_size
|
class chunk_size
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
// Storage for the longest hex string we might need
|
|
||||||
class value_type
|
|
||||||
{
|
|
||||||
friend class chunk_size;
|
|
||||||
|
|
||||||
// First byte holds the length
|
|
||||||
char buf_[1 + 2 * sizeof(std::size_t)];
|
|
||||||
|
|
||||||
template<class = void>
|
|
||||||
void
|
|
||||||
prepare(std::size_t n);
|
|
||||||
|
|
||||||
template<class OutIter>
|
template<class OutIter>
|
||||||
static
|
static
|
||||||
OutIter
|
OutIter
|
||||||
@ -97,16 +85,27 @@ public:
|
|||||||
}
|
}
|
||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
public:
|
|
||||||
operator
|
struct sequence
|
||||||
boost::asio::const_buffer() const
|
|
||||||
{
|
{
|
||||||
return {
|
boost::asio::const_buffer b;
|
||||||
buf_ + sizeof(buf_) - buf_[0],
|
char data[1 + 2 * sizeof(std::size_t)];
|
||||||
static_cast<unsigned>(buf_[0])};
|
|
||||||
|
explicit
|
||||||
|
sequence(std::size_t n)
|
||||||
|
{
|
||||||
|
char* it0 = data + sizeof(data);
|
||||||
|
auto it = to_hex(it0, n);
|
||||||
|
b = {it,
|
||||||
|
static_cast<std::size_t>(it0 - it)};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::shared_ptr<sequence> sp_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using value_type = boost::asio::const_buffer;
|
||||||
|
|
||||||
using const_iterator = value_type const*;
|
using const_iterator = value_type const*;
|
||||||
|
|
||||||
chunk_size(chunk_size const& other) = default;
|
chunk_size(chunk_size const& other) = default;
|
||||||
@ -116,14 +115,14 @@ public:
|
|||||||
@param n The number of octets in this chunk.
|
@param n The number of octets in this chunk.
|
||||||
*/
|
*/
|
||||||
chunk_size(std::size_t n)
|
chunk_size(std::size_t n)
|
||||||
|
: sp_(std::make_shared<sequence>(n))
|
||||||
{
|
{
|
||||||
value_.prepare(n);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
const_iterator
|
||||||
begin() const
|
begin() const
|
||||||
{
|
{
|
||||||
return &value_;
|
return &sp_->b;
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
const_iterator
|
||||||
@ -131,22 +130,8 @@ public:
|
|||||||
{
|
{
|
||||||
return begin() + 1;
|
return begin() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
value_type value_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class>
|
|
||||||
void
|
|
||||||
chunk_size::
|
|
||||||
value_type::
|
|
||||||
prepare(std::size_t n)
|
|
||||||
{
|
|
||||||
auto const last = &buf_[sizeof(buf_)];
|
|
||||||
auto it = to_hex(last, n);
|
|
||||||
buf_[0] = static_cast<char>(last - it);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
/// Returns a buffer sequence holding a CRLF for chunk encoding
|
/// Returns a buffer sequence holding a CRLF for chunk encoding
|
||||||
|
Reference in New Issue
Block a user