A class for representing binary data. More...
#include <ByteArray.h>
Public Member Functions | |
| ByteArray () | |
| It creates a new empty byte array. | |
| ByteArray (char *data, std::size_t capacity, std::size_t usedBytes) | |
| It creates a new byte array taking the ownership of the external data buffer. | |
| ByteArray (char *data, std::size_t size) | |
| It creates a new byte array taking the ownership of the external data buffer. | |
| ByteArray (const ByteArray &rhs) | |
| Copy constructor. | |
| ByteArray (std::size_t capacity) | |
| It creates a new byte array and allocates size bytes. | |
| std::size_t | bytesUsed () const |
| It returns the number of used bytes in the internal buffer. | |
| std::size_t | capacity () const |
| It returns the size of the internal buffer. | |
| void | clear () |
| It clears the byte array. | |
| AbstractData * | clone () const |
| It creates a new clone of the byte array. | |
| void | copy (char *data, std::size_t size) |
| It copies the data from the given pointer to the byte array. | |
| void | copy (char *data, std::size_t size, std::size_t offset) |
| It copies the data from the given pointer to the byte array. | |
| char * | getData () const |
| It returns the data array. | |
| int | getTypeCode () const |
| The type code for byte array data: BYTE_ARRAY_TYPE. | |
| ByteArray & | operator= (const ByteArray &rhs) |
| Assignment operator. | |
| void | setBytesUsed (std::size_t size) |
| It sets the number of used bytes in the internal buffer. | |
| void | take (char *data, std::size_t capacity, std::size_t usedBytes) |
| It takes the ownership of the external data buffer. | |
| void | take (char *data, std::size_t size) |
| It takes the ownership of the external data buffer. | |
| std::string | toString () const |
| It returns the byte array in an string notation. | |
| ~ByteArray () | |
| Destructor. | |
Private Attributes | |
| std::size_t | m_bytesOccupied |
| The number of bytes occupied in the buffer. | |
| std::size_t | m_capacity |
| The number of bytes allocated by the internal buffer. | |
| char * | m_data |
| The buffer data. | |
A class for representing binary data.
A byte array can be used as a container for binary data.
Definition at line 51 of file ByteArray.h.
| te::dt::ByteArray::ByteArray | ( | ) |
It creates a new empty byte array.
Referenced by ByteArray(), and operator=().
| te::dt::ByteArray::ByteArray | ( | std::size_t | capacity | ) |
It creates a new byte array and allocates size bytes.
| capacity | The number of bytes for the internal data buffer. |
References capacity().
| te::dt::ByteArray::ByteArray | ( | char * | data, |
| std::size_t | size ) |
It creates a new byte array taking the ownership of the external data buffer.
| data | The data array. |
| size | The number of bytes in the data array. This value will be also the capacity of the byte array buffer. |
| te::dt::ByteArray::ByteArray | ( | char * | data, |
| std::size_t | capacity, | ||
| std::size_t | usedBytes ) |
It creates a new byte array taking the ownership of the external data buffer.
| data | The data array. |
| capacity | The number of bytes available in the data buffer, it must be greater than or equal to usedBytes. |
| usedBytes | The number of used bytes in the given data buffer. |
References capacity().
| te::dt::ByteArray::ByteArray | ( | const ByteArray & | rhs | ) |
| te::dt::ByteArray::~ByteArray | ( | ) |
Destructor.
| std::size_t te::dt::ByteArray::bytesUsed | ( | ) | const |
It returns the number of used bytes in the internal buffer.
Referenced by operator<<().
| std::size_t te::dt::ByteArray::capacity | ( | ) | const |
It returns the size of the internal buffer.
Referenced by ByteArray(), ByteArray(), and take().
| void te::dt::ByteArray::clear | ( | ) |
It clears the byte array.
|
virtual |
It creates a new clone of the byte array.
Implements te::dt::AbstractData.
References te::dt::AbstractData::AbstractData().
| void te::dt::ByteArray::copy | ( | char * | data, |
| std::size_t | size ) |
It copies the data from the given pointer to the byte array.
| data | The data array to be copied. |
| size | The number of bytes to be copied from the input array. |
Referenced by operator<<().
| void te::dt::ByteArray::copy | ( | char * | data, |
| std::size_t | size, | ||
| std::size_t | offset ) |
It copies the data from the given pointer to the byte array.
| data | The data array to be copied. |
| size | The number of bytes to be copied from the input array. |
| offset | An offset in the internal data buffer. |
| char * te::dt::ByteArray::getData | ( | ) | const |
It returns the data array.
|
inlinevirtual |
The type code for byte array data: BYTE_ARRAY_TYPE.
Implements te::dt::AbstractData.
Definition at line 198 of file ByteArray.h.
References te::dt::BYTE_ARRAY_TYPE.
Assignment operator.
| rhs | The right-hand-side instance. |
References ByteArray().
| void te::dt::ByteArray::setBytesUsed | ( | std::size_t | size | ) |
It sets the number of used bytes in the internal buffer.
| size | The number of used bytes in the internal buffer. |
| void te::dt::ByteArray::take | ( | char * | data, |
| std::size_t | capacity, | ||
| std::size_t | usedBytes ) |
It takes the ownership of the external data buffer.
| data | The data array. |
| capacity | The number of bytes available in the data buffer, it must be greater than or equal to usedBytes. |
| usedBytes | The number of used bytes in the given data buffer. |
References capacity().
| void te::dt::ByteArray::take | ( | char * | data, |
| std::size_t | size ) |
It takes the ownership of the external data buffer.
| data | The data array. |
| size | The number of bytes in the array of data. This value will be also the capacity of the byte array buffer. |
|
virtual |
It returns the byte array in an string notation.
Implements te::dt::AbstractData.
|
private |
The number of bytes occupied in the buffer.
Definition at line 213 of file ByteArray.h.
|
private |
The number of bytes allocated by the internal buffer.
Definition at line 212 of file ByteArray.h.
|
private |
The buffer data.
Definition at line 211 of file ByteArray.h.