std::vector-like growing array for byte storage.
More...
#include <AUI/Common/AByteBuffer.h>
|
| AByteBuffer (const char *buffer, size_t size) |
|
| AByteBuffer (size_t initialCapacity) |
|
| AByteBuffer (const unsigned char *buffer, size_t size) |
|
| AByteBuffer (AByteBufferView other) |
|
| AByteBuffer (const AByteBuffer &other) |
|
| AByteBuffer (AByteBuffer &&other) noexcept |
|
void | write (const char *src, size_t size) override |
| Writes exact size bytes to stream. Blocking (waiting for write all data) is allowed.
|
|
AByteBufferView | slice (std::size_t offset, std::size_t size) const noexcept |
|
AByteBufferView | slice (std::size_t offset) const noexcept |
|
void | write (IInputStream &stream, size_t size) |
|
| operator AByteBufferView () const noexcept |
|
void | clear () |
|
void | reserve (size_t size) |
| Resizes internal buffer.
|
|
void | increaseInternalBuffer (size_t size) |
| Increases internal buffer.
|
|
void | grow (size_t size) |
| If getReserved() - getSize() is less than size increases internal buffer size enough to store size bytes.
|
|
size_t | getAvailableToWrite () const |
|
char * | data () const |
|
template<typename T> |
T & | at (size_t byteIndex) |
| Gets value of specified type by byte index relative to the beginning of internal buffer.
|
|
template<typename T> |
const T & | at (size_t byteIndex) const |
| Gets value of specified type by byte index relative to the beginning of internal buffer.
|
|
void | setSize (size_t s) |
|
void | increaseSize (size_t s) |
|
void | resize (size_t s) |
|
void | reallocate (size_t s) |
|
size_t | getSize () const noexcept |
|
bool | empty () const noexcept |
|
size_t | size () const noexcept |
|
size_t | capacity () const noexcept |
|
size_t | getReserved () const noexcept |
|
AByteBuffer & | operator= (AByteBuffer &&other) noexcept |
|
AByteBuffer & | operator= (const AByteBuffer &other) |
|
bool | operator== (const AByteBuffer &r) const |
|
bool | operator!= (const AByteBuffer &r) const |
|
char * | begin () |
|
char * | end () |
|
char * | endReserved () |
|
const char * | begin () const |
|
const char * | end () const |
|
template<typename T> |
T | as () const |
|
AString | toHexString () const |
|
AString | toBase64String () const |
|
iterator | erase (iterator begin, iterator end) noexcept |
|
bool | ownsIterator (iterator i) const noexcept |
|
template<typename T> |
void | write (const T &t) |
|
template<typename T> |
IOutputStream & | operator<< (const T &t) |
|
std::vector-like growing array for byte storage.
◆ at() [1/2]
template<typename T>
T & AByteBuffer::at |
( |
size_t | byteIndex | ) |
|
|
inline |
Gets value of specified type by byte index relative to the beginning of internal buffer.
- Template Parameters
-
- Parameters
-
byteIndex | byte offset realtive to the beginning of internal buffer |
- Returns
- data
◆ at() [2/2]
template<typename T>
const T & AByteBuffer::at |
( |
size_t | byteIndex | ) |
const |
|
inline |
Gets value of specified type by byte index relative to the beginning of internal buffer.
- Template Parameters
-
- Parameters
-
byteIndex | byte offset realtive to the beginning of internal buffer |
- Returns
- data
◆ capacity()
size_t AByteBuffer::capacity |
( |
| ) |
const |
|
inlinenoexcept |
- Returns
- size of whole buffer (including possibly invalid data)
◆ data()
char * AByteBuffer::data |
( |
| ) |
const |
|
inline |
◆ empty()
bool AByteBuffer::empty |
( |
| ) |
const |
|
inlinenoexcept |
◆ getAvailableToWrite()
size_t AByteBuffer::getAvailableToWrite |
( |
| ) |
const |
|
inline |
- Returns
- delta between internal buffer size and payload size.
◆ getReserved()
size_t AByteBuffer::getReserved |
( |
| ) |
const |
|
inlinenoexcept |
- Returns
- size of internal buffer. Must be greater that getSize()
◆ getSize()
size_t AByteBuffer::getSize |
( |
| ) |
const |
|
inlinenoexcept |
- Returns
- size of payload (valid data)
◆ increaseSize()
void AByteBuffer::increaseSize |
( |
size_t | s | ) |
|
|
inline |
Forces new size of the buffer.
- Sneaky assert:
- Assert fails when new size is greater that reserved buffer size. Use
AByteBuffer::resize
to avoid this.
- Parameters
-
◆ reallocate()
void AByteBuffer::reallocate |
( |
size_t | s | ) |
|
|
inline |
Resizes the buffer WITHOUT keeping it's contents. When reserved buffer size is differs from the new size, buffer is reallocated with new size.
- Parameters
-
◆ resize()
void AByteBuffer::resize |
( |
size_t | s | ) |
|
|
inline |
Resizes the buffer keeping it's contents. When reserved buffer size is less than the new size, buffer is reallocated with new size.
- Parameters
-
◆ setSize()
void AByteBuffer::setSize |
( |
size_t | s | ) |
|
|
inline |
Forces new size of the buffer.
- Sneaky assert:
- Assert fails when new size is greater that reserved buffer size. Use
AByteBuffer::resize
to avoid this.
- Parameters
-
◆ size()
size_t AByteBuffer::size |
( |
| ) |
const |
|
inlinenoexcept |
- Returns
- size of payload (valid data)
◆ write() [1/2]
void AByteBuffer::write |
( |
const char * | src, |
|
|
size_t | size ) |
|
overridevirtual |
Writes exact size
bytes to stream. Blocking (waiting for write all data) is allowed.
- Sneaky exceptions
- An implementation can throw any exception that subclasses AIOException.
- Parameters
-
src | source buffer |
size | source buffer's size. > 0 |
Implements IOutputStream.
◆ write() [2/2]
void AByteBuffer::write |
( |
IInputStream & | stream, |
|
|
size_t | size ) |
Reads exact size
bytes from stream
.
- Parameters
-
The documentation for this class was generated from the following files:
- aui.core/src/AUI/Common/AByteBuffer.h
- aui.core/src/AUI/Common/AByteBuffer.cpp
- aui.core/src/AUI/Common/AByteBufferBase64.cpp