Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre_src_v1-9-0/OgreMain/include/OgreSerializer.h @ 151

Last change on this file since 151 was 148, checked in by patricwi, 6 years ago

Added new dependencies for ogre1.9 and cegui0.8

File size: 4.5 KB
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-2013 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28
29#ifndef __Serializer_H__
30#define __Serializer_H__
31
32#include "OgrePrerequisites.h"
33#include "OgreString.h"
34#include "OgreDataStream.h"
35#include "OgreHeaderPrefix.h"
36
37namespace Ogre {
38
39        /** \addtogroup Core
40        *  @{
41        */
42        /** \addtogroup General
43        *  @{
44        */
45        /** Generic class for serialising data to / from binary stream-based files.
46    @remarks
47        This class provides a number of useful methods for exporting / importing data
48        from stream-oriented binary files (e.g. .mesh and .skeleton).
49    */
50        class _OgreExport Serializer : public SerializerAlloc
51    {
52    public:
53        Serializer();
54        virtual ~Serializer();
55
56                /// The endianness of written files
57                enum Endian
58                {
59                        /// Use the platform native endian
60                        ENDIAN_NATIVE,
61                        /// Use big endian (0x1000 is serialised as 0x10 0x00)
62                        ENDIAN_BIG,
63                        /// Use little endian (0x1000 is serialised as 0x00 0x10)
64                        ENDIAN_LITTLE
65                };
66
67
68    protected:
69
70        uint32 mCurrentstreamLen;
71        DataStreamPtr mStream;
72        String mVersion;
73                bool mFlipEndian; /// Default to native endian, derive from header
74
75        // Internal methods
76        virtual void writeFileHeader(void);
77        virtual void writeChunkHeader(uint16 id, size_t size);
78       
79        void writeFloats(const float* const pfloat, size_t count);
80        void writeFloats(const double* const pfloat, size_t count);
81        void writeShorts(const uint16* const pShort, size_t count);
82        void writeInts(const uint32* const pInt, size_t count); 
83        void writeBools(const bool* const pLong, size_t count);
84        void writeObject(const Vector3& vec);
85        void writeObject(const Quaternion& q);
86       
87        void writeString(const String& string);
88        void writeData(const void* const buf, size_t size, size_t count);
89       
90        virtual void readFileHeader(DataStreamPtr& stream);
91        virtual unsigned short readChunk(DataStreamPtr& stream);
92       
93        void readBools(DataStreamPtr& stream, bool* pDest, size_t count);
94        void readFloats(DataStreamPtr& stream, float* pDest, size_t count);
95        void readFloats(DataStreamPtr& stream, double* pDest, size_t count);
96        void readShorts(DataStreamPtr& stream, uint16* pDest, size_t count);
97        void readInts(DataStreamPtr& stream, uint32* pDest, size_t count);
98        void readObject(DataStreamPtr& stream, Vector3& pDest);
99        void readObject(DataStreamPtr& stream, Quaternion& pDest);
100
101        String readString(DataStreamPtr& stream);
102        String readString(DataStreamPtr& stream, size_t numChars);
103       
104        virtual void flipToLittleEndian(void* pData, size_t size, size_t count = 1);
105        virtual void flipFromLittleEndian(void* pData, size_t size, size_t count = 1);
106       
107        virtual void flipEndian(void * pData, size_t size, size_t count);
108        virtual void flipEndian(void * pData, size_t size);
109
110                /// Determine the endianness of the incoming stream compared to native
111                virtual void determineEndianness(DataStreamPtr& stream);
112                /// Determine the endianness to write with based on option
113                virtual void determineEndianness(Endian requestedEndian);
114    };
115        /** @} */
116        /** @} */
117
118}
119
120#include "OgreHeaderSuffix.h"
121
122#endif
Note: See TracBrowser for help on using the repository browser.