decDataChunk Class Reference

Manages a chunk of data in memory. More...

#include <decDataChunk.h>

List of all members.

Public Member Functions

Constructors and Destructors
 decDataChunk ()
 Creates an empty data chunk object.
 ~decDataChunk ()
 Cleans up data chunk object.
Accessors
char * GetData () const
 Retrieves pointer to start of data.
int GetSize () const
 Retrieves the size of the entire data buffer.
int GetUsed () const
 Retrieves the real size used by the data.
int GetPosition () const
 Retrieves the read/write position.
Management
void Clear (int used)
 Clears the data buffer resetting the used size to 0.
void SetPosition (int pos)
 Sets the read/write position from the start of the buffer.
void MovePosition (int offset)
 Moves the read/write position by the given offset.
void GrowTo (int size)
 Grows the capacity of the data chunk to the given size.
Reading
void Read (void *buffer, int size)
 Reads 'size' bytes into 'buffer' and advances the file pointer.
char ReadChar ()
 Reads one byte ( 1 byte ) and advances the file pointer.
unsigned char ReadByte ()
 Reads one unsigned byte ( 1 byte ) and advances the file pointer.
short ReadShort ()
 Reads one short ( 2 bytes ) and advances the file pointer.
unsigned short ReadUShort ()
 Reads one unsigned short ( 2 bytes ) and advances the file pointer.
int ReadInt ()
 Reads one int ( 4 bytes ) and advances the file pointer.
unsigned int ReadUInt ()
 Reads one unsigned int ( 4 bytes ) and advances the file pointer.
float ReadFloat ()
 Reads one float ( 4 bytes ) and advances the file pointer.
const char * ReadString8 ()
 Reads a string prefixed by a 1-byte length field and advances the file pointer.
const char * ReadString16 ()
 Reads a string prefixed by a 2-byte2 length field and advances the file pointer.
decVector ReadVector ()
 Reads a 3-float vector and advances the file pointer.
decTexel ReadTexel ()
 Reads a 2-float texture position and advances the file pointer.
void SkipString8 ()
 Skips a string prefixed by a 1-byte length field and advances the file pointer.
void SkipString16 ()
 Skips a string prefixed by a 2-byte2 length field and advances the file pointer.
Writing
void Write (void *buffer, int size)
 Writes 'size' bytes of 'buffer' to file and advances write pointer.
void WriteChar (char Value)
 Writes one byte ( 1 byte ) to file and advances write pointer.
void WriteByte (unsigned char Value)
 Writes one unsigned byte ( 1 byte ) to file and advances write pointer.
void WriteShort (short Value)
 Writes one short ( 2 bytes ) to file and advances write pointer.
void WriteUShort (unsigned short Value)
 Writes one unsigned short ( 2 bytes ) to file and advances write pointer.
void WriteInt (int Value)
 Writes one int ( 4 bytes ) to file and advances write pointer.
void WriteUInt (unsigned int Value)
 Writes one unsigned int ( 4 bytes ) to file and advances write pointer.
void WriteFloat (float Value)
 Writes one float ( 4 bytes ) to file and advances write pointer.
void WriteString8 (const char *String)
 Writes string-length bytes of string to file with a 1-byte length field in front and advances write pointer.
void WriteString16 (const char *String)
 Writes string-length bytes of string to file with a 2-byte length field in front and advances write pointer.
void WriteVector (const decVector &v)
 Writes a 3-float vector to the file ( order x, y, z ) and advances write pointer.
void WriteTexel (const decTexel &t)
 Writes a 2-float texture position to the file ( order u, v ) and advances write pointer.

Detailed Description

Manages a chunk of data in memory.

Author:
Plüss Roland
Version:
1.0
Date:
2008

Constructor & Destructor Documentation

decDataChunk::decDataChunk (  )

Creates an empty data chunk object.

decDataChunk::~decDataChunk (  )

Cleans up data chunk object.


Member Function Documentation

void decDataChunk::Clear ( int  used )

Clears the data buffer resetting the used size to 0.

char* decDataChunk::GetData (  ) const [inline]

Retrieves pointer to start of data.

