mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 12:57:31 +02:00
Meet DynamicBuffer requirements for static_streambuf
This commit is contained in:
@ -7,6 +7,10 @@ HTTP
|
|||||||
* Check invariants in parse_op:
|
* Check invariants in parse_op:
|
||||||
* Clean up message docs
|
* Clean up message docs
|
||||||
|
|
||||||
|
Core
|
||||||
|
|
||||||
|
* Meet DynamicBuffer requirements for static_streambuf
|
||||||
|
|
||||||
Extras
|
Extras
|
||||||
|
|
||||||
* unit_test::suite fixes:
|
* unit_test::suite fixes:
|
||||||
|
@ -279,6 +279,16 @@ static_streambuf::mutable_buffers_type::end() const ->
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
inline
|
||||||
|
auto
|
||||||
|
static_streambuf::data() const ->
|
||||||
|
const_buffers_type
|
||||||
|
{
|
||||||
|
return const_buffers_type{in_,
|
||||||
|
static_cast<std::size_t>(out_ - in_)};
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
auto
|
auto
|
||||||
static_streambuf::prepare(std::size_t n) ->
|
static_streambuf::prepare(std::size_t n) ->
|
||||||
@ -290,15 +300,6 @@ static_streambuf::prepare(std::size_t n) ->
|
|||||||
return mutable_buffers_type{out_, n};
|
return mutable_buffers_type{out_, n};
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
|
||||||
auto
|
|
||||||
static_streambuf::data() const ->
|
|
||||||
const_buffers_type
|
|
||||||
{
|
|
||||||
return const_buffers_type{in_,
|
|
||||||
static_cast<std::size_t>(out_ - in_)};
|
|
||||||
}
|
|
||||||
|
|
||||||
} // beast
|
} // beast
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -32,6 +32,7 @@ private:
|
|||||||
#else
|
#else
|
||||||
protected:
|
protected:
|
||||||
#endif
|
#endif
|
||||||
|
std::uint8_t* begin_;
|
||||||
std::uint8_t* in_;
|
std::uint8_t* in_;
|
||||||
std::uint8_t* out_;
|
std::uint8_t* out_;
|
||||||
std::uint8_t* last_;
|
std::uint8_t* last_;
|
||||||
@ -57,21 +58,35 @@ public:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Returns the largest size output sequence possible.
|
/// Return the size of the input sequence.
|
||||||
std::size_t
|
|
||||||
max_size() const
|
|
||||||
{
|
|
||||||
return end_ - in_;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the size of the input sequence.
|
|
||||||
std::size_t
|
std::size_t
|
||||||
size() const
|
size() const
|
||||||
{
|
{
|
||||||
return out_ - in_;
|
return out_ - in_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get a list of buffers that represents the output sequence, with the given size.
|
/// Return the maximum sum of the input and output sequence sizes.
|
||||||
|
std::size_t
|
||||||
|
max_size() const
|
||||||
|
{
|
||||||
|
return end_ - begin_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return the maximum sum of input and output sizes that can be held without an allocation.
|
||||||
|
std::size_t
|
||||||
|
capacity() const
|
||||||
|
{
|
||||||
|
return end_ - in_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get a list of buffers that represent the input sequence.
|
||||||
|
|
||||||
|
@note These buffers remain valid across subsequent calls to `prepare`.
|
||||||
|
*/
|
||||||
|
const_buffers_type
|
||||||
|
data() const;
|
||||||
|
|
||||||
|
/** Get a list of buffers that represent the output sequence, with the given size.
|
||||||
|
|
||||||
@throws std::length_error if the size would exceed the limit
|
@throws std::length_error if the size would exceed the limit
|
||||||
imposed by the underlying mutable buffer sequence.
|
imposed by the underlying mutable buffer sequence.
|
||||||
@ -93,13 +108,6 @@ public:
|
|||||||
out_ += std::min<std::size_t>(n, last_ - out_);
|
out_ += std::min<std::size_t>(n, last_ - out_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get a list of buffers that represents the input sequence.
|
|
||||||
|
|
||||||
@note These buffers remain valid across subsequent calls to `prepare`.
|
|
||||||
*/
|
|
||||||
const_buffers_type
|
|
||||||
data() const;
|
|
||||||
|
|
||||||
/// Remove bytes from the input sequence.
|
/// Remove bytes from the input sequence.
|
||||||
void
|
void
|
||||||
consume(std::size_t n)
|
consume(std::size_t n)
|
||||||
@ -120,6 +128,7 @@ protected:
|
|||||||
void
|
void
|
||||||
reset(std::uint8_t* p, std::size_t n)
|
reset(std::uint8_t* p, std::size_t n)
|
||||||
{
|
{
|
||||||
|
begin_ = p;
|
||||||
in_ = p;
|
in_ = p;
|
||||||
out_ = p;
|
out_ = p;
|
||||||
last_ = p;
|
last_ = p;
|
||||||
|
Reference in New Issue
Block a user