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:

[legend]
List of all members.

## Public Methods

| SDDataChunk ()
| SDDataChunk (void *pData, size_t size)
| ~SDDataChunk ()
| Overloaded destructor.
uchar * | allocate (size_t size, const uchar *ptr=NULL)
| Allocates the passed number of bytes.
DataChunk & | clear ()
| Frees all internally allocated memory.
size_t | getSize () const
| Returns the size of the allocated chunk in bytes.
uchar * | getPtr ()
| Returns a pointer to the start of the memory.
const uchar * | getPtr () const
| Returns a const pointer to the start of the memory.
uchar * | getCurrentPtr ()
| Returns a pointer to the current position in memory.
const uchar * | getCurrentPtr () const
| Returns a const pointer to the current position in 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.
DataChunk & | seek (size_t pos)
| Repositions the internal read pointer to a specified byte.
DataChunk & | skip (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

uchar * | mData
uchar * | mPos
uchar * | mEnd
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::ILImageCodec::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(), Ogre::BspLevel::load(), and Ogre::HeightmapTerrainPageSource::loadHeightmap().

String Ogre::DataChunk::getAsString | ( | void |  | ) | const`[inherited]`

| Get the entire contents of the chunk as a string. Definition at line 196 of file OgreDataChunk.cpp. References Ogre::DataChunk::mData, Ogre::DataChunk::mSize, and Ogre::String. Referenced by Ogre::GpuProgram::load(), Ogre::D3D9GpuProgram::load(), and Ogre::HighLevelGpuProgram::loadHighLevelImpl().

const uchar* Ogre::DataChunk::getCurrentPtr | ( |  | ) | const`[inherited]`

| Returns a const pointer to the current position in memory.

const uchar * Ogre::DataChunk::getCurrentPtr | ( |  | ) | `[inherited]`

| Returns a pointer to the current position in memory. Definition at line 98 of file OgreDataChunk.cpp. References Ogre::DataChunk::mPos, and Ogre::uchar.

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 183 of file OgreDataChunk.cpp.

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

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 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::ILImageCodec::decode(), Ogre::Zip::fileRead(), Ogre::Quake3Level::initialise(), Ogre::Image::load(), Ogre::Image::loadRawData(), and Ogre::HeightmapTerrainPageSource::requestPage().

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::ILImageCodec::decode(), Ogre::HeightmapTerrainPageSource::loadHeightmap(), Ogre::Win32Window::writeContentsToFile(), Ogre::SDLWindow::writeContentsToFile(), and Ogre::GLXWindow::writeContentsToFile().

bool Ogre::DataChunk::isEOF | ( |  | ) | const`[inherited]`

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

Definition at line 174 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::readEdgeList(), Ogre::MeshSerializerImpl_v1_2::readGeometry(), Ogre::MeshSerializerImpl::readGeometry(), Ogre::MeshSerializerImpl::readGeometryVertexDeclaration(), Ogre::MeshSerializerImpl::readMesh(), 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 110 of file OgreDataChunk.cpp.

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

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

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 143 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 125 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 133 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::readEdgeList(), Ogre::MeshSerializerImpl_v1_2::readGeometry(), Ogre::MeshSerializerImpl::readGeometry(), Ogre::MeshSerializerImpl::readGeometryVertexDeclaration(), Ogre::MeshSerializerImpl::readMesh(), 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 161 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::getCurrentPtr(), 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:

- OgreSDDataChunk.h
- OgreSDDataChunk.cpp

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:51:37 2004