#include <bytecontainer.h>
|
| | ByteContainer (const size_t nbytes, const char c='\x00') |
| | Constructs the container with nbytes copies of elements with value c.
|
| |
| | ByteContainer (const std::vector< char > &bytes) |
| | Constructs the container by copying the bytes in vector bytes.
|
| |
| | ByteContainer (const char *bytes, size_t nbytes) |
| | Constructs the container by copying the bytes in this byte array.
|
| |
| | ByteContainer (const std::string &hexstring) |
| |
| size_type | size () const noexcept |
| | Returns the number of bytes in the container.
|
| |
| void | clear () |
| | Clears the contents of the container.
|
| |
| iterator | begin () |
| | NC.
|
| |
| const_iterator | begin () const |
| | NC.
|
| |
| iterator | end () |
| | NC.
|
| |
| const_iterator | end () const |
| | NC.
|
| |
| ByteContainer & | append (const ByteContainer &other) |
| |
| ByteContainer & | append (const char *byte_array, size_t nbytes) |
| | Appends a byte array to this container.
|
| |
| ByteContainer & | append (const std::string &other) |
| | Appends a binary string to this container.
|
| |
| void | insert (iterator pos, const ByteContainer &other) |
| | Inserts another ByteContainer object into this container, before pos.
|
| |
| void | push_back (char c) |
| | Appends a character at the end of the container.
|
| |
| reference | operator[] (size_type n) |
| |
| const_reference | operator[] (size_type n) const |
| |
| reference | back () |
| |
| const_reference | back () const |
| |
| reference | front () |
| |
| const_reference | front () const |
| |
| char * | data () noexcept |
| |
| const char * | data () const noexcept |
| |
| bool | operator== (const ByteContainer &other) const |
| | Returns true is the contents of the containers are equal.
|
| |
| bool | operator!= (const ByteContainer &other) const |
| | Returns true is the contents of the containers are not equal.
|
| |
| void | reserve (size_t n) |
| | Increase the capacity of the container.
|
| |
| void | resize (size_t n) |
| | Resizes the container to contain bytes.
|
| |
| void | resize (size_t n, char c) |
| |
| void | apply_mask (const ByteContainer &mask) |
| |
| std::string | to_hex (size_t start, size_t s, bool upper_case=false) const |
| |
| std::string | to_hex (bool upper_case=false) const |
| | Returns the hexadecimal representation of the byte container as a string.
|
| |
This class is used everytime a vector of bytes is needed in bmv2. It is most notably used by the Field class (to store the byte representation of a field) as well as to store match keys in tables.
◆ ByteContainer() [1/4]
| bm::ByteContainer::ByteContainer |
( |
const size_t |
nbytes, |
|
|
const char |
c = '\x00' |
|
) |
| |
|
inlineexplicit |
Constructs the container with nbytes copies of elements with value c.
◆ ByteContainer() [2/4]
| bm::ByteContainer::ByteContainer |
( |
const std::vector< char > & |
bytes | ) |
|
|
inlineexplicit |
Constructs the container by copying the bytes in vector bytes.
◆ ByteContainer() [3/4]
| bm::ByteContainer::ByteContainer |
( |
const char * |
bytes, |
|
|
size_t |
nbytes |
|
) |
| |
|
inline |
Constructs the container by copying the bytes in this byte array.
◆ ByteContainer() [4/4]
| bm::ByteContainer::ByteContainer |
( |
const std::string & |
hexstring | ) |
|
|
inlineexplicit |
Constructs the container from a hexadecimal string. Parameter hexstring can optionally include the 0x prefix.
◆ append() [1/3]
Appends another ByteContainer to this container. other has to be different from *this.
◆ append() [2/3]
| ByteContainer & bm::ByteContainer::append |
( |
const char * |
byte_array, |
|
|
size_t |
nbytes |
|
) |
| |
|
inline |
Appends a byte array to this container.
◆ append() [3/3]
| ByteContainer & bm::ByteContainer::append |
( |
const std::string & |
other | ) |
|
|
inline |
Appends a binary string to this container.
◆ apply_mask()
Perform a byte-by-byte masking of the container. Will assert if size() != mask.size().
◆ back() [1/2]
| reference bm::ByteContainer::back |
( |
| ) |
|
|
inline |
Access the last byte of the container. Undefined if the container is empty.
◆ back() [2/2]
| const_reference bm::ByteContainer::back |
( |
| ) |
const |
|
inline |
Access the last byte of the container. Undefined if the container is empty.
◆ begin() [1/2]
| iterator bm::ByteContainer::begin |
( |
| ) |
|
|
inline |
◆ begin() [2/2]
| const_iterator bm::ByteContainer::begin |
( |
| ) |
const |
|
inline |
◆ clear()
| void bm::ByteContainer::clear |
( |
| ) |
|
|
inline |
Clears the contents of the container.
◆ data() [1/2]
| const char * bm::ByteContainer::data |
( |
| ) |
const |
|
inlinenoexcept |
Returns pointer to the underlying array serving as element storage. The pointer is such that range [data(); data() + size()) is always a valid range, even if the container is empty.
◆ data() [2/2]
| char * bm::ByteContainer::data |
( |
| ) |
|
|
inlinenoexcept |
Returns pointer to the underlying array serving as element storage. The pointer is such that range [data(); data() + size()) is always a valid range, even if the container is empty.
◆ end() [1/2]
| iterator bm::ByteContainer::end |
( |
| ) |
|
|
inline |
◆ end() [2/2]
| const_iterator bm::ByteContainer::end |
( |
| ) |
const |
|
inline |
◆ front() [1/2]
| reference bm::ByteContainer::front |
( |
| ) |
|
|
inline |
Access the first byte of the container. Undefined if the container is empty.
◆ front() [2/2]
| const_reference bm::ByteContainer::front |
( |
| ) |
const |
|
inline |
Access the first byte of the container. Undefined if the container is empty.
◆ insert()
| void bm::ByteContainer::insert |
( |
iterator |
pos, |
|
|
const ByteContainer & |
other |
|
) |
| |
|
inline |
Inserts another ByteContainer object into this container, before pos.
◆ operator!=()
| bool bm::ByteContainer::operator!= |
( |
const ByteContainer & |
other | ) |
const |
|
inline |
Returns true is the contents of the containers are not equal.
◆ operator==()
| bool bm::ByteContainer::operator== |
( |
const ByteContainer & |
other | ) |
const |
|
inline |
Returns true is the contents of the containers are equal.
◆ operator[]() [1/2]
| reference bm::ByteContainer::operator[] |
( |
size_type |
n | ) |
|
|
inline |
Access the character at position n. Will assert if n is greater or equal than the number of elements in the container.
◆ operator[]() [2/2]
| const_reference bm::ByteContainer::operator[] |
( |
size_type |
n | ) |
const |
|
inline |
Access the character at position n. Will assert if n is greater or equal than the number of elements in the container.
◆ push_back()
| void bm::ByteContainer::push_back |
( |
char |
c | ) |
|
|
inline |
Appends a character at the end of the container.
◆ reserve()
| void bm::ByteContainer::reserve |
( |
size_t |
n | ) |
|
|
inline |
Increase the capacity of the container.
◆ resize() [1/2]
| void bm::ByteContainer::resize |
( |
size_t |
n | ) |
|
|
inline |
Resizes the container to contain bytes.
◆ resize() [2/2]
| void bm::ByteContainer::resize |
( |
size_t |
n, |
|
|
char |
c |
|
) |
| |
|
inline |
Resizes the container to contain bytes, initializing the new bytes to c
◆ size()
| size_type bm::ByteContainer::size |
( |
| ) |
const |
|
inlinenoexcept |
Returns the number of bytes in the container.
◆ to_hex() [1/2]
| std::string bm::ByteContainer::to_hex |
( |
bool |
upper_case = false | ) |
const |
|
inline |
Returns the hexadecimal representation of the byte container as a string.
◆ to_hex() [2/2]
| std::string bm::ByteContainer::to_hex |
( |
size_t |
start, |
|
|
size_t |
s, |
|
|
bool |
upper_case = false |
|
) |
| const |
Returns the hexadecimal representation of the bytes with a position in the range [start, start + s) as a string
The documentation for this class was generated from the following file: