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:

Inheritance graph
[legend]
List of all members.

Public Methods

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

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

DataChunkclear ()
 Frees all internally allocated memory.

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

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

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

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

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

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

size_t 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.

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

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

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

String getAsString (void) const
 Get the entire contents of the chunk as a string.


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).

Definition at line 44 of file OgreSDDataChunk.h.


Constructor & Destructor Documentation

Ogre::SDDataChunk::SDDataChunk  
 

Definition at line 30 of file OgreSDDataChunk.cpp.

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

Definition at line 35 of file OgreSDDataChunk.cpp.

Ogre::SDDataChunk::~SDDataChunk  
 

Overloaded destructor.

Note:
Deletes the allocated chunk

Definition at line 40 of file OgreSDDataChunk.cpp.

References Ogre::DataChunk::mData.


Member Function Documentation

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

Allocates the passed number of bytes.

Definition at line 46 of file OgreDataChunk.cpp.

References Ogre::DataChunk::mData, Ogre::DataChunk::mEnd, Ogre::DataChunk::mPos, Ogre::DataChunk::mSize, and Ogre::uchar.

Referenced by Ogre::TGACodec::decode(), Ogre::ILImageCodec::decode(), Ogre::DDSCodec::decode(), Ogre::BMPCodec::decode(), and Ogre::Zip::fileRead().

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

Frees all internally allocated memory.

Definition at line 69 of file OgreDataChunk.cpp.

References Ogre::DataChunk::mData, and Ogre::DataChunk::mSize.

Referenced by Ogre::Skeleton::load(), Ogre::Mesh::load(), and Ogre::BspLevel::load().

String Ogre::DataChunk::getAsString void    const [inherited]
 

Get the entire contents of the chunk as a string.

Definition at line 185 of file OgreDataChunk.cpp.

References Ogre::DataChunk::mData, and Ogre::DataChunk::mSize.

Referenced by Ogre::GpuProgram::load(), Ogre::D3D9GpuProgram::load(), and Ogre::HighLevelGpuProgram::loadHighLevelImpl().

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))

Definition at line 172 of file OgreDataChunk.cpp.

References Ogre::DataChunk::readUpTo(), and Ogre::String::trim().

Referenced by Ogre::ParticleSystemManager::parseNewAffector(), Ogre::OverlayManager::parseNewElement(), Ogre::ParticleSystemManager::parseNewEmitter(), Ogre::OverlayManager::parseNewMesh(), Ogre::Quake3ShaderManager::parseNewShaderPass(), Ogre::OverlayManager::parseOverlayFile(), Ogre::ParticleSystemManager::parseScript(), Ogre::MaterialSerializer::parseScript(), Ogre::FontManager::parseScript(), Ogre::Quake3ShaderManager::parseShaderFile(), Ogre::ParticleSystemManager::skipToNextCloseBrace(), Ogre::OverlayManager::skipToNextCloseBrace(), Ogre::ParticleSystemManager::skipToNextOpenBrace(), and Ogre::OverlayManager::skipToNextOpenBrace().

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.

Definition at line 87 of file OgreDataChunk.cpp.

References Ogre::DataChunk::mData, and Ogre::uchar.

Referenced by Ogre::D3D9Texture::_loadCubeTex(), Ogre::D3D9Texture::_loadNormTex(), Ogre::D3D9Texture::_loadVolumeTex(), Ogre::Font::createTextureFromFont(), Ogre::TGACodec::decode(), Ogre::ILImageCodec::decode(), Ogre::DDSCodec::decode(), Ogre::BMPCodec::decode(), Ogre::Zip::fileRead(), Ogre::Quake3Level::initialise(), Ogre::Image::load(), and Ogre::Image::loadRawData().

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

Returns the size of the allocated chunk in bytes.

Definition at line 81 of file OgreDataChunk.cpp.

References Ogre::DataChunk::mSize.

Referenced by Ogre::D3D9Texture::_loadCubeTex(), Ogre::D3D9Texture::_loadNormTex(), Ogre::D3D9Texture::_loadVolumeTex(), Ogre::Font::createTextureFromFont(), Ogre::TGACodec::decode(), Ogre::ILImageCodec::decode(), Ogre::DDSCodec::decode(), Ogre::BMPCodec::decode(), Ogre::Win32Window::writeContentsToFile(), and Ogre::SDLWindow::writeContentsToFile().

bool Ogre::DataChunk::isEOF   const [inherited]
 

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

Definition at line 163 of file OgreDataChunk.cpp.

References Ogre::DataChunk::mEnd, and Ogre::DataChunk::mPos.

