Phoenard
Public Member Functions | Public Attributes | List of all members
DataBuffer Class Reference

Maintains data stored on the heap and frees it when the class is destructed. More...

#include <DataBuffer.h>

Inheritance diagram for DataBuffer:
PHN_TextContainer

Public Member Functions

 DataBuffer ()
 Creates a new buffer without any data.
 
 DataBuffer (const void *data, int dataSize)
 Creates a new buffer, copying the initial data into the buffer.
 
 ~DataBuffer ()
 Destructor frees the memory.
 
void resize (int newDataSize)
 Resizes the buffer preserving contents to newDataSize, shrinking if needed.
 
void growToFit (int newDataSize)
 Resizes the buffer preserving contents to fit newDataSize.
 
void set (const void *data, int dataSize)
 Sets new data to be stored, the data is copied into this buffer.
 
DataBufferoperator= (const DataBuffer &other)
 Assigns data from one buffer to another.
 
virtual const char * text ()
 Gets the text displayed.
 
virtual void setTextRaw (const char *text, int textLen)
 Sets the new text to display using a buffer and length.
 
- Public Member Functions inherited from PHN_TextContainer
void setText (String textString)
 Sets the new text to display using an Arduino type String.
 
void setText (int valueText)
 Sets the new text to display using an integer value.
 
void setText (long valueText)
 Sets the new text to display using a long value.
 
void setText (double valueText)
 Sets the new text to display using a float value.
 
void setText (const char *text)
 Sets the new text to display using a null-terminated String.
 
void clearText ()
 Clears all the text, setting it to an Empty String.
 
virtual int textLength ()
 Gets the length of the text displayed.
 

Public Attributes

void * data
 
int dataSize
 

Detailed Description

Maintains data stored on the heap and frees it when the class is destructed.

The problem of storing arrays as containers is that they are fixed-size, and with heap memory the size and freeing all has to be maintained. That is what this class solves. Memory can be easily allocated/resized and destroyed as the class is used.


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