mirror of
https://github.com/matrix-construct/construct
synced 2025-01-13 08:23:56 +01:00
ircd::json::stack: Add raw rewind method to interface.
This commit is contained in:
parent
7d96e90347
commit
d2380ecd36
2 changed files with 13 additions and 1 deletions
|
@ -71,6 +71,7 @@ struct ircd::json::stack
|
|||
const_buffer completed() const;
|
||||
|
||||
bool flush(const bool &force = false) noexcept;
|
||||
size_t rewind(const size_t &bytes);
|
||||
void clear();
|
||||
|
||||
stack(const mutable_buffer &,
|
||||
|
|
13
ircd/json.cc
13
ircd/json.cc
|
@ -546,10 +546,21 @@ catch(...)
|
|||
void
|
||||
ircd::json::stack::clear()
|
||||
{
|
||||
buf.rewind(buf.consumed());
|
||||
rewind(buf.consumed());
|
||||
this->eptr = std::exception_ptr{};
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::json::stack::rewind(const size_t &bytes)
|
||||
{
|
||||
const size_t before(buf.consumed());
|
||||
const size_t &amount(std::min(bytes, before));
|
||||
const size_t after(size(buf.rewind(amount)));
|
||||
assert(before >= after);
|
||||
assert(before - after == amount);
|
||||
return amount;
|
||||
}
|
||||
|
||||
ircd::const_buffer
|
||||
ircd::json::stack::completed()
|
||||
const
|
||||
|
|
Loading…
Reference in a new issue