Sponge
CS144's user-space TCP library
|
A reference-counted read-only string that can discard bytes from the front. More...
#include <buffer.hh>
Public Member Functions | |
Buffer ()=default | |
Buffer (std::string &&str) noexcept | |
Construct by taking ownership of a string. More... | |
uint8_t | at (const size_t n) const |
Get character at location n More... | |
std::string | copy () const |
Make a copy to a new std::string. More... | |
void | remove_prefix (const size_t n) |
Discard the first n bytes of the string (does not require a copy or move) More... | |
size_t | size () const |
Size of the string. More... | |
Expose contents as a std::string_view | |
std::string_view | str () const |
operator std::string_view () const | |
Private Attributes | |
size_t | _starting_offset {} |
std::shared_ptr< std::string > | _storage {} |
A reference-counted read-only string that can discard bytes from the front.
|
default |
|
inlinenoexcept |
|
inline |
|
inline |
Make a copy to a new std::string.
void Buffer::remove_prefix | ( | const size_t | n | ) |
|
private |