mirror of
https://github.com/matrix-construct/construct
synced 2024-09-27 11:18:51 +02:00
ircd::buffer: Add remains() to window_buffer interface.
This commit is contained in:
parent
e9a6f2ec92
commit
ca7d401144
1 changed files with 23 additions and 1 deletions
|
@ -32,10 +32,13 @@ struct ircd::buffer::window_buffer
|
|||
size_t remaining() const;
|
||||
size_t consumed() const;
|
||||
|
||||
const_buffer remains() const;
|
||||
const_buffer completed() const;
|
||||
explicit operator const_buffer() const;
|
||||
mutable_buffer remains();
|
||||
mutable_buffer completed();
|
||||
|
||||
explicit operator const_buffer() const;
|
||||
|
||||
const_buffer operator()(const closure &);
|
||||
const_buffer operator()(const closure_cbuf &);
|
||||
const_buffer rewind(const size_t &n = 1);
|
||||
|
@ -112,6 +115,15 @@ ircd::buffer::window_buffer::completed()
|
|||
return { base.begin(), base.begin() + consumed() };
|
||||
}
|
||||
|
||||
/// View the remaining portion of the stream
|
||||
inline ircd::buffer::mutable_buffer
|
||||
ircd::buffer::window_buffer::remains()
|
||||
{
|
||||
assert(base.begin() <= begin());
|
||||
assert(base.begin() + consumed() <= base.end());
|
||||
return { base.begin() + consumed(), base.end() };
|
||||
}
|
||||
|
||||
/// Convenience conversion to get the completed portion
|
||||
inline ircd::buffer::window_buffer::operator
|
||||
const_buffer()
|
||||
|
@ -130,6 +142,16 @@ const
|
|||
return { base.begin(), base.begin() + consumed() };
|
||||
}
|
||||
|
||||
/// View the remaining portion of the stream
|
||||
inline ircd::buffer::const_buffer
|
||||
ircd::buffer::window_buffer::remains()
|
||||
const
|
||||
{
|
||||
assert(base.begin() <= begin());
|
||||
assert(base.begin() + consumed() <= base.end());
|
||||
return { base.begin() + consumed(), base.end() };
|
||||
}
|
||||
|
||||
/// Bytes used by writes to the stream buffer
|
||||
inline size_t
|
||||
ircd::buffer::window_buffer::consumed()
|
||||
|
|
Loading…
Reference in a new issue