28 #ifndef __StreamSerialiser_H__
29 #define __StreamSerialiser_H__
102 Chunk() : id(0), version(1), length(0), offset(0) {}
123 bool autoHeader =
true,
125 RealStorageFormat realFormat = REAL_DOUBLE
127 RealStorageFormat realFormat = REAL_FLOAT
159 uint32 getCurrentChunkID()
const;
168 size_t getOffsetFromChunkStart()
const;
181 virtual const Chunk* readChunkBegin();
206 virtual void undoReadChunk(
uint32 id);
209 virtual uint32 peekNextChunkID();
219 virtual void readChunkEnd(
uint32 id);
224 virtual bool isEndOfChunk(
uint32 id);
227 virtual bool eof()
const;
230 virtual const Chunk* getCurrentChunk()
const;
246 virtual void writeChunkBegin(
uint32 id,
uint16 version = 1);
251 virtual void writeChunkEnd(
uint32 id);
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);
269 virtual void write(
const Real* val,
size_t count = 1);
271 virtual void write(
const Vector2* vec,
size_t count = 1);
272 virtual void write(
const Vector3* vec,
size_t count = 1);
273 virtual void write(
const Vector4* vec,
size_t count = 1);
274 virtual void write(
const Quaternion* q,
size_t count = 1);
275 virtual void write(
const Matrix3* m,
size_t count = 1);
276 virtual void write(
const Matrix4* m,
size_t count = 1);
277 virtual void write(
const String*
string);
279 virtual void write(
const Sphere* sphere,
size_t count = 1);
280 virtual void write(
const Plane* plane,
size_t count = 1);
281 virtual void write(
const Ray* ray,
size_t count = 1);
282 virtual void write(
const Radian* angle,
size_t count = 1);
283 virtual void write(
const Node* node,
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);
303 virtual void read(
Real* val,
size_t count = 1);
306 virtual void read(
Vector2* vec,
size_t count = 1);
307 virtual void read(
Vector3* vec,
size_t count = 1);
308 virtual void read(
Vector4* vec,
size_t count = 1);
309 virtual void read(
Quaternion* q,
size_t count = 1);
310 virtual void read(
Matrix3* m,
size_t count = 1);
311 virtual void read(
Matrix4* m,
size_t count = 1);
312 virtual void read(
String*
string);
314 virtual void read(
Sphere* sphere,
size_t count = 1);
315 virtual void read(
Plane* plane,
size_t count = 1);
316 virtual void read(
Ray* ray,
size_t count = 1);
317 virtual void read(
Radian* angle,
size_t count = 1);
318 virtual void read(
Node* node,
size_t count = 1);
319 virtual void read(
bool* val,
size_t count = 1);
324 virtual void startDeflate(
size_t avail_in = 0);
327 virtual void stopDeflate();
343 virtual Chunk* readChunkImpl();
345 virtual void readHeader();
346 virtual void writeHeader();
348 virtual void checkStream(
bool failOnEof =
false,
349 bool validateReadable =
false,
bool validateWriteable =
false)
const;
351 virtual void flipEndian(
void * pData,
size_t size,
size_t count);
352 virtual void flipEndian(
void * pData,
size_t size);
353 virtual void determineEndianness();
356 virtual void writeFloatsAsDoubles(
const float* val,
size_t count);
357 virtual void writeDoublesAsFloats(
const double* val,
size_t count);
358 virtual void readFloatsAsDoubles(
double* val,
size_t count);
359 virtual void readDoublesAsFloats(
float* val,
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++);
Representation of a ray in space, i.e.
#define OGRE_ALLOC_T(T, count, category)
Allocate a block of memory for a primitive type, and indicate the category of usage.
Class encapsulating a standard 4x4 homogeneous matrix.
size_t getCurrentChunkDepth() const
Report the current depth of the chunk nesting, whether reading or writing.
float Real
Software floating point type.
ChunkStack mChunkStack
Current list of open chunks.
Defines a plane in 3D space.
DataStreamPtr mOriginalStream
uint32 length
Length of the chunk data in bytes, excluding the header of this chunk (stored)
void read(T *pT, size_t count=1)
Catch-all method to read primitive types.
A 3D box aligned with the x/y/z axes.
A 3x3 matrix which can represent rotations around axes.
deque< Chunk * >::type ChunkStack
uint32 id
Identifier of the chunk (for example from makeIdentifier) (stored)
Automatically determine endianness.
Implementation of a Quaternion, i.e.
void write(const T *pT, size_t count=1)
Catch-all method to write primitive types.
uint32 offset
Location of the chunk (header) in bytes from the start of a stream (derived)
uint16 version
Version of the chunk (stored)
static uint32 REVERSE_HEADER_ID
Real is stored as float, reducing precision if you're using OGRE_DOUBLE_PRECISION.
A sphere primitive, mostly used for bounds checking.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Standard 2-dimensional vector.
Utility class providing helper methods for reading / writing structured data held in a DataStream...
RealStorageFormat mRealFormat
static uint32 CHUNK_HEADER_SIZE
Standard 3-dimensional vector.
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Endian
The endianness of files.
virtual Endian getEndian() const
Get the endian mode.
Wrapper class which indicates a given angle value is in Radians.
RealStorageFormat
The storage format of Real values.
void writeConverted(const T *src, U typeToWrite, size_t count)
#define OGRE_FREE(ptr, category)
Free the memory allocated with OGRE_MALLOC or OGRE_ALLOC_T. Category is required to be restated to en...
#define OGRE_DOUBLE_PRECISION
If set to 1, Real is typedef'ed to double.
Use big endian (0x1000 is serialised as 0x10 0x00)
4-dimensional homogeneous vector.
void readConverted(T *dst, U typeToRead, size_t count)
Class representing a general-purpose node an articulated scene graph.
Definition of a chunk of data in a file.