OgreSerializer.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __Serializer_H__
#define __Serializer_H__
#include "OgrePrerequisites.h"
#include "OgreString.h"
#include "OgreDataStream.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
class _OgreExport Serializer : public SerializerAlloc
{
public:
Serializer();
virtual ~Serializer();
enum Endian
{
ENDIAN_NATIVE,
ENDIAN_BIG,
ENDIAN_LITTLE
};
protected:
uint32 mCurrentstreamLen;
DataStreamPtr mStream;
String mVersion;
bool mFlipEndian;
// Internal methods
virtual void writeFileHeader(void);
virtual void writeChunkHeader(uint16 id, size_t size);
void writeFloats(const float* const pfloat, size_t count);
void writeFloats(const double* const pfloat, size_t count);
void writeShorts(const uint16* const pShort, size_t count);
void writeInts(const uint32* const pInt, size_t count);
void writeBools(const bool* const pLong, size_t count);
void writeObject(const Vector3& vec);
void writeObject(const Quaternion& q);
void writeString(const String& string);
void writeData(const void* const buf, size_t size, size_t count);
virtual void readFileHeader(DataStreamPtr& stream);
virtual unsigned short readChunk(DataStreamPtr& stream);
void readBools(DataStreamPtr& stream, bool* pDest, size_t count);
void readFloats(DataStreamPtr& stream, float* pDest, size_t count);
void readFloats(DataStreamPtr& stream, double* pDest, size_t count);
void readShorts(DataStreamPtr& stream, uint16* pDest, size_t count);
void readInts(DataStreamPtr& stream, uint32* pDest, size_t count);
void readObject(DataStreamPtr& stream, Vector3& pDest);
void readObject(DataStreamPtr& stream, Quaternion& pDest);
String readString(DataStreamPtr& stream);
String readString(DataStreamPtr& stream, size_t numChars);
virtual void flipToLittleEndian(void* pData, size_t size, size_t count = 1);
virtual void flipFromLittleEndian(void* pData, size_t size, size_t count = 1);
virtual void flipEndian(void * pData, size_t size, size_t count);
virtual void flipEndian(void * pData, size_t size);
virtual void determineEndianness(DataStreamPtr& stream);
virtual void determineEndianness(Endian requestedEndian);
};
}
#include "OgreHeaderSuffix.h"
#endif
Ogre::Serializer
Generic class for serialising data to / from binary stream-based files.
Definition: OgreSerializer.h:50
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::Quaternion
Implementation of a Quaternion, i.e.
Definition: OgreQuaternion.h:57
Ogre::Serializer::mCurrentstreamLen
uint32 mCurrentstreamLen
Definition: OgreSerializer.h:70
Ogre::Serializer::Endian
Endian
The endianness of written files.
Definition: OgreSerializer.h:57
OgreString.h
OgreDataStream.h
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
OgrePrerequisites.h
Ogre::Serializer::ENDIAN_NATIVE
Use the platform native endian.
Definition: OgreSerializer.h:60
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::Serializer::mFlipEndian
bool mFlipEndian
Definition: OgreSerializer.h:73
OgreHeaderSuffix.h
Ogre::uint32
unsigned int uint32
Definition: OgrePlatform.h:359
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::Serializer::mVersion
String mVersion
Definition: OgreSerializer.h:72
Ogre::SharedPtr< DataStream >
OgreHeaderPrefix.h
Ogre::Serializer::mStream
DataStreamPtr mStream
Definition: OgreSerializer.h:71
Ogre::Serializer::ENDIAN_BIG
Use big endian (0x1000 is serialised as 0x10 0x00)
Definition: OgreSerializer.h:62
Ogre::uint16
unsigned short uint16
Definition: OgrePlatform.h:360
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.