A class for representing binary data. More...
#include <ByteArray.h>
Public Member Functions | |
ByteArray () | |
It creates a new empty byte array. More... | |
ByteArray (std::size_t capacity) | |
It creates a new byte array and allocates size bytes. More... | |
ByteArray (char *data, std::size_t size) | |
It creates a new byte array taking the ownership of the external data buffer. More... | |
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. More... | |
ByteArray (const ByteArray &rhs) | |
Copy constructor. More... | |
std::size_t | bytesUsed () const |
It returns the number of used bytes in the internal buffer. More... | |
std::size_t | capacity () const |
It returns the size of the internal buffer. More... | |
void | clear () |
It clears the byte array. More... | |
AbstractData * | clone () const |
It creates a new clone of the byte array. More... | |
void | copy (char *data, std::size_t size) |
It copies the data from the given pointer to the byte array. More... | |
void | copy (char *data, std::size_t size, std::size_t offset) |
It copies the data from the given pointer to the byte array. More... | |
char * | getData () const |
It returns the data array. More... | |
int | getTypeCode () const |
The type code for byte array data: BYTE_ARRAY_TYPE. More... | |
ByteArray & | operator= (const ByteArray &rhs) |
Assignment operator. More... | |
void | setBytesUsed (std::size_t size) |
It sets the number of used bytes in the internal buffer. More... | |
void | take (char *data, std::size_t size) |
It takes the ownership of the external data buffer. More... | |
void | take (char *data, std::size_t capacity, std::size_t usedBytes) |
It takes the ownership of the external data buffer. More... | |
std::string | toString () const |
It returns the byte array in an string notation. More... | |
~ByteArray () | |
Destructor. More... | |
Private Attributes | |
std::size_t | m_bytesOccupied |
The number of bytes occupied in the buffer. More... | |
std::size_t | m_capacity |
The number of bytes allocated by the internal buffer. More... | |
char * | m_data |
The buffer data. More... | |
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.
Definition at line 34 of file ByteArray.cpp.
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. |
Definition at line 41 of file ByteArray.cpp.
References capacity(), and m_data.
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. |
Definition at line 49 of file ByteArray.cpp.
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. |
Definition at line 56 of file ByteArray.cpp.
te::dt::ByteArray::ByteArray | ( | const ByteArray & | rhs | ) |
Copy constructor.
rhs | The right-hand-side instance. |
Definition at line 63 of file ByteArray.cpp.
References m_bytesOccupied, m_capacity, and m_data.
te::dt::ByteArray::~ByteArray | ( | ) |
Destructor.
Definition at line 100 of file ByteArray.cpp.
std::size_t te::dt::ByteArray::bytesUsed | ( | ) | const |
It returns the number of used bytes in the internal buffer.
Definition at line 169 of file ByteArray.cpp.
Referenced by te::pgis::PreparedQuery::bind(), te::sqlite::PreparedQuery::bind(), and operator<<().
std::size_t te::dt::ByteArray::capacity | ( | ) | const |
It returns the size of the internal buffer.
Definition at line 164 of file ByteArray.cpp.
Referenced by ByteArray().
void te::dt::ByteArray::clear | ( | ) |
It clears the byte array.
Definition at line 179 of file ByteArray.cpp.
|
virtual |
It creates a new clone of the byte array.
Implements te::dt::AbstractData.
Definition at line 187 of file ByteArray.cpp.
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. |
Definition at line 128 of file ByteArray.cpp.
Referenced by te::ogr::DataSet::getByteArray(), te::pgis::DataSet::getByteArray(), and 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. |
Definition at line 142 of file ByteArray.cpp.
char * te::dt::ByteArray::getData | ( | ) | const |
It returns the data array.
Definition at line 105 of file ByteArray.cpp.
Referenced by te::pgis::PreparedQuery::bind(), and te::sqlite::PreparedQuery::bind().
|
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.
te::dt::ByteArray & te::dt::ByteArray::operator= | ( | const ByteArray & | rhs | ) |
Assignment operator.
rhs | The right-hand-side instance. |
Definition at line 78 of file ByteArray.cpp.
References m_bytesOccupied, m_capacity, and m_data.
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. |
Definition at line 174 of file ByteArray.cpp.
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. |
Definition at line 110 of file ByteArray.cpp.
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. |
Definition at line 119 of file ByteArray.cpp.
|
virtual |
It returns the byte array in an string notation.
Implements te::dt::AbstractData.
Definition at line 192 of file ByteArray.cpp.
References te::common::Binary2Hex().
|
private |
The number of bytes occupied in the buffer.
Definition at line 213 of file ByteArray.h.
Referenced by ByteArray(), and operator=().
|
private |
The number of bytes allocated by the internal buffer.
Definition at line 212 of file ByteArray.h.
Referenced by ByteArray(), and operator=().
|
private |
The buffer data.
Definition at line 211 of file ByteArray.h.
Referenced by ByteArray(), and operator=().