Referenced by Ogre::MeshSerializerImpl::importMesh(), Ogre::SkeletonSerializer::importSkeleton(), Ogre::ParticleSystemManager::parseNewAffector(), Ogre::OverlayManager::parseNewElement(), Ogre::ParticleSystemManager::parseNewEmitter(), Ogre::OverlayManager::parseNewMesh(), Ogre::Quake3ShaderManager::parseNewShaderPass(), Ogre::OverlayManager::parseOverlayFile(), Ogre::ParticleSystemManager::parseScript(), Ogre::MaterialSerializer::parseScript(), Ogre::FontManager::parseScript(), Ogre::Quake3ShaderManager::parseShaderFile(), Ogre::SkeletonSerializer::readAnimation(), Ogre::SkeletonSerializer::readAnimationTrack(), Ogre::MeshSerializerImpl_v1::readGeometry(), Ogre::MeshSerializerImpl::readGeometry(), Ogre::MeshSerializerImpl_v1::readMaterial(), Ogre::MeshSerializerImpl_v1::readMesh(), Ogre::MeshSerializerImpl::readMesh(), Ogre::MeshSerializerImpl_v1::readSubMesh(), Ogre::MeshSerializerImpl::readSubMesh(), Ogre::MeshSerializerImpl::readSubMeshNameTable(), Ogre::ParticleSystemManager::skipToNextCloseBrace(), Ogre::OverlayManager::skipToNextCloseBrace(), Ogre::ParticleSystemManager::skipToNextOpenBrace(), and Ogre::OverlayManager::skipToNextOpenBrace().

size_t Ogre::DataChunk::read void *    buffer,
size_t    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

Definition at line 99 of file OgreDataChunk.cpp.

References Ogre::DataChunk::mEnd, and Ogre::DataChunk::mPos.

Referenced by Ogre::Serializer::readBools(), Ogre::Serializer::readInts(), Ogre::Serializer::readLongs(), Ogre::Serializer::readReals(), and Ogre::Serializer::readShorts().

size_t 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.

Definition at line 132 of file OgreDataChunk.cpp.

References Ogre::DataChunk::mEnd, and Ogre::DataChunk::mPos.

Referenced by Ogre::DataChunk::getLine(), Ogre::Quake3ShaderManager::parseShaderFile(), and Ogre::Serializer::readString().

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

Repositions the internal read pointer to a specified byte.

Definition at line 114 of file OgreDataChunk.cpp.

References Ogre::DataChunk::mData, Ogre::DataChunk::mPos, and Ogre::DataChunk::mSize.

Referenced by Ogre::MeshSerializer::importMesh().

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.

Definition at line 122 of file OgreDataChunk.cpp.

References Ogre::DataChunk::mData, Ogre::DataChunk::mEnd, and Ogre::DataChunk::mPos.

Referenced by Ogre::SkeletonSerializer::readAnimation(), Ogre::SkeletonSerializer::readAnimationTrack(), Ogre::MeshSerializerImpl_v1::readGeometry(), Ogre::MeshSerializerImpl::readGeometry(), Ogre::MeshSerializerImpl_v1::readMaterial(), Ogre::MeshSerializerImpl_v1::readMesh(), Ogre::MeshSerializerImpl::readMesh(), Ogre::MeshSerializerImpl_v1::readSubMesh(), Ogre::MeshSerializerImpl::readSubMesh(), and Ogre::MeshSerializerImpl::readSubMeshNameTable().

size_t 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.

Definition at line 150 of file OgreDataChunk.cpp.

References Ogre::DataChunk::mEnd, and Ogre::DataChunk::mPos.

Referenced by Ogre::FontManager::parseScript().


Member Data Documentation

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

Definition at line 56 of file OgreDataChunk.h.

Referenced by Ogre::DataChunk::allocate(), Ogre::DataChunk::clear(), Ogre::DataChunk::DataChunk(), Ogre::DataChunk::getAsString(), Ogre::DataChunk::getPtr(), Ogre::DataChunk::seek(), Ogre::DataChunk::skip(), and ~SDDataChunk().

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

Definition at line 58 of file OgreDataChunk.h.

Referenced by Ogre::DataChunk::allocate(), Ogre::DataChunk::DataChunk(), Ogre::DataChunk::isEOF(), Ogre::DataChunk::read(), Ogre::DataChunk::readUpTo(), Ogre::DataChunk::skip(), and Ogre::DataChunk::skipUpTo().

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

Definition at line 57 of file OgreDataChunk.h.

Referenced by Ogre::DataChunk::allocate(), Ogre::DataChunk::DataChunk(), Ogre::DataChunk::isEOF(), Ogre::DataChunk::read(), Ogre::DataChunk::readUpTo(), Ogre::DataChunk::seek(), Ogre::DataChunk::skip(), and Ogre::DataChunk::skipUpTo().

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

Definition at line 59 of file OgreDataChunk.h.

Referenced by Ogre::DataChunk::allocate(), Ogre::DataChunk::clear(), Ogre::DataChunk::DataChunk(), Ogre::DataChunk::getAsString(), Ogre::DataChunk::getSize(), and Ogre::DataChunk::seek().


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

Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:27:13 2004