rippled
|
An immutable linear range of bytes. More...
Public Types | |
using | value_type = std::uint8_t |
using | const_iterator = value_type const * |
Public Member Functions | |
Slice () noexcept=default | |
Default constructed Slice has length 0. More... | |
Slice (Slice const &) noexcept=default | |
Slice & | operator= (Slice const &) noexcept=default |
Slice (void const *data, std::size_t size) noexcept | |
Create a slice pointing to existing memory. More... | |
bool | empty () const noexcept |
Return true if the byte range is empty. More... | |
std::uint8_t const * | data () const noexcept |
Return a pointer to beginning of the storage. More... | |
std::uint8_t | operator[] (std::size_t i) const noexcept |
Access raw bytes. More... | |
void | remove_prefix (std::size_t n) |
Shrinks the slice by moving its start forward by n characters. More... | |
void | remove_suffix (std::size_t n) |
Shrinks the slice by moving its end backward by n characters. More... | |
const_iterator | begin () const noexcept |
const_iterator | cbegin () const noexcept |
const_iterator | end () const noexcept |
const_iterator | cend () const noexcept |
Slice | substr (std::size_t pos, std::size_t count=std::numeric_limits< std::size_t >::max()) const |
Return a "sub slice" of given length starting at the given position. More... | |
std::size_t | size () const noexcept |
Returns the number of bytes in the storage. More... | |
std::size_t | length () const noexcept |
Slice & | operator+= (std::size_t n) |
Advance the buffer. More... | |
Slice | operator+ (std::size_t n) const |
Private Attributes | |
std::uint8_t const * | data_ = nullptr |
std::size_t | size_ = 0 |
An immutable linear range of bytes.
A fully constructed Slice is guaranteed to be in a valid state. A Slice is lightweight and copyable, it retains no ownership of the underlying memory.
using ripple::Slice::const_iterator = value_type const* |
|
defaultnoexcept |
Default constructed Slice has length 0.
|
defaultnoexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
Slice& ripple::Slice::operator+= | ( | std::size_t | n | ) |
Slice ripple::Slice::operator+ | ( | std::size_t | n | ) | const |
void ripple::Slice::remove_prefix | ( | std::size_t | n | ) |
void ripple::Slice::remove_suffix | ( | std::size_t | n | ) |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
Slice ripple::Slice::substr | ( | std::size_t | pos, |
std::size_t | count = std::numeric_limits<std::size_t>::max() |
||
) | const |
Return a "sub slice" of given length starting at the given position.
Note that the subslice encompasses the range [pos, pos + rcount), where rcount is the smaller of count and size() - pos.
pos | position of the first character @count requested length |
std::out_of_range | if pos > size() |
|
private |
|
private |