1 #ifndef SPONGE_LIBSPONGE_BUFFER_HH
2 #define SPONGE_LIBSPONGE_BUFFER_HH
10 #include <string_view>
28 std::string_view
str()
const {
35 operator std::string_view()
const {
return str(); }
39 uint8_t
at(
const size_t n)
const {
return str().at(n); }
42 size_t size()
const {
return str().size(); }
A reference-counted read-only string that can discard bytes from the front.
size_t size() const
Size of the string.
std::shared_ptr< std::string > _storage
Buffer(std::string &&str) noexcept
Construct by taking ownership of a string.
uint8_t at(const size_t n) const
Get character at location n
std::string copy() const
Make a copy to a new std::string.
std::string_view str() const
void remove_prefix(const 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.
const std::deque< Buffer > & buffers() const
Access the underlying queue of Buffers.
void append(const BufferList &other)
Append a BufferList.
std::deque< Buffer > _buffers
BufferList(std::string &&str) noexcept
Construct by taking ownership of a std::string.
std::string concatenate() const
Make a copy to a new std::string.
BufferList(Buffer buffer)
Construct from a Buffer.
void remove_prefix(size_t n)
Discard the first n bytes of the string (does not require a copy or move)
size_t size() const
Size of the string.
A non-owning temporary view (similar to std::string_view) of a discontiguous string.
std::deque< std::string_view > _views
BufferViewList(const char *s)
Construct from a C string (must be NULL-terminated)
BufferViewList(std::string_view str)
Construct from a std::string_view.
BufferViewList(const std::string &str)
Construct from a std::string.
size_t size() const
Size of the string.
void remove_prefix(size_t n)
Discard the first n bytes of the string (does not require a copy or move)
std::vector< iovec > as_iovecs() const
Convert to a vector of iovec structures.