int decDataChunk::GetPosition (  ) const [inline]

Retrieves the read/write position.

int decDataChunk::GetSize (  ) const [inline]

Retrieves the size of the entire data buffer.

int decDataChunk::GetUsed (  ) const [inline]

Retrieves the real size used by the data.

void decDataChunk::GrowTo ( int  size )

Grows the capacity of the data chunk to the given size.

void decDataChunk::MovePosition ( int  offset )

Moves the read/write position by the given offset.

void decDataChunk::Read ( void *  buffer,
int  size 
)

Reads 'size' bytes into 'buffer' and advances the file pointer.

unsigned char decDataChunk::ReadByte (  )

Reads one unsigned byte ( 1 byte ) and advances the file pointer.

char decDataChunk::ReadChar (  )

Reads one byte ( 1 byte ) and advances the file pointer.

float decDataChunk::ReadFloat (  )

Reads one float ( 4 bytes ) and advances the file pointer.

int decDataChunk::ReadInt (  )

Reads one int ( 4 bytes ) and advances the file pointer.

short decDataChunk::ReadShort (  )

Reads one short ( 2 bytes ) and advances the file pointer.

const char* decDataChunk::ReadString16 (  )

Reads a string prefixed by a 2-byte2 length field and advances the file pointer.

The returned string pointer has to be freed by the caller itself. The next time a ReadString8 or ReadString16 function is called the returned string is reused hence copy away the string right after.

const char* decDataChunk::ReadString8 (  )

Reads a string prefixed by a 1-byte length field and advances the file pointer.

The returned string pointer has not to be freed by the caller itself. The next time a ReadString8 or ReadString16 function is called the returned string is reused hence copy away the string right after.

decTexel decDataChunk::ReadTexel (  )

Reads a 2-float texture position and advances the file pointer.

The texture position components are read in the order u and v.

unsigned int decDataChunk::ReadUInt (  )

Reads one unsigned int ( 4 bytes ) and advances the file pointer.

unsigned short decDataChunk::ReadUShort (  )

Reads one unsigned short ( 2 bytes ) and advances the file pointer.

decVector decDataChunk::ReadVector (  )

Reads a 3-float vector and advances the file pointer.

The vector components are read in the order x, y and z.

void decDataChunk::SetPosition ( int  pos )

Sets the read/write position from the start of the buffer.

void decDataChunk::SkipString16 (  )

Skips a string prefixed by a 2-byte2 length field and advances the file pointer.

void decDataChunk::SkipString8 (  )

Skips a string prefixed by a 1-byte length field and advances the file pointer.

void decDataChunk::Write ( void *  buffer,
int  size 
)

Writes 'size' bytes of 'buffer' to file and advances write pointer.

void decDataChunk::WriteByte ( unsigned char  Value )

Writes one unsigned byte ( 1 byte ) to file and advances write pointer.

void decDataChunk::WriteChar ( char  Value )

Writes one byte ( 1 byte ) to file and advances write pointer.

void decDataChunk::WriteFloat ( float  Value )

Writes one float ( 4 bytes ) to file and advances write pointer.

void decDataChunk::WriteInt ( int  Value )

Writes one int ( 4 bytes ) to file and advances write pointer.

void decDataChunk::WriteShort ( short  Value )

Writes one short ( 2 bytes ) to file and advances write pointer.

void decDataChunk::WriteString16 ( const char *  String )

Writes string-length bytes of string to file with a 2-byte length field in front and advances write pointer.

void decDataChunk::WriteString8 ( const char *  String )

Writes string-length bytes of string to file with a 1-byte length field in front and advances write pointer.

void decDataChunk::WriteTexel ( const decTexel t )

Writes a 2-float texture position to the file ( order u, v ) and advances write pointer.

void decDataChunk::WriteUInt ( unsigned int  Value )

Writes one unsigned int ( 4 bytes ) to file and advances write pointer.

void decDataChunk::WriteUShort ( unsigned short  Value )

Writes one unsigned short ( 2 bytes ) to file and advances write pointer.

void decDataChunk::WriteVector ( const decVector v )

Writes a 3-float vector to the file ( order x, y, z ) and advances write pointer.


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