|
Sponge
CS144's user-space TCP library
|
Go to the documentation of this file.
6 if (n > str().size()) {
10 if (_storage and _starting_offset == _storage->size()) {
16 for (
const auto &buf : other.
_buffers) {
17 _buffers.push_back(buf);
21 BufferList::operator
Buffer()
const {
22 switch (_buffers.size()) {
29 "BufferList: please use concatenate() to combine a multi-Buffer BufferList into one Buffer");
37 for (
const auto &buf : _buffers) {
45 for (
const auto &buf : _buffers) {
53 if (_buffers.empty()) {
57 if (n < _buffers.front().str().size()) {
58 _buffers.front().remove_prefix(n);
61 n -= _buffers.front().str().size();
68 for (
const auto &x : buffers.
buffers()) {
79 if (n < _views.front().size()) {
80 _views.front().remove_prefix(n);
83 n -= _views.front().size();
91 for (
const auto &buf : _views) {
100 for (
const auto &x : _views) {
101 ret.
push_back({
const_cast<char *
>(x.data()), x.size()});
void append(const BufferList &other)
Append a BufferList.
void remove_prefix(size_t n)
Discard the first n bytes of the string (does not require a copy or move)
A reference-counted discontiguous string that can discard bytes from the front.
A reference-counted read-only string that can discard bytes from the front.
void remove_prefix(const size_t n)
Discard the first n bytes of the string (does not require a copy or move)
std::deque< Buffer > _buffers
size_t size() const
Size of the string.
std::vector< iovec > as_iovecs() const
Convert to a vector of iovec structures.
BufferViewList(const std::string &str)
Construct from a std::string.
size_t size() const
Size of the string.
const std::deque< Buffer > & buffers() const
Access the underlying queue of Buffers.
void remove_prefix(size_t n)
Discard the first n bytes of the string (does not require a copy or move)
std::string concatenate() const
Make a copy to a new std::string.