| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- /*
- * Copyright (C) 2022 The V-Gears Team
- *
- * This file is part of V-Gears
- *
- * V-Gears is free software: you can redistribute it and/or modify it under
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, version 3.0 (GPLv3) of the License.
- *
- * V-Gears is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
- #pragma once
- #include <OgreAxisAlignedBox.h>
- #include <OgreColourValue.h>
- #include <OgreDataStream.h>
- #include <OgreSerializer.h>
- #include <Ogre.h>
- #include "common/TypeDefine.h"
- namespace QGears{
- /**
- * Handles file serialization.
- */
- class Serializer : public Ogre::Serializer{
- public:
- /**
- * Constructor.
- *
- * Determines the endian mode of the file.
- */
- Serializer();
- /**
- * Destructor
- */
- virtual ~Serializer();
- // TODO implement some more serialization!?
- // ISerializeable readObject(serializer)
- // virtual void readObject(ISerializable o) { o.readObject(this); }
- // template<T> readObject(T)
- protected:
- /**
- * Reads an object as a 2 dimensional vector.
- *
- * @param stream[in] Input data.
- * @param dest[out] The formed vector data.
- */
- void readObject(Ogre::DataStreamPtr &stream, Ogre::Vector2 &dest);
- /**
- * Reads an object as a 3 dimensional vector.
- *
- * @param stream[in] Input data.
- * @param dest[out] The formed vector data.
- */
- void readObject(Ogre::DataStreamPtr &stream, Ogre::Vector3 &dest);
- /**
- * Reads an object as an axis aligned box.
- *
- * Can be used for bounding boxes.
- *
- * @param stream[in] Input data.
- * @param dest[out] The formed box data.
- */
- void readObject(
- Ogre::DataStreamPtr &stream, Ogre::AxisAlignedBox &dest
- );
- /**
- * Reads an object as a pixel.
- *
- * @param stream[in] Input data.
- * @param dest[out] The formed pixel data.
- */
- void readObject(Ogre::DataStreamPtr &stream, Pixel &dest);
- /**
- * Reads a stream as text.
- *
- * @param stream[in] Input data.
- * @param dest[out] The read characters will be stored here.
- * @param count[in] Read this many characters.
- */
- void ReadChars(
- Ogre::DataStreamPtr& stream, char* dest, size_t count
- );
- /**
- * Reads one byte from a stream and evaluates it as a boolean.
- *
- * @param stream[in] Input data.
- * @param dest[out] The evaluated boolean.
- * @todo 1 is true?
- */
- void Read1ByteBool(Ogre::DataStreamPtr &stream, bool &dest);
- /**
- * Reads two bytes from a stream and evaluates them as a boolean.
- *
- * @param stream[in] Input data.
- * @param dest[out] The evaluated boolean.
- * @todo 1 is true?
- */
- void Read2ByteBool(Ogre::DataStreamPtr &stream, bool &dest);
- /**
- * Reads 16 bytes from a stream and evaluates as an unsigned short.
- *
- * @param stream[in] Input data.
- * @param dest[out] The evaluated number.
- */
- void ReadShort(Ogre::DataStreamPtr &stream, uint16 &dest);
- /**
- * Reads 16 bytes from a stream and evaluates as a signed integer.
- *
- * @param stream[in] Input data.
- * @param dest[out] The evaluated number.
- */
- void ReadInt16(Ogre::DataStream &stream, sint16 &dest);
- /**
- * Reads 16 bytes from a stream and evaluates as an unsigned int.
- *
- * @param stream[in] Input data.
- * @param dest[out] The evaluated number.
- */
- void ReadUInt16(Ogre::DataStream &stream, uint16 &dest);
- /**
- * Reads 16 bytes from a stream and evaluates as a signed integer.
- *
- * @param stream[in] Input data.
- * @param dest[out] The evaluated number.
- */
- void ReadInt16(Ogre::DataStreamPtr &stream, sint16 &dest);
- /**
- * Reads 16 bytes from a stream and evaluates as an unsigned int.
- *
- * @param stream[in] Input data.
- * @param dest[out] The evaluated number.
- */
- void ReadUInt16(Ogre::DataStreamPtr &stream, uint16 &dest);
- /**
- * Reads 32 bytes from a stream and evaluates as an unsigned int.
- *
- * @param stream[in] Input data.
- * @param dest[out] The evaluated number.
- */
- void ReadUInt32(Ogre::DataStreamPtr &stream, uint32 &dest);
- /**
- * Reads 32 bytes from a stream and evaluates as a signed int.
- *
- * @param stream[in] Input data.
- * @param dest[out] The evaluated number.
- */
- void ReadSInt32(Ogre::DataStreamPtr &stream, sint32 &dest);
- /**
- * Reads 32 bytes from a stream and evaluates as an unsigned int.
- *
- * @param stream[in] Input data.
- * @param dest[out] The evaluated number.
- */
- void ReadUInt32(Ogre::DataStream &stream, uint32 &dest);
- /**
- * Reads 8 bytes from a stream and evaluates as an unsigned int.
- *
- * @param stream[in] Input data.
- * @param dest[out] The evaluated number.
- */
- void ReadUInt8(Ogre::DataStream& stream, uint8 &dest);
- /**
- * Reads 8 bytes from a stream and evaluates as an unsigned int.
- *
- * @param stream[in] Input data.
- * @param dest[out] The evaluated number.
- */
- void ReadUInt8(Ogre::DataStreamPtr &stream, uint8 &dest);
- /**
- * Reads bytes from a stream and evaluates them as a float.
- *
- * @param stream[in] Input data.
- * @param dest[out] The evaluated number.
- */
- void ReadFloat(Ogre::DataStreamPtr &stream, float &dest);
- /**
- * @todo Understand and document.
- */
- void ReadEndString(
- Ogre::DataStreamPtr &stream, const String &end_text
- );
- /**
- * @todo Understand and document.
- */
- String GetLine(Ogre::DataStreamPtr &stream) const;
- /**
- * A comment tag.
- */
- static const String TAG_COMMENT;
- };
- }
|