Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Ogre::SDDataChunk Class Reference

Wraps a chunk of memory, storing both size and a pointer to the data. More...

#include <OgreSDDataChunk.h>

Inheritance diagram for Ogre::SDDataChunk:

Ogre::DataChunk List of all members.

Public Methods

 SDDataChunk ()
 SDDataChunk (void *pData, size_t size)
 ~SDDataChunk ()
 Overloaded destructor. More...

ucharallocate (size_t size, const uchar *ptr=NULL)
 Allocates the passed number of bytes. More...

DataChunkclear ()
 Frees all internally allocated memory. More...

size_t getSize () const
 Returns the size of the allocated chunk in bytes. More...

uchargetPtr ()
 Returns a const pointer to the start of the memory. More...

const uchargetPtr () const
 Returns a const pointer to the start of the memory. More...

ulong read (void *buffer, unsigned long size)
 Reads memory from the main buffer into another, incrementing an internal 'current' pointer to allow progressive reads. More...

DataChunkseek (size_t pos)
 Repositions the internal read pointer to a specified byte. More...

DataChunkskip (long offset)
 Moves the internal read pointer backwards or forwards by the number of bytes specified. More...

unsigned long readUpTo (void *buffer, size_t size, const char *delim="\n")
 Reads data into the provided buffer until hitting the specified character or reaching the upper limit provided. More...

unsigned long skipUpTo (const char *delim)
 Skips data into the provided buffer until hitting the specified character or reaching the end of the data. More...

bool isEOF ()
 Returns true if the buffer pointer has reached the end of the buffer. More...

String getLine (bool trimAfter=true)
 Returns a String containing the next line of data, optionally trimmed for whitespace. More...


Protected Attributes

ucharmData
ucharmPos
ucharmEnd
size_t mSize

Detailed Description

Wraps a chunk of memory, storing both size and a pointer to the data.

Remarks:
This class simply wraps a chunk of memory. It provides extra info about the size of the data contained within it, simple allocation and free methods, and simple stream-like 'read' methods for parsing through the memory chunk rather like a file.

This class contains all the functionality of the DataChunk superclass, only that when an object of this class gets deleted, it also deletes the allocated memory (SD stands for Self-Delete).


Constructor & Destructor Documentation

Ogre::SDDataChunk::SDDataChunk  
 

Ogre::SDDataChunk::SDDataChunk void *    pData,
size_t    size
 

Ogre::SDDataChunk::~SDDataChunk  
 

Overloaded destructor.

Note:
Deletes the allocated chunk


Member Function Documentation

uchar * Ogre::DataChunk::allocate size_t    size,
const uchar   ptr = NULL
[inherited]
 

Allocates the passed number of bytes.

DataChunk & Ogre::DataChunk::clear   [inherited]
 

Frees all internally allocated memory.

String Ogre::DataChunk::getLine bool    trimAfter = true [inherited]
 

Returns a String containing the next line of data, optionally trimmed for whitespace.

Remarks:
This is a convenience method for text chunks only, allowing you to retrieve a String object containing the next line of data. The data is read up to the next newline character and the result trimmed if required.
Parameters:
trimAfter  If true, the line is trimmed for whitespace (as in String.trim(true,true))

const uchar* Ogre::DataChunk::getPtr   const [inherited]
 

Returns a const pointer to the start of the memory.

const uchar * Ogre::DataChunk::getPtr   [inherited]
 

Returns a const pointer to the start of the memory.

size_t Ogre::DataChunk::getSize   const [inherited]
 

Returns the size of the allocated chunk in bytes.

bool Ogre::DataChunk::isEOF   [inherited]
 

Returns true if the buffer pointer has reached the end of the buffer.

ulong Ogre::DataChunk::read void *    buffer,
unsigned long    size
[inherited]
 

Reads memory from the main buffer into another, incrementing an internal 'current' pointer to allow progressive reads.

Parameters:
buffer  Pointer to buffer to read into
size  Number of bytes to read
Returns:
The number of bytes actually read

ulong Ogre::DataChunk::readUpTo void *    buffer,
size_t    size,
const char *    delim = "\n"
[inherited]
 

Reads data into the provided buffer until hitting the specified character or reaching the upper limit provided.

Remarks:
The terminating character is not included in the data returned, and it is skipped over so the next read will occur after it.
Parameters:
buffer  Pointer to buffer to read into
size  Size of the buffer i.e. max bytes to read
delim  List of delimiters to read up to (default newline)
Returns:
The actual number of characters copied into the buffer.

DataChunk & Ogre::DataChunk::seek size_t    pos [inherited]
 

Repositions the internal read pointer to a specified byte.

DataChunk & Ogre::DataChunk::skip long    offset [inherited]
 

Moves the internal read pointer backwards or forwards by the number of bytes specified.

Remarks:
The sign of the parameter determines the direction of the skip.

ulong Ogre::DataChunk::skipUpTo const char *    delim [inherited]
 

Skips data into the provided buffer until hitting the specified character or reaching the end of the data.

Remarks:
The terminating characters is not included in the data returned, and it is skipped over so the next read will occur after it.
Parameters:
delim  List of delimiters to skip up to.
Returns:
The number of characters that were skipped.


Member Data Documentation

uchar* Ogre::DataChunk::mData [protected, inherited]
 

uchar* Ogre::DataChunk::mEnd [protected, inherited]
 

uchar* Ogre::DataChunk::mPos [protected, inherited]
 

size_t Ogre::DataChunk::mSize [protected, inherited]
 

Copyright © 2002 by The OGRE Team