Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound 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://ogre.sourceforge.net/
00006 
00007 Copyright © 2000-2002 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 
00032 namespace Ogre {
00033 
00039     class _OgreExport Serializer
00040     {
00041     public:
00042         Serializer();
00043         virtual ~Serializer();
00044 
00045 
00046     protected:
00047 
00048         unsigned long mCurrentChunkLen;
00049         FILE* mpfFile;
00050         String mVersion;
00051 
00052         // Internal methods
00053         virtual void writeFileHeader(void);
00054         virtual void writeChunkHeader(unsigned short id, unsigned long size);
00055         
00056         void writeReals(const Real* pReal, unsigned short count);
00057         void writeShorts(const unsigned short* pShort, unsigned short count);
00058         void writeLongs(const unsigned long* pLong, unsigned short count); 
00059         void writeBools(const bool* pLong, unsigned short count);
00060         void writeObject(const Vector3& vec);
00061         void writeObject(const Quaternion& q);
00062         
00063         void writeString(const String& string);
00064         void writeData(const void* buf, size_t size, size_t count);
00065         
00066         virtual void readFileHeader(DataChunk& chunk);
00067         virtual unsigned short readChunk(DataChunk& chunk);
00068         
00069         void readBools(DataChunk& chunk, bool* pDest, unsigned short count);
00070         void readReals(DataChunk& chunk, Real* pDest, unsigned short count);
00071         void readShorts(DataChunk& chunk, unsigned short* pDest, unsigned short count);
00072         void readLongs(DataChunk& chunk, unsigned long* pDest, unsigned short count); 
00073         void readObject(DataChunk& chunk, Vector3* pDest);
00074         void readObject(DataChunk& chunk, Quaternion* pDest);
00075 
00076         String readString(DataChunk& chunk);
00077         
00078         void flipToLittleEndian(void* pData, size_t size, unsigned short count = 1);
00079         void flipFromLittleEndian(void* pData, size_t size, unsigned short count = 1);
00080         
00081         void flipEndian(void * pData, size_t size, unsigned short count);
00082         void flipEndian(void * pData, size_t size);
00083     };
00084 
00085 }
00086 
00087 
00088 #endif

Copyright © 2002 by The OGRE Team