Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

OgreSerializer.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2005 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 
00026 #ifndef __Serializer_H__
00027 #define __Serializer_H__
00028 
00029 #include "OgrePrerequisites.h"
00030 #include "OgreString.h"
00031 #include "OgreDataStream.h"
00032 
00033 namespace Ogre {
00034 
00040     class _OgreExport Serializer
00041     {
00042     public:
00043         Serializer();
00044         virtual ~Serializer();
00045 
00047         enum Endian
00048         {
00050             ENDIAN_NATIVE,
00052             ENDIAN_BIG,
00054             ENDIAN_LITTLE
00055         };
00056 
00057 
00058     protected:
00059 
00060         uint32 mCurrentstreamLen;
00061         FILE* mpfFile;
00062         String mVersion;
00063         bool mFlipEndian; // default to native endian, derive from header
00064 
00065         // Internal methods
00066         virtual void writeFileHeader(void);
00067         virtual void writeChunkHeader(uint16 id, uint32 size);
00068         
00069         void writeFloats(const float* const pfloat, size_t count);
00070         void writeFloats(const double* const pfloat, size_t count);
00071         void writeShorts(const uint16* const pShort, size_t count);
00072         void writeInts(const uint32* const pInt, size_t count); 
00073         void writeBools(const bool* const pLong, size_t count);
00074         void writeObject(const Vector3& vec);
00075         void writeObject(const Quaternion& q);
00076         
00077         void writeString(const String& string);
00078         void writeData(const void* const buf, size_t size, size_t count);
00079         
00080         virtual void readFileHeader(DataStreamPtr& stream);
00081         virtual unsigned short readChunk(DataStreamPtr& stream);
00082         
00083         void readBools(DataStreamPtr& stream, bool* pDest, size_t count);
00084         void readFloats(DataStreamPtr& stream, float* pDest, size_t count);
00085         void readFloats(DataStreamPtr& stream, double* pDest, size_t count);
00086         void readShorts(DataStreamPtr& stream, uint16* pDest, size_t count);
00087         void readInts(DataStreamPtr& stream, uint32* pDest, size_t count);
00088         void readObject(DataStreamPtr& stream, Vector3& pDest);
00089         void readObject(DataStreamPtr& stream, Quaternion& pDest);
00090 
00091         String readString(DataStreamPtr& stream);
00092         String readString(DataStreamPtr& stream, size_t numChars);
00093         
00094         virtual void flipToLittleEndian(void* pData, size_t size, size_t count = 1);
00095         virtual void flipFromLittleEndian(void* pData, size_t size, size_t count = 1);
00096         
00097         virtual void flipEndian(void * pData, size_t size, size_t count);
00098         virtual void flipEndian(void * pData, size_t size);
00099 
00101         virtual void determineEndianness(DataStreamPtr& stream);
00103         virtual void determineEndianness(Endian requestedEndian);
00104     };
00105 
00106 }
00107 
00108 
00109 #endif

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:49 2006