19        const auto orig_size = m_data.size();
 
   20        m_data.resize(orig_size + len);
 
   21        std::memcpy(&m_data[orig_size], 
data, len);
 
 
   37        return &m_data[offset];
 
 
   41        return &m_data[offset];
 
 
   45        return m_data == other.m_data;
 
 
   49        m_data.resize(m_data.size() + len);
 
 
   54        return reinterpret_cast<const unsigned char*
>(m_data.data());
 
 
   59        return reinterpret_cast<const char*
>(m_data.data());
 
 
   65        std::stringstream ret;
 
   66        ret << std::hex << std::setfill(
'0');
 
   68        for(
const auto& 
byte : m_data) {
 
   71            ret << std::setw(2) << static_cast<int>(
byte);
 
 
   79        auto res = std::string();
 
 
   86        constexpr auto max_size = 102400;
 
   87        if(hex.empty() || ((hex.size() % 2) != 0) || (hex.size() > max_size)) {
 
   93        for(
size_t i = 0; i < hex.size(); i += 2) {
 
   98            s << std::hex << hex.substr(i, 2);
 
  102            ret.m_data.push_back(
static_cast<std::byte
>(v));
 
 
  109                                   const std::string& prefix)
 
  110        -> std::optional<buffer> {
 
  112        if(hex.rfind(prefix, 0) == 0) {
 
  113            offset = prefix.size();
 
  115        auto hex_str = hex.substr(offset);
 
  116        if(hex_str.size() % 2 != 0) {
 
  117            hex_str.insert(0, 
"0");
 
  119        return from_hex(hex_str);
 
 
Buffer to store and retrieve byte data.
 
auto data() -> void *
Returns a raw pointer to the start of the buffer data.
 
void clear()
Removes any existing content in the buffer making its size 0.
 
static auto from_hex(const std::string &hex) -> std::optional< cbdc::buffer >
Creates a new buffer from the provided hex string.
 
auto operator==(const buffer &other) const -> bool
 
auto to_hex_prefixed(const std::string &prefix="0x") const -> std::string
Returns a hex string representation of the contents of the buffer prefixed with a prefix sequence.
 
auto c_str() const -> const char *
Returns a pointer to the data, cast to a char*.
 
void append(const void *data, size_t len)
Adds the given number of bytes from the given pointer to the end of the buffer.
 
void extend(size_t len)
Extends the size of the buffer by the given length.
 
auto c_ptr() const -> const unsigned char *
Returns a pointer to the data, cast to an unsigned char*.
 
static auto from_hex_prefixed(const std::string &hex, const std::string &prefix="0x") -> std::optional< buffer >
Creates a new buffer from the provided hex string optionally prefixed with a prefix sequence.
 
auto to_hex() const -> std::string
Returns a hex string representation of the contents of the buffer.
 
auto size() const -> size_t
Returns the number of bytes contained in the buffer.
 
auto data_at(size_t offset) -> void *
Returns a raw pointer to the start of the buffer data.
 
@ buffer
A singular RLP value (byte array)