A class for representing binary data.  
 More...
#include <ByteArray.h>
 | 
|   | 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...
  | 
|   | 
A class for representing binary data. 
A byte array can be used as a container for binary data.
- See also
 - AbstractData, DataType, DateTime, SimpleData, CompositeData 
 
Definition at line 51 of file ByteArray.h.
 
      
        
          | te::dt::ByteArray::ByteArray  | 
          ( | 
           | ) | 
           | 
        
      
 
It creates a new empty byte array. 
 
 
      
        
          | te::dt::ByteArray::ByteArray  | 
          ( | 
          std::size_t  | 
          capacity | ) | 
           | 
        
      
 
It creates a new byte array and allocates size bytes. 
- Parameters
 - 
  
    | capacity | The number of bytes for the internal data buffer.  | 
  
   
 
 
      
        
          | te::dt::ByteArray::ByteArray  | 
          ( | 
          char *  | 
          data,  | 
        
        
           | 
           | 
          std::size_t  | 
          size  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
It creates a new byte array taking the ownership of the external data buffer. 
- Parameters
 - 
  
    | 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. | 
  
   
- Note
 - The byte array will take the ownership of the given data. 
 
 
 
      
        
          | 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. 
- Parameters
 - 
  
    | 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. | 
  
   
- Note
 - The byte array will take the ownership of the given data. 
 
 
 
      
        
          | te::dt::ByteArray::ByteArray  | 
          ( | 
          const ByteArray &  | 
          rhs | ) | 
           | 
        
      
 
Copy constructor. 
- Parameters
 - 
  
    | rhs | The right-hand-side instance.  | 
  
   
 
 
      
        
          | te::dt::ByteArray::~ByteArray  | 
          ( | 
           | ) | 
           | 
        
      
 
 
      
        
          | std::size_t te::dt::ByteArray::bytesUsed  | 
          ( | 
           | ) | 
           const | 
        
      
 
It returns the number of used bytes in the internal buffer. 
- 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. 
- Returns
 - The number of bytes in the internal buffer. 
 
 
 
      
        
          | void te::dt::ByteArray::clear  | 
          ( | 
           | ) | 
           | 
        
      
 
It clears the byte array. 
 
 
It creates a new clone of the byte array. 
- Returns
 - A new clone of the byte array. The caller will take its ownership. 
 
Implements te::dt::AbstractData.
 
 
      
        
          | void te::dt::ByteArray::copy  | 
          ( | 
          char *  | 
          data,  | 
        
        
           | 
           | 
          std::size_t  | 
          size  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
It copies the data from the given pointer to the byte array. 
- Parameters
 - 
  
    | data | The data array to be copied.  | 
    | size | The number of bytes to be copied from the input array. | 
  
   
- Note
 - It will drop the internal buffer if its capacity is less than size bytes. 
 
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. 
- Parameters
 - 
  
    | 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. | 
  
   
- Note
 - It will expand the internal buffer if its capacity is less than offset + size bytes.
 
- 
After this operation the number of bytes ocupied will be set to offset + size. 
 
 
 
      
        
          | char* te::dt::ByteArray::getData  | 
          ( | 
           | ) | 
           const | 
        
      
 
It returns the data array. 
- Returns
 - The data array.
 
- Note
 - Don't free the returned pointer (it belongs to the byte array object). 
 
 
 
  
  
      
        
          | int te::dt::ByteArray::getTypeCode  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
inlinevirtual   | 
  
 
 
Assignment operator. 
- Parameters
 - 
  
    | rhs | The right-hand-side instance. | 
  
   
- Returns
 - A reference to this byte array. 
 
 
 
      
        
          | void te::dt::ByteArray::setBytesUsed  | 
          ( | 
          std::size_t  | 
          size | ) | 
           | 
        
      
 
It sets the number of used bytes in the internal buffer. 
- Parameters
 - 
  
    | size | The number of used bytes in the internal buffer.  | 
  
   
 
 
      
        
          | void te::dt::ByteArray::take  | 
          ( | 
          char *  | 
          data,  | 
        
        
           | 
           | 
          std::size_t  | 
          size  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
It takes the ownership of the external data buffer. 
- Parameters
 - 
  
    | 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. | 
  
   
- Note
 - The byte array will take the ownership of the given data.
 
- 
It will drop the internal buffer before taking the data argument. 
 
 
 
      
        
          | void te::dt::ByteArray::take  | 
          ( | 
          char *  | 
          data,  | 
        
        
           | 
           | 
          std::size_t  | 
          capacity,  | 
        
        
           | 
           | 
          std::size_t  | 
          usedBytes  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
It takes the ownership of the external data buffer. 
- Parameters
 - 
  
    | 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. | 
  
   
- Note
 - The byte array will take the ownership of the given data.
 
- 
It will drop the internal buffer before taking the data argument. 
 
 
 
  
  
      
        
          | std::string te::dt::ByteArray::toString  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
virtual   | 
  
 
It returns the byte array in an string notation. 
- Returns
 - An hex-string encoded version of the internal data buffer.
 
Implements te::dt::AbstractData.
 
 
  
  
      
        
          | std::size_t te::dt::ByteArray::m_bytesOccupied | 
         
       
   | 
  
private   | 
  
 
The number of bytes occupied in the buffer. 
Definition at line 213 of file ByteArray.h.
 
 
  
  
      
        
          | std::size_t te::dt::ByteArray::m_capacity | 
         
       
   | 
  
private   | 
  
 
The number of bytes allocated by the internal buffer. 
Definition at line 212 of file ByteArray.h.
 
 
  
  
      
        
          | char* te::dt::ByteArray::m_data | 
         
       
   | 
  
private   | 
  
 
 
The documentation for this class was generated from the following file:
- /home/castejon/castejon_files/develop/terralib5/git_master/src/terralib/datatype/ByteArray.h