|
| BufferType ()=default |
| Default constructor for BufferType.
|
|
| BufferType (void *data, const size_t size, const bool filled) |
| Constructor for BufferType that takes a void pointer, size, and a flag indicating if the buffer is filled.
|
|
| BufferType (T *data, const size_t size, const bool filled) |
| Constructor for BufferType that takes a T pointer, size, and a flag indicating if the buffer is filled.
|
|
| ConstBufferType () |
| Default constructor for ConstBufferType.
|
|
| ConstBufferType (void *data, const size_t size, const bool filled) |
| Constructs a ConstBufferType from a void pointer and size.
|
|
template<typename U = T, typename std::enable_if_t<!std::is_const_v< U >, int > = 0> |
| ConstBufferType (const void *data, const size_t size, const bool filled) |
| Constructs a ConstBufferType from a const void pointer and size. This constructor is disabled when T is already const.
|
|
| ConstBufferType (T *data, const size_t size, const bool filled) |
| Constructs a ConstBufferType from a pointer to T and size.
|
|
template<typename U = T, typename std::enable_if_t<!std::is_const_v< U >, int > = 0> |
| ConstBufferType (const U *data, const size_t size, const bool filled) |
| Constructs a ConstBufferType from a const pointer to T and size. This constructor is disabled when T is already const.
|
|
virtual | ~ConstBufferType ()=default |
| Needed because this class has virtual member functions and is intended as a base class.
|
|
const auto & | operator[] (const size_t index) const |
| Const indexing operator for ConstBufferType.
|
|
auto & | operator[] (const size_t index) |
| Non-const indexing operator for ConstBufferType.
|
|
void | init_headroom (const size_t headroom) |
| Initializes the headroom (offset) of the buffer.
|
|
void | reset_offset (const size_t offset) |
| Resets the offset of the buffer.
|
|
void | reset_size () |
| Resets the size of the buffer to zero.
|
|
void | reset_content () |
| Resets the content of the buffer.
|
|
const T * | c_str () const |
| Returns a const pointer to the null-terminated string representation of the buffer.
|
|
size_t | length () const |
| Returns the length of the buffer.
|
|
const T * | c_data () const |
| Returns a const pointer to the start of the buffer.
|
|
const T * | c_data_end () const |
| Returns a const pointer to the end of the buffer.
|
|
const T * | c_data_raw () const |
| Returns a const pointer to the start of the raw data in the buffer.
|
|
size_t | capacity () const |
| Returns the capacity (raw size) of the allocated buffer in T objects.
|
|
size_t | offset () const |
| Returns the current offset (headroom) into the buffer.
|
|
bool | defined () const |
| Returns true if the buffer is not empty.
|
|
bool | allocated () const |
| Returns true if the data memory is defined (allocated).
|
|
bool | empty () const |
| Returns true if the buffer is empty.
|
|
size_t | size () const |
| Returns the size of the buffer in T objects.
|
|
T | pop_back () |
| Removes and returns the last element from the buffer.
|
|
T | pop_front () |
| Removes and returns the first element from the buffer.
|
|
T | front () const |
| Returns the first element of the buffer.
|
|
T | back () const |
| Returns the last element of the buffer.
|
|
void | advance (const size_t delta) |
| Advances the buffer by the specified delta.
|
|
bool | contains_null () const |
| Returns true if the buffer contains a null character.
|
|
bool | is_zeroed () const |
| Returns true if the buffer is zeroed (all elements are zero).
|
|
openvpn_io::const_buffer | const_buffer () const |
| Return an openvpn_io::const_buffer object used by asio write methods.
|
|
openvpn_io::const_buffer | const_buffer_clamp () const |
| Return a clamped version of const_buffer().
|
|
openvpn_io::const_buffer | const_buffer_limit (const size_t limit) const |
| Return a const_buffer object with a specified size limit.
|
|
void | read (NCT *data, const size_t size) |
| Read data from the buffer into the specified memory location.
|
|
void | read (void *data, const size_t size) |
| Read data from the buffer into the specified memory location.
|
|
auto * | read_alloc (const size_t size) |
| Allocate memory and read data from the buffer into the allocated memory.
|
|
auto | read_alloc_buf (const size_t size) |
| Allocate memory and read data from the buffer into the allocated memory.
|
|
size_t | max_size () const |
| Return the maximum allowable size value in T objects given the current offset (without considering resize).
|
|
void | set_size (const size_t size) |
| After an external method, operating on the array as a mutable unsigned char buffer, has written data to the array, use this method to set the array length in terms of T objects.
|
|
void | inc_size (const size_t delta) |
| Increment the size of the array (usually used in a similar context to set_size such as after mutable_buffer_append).
|
|
ConstBufferType | range (size_t offset, size_t len) const |
| Get a range of the buffer as a ConstBufferType object.
|
|
const T * | c_index (const size_t index) const |
| Get a const pointer to the element at the specified index in the array.
|
|
bool | operator== (const ConstBufferType &other) const |
| Equality operator to compare this buffer with another ConstBufferType object.
|
|
bool | operator!= (const ConstBufferType &other) const |
| Inequality operator to compare this buffer with another ConstBufferType object.
|
|
|
| BufferType (T *data, const size_t offset, const size_t size, const size_t capacity) |
| Protected constructor for BufferType that takes a T pointer, offset, size, and capacity.
|
|
void | reserve (const size_t n) |
| Reserve additional memory for the buffer.
|
|
T * | data () |
| Get a mutable pointer to the start of the array.
|
|
T * | data_end () |
| Get a mutable pointer to the end of the array.
|
|
T * | data_raw () |
| Get a mutable pointer to the start of the raw data.
|
|
size_t | remaining (const size_t tailroom=0) const |
| Return the number of additional T objects that can be added before capacity is reached (without considering resize).
|
|
size_t | max_size_tailroom (const size_t tailroom) const |
| Return the maximum allowable size value in T objects, taking into account the specified tailroom.
|
|
void | push_back (const T &value) |
| Append a T object to the end of the array, resizing the array if necessary.
|
|
void | push_front (const T &value) |
| Append a T object to the array, with possible resize.
|
|
void | set_trailer (const T &value) |
| Place a T object after the last object in the array, with possible resize to contain it. However, it doesn't actually change the size of the array to reflect the added object. Useful for maintaining null-terminated strings.
|
|
void | null_terminate () |
| Null-terminate the array.
|
|
T * | index (const size_t index) |
| Get a mutable index into the array.
|
|
openvpn_io::mutable_buffer | mutable_buffer (const size_t tailroom=0) |
| Return an openvpn_io::mutable_buffer object used by asio read methods, starting from data().
|
|
openvpn_io::mutable_buffer | mutable_buffer_append (const size_t tailroom=0) |
| Return an openvpn_io::mutable_buffer object used by asio read methods, starting from data_end().
|
|
openvpn_io::mutable_buffer | mutable_buffer_clamp (const size_t tailroom=0) |
| Clamped version of mutable_buffer().
|
|
openvpn_io::mutable_buffer | mutable_buffer_append_clamp (const size_t tailroom=0) |
| Clamped version of mutable_buffer_append().
|
|
void | realign (size_t headroom) |
| Realign the buffer with the specified headroom.
|
|
void | write (const T *data, const size_t size) |
| Write data to the buffer.
|
|
void | write (const void *data, const size_t size) |
| Write data to the buffer.
|
|
void | prepend (const T *data, const size_t size) |
| Prepend data to the buffer.
|
|
void | prepend (const void *data, const size_t size) |
| Prepend data to the buffer.
|
|
T * | write_alloc (const size_t size) |
| Allocate space for writing data to the buffer.
|
|
T * | prepend_alloc (const size_t size) |
| Allocate space for prepending data to the buffer.
|
|
void | reset (const size_t min_capacity, const unsigned int flags) |
| Reset the buffer with the specified minimum capacity and flags.
|
|
void | reset (const size_t headroom, const size_t min_capacity, const unsigned int flags) |
| Reset the buffer with the specified headroom, minimum capacity, and flags.
|
|
template<typename B > |
void | append (const B &other) |
| Append data from another buffer to this buffer.
|
|
template<typename T_ > |
void | swap (ConstBufferType< T_ > &other) |
| Swap the contents of this buffer with another buffer.
|
|
void | buffer_full_error (const size_t newcap, const bool allocated) const |
| Throw an exception when the buffer is full.
|
|
virtual void | reset_impl (const size_t min_capacity, const unsigned int flags) |
| Called when the reset method needs to expand the buffer size.
|
|
virtual void | resize (const size_t new_capacity) |
| Derived classes can implement buffer growing semantics by overloading this method. In the default implementation, buffers are non-growable, so an exception is thrown.
|
|
| ConstBufferType (T *data, const size_t offset, const size_t size, const size_t capacity) |
| Construct a ConstBufferType object.
|
|
template<typename U = T, typename std::enable_if_t<!std::is_const_v< U >, int > = 0> |
| ConstBufferType (const U *data, const size_t offset, const size_t size, const size_t capacity) |
| Construct a ConstBufferType object from a const U* pointer. This constructor is disabled when T is already const.
|
|
template<typename T>
class openvpn::BufferType< T >
Definition at line 785 of file buffer.hpp.