Blob Class Reference

Manages a binary object of arbitrary length. More...

`#include <Blob.h>`

Inheritance diagram for Blob:
[legend]

## Public Member Functions

| Blob ()
| Default constructor.
| Blob (const uint8_t *data, unsigned length)
| Constructor. More...
| Blob (const Blob &other)
| Copy constructor. More...
virtual | ~Blob ()
| Destructor. More...
| Blob ()
| Default constructor.
| Blob (const uint8_t *data, unsigned length)
| Constructor.
| Blob (const Blob &other)
| Copy constructor.
virtual | ~Blob ()
| Destructor.
Operations
void | setData (const uint8_t *data, unsigned length)
| Replaces the blob's data. More...
void | setLength (unsigned length)
| Change the size of the blob's data. More...
void | append (const uint8_t *newData, unsigned newDataLength)
| Adds data to the end of the blob.
void | clear ()
| Disposes of the data.
void | relinquish ()
| Tell the blob that it no longer owns its data.
void | setData (const uint8_t *data, unsigned length)
| Replaces the blob's data.
void | setLength (unsigned length)
| Change the size of the blob's data.
void | append (const uint8_t *newData, unsigned newDataLength)
| Adds data to the end of the blob.
void | clear ()
| Disposes of the data.
void | relinquish ()
| Tell the blob that it no longer owns its data.
Accessors
uint8_t * | getData ()
const uint8_t * | getData () const
unsigned | getLength () const
uint8_t * | getData ()
const uint8_t * | getData () const
unsigned | getLength () const
Operators
| operator uint8_t * ()
| operator const uint8_t * () const
| operator uint8_t * ()
| operator const uint8_t * () const

## Protected Attributes

uint8_t * | m_data
| The binary data held by this object.
unsigned | m_length
| Number of bytes pointed to by m_data.

## Detailed Description

Manages a binary object of arbitrary length.

The data block is allocated with malloc() instead of the new operator so that we can use realloc() to resize it.

## Constructor & Destructor Documentation

Blob::Blob | ( | const uint8_t * | data,
|  | unsigned | length
| ) |  |

Constructor.

Makes a local copy of the data argument.

Blob::Blob | ( | const Blob & | other | ) |

Copy constructor.

Makes a local copy of the data owned by other.

Blob::~Blob | ( |  | ) |

virtual

Destructor.

Disposes of the binary data associated with this object.

## Member Function Documentation

void Blob::setData | ( | const uint8_t * | data,
|  | unsigned | length
| ) |  |

Replaces the blob's data.

Copies data onto the blob's data. The blob does not assume ownership of data.

Parameters

  data | Pointer to a buffer containing the data which will be copied into the blob.
  length | Number of bytes pointed to by data.

void Blob::setLength | ( | unsigned | length | ) |

Change the size of the blob's data.

Sets the m_length member variable to length and resizes m_data to the new length. The contents of m_data past any previous contents are undefined. If the new length is 0 then the data will be freed and a subsequent call to getData() will return NULL.

Parameters

  length | New length of the blob's data in bytes.

The documentation for this class was generated from the following files:

- apps/elftosb/common/Blob.h
- apps/elftosb/common/Blob.cpp