1#ifndef XRPL_BASICS_SLICE_H_INCLUDED
2#define XRPL_BASICS_SLICE_H_INCLUDED
4#include <xrpl/basics/contract.h>
5#include <xrpl/basics/strHex.h>
6#include <xrpl/beast/utility/instrumentation.h>
41 operator=(
Slice const&) noexcept = default;
90 "ripple::Slice::operator[](std::size_t) const : valid input");
100 Throw<std::domain_error>(
"too small");
178template <
class Hasher>
188 if (lhs.size() != rhs.size())
194 return std::memcmp(lhs.data(), rhs.data(), lhs.size()) == 0;
200 return !(lhs == rhs);
208 lhs.data() + lhs.size(),
210 rhs.data() + rhs.size());
213template <
class Stream>
221template <
class T, std::
size_t N>
230template <
class T,
class Alloc>
239template <
class Traits,
class Alloc>
An immutable linear range of bytes.
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.
std::uint8_t const * data_
bool empty() const noexcept
Return true if the byte range is empty.
const_iterator begin() const noexcept
const_iterator cend() const noexcept
const_iterator end() const noexcept
void remove_suffix(std::size_t n)
Shrinks the slice by moving its end backward by n characters.
Slice() noexcept=default
Default constructed Slice has length 0.
void remove_prefix(std::size_t n)
Shrinks the slice by moving its start forward by n characters.
Slice operator+(std::size_t n) const
const_iterator cbegin() const noexcept
value_type const * const_iterator
std::uint8_t const * data() const noexcept
Return a pointer to beginning of the storage.
std::uint8_t operator[](std::size_t i) const noexcept
Access raw bytes.
Slice & operator+=(std::size_t n)
Advance the buffer.
std::size_t size() const noexcept
Returns the number of bytes in the storage.
std::size_t length() const noexcept
T lexicographical_compare(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
void hash_append(Hasher &h, Slice const &v)
bool operator!=(Buffer const &lhs, Buffer const &rhs) noexcept
std::ostream & operator<<(std::ostream &out, base_uint< Bits, Tag > const &u)
std::string strHex(FwdIt begin, FwdIt end)
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
bool operator<(Slice const &lhs, Slice const &rhs) noexcept
constexpr bool operator==(base_uint< Bits, Tag > const &lhs, base_uint< Bits, Tag > const &rhs)