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 miReadData2(void *buf, size_t size, size_t count);
|
---|
48 | char *miReadData(char *pDest, size_t pDestsize);
|
---|
49 | void ReadArray(bool *pDest, size_t count);
|
---|
50 | void ReadArray(float *pDest, size_t count);
|
---|
51 | void ReadArray(uint16 *pDest, size_t count);
|
---|
52 | void ReadArray(uint32 *pDest, size_t count);
|
---|
53 | void ReadArray(Vector3 *pDest, size_t count);
|
---|
54 | void ReadArray(Vector2 *pDest, size_t count);
|
---|
55 |
|
---|
56 | // GPR.
|
---|
57 | void WriteData(const String &string);
|
---|
58 | // fin GPR.
|
---|
59 |
|
---|
60 | virtual size_t GetSize()
|
---|
61 | {
|
---|
62 | return mSize;
|
---|
63 | }
|
---|
64 |
|
---|
65 | int serializereof() {
|
---|
66 | return feof(mFile);
|
---|
67 | }
|
---|
68 |
|
---|
69 | protected:
|
---|
70 |
|
---|
71 | size_t mSize;
|
---|
72 | FILE *mFile;
|
---|
73 | Mode mMode;
|
---|
74 |
|
---|
75 | void FlipToLittleEndian(void *pData, size_t size, size_t count = 1);
|
---|
76 | void FlipFromLittleEndian(void *pData, size_t size, size_t count = 1);
|
---|
77 | void FlipEndian(void *pData, size_t size, size_t count);
|
---|
78 | void FlipEndian(void *pData, size_t size);
|
---|
79 | };
|
---|
80 |
|
---|
81 | }
|
---|
82 |
|
---|
83 |
|
---|
84 | #endif
|
---|