![]() |
AppEasy Core SDK
1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
|
Provides stream write like access to a memory buffer. More...
#include <CzDataIO.h>
Public Member Functions | |
CzDataOutput (bool managed) | |
CzDataOutput () | |
virtual | ~CzDataOutput () |
bool | Init (int length) |
Initialises the stream object. | |
virtual void | Release () |
Releases the stream object. | |
char * | getData () |
void | setData (char *data) |
Sets the stream data. | |
void | setData (char *data, int length) |
Sets the stream data and its length. | |
void | setManaged (bool managed) |
bool | isManaged () const |
int | Skip (int num_bytes) |
Moves the stream pointer back and forth. | |
int | setPos (int pos) |
Sets the stream position. | |
int | getPos () const |
int | getLength () const |
bool | isEOF () const |
int | Remaining () const |
void | set (char data) |
Writes a char to the stream. | |
void | set (short data) |
Writes a short to the stream. | |
void | set (int data) |
Writes an int to the stream. | |
void | set (float data) |
Writes a float to the stream. | |
void | set (char *data, int count) |
Writes a char buffer to the stream. | |
void | set (short *data, int count) |
Writes a short buffer to the stream. | |
void | set (int *data, int count) |
Writes an int buffer to the stream. | |
void | set (float *data, int count) |
Writes a float buffer to the stream. | |
void | set (CzString *pString) |
Writes a string to the stream. | |
int | CalculateCheckSum () |
Calculates the check sum of teh strean. | |
Protected Attributes | |
char * | Data |
Streams data. | |
int | Position |
Current position in stream. | |
int | Length |
Length of stream (actual allocated memory sie is aligned to 32 bytes) | |
bool | EndOfFile |
true if end of stream reached | |
bool | Managed |
If true data buffer will not be released when object deleted. |
Provides stream write like access to a memory buffer.
Lets take a look at an example showing how to use this class:
// Create and initialise an input stream of 1024 bytes CzDataOutput *stream = new CzDataOutput(); stream->Init(1024); // Write some data into the stream stream->set('a'); // Write a character stream->set(10); // Write an integer stream->set(1.2f); // Write a floating point value stream->set("Hello", 5); // Write some text
CzDataOutput::CzDataOutput | ( | bool | managed | ) | [inline] |
CzDataOutput::CzDataOutput | ( | ) | [inline] |
virtual CzDataOutput::~CzDataOutput | ( | ) | [inline, virtual] |
int CzDataOutput::CalculateCheckSum | ( | ) |
Calculates the check sum of teh strean.
char* CzDataOutput::getData | ( | ) | [inline] |
int CzDataOutput::getLength | ( | ) | const [inline] |
int CzDataOutput::getPos | ( | ) | const [inline] |
bool CzDataOutput::Init | ( | int | length | ) |
Initialises the stream object.
Allocates a memory buffer of the specified length and sets the stream market to the start
length | The stream length. |
bool CzDataOutput::isEOF | ( | ) | const [inline] |
bool CzDataOutput::isManaged | ( | ) | const [inline] |
void CzDataOutput::Release | ( | ) | [virtual] |
Releases the stream object.
Deletes the memory associated with the stream
int CzDataOutput::Remaining | ( | ) | const [inline] |
void CzDataOutput::set | ( | char | data | ) |
Writes a char to the stream.
data | The data to write. |
void CzDataOutput::set | ( | short | data | ) |
Writes a short to the stream.
data | The data to write. |
void CzDataOutput::set | ( | int | data | ) |
Writes an int to the stream.
data | The data to write. |
void CzDataOutput::set | ( | float | data | ) |
Writes a float to the stream.
data | The data to write. |
void CzDataOutput::set | ( | char * | data, |
int | count | ||
) |
Writes a char buffer to the stream.
data | The data to write. |
count | Number of bytes to write. |
void CzDataOutput::set | ( | short * | data, |
int | count | ||
) |
Writes a short buffer to the stream.
data | The data to write. |
count | Number of shorts to write. |
void CzDataOutput::set | ( | int * | data, |
int | count | ||
) |
Writes an int buffer to the stream.
data | The data to write. |
count | Number of ints to write. |
void CzDataOutput::set | ( | float * | data, |
int | count | ||
) |
Writes a float buffer to the stream.
data | The data to write. |
count | Number of floats to write. |
void CzDataOutput::set | ( | CzString * | data | ) |
Writes a string to the stream.
data | The string to write. |
void CzDataOutput::setData | ( | char * | data | ) |
Sets the stream data.
Sets the data stream, taking ownership of the supplied data. If the stream already has data assigned then it will be deleted.
[in] | data | If non-null, the data stream. |
void CzDataOutput::setData | ( | char * | data, |
int | length | ||
) |
Sets the stream data and its length.
Sets the data stream, taking ownership of the supplied data. The length of the stream is also set to the supplied length. If the stream already has data assigned then it will be deleted.
[in] | data | If non-null, the data. |
length | The length of the data. |
void CzDataOutput::setManaged | ( | bool | managed | ) | [inline] |
int CzDataOutput::setPos | ( | int | pos | ) |
Sets the stream position.
pos | Position to set stream position to. |
int CzDataOutput::Skip | ( | int | num_bytes | ) |
Moves the stream pointer back and forth.
Skips te supplied number of bytes in the stream, num_bytes can be negative. Attempted to skip past the start or end of teh stream will cause EOF.
num_bytes | Number of bytes. |
char* CzDataOutput::Data [protected] |
Streams data.
bool CzDataOutput::EndOfFile [protected] |
true if end of stream reached
int CzDataOutput::Length [protected] |
Length of stream (actual allocated memory sie is aligned to 32 bytes)
bool CzDataOutput::Managed [protected] |
If true data buffer will not be released when object deleted.
int CzDataOutput::Position [protected] |
Current position in stream.