source: GTP/trunk/App/Demos/Geom/include/OgreSerializer.h @ 1030

Revision 1030, 3.6 KB checked in by gumbau, 18 years ago (diff)

Ogre Stuff initial import

Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25
26#ifndef __Serializer_H__
27#define __Serializer_H__
28
29#include "OgrePrerequisites.h"
30#include "OgreString.h"
31#include "OgreDataStream.h"
32
33namespace Ogre {
34
35    /** Generic class for serialising data to / from binary stream-based files.
36    @remarks
37        This class provides a number of useful methods for exporting / importing data
38        from stream-oriented binary files (e.g. .mesh and .skeleton).
39    */
40    class _OgreExport Serializer
41    {
42    public:
43        Serializer();
44        virtual ~Serializer();
45
46
47    protected:
48
49        uint32 mCurrentstreamLen;
50        FILE* mpfFile;
51        String mVersion;
52
53        // Internal methods
54        virtual void writeFileHeader(void);
55        virtual void writeChunkHeader(uint16 id, uint32 size);
56       
57        void writeFloats(const float* const pfloat, size_t count);
58        void writeFloats(const double* const pfloat, size_t count);
59        void writeShorts(const uint16* const pShort, size_t count);
60        void writeInts(const uint32* const pInt, size_t count);
61        void writeBools(const bool* const pLong, size_t count);
62        void writeObject(const Vector3& vec);
63        void writeObject(const Quaternion& q);
64       
65        void writeString(const String& string);
66        void writeData(const void* const buf, size_t size, size_t count);
67       
68        virtual void readFileHeader(DataStreamPtr& stream);
69        virtual unsigned short readChunk(DataStreamPtr& stream);
70       
71        void readBools(DataStreamPtr& stream, bool* pDest, size_t count);
72        void readFloats(DataStreamPtr& stream, float* pDest, size_t count);
73        void readFloats(DataStreamPtr& stream, double* pDest, size_t count);
74        void readShorts(DataStreamPtr& stream, uint16* pDest, size_t count);
75        void readInts(DataStreamPtr& stream, uint32* pDest, size_t count);
76        void readObject(DataStreamPtr& stream, Vector3& pDest);
77        void readObject(DataStreamPtr& stream, Quaternion& pDest);
78
79        String readString(DataStreamPtr& stream);
80        String readString(DataStreamPtr& stream, size_t numChars);
81       
82        virtual void flipToLittleEndian(void* pData, size_t size, size_t count = 1);
83        virtual void flipFromLittleEndian(void* pData, size_t size, size_t count = 1);
84       
85        virtual void flipEndian(void * pData, size_t size, size_t count);
86        virtual void flipEndian(void * pData, size_t size);
87    };
88
89}
90
91
92#endif
Note: See TracBrowser for help on using the repository browser.