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.
Referenced by clone().
| 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 | ( | ) |
| 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.
References m_bytesOccupied.
Referenced by te::sqlite::PreparedQuery::bind(), te::pgis::PreparedQuery::bind(), operator<<(), TsByteArray::tcByteArray(), TsByteArray::tcByteArraySize(), TsByteArray::tcClear(), TsByteArray::tcClone(), TsByteArray::tcCopy1(), TsByteArray::tcInit(), TsByteArray::tcInit1(), TsByteArray::tcSetBytesUsed(), TsByteArray::tcTake1(), and TsByteArray::tcToString().
| std::size_t te::dt::ByteArray::capacity | ( | ) | const |
It returns the size of the internal buffer.
Definition at line 164 of file ByteArray.cpp.
References m_capacity.
Referenced by ByteArray(), take(), TsByteArray::tcByteArray(), TsByteArray::tcByteArraySize(), TsByteArray::tcClear(), TsByteArray::tcClone(), TsByteArray::tcCopy(), TsByteArray::tcCopy1(), TsByteArray::tcInit(), TsByteArray::tcInit1(), TsByteArray::tcTake(), TsByteArray::tcTake1(), and TsByteArray::tcToString().
| void te::dt::ByteArray::clear | ( | ) |
It clears the byte array.
Definition at line 179 of file ByteArray.cpp.
References m_bytesOccupied, m_capacity, and m_data.
Referenced by copy(), take(), TsByteArray::tcClear(), and TsByteArray::tcOperator().
|
virtual |
It creates a new clone of the byte array.
Implements te::dt::AbstractData.
Definition at line 187 of file ByteArray.cpp.
References ByteArray().
Referenced by TsByteArray::tcClone().
| 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.
References clear(), m_bytesOccupied, m_capacity, and m_data.
Referenced by te::ogr::DataSet::getByteArray(), te::gpkg::DataSet::getByteArray(), te::pgis::DataSet::getByteArray(), te::pgis::ConnectedDataSet::getByteArray(), operator<<(), TsByteArray::tcCopy(), and TsByteArray::tcCopy1().
| 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.
References m_bytesOccupied, m_capacity, m_data, and take().
| char * te::dt::ByteArray::getData | ( | ) | const |
It returns the data array.
Definition at line 105 of file ByteArray.cpp.
References m_data.
Referenced by te::sqlite::PreparedQuery::bind(), te::pgis::PreparedQuery::bind(), TsByteArray::tcByteArray(), TsByteArray::tcByteArrayConstructor(), TsByteArray::tcByteArraySize(), TsByteArray::tcClone(), TsByteArray::tcCopy(), TsByteArray::tcInit(), TsByteArray::tcInit1(), TsByteArray::tcOperator(), TsByteArray::tcTake(), and TsByteArray::tcTake1().
|
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.
Referenced by TsByteArray::tcGetTypeCode().
| 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.
References m_bytesOccupied.
Referenced by TsByteArray::tcSetBytesUsed().
| 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.
References clear(), m_bytesOccupied, m_capacity, and m_data.
Referenced by copy(), TsByteArray::tcTake(), and TsByteArray::tcTake1().
| 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.
References capacity(), clear(), m_bytesOccupied, m_capacity, and m_data.
|
virtual |
It returns the byte array in an string notation.
Implements te::dt::AbstractData.
Definition at line 192 of file ByteArray.cpp.
References te::core::Binary2Hex(), m_bytesOccupied, and m_data.
Referenced by TsByteArray::tcOperator(), and TsByteArray::tcToString().
|
private |
The number of bytes occupied in the buffer.
Definition at line 213 of file ByteArray.h.
Referenced by ByteArray(), bytesUsed(), clear(), copy(), operator=(), setBytesUsed(), take(), and toString().
|
private |
The number of bytes allocated by the internal buffer.
Definition at line 212 of file ByteArray.h.
Referenced by ByteArray(), capacity(), clear(), copy(), operator=(), and take().
|
private |
The buffer data.
Definition at line 211 of file ByteArray.h.
Referenced by ByteArray(), clear(), copy(), getData(), operator=(), take(), toString(), and ~ByteArray().