OpenCBDC Transaction Processor
|
Buffer to store and retrieve byte data. More...
#include <buffer.hpp>
Public Member Functions | |
buffer ()=default | |
auto | size () const -> size_t |
Returns the number of bytes contained in the buffer. | |
auto | data () -> void * |
Returns a raw pointer to the start of the buffer data. | |
auto | data () const -> const void * |
Returns a raw pointer to the start of the buffer data. | |
auto | data_at (size_t offset) -> void * |
Returns a raw pointer to the start of the buffer data. | |
auto | data_at (size_t offset) const -> const void * |
Returns a raw pointer to the start of the packet data. | |
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 | clear () |
Removes any existing content in the buffer making its size 0. | |
auto | operator== (const buffer &other) const -> bool |
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*. | |
auto | c_str () const -> const char * |
Returns a pointer to the data, cast to a char*. | |
auto | to_hex () const -> std::string |
Returns a hex string representation of the contents of the buffer. | |
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. | |
Static Public Member Functions | |
static auto | from_hex (const std::string &hex) -> std::optional< cbdc::buffer > |
Creates a new buffer from the provided hex string. | |
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. | |
Buffer to store and retrieve byte data.
Definition at line 15 of file buffer.hpp.
|
default |
void cbdc::buffer::append | ( | const void * | data, |
size_t | len ) |
Adds the given number of bytes from the given pointer to the end of the buffer.
data | pointer to the start of the data. |
len | the number of bytes to read. |
Definition at line 18 of file buffer.cpp.
References data().
|
nodiscard |
Returns a pointer to the data, cast to an unsigned char*.
Definition at line 52 of file buffer.cpp.
|
nodiscard |
Returns a pointer to the data, cast to a char*.
Definition at line 57 of file buffer.cpp.
void cbdc::buffer::clear | ( | ) |
Removes any existing content in the buffer making its size 0.
Definition at line 14 of file buffer.cpp.
Referenced by cbdc::rlp_value::assign(), and cbdc::rlp_value::read_from().
|
nodiscard |
Returns a raw pointer to the start of the buffer data.
Definition at line 28 of file buffer.cpp.
Referenced by cbdc::parsec::agent::runner::add_to_bloom(), append(), cbdc::rlp_value::assign(), cbdc::rlp_value::data(), cbdc::rlp_value::read_from(), and cbdc::rlp_value::value().
|
nodiscard |
Returns a raw pointer to the start of the buffer data.
Definition at line 32 of file buffer.cpp.
|
nodiscard |
Returns a raw pointer to the start of the buffer data.
offset | the byte offset into the buffer. |
Definition at line 36 of file buffer.cpp.
Referenced by cbdc::parsec::agent::runner::add_to_bloom().
|
nodiscard |
Returns a raw pointer to the start of the packet data.
offset | the byte offset into the packet. |
Definition at line 40 of file buffer.cpp.
void cbdc::buffer::extend | ( | size_t | len | ) |
Extends the size of the buffer by the given length.
len | the number of bytes to add. |
Definition at line 48 of file buffer.cpp.
Referenced by cbdc::rlp_value::assign(), and cbdc::rlp_value::read_from().
|
static |
Creates a new buffer from the provided hex string.
hex | string-encoded hex representation of this buffer. |
Definition at line 85 of file buffer.cpp.
References cbdc::buffer.
Referenced by cbdc::parsec::agent::runner::address_from_json(), cbdc::parsec::agent::runner::buffer_from_json(), importinput_command(), cbdc::parsec::agent::runner::mint_initial_accounts(), and cbdc::parsec::agent::runner::raw_tx_from_json().
|
static |
Creates a new buffer from the provided hex string optionally prefixed with a prefix sequence.
hex | string-encoded hex representation of this buffer. |
prefix | text at start of hex string. Defaults to "0x". |
Definition at line 108 of file buffer.cpp.
Referenced by cbdc::parsec::agent::runner::from_hex(), and cbdc::parsec::agent::runner::uint256be_from_hex().
auto cbdc::buffer::operator== | ( | const buffer & | other | ) | const -> bool |
Definition at line 44 of file buffer.cpp.
|
nodiscard |
Returns the number of bytes contained in the buffer.
Definition at line 24 of file buffer.cpp.
Referenced by cbdc::parsec::agent::runner::add_to_bloom(), cbdc::buffer_serializer::end_of_buffer(), cbdc::rlp_value::size(), and cbdc::rlp_value::value().
|
nodiscard |
Returns a hex string representation of the contents of the buffer.
Definition at line 62 of file buffer.cpp.
|
nodiscard |
Returns a hex string representation of the contents of the buffer prefixed with a prefix sequence.
Definition at line 77 of file buffer.cpp.