[138] | 1 | #ifndef __GEO_SERIALIZER_H__
|
---|
| 2 | #define __GEO_SERIALIZER_H__
|
---|
| 3 |
|
---|
| 4 | #include "GeoBase.h"
|
---|
| 5 | #include "GeoVector2.h"
|
---|
| 6 | #include "GeoVector3.h"
|
---|
| 7 |
|
---|
| 8 | namespace Geometry {
|
---|
| 9 |
|
---|
| 10 | /// Serializer interface
|
---|
| 11 | /** Serializer is a helper class than manages file input/output.
|
---|
| 12 | */
|
---|
| 13 | class Serializer
|
---|
| 14 | {
|
---|
| 15 | public:
|
---|
| 16 |
|
---|
| 17 | enum Mode
|
---|
| 18 | {
|
---|
| 19 | READ,
|
---|
| 20 | WRITE,
|
---|
| 21 | APPEND
|
---|
| 22 | };
|
---|
| 23 |
|
---|
| 24 | ///Constructor
|
---|
| 25 | Serializer(String name, Mode mode);
|
---|
| 26 |
|
---|
| 27 | ///Destructor
|
---|
| 28 | virtual ~Serializer();
|
---|
| 29 |
|
---|
| 30 | /// Copy constructor
|
---|
| 31 | //Serializer(const Serializer&);
|
---|
| 32 |
|
---|
| 33 | /// Assignment operator
|
---|
| 34 | //Serializer& operator =(const Serializer&);
|
---|
| 35 |
|
---|
| 36 |
|
---|
| 37 | public:
|
---|
| 38 | void WriteData(const void* const buf, size_t size, size_t count);
|
---|
| 39 | void WriteArray(const float* const pfloat, size_t count);
|
---|
| 40 | void WriteArray(const uint16* const pShort, size_t count);
|
---|
| 41 | void WriteArray(const uint32* const pInt, size_t count);
|
---|
| 42 | void WriteArray(const bool* const pLong, size_t count);
|
---|
| 43 | void WriteArray(const Vector3* const pvector3, size_t count);
|
---|
| 44 | void WriteArray(const Vector2* const pvector3, size_t count);
|
---|
| 45 |
|
---|
| 46 | void ReadData(void *buf, size_t size, size_t count);
|
---|
| 47 | void ReadArray(bool *pDest, size_t count);
|
---|
| 48 | void ReadArray(float *pDest, size_t count);
|
---|
| 49 | void ReadArray(uint16 *pDest, size_t count);
|
---|
| 50 | void ReadArray(uint32 *pDest, size_t count);
|
---|
| 51 | void ReadArray(Vector3 *pDest, size_t count);
|
---|
| 52 | void ReadArray(Vector2 *pDest, size_t count);
|
---|
| 53 |
|
---|
| 54 | virtual size_t GetSize()
|
---|
| 55 | {
|
---|
| 56 | return mSize;
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | protected:
|
---|
| 60 |
|
---|
| 61 | size_t mSize;
|
---|
| 62 | FILE *mFile;
|
---|
| 63 | Mode mMode;
|
---|
| 64 |
|
---|
| 65 | void FlipToLittleEndian(void *pData, size_t size, size_t count = 1);
|
---|
| 66 | void FlipFromLittleEndian(void *pData, size_t size, size_t count = 1);
|
---|
| 67 | void FlipEndian(void *pData, size_t size, size_t count);
|
---|
| 68 | void FlipEndian(void *pData, size_t size);
|
---|
| 69 | };
|
---|
| 70 |
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 |
|
---|
| 74 | #endif
|
---|