aboutsummaryrefslogtreecommitdiff
path: root/src/serializer.h
blob: 3af489c907ffe8f5dfd5d3556f4c267a7162a4c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef SERIALIZABLE_H
#define SERIALIZABLE_H

#include <stdint.h>
#include <string>
#include <list>
//#include "serializable.h"

class Serializer
{
private:
	bool bLoading;
public:
	bool isLoading();

	enum
	{
		load	=	true,
		save	=	false
	};
	
	Serializer(bool bLoading);
	virtual ~Serializer();
	virtual void close()=0;

	virtual void write(const void *, int32_t)=0;
	virtual void read(void *, int32_t)=0;
	
	virtual Serializer &operator<<(bool);
	virtual Serializer &operator<<(int8_t);
	virtual Serializer &operator<<(int16_t);
	virtual Serializer &operator<<(int32_t);
	virtual Serializer &operator<<(int64_t);
	virtual Serializer &operator<<(uint8_t);
	virtual Serializer &operator<<(uint16_t);
	virtual Serializer &operator<<(uint32_t);
	virtual Serializer &operator<<(uint64_t);
	virtual Serializer &operator<<(long);
	virtual Serializer &operator<<(float);
	virtual Serializer &operator<<(double);
	virtual Serializer &operator<<(long double);

	virtual Serializer &operator>>(bool &);
	virtual Serializer &operator>>(int8_t &);
	virtual Serializer &operator>>(int16_t &);
	virtual Serializer &operator>>(int32_t &);
	virtual Serializer &operator>>(int64_t &);
	virtual Serializer &operator>>(uint8_t &);
	virtual Serializer &operator>>(uint16_t &);
	virtual Serializer &operator>>(uint32_t &);
	virtual Serializer &operator>>(uint64_t &);
	virtual Serializer &operator>>(long &);
	virtual Serializer &operator>>(float &);
	virtual Serializer &operator>>(double &);
	virtual Serializer &operator>>(long double &);
	
	virtual Serializer &operator&&(bool &);
	virtual Serializer &operator&&(int8_t &);
	virtual Serializer &operator&&(int16_t &);
	virtual Serializer &operator&&(int32_t &);
	virtual Serializer &operator&&(int64_t &);
	virtual Serializer &operator&&(uint8_t &);
	virtual Serializer &operator&&(uint16_t &);
	virtual Serializer &operator&&(uint32_t &);
	virtual Serializer &operator&&(uint64_t &);
	virtual Serializer &operator&&(float &);
	virtual Serializer &operator&&(double &);
	virtual Serializer &operator&&(long double &);

	//virtual Serializer &operator&(Serializable &);
};

Serializer &operator<<(Serializer &, class Serializable &);
Serializer &operator>>(Serializer &, class Serializable &);
Serializer &operator&&(Serializer &s, class Serializable &p);

Serializer &operator<<(Serializer &, std::string &);
Serializer &operator>>(Serializer &, std::string &);

#endif