AppEasy Core SDK  1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
CzDataOutput Class Reference

Provides stream write like access to a memory buffer. More...

#include <CzDataIO.h>

List of all members.

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.

Detailed Description

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

Constructor & Destructor Documentation

CzDataOutput::CzDataOutput ( bool  managed) [inline]
virtual CzDataOutput::~CzDataOutput ( ) [inline, virtual]

Member Function Documentation

Calculates the check sum of teh strean.

Returns:
The calculated check sum.
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

Parameters:
lengthThe stream length.
Returns:
true if it succeeds, false if it fails.
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.

Parameters:
dataThe data to write.
void CzDataOutput::set ( short  data)

Writes a short to the stream.

Parameters:
dataThe data to write.
void CzDataOutput::set ( int  data)

Writes an int to the stream.

Parameters:
dataThe data to write.
void CzDataOutput::set ( float  data)

Writes a float to the stream.

Parameters:
dataThe data to write.
void CzDataOutput::set ( char *  data,
int  count 
)

Writes a char buffer to the stream.

Parameters:
dataThe data to write.
countNumber of bytes to write.
void CzDataOutput::set ( short *  data,
int  count 
)

Writes a short buffer to the stream.

Parameters:
dataThe data to write.
countNumber of shorts to write.
void CzDataOutput::set ( int *  data,
int  count 
)

Writes an int buffer to the stream.

Parameters:
dataThe data to write.
countNumber of ints to write.
void CzDataOutput::set ( float *  data,
int  count 
)

Writes a float buffer to the stream.

Parameters:
dataThe data to write.
countNumber of floats to write.
void CzDataOutput::set ( CzString data)

Writes a string to the stream.

Parameters:
dataThe 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.

Parameters:
[in]dataIf 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.

Parameters:
[in]dataIf non-null, the data.
lengthThe length of the data.
void CzDataOutput::setManaged ( bool  managed) [inline]
int CzDataOutput::setPos ( int  pos)

Sets the stream position.

Parameters:
posPosition to set stream position to.
Returns:
Stream position.
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.

Parameters:
num_bytesNumber of bytes.
Returns:
Stream position.

Member Data Documentation

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.


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