Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | 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-2006 Torus Knot Software Ltd
    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 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029
    00030 #ifndef __Serializer_H__
    00031 #define __Serializer_H__
    00032
    00033 #include "OgrePrerequisites.h"
    00034 #include "OgreString.h"
    00035 #include "OgreDataStream.h"
    00036
    00037 namespace Ogre {
    00038
    00044     class _OgreExport Serializer
    00045     {
    00046     public:
    00047         Serializer();
    00048         virtual ~Serializer();
    00049
    00051         enum Endian
    00052         {
    00054             ENDIAN_NATIVE,
    00056             ENDIAN_BIG,
    00058             ENDIAN_LITTLE
    00059         };
    00060
    00061
    00062     protected:
    00063
    00064         uint32 mCurrentstreamLen;
    00065         FILE* mpfFile;
    00066         String mVersion;
    00067         bool mFlipEndian; // default to native endian, derive from header
    00068
    00069         // Internal methods
    00070         virtual void writeFileHeader(void);
    00071         virtual void writeChunkHeader(uint16 id, size_t size);
    00072
    00073         void writeFloats(const float* const pfloat, size_t count);
    00074         void writeFloats(const double* const pfloat, size_t count);
    00075         void writeShorts(const uint16* const pShort, size_t count);
    00076         void writeInts(const uint32* const pInt, size_t count);
    00077         void writeBools(const bool* const pLong, size_t count);
    00078         void writeObject(const Vector3& vec);
    00079         void writeObject(const Quaternion& q);
    00080
    00081         void writeString(const String& string);
    00082         void writeData(const void* const buf, size_t size, size_t count);
    00083
    00084         virtual void readFileHeader(DataStreamPtr& stream);
    00085         virtual unsigned short readChunk(DataStreamPtr& stream);
    00086
    00087         void readBools(DataStreamPtr& stream, bool* pDest, size_t count);
    00088         void readFloats(DataStreamPtr& stream, float* pDest, size_t count);
    00089         void readFloats(DataStreamPtr& stream, double* pDest, size_t count);
    00090         void readShorts(DataStreamPtr& stream, uint16* pDest, size_t count);
    00091         void readInts(DataStreamPtr& stream, uint32* pDest, size_t count);
    00092         void readObject(DataStreamPtr& stream, Vector3& pDest);
    00093         void readObject(DataStreamPtr& stream, Quaternion& pDest);
    00094
    00095         String readString(DataStreamPtr& stream);
    00096         String readString(DataStreamPtr& stream, size_t numChars);
    00097
    00098         virtual void flipToLittleEndian(void* pData, size_t size, size_t count = 1);
    00099         virtual void flipFromLittleEndian(void* pData, size_t size, size_t count = 1);
    00100
    00101         virtual void flipEndian(void * pData, size_t size, size_t count);
    00102         virtual void flipEndian(void * pData, size_t size);
    00103
    00105         virtual void determineEndianness(DataStreamPtr& stream);
    00107         virtual void determineEndianness(Endian requestedEndian);
    00108     };
    00109
    00110 }
    00111
    00112
    00113 #endif

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 30 10:50:57 2007