Go to the documentation of this file.
28 #ifndef __StreamSerialiser_H__
29 #define __StreamSerialiser_H__
102 Chunk() : id(0), version(1), length(0), offset(0) {}
123 bool autoHeader =
true,
259 virtual void writeData(
const void* buf,
size_t size,
size_t count);
262 template <
typename T>
263 void write(
const T* pT,
size_t count = 1)
265 writeData(pT,
sizeof(T), count);
281 virtual void write(
const Ray* ray,
size_t count = 1);
284 virtual void write(
const bool*
boolean,
size_t count = 1);
293 virtual void readData(
void* buf,
size_t size,
size_t count);
296 template <
typename T>
297 void read(T* pT,
size_t count = 1)
299 readData(pT,
sizeof(T), count);
316 virtual void read(
Ray* ray,
size_t count = 1);
319 virtual void read(
bool* val,
size_t count = 1);
349 bool validateReadable =
false,
bool validateWriteable =
false)
const;
351 virtual void flipEndian(
void * pData,
size_t size,
size_t count);
360 template <
typename T,
typename U>
366 for (
size_t i = 0; i < count; ++i)
367 *pDst++ =
static_cast<U
>(*pSrc++);
369 writeData(tmp,
sizeof(U), count);
373 template <
typename T,
typename U>
377 readData(tmp,
sizeof(U), count);
381 for (
size_t i = 0; i < count; ++i)
382 *pDst++ =
static_cast<T
>(*pSrc++);
virtual bool eof() const
Reports whether the stream is at the end of file.
virtual ~StreamSerialiser()
virtual void write(const Radian *angle, size_t count=1)
size_t getOffsetFromChunkStart() const
Get the current byte position relative to the start of the data section of the last chunk that was re...
RealStorageFormat mRealFormat
virtual void readData(void *buf, size_t size, size_t count)
Read arbitrary data from a stream.
virtual void write(const Sphere *sphere, size_t count=1)
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
ChunkStack mChunkStack
Current list of open chunks.
Defines a plane in 3D space.
virtual void write(const Vector4 *vec, size_t count=1)
virtual void stopDeflate()
Stop (un)compressing data.
virtual void writeHeader()
virtual void startDeflate(size_t avail_in=0)
Start (un)compressing data.
virtual void checkStream(bool failOnEof=false, bool validateReadable=false, bool validateWriteable=false) const
void readConverted(T *dst, U typeToRead, size_t count)
virtual void write(const Ray *ray, size_t count=1)
virtual void read(Sphere *sphere, size_t count=1)
RealStorageFormat
The storage format of Real values.
#define OGRE_FREE(ptr, category)
Free the memory allocated with OGRE_MALLOC or OGRE_ALLOC_T. Category is required to be restated to en...
virtual void readFloatsAsDoubles(double *val, size_t count)
virtual void writeChunkImpl(uint32 id, uint16 version)
virtual void read(Quaternion *q, size_t count=1)
virtual void write(const Real *val, size_t count=1)
virtual void read(AxisAlignedBox *aabb, size_t count=1)
void read(T *pT, size_t count=1)
Catch-all method to read primitive types.
virtual void read(Node *node, size_t count=1)
A 3x3 matrix which can represent rotations around axes.
virtual const Chunk * getCurrentChunk() const
Get the definition of the current chunk being read (if any).
virtual void writeChunkBegin(uint32 id, uint16 version=1)
Begin writing a new chunk.
virtual void readHeader()
#define OGRE_ALLOC_T(T, count, category)
Allocate a block of memory for a primitive type, and indicate the category of usage.
uint32 getCurrentChunkID() const
Get the ID of the chunk that's currently being read/written, if any.
virtual bool isEndOfChunk(uint32 id)
Return whether the current data pointer is at the end of the current chunk.
virtual void write(const Vector2 *vec, size_t count=1)
virtual void read(Real *val, size_t count=1)
DataStreamPtr mOriginalStream
Implementation of a Quaternion, i.e.
uint16 version
Version of the chunk (stored)
virtual void read(Vector4 *vec, size_t count=1)
virtual void write(const Node *node, size_t count=1)
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
@ ENDIAN_BIG
Use big endian (0x1000 is serialised as 0x10 0x00)
static uint32 makeIdentifier(const String &code)
Pack a 4-character code into a 32-bit identifier.
Class encapsulating a standard 4x4 homogeneous matrix.
virtual Chunk * popChunk(uint id)
uint32 offset
Location of the chunk (header) in bytes from the start of a stream (derived)
virtual uint32 peekNextChunkID()
Call this to 'peek' at the next chunk ID without permanently moving the stream pointer.
virtual void flipEndian(void *pData, size_t size)
virtual void read(Matrix4 *m, size_t count=1)
Wrapper class which indicates a given angle value is in Radians.
void writeConverted(const T *src, U typeToWrite, size_t count)
virtual void read(Vector2 *vec, size_t count=1)
read a Vector3
A 3D box aligned with the x/y/z axes.
StreamSerialiser(const DataStreamPtr &stream, Endian endianMode=ENDIAN_AUTO, bool autoHeader=true, RealStorageFormat realFormat=REAL_FLOAT)
Constructor.
uint32 id
Identifier of the chunk (for example from makeIdentifier) (stored)
virtual void write(const String *string)
virtual void read(Vector3 *vec, size_t count=1)
@ MEMCATEGORY_GENERAL
General purpose.
A sphere primitive, mostly used for bounds checking.
size_t getCurrentChunkDepth() const
Report the current depth of the chunk nesting, whether reading or writing.
void write(const T *pT, size_t count=1)
Catch-all method to write primitive types.
Definition of a chunk of data in a file.
static uint32 CHUNK_HEADER_SIZE
static uint32 REVERSE_HEADER_ID
Utility class providing helper methods for reading / writing structured data held in a DataStream.
virtual void read(Plane *plane, size_t count=1)
deque< Chunk * >::type ChunkStack
virtual void write(const Matrix4 *m, size_t count=1)
virtual void writeChunkEnd(uint32 id)
End writing a chunk.
virtual void writeDoublesAsFloats(const double *val, size_t count)
Endian
The endianness of files.
virtual void undoReadChunk(uint32 id)
Call this to 'rewind' the stream to just before the start of the current chunk.
4-dimensional homogeneous vector.
virtual void read(Matrix3 *m, size_t count=1)
virtual void write(const AxisAlignedBox *aabb, size_t count=1)
virtual void flipEndian(void *pData, size_t size, size_t count)
virtual void determineEndianness()
#define OGRE_DOUBLE_PRECISION
If set to 1, Real is typedef'ed to double.
Standard 2-dimensional vector.
virtual void writeFloatsAsDoubles(const float *val, size_t count)
virtual void write(const Vector3 *vec, size_t count=1)
virtual void readDoublesAsFloats(float *val, size_t count)
@ ENDIAN_AUTO
Automatically determine endianness.
uint32 length
Length of the chunk data in bytes, excluding the header of this chunk (stored)
float Real
Software floating point type.
virtual uint32 calculateChecksum(Chunk *c)
virtual const Chunk * readChunkBegin()
Reads the start of the next chunk in the file.
virtual void write(const Quaternion *q, size_t count=1)
virtual void readChunkEnd(uint32 id)
Finish the reading of a chunk.
virtual void read(String *string)
virtual Chunk * readChunkImpl()
virtual Endian getEndian() const
Get the endian mode.
Class representing a general-purpose node an articulated scene graph.
Representation of a ray in space, i.e.
virtual void write(const Matrix3 *m, size_t count=1)
virtual const Chunk * readChunkBegin(uint32 id, uint16 maxVersion, const String &msg=StringUtil::BLANK)
Reads the start of the next chunk so long as it's of a given ID and version.
virtual void read(Ray *ray, size_t count=1)
virtual void write(const Plane *plane, size_t count=1)
virtual void read(bool *val, size_t count=1)
virtual void write(const bool *boolean, size_t count=1)
Standard 3-dimensional vector.
@ REAL_FLOAT
Real is stored as float, reducing precision if you're using OGRE_DOUBLE_PRECISION.
virtual void writeData(const void *buf, size_t size, size_t count)
Write arbitrary data to a stream.
virtual void read(Radian *angle, size_t count=1)
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.