diff options
Diffstat (limited to 'src/archive.h')
-rw-r--r-- | src/archive.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/archive.h b/src/archive.h new file mode 100644 index 0000000..7de9220 --- /dev/null +++ b/src/archive.h | |||
@@ -0,0 +1,93 @@ | |||
1 | #ifndef ARCHIVE_H | ||
2 | #define ARCHIVE_H | ||
3 | |||
4 | #include <stdint.h> | ||
5 | #include <string> | ||
6 | #include "archable.h" | ||
7 | |||
8 | namespace Bu | ||
9 | { | ||
10 | class Archive | ||
11 | { | ||
12 | private: | ||
13 | bool bLoading; | ||
14 | public: | ||
15 | bool isLoading(); | ||
16 | |||
17 | enum | ||
18 | { | ||
19 | load = true, | ||
20 | save = false | ||
21 | }; | ||
22 | |||
23 | Archive( bool bLoading ); | ||
24 | virtual ~Archive(); | ||
25 | virtual void close()=0; | ||
26 | |||
27 | virtual void write(const void *, int32_t)=0; | ||
28 | virtual void read(void *, int32_t)=0; | ||
29 | |||
30 | virtual Archive &operator<<(bool); | ||
31 | virtual Archive &operator<<(int8_t); | ||
32 | virtual Archive &operator<<(int16_t); | ||
33 | virtual Archive &operator<<(int32_t); | ||
34 | virtual Archive &operator<<(int64_t); | ||
35 | virtual Archive &operator<<(uint8_t); | ||
36 | virtual Archive &operator<<(uint16_t); | ||
37 | virtual Archive &operator<<(uint32_t); | ||
38 | virtual Archive &operator<<(uint64_t); | ||
39 | virtual Archive &operator<<(long); | ||
40 | virtual Archive &operator<<(float); | ||
41 | virtual Archive &operator<<(double); | ||
42 | virtual Archive &operator<<(long double); | ||
43 | |||
44 | virtual Archive &operator>>(bool &); | ||
45 | virtual Archive &operator>>(int8_t &); | ||
46 | virtual Archive &operator>>(int16_t &); | ||
47 | virtual Archive &operator>>(int32_t &); | ||
48 | virtual Archive &operator>>(int64_t &); | ||
49 | virtual Archive &operator>>(uint8_t &); | ||
50 | virtual Archive &operator>>(uint16_t &); | ||
51 | virtual Archive &operator>>(uint32_t &); | ||
52 | virtual Archive &operator>>(uint64_t &); | ||
53 | virtual Archive &operator>>(long &); | ||
54 | virtual Archive &operator>>(float &); | ||
55 | virtual Archive &operator>>(double &); | ||
56 | virtual Archive &operator>>(long double &); | ||
57 | |||
58 | virtual Archive &operator&&(bool &); | ||
59 | virtual Archive &operator&&(int8_t &); | ||
60 | virtual Archive &operator&&(int16_t &); | ||
61 | virtual Archive &operator&&(int32_t &); | ||
62 | virtual Archive &operator&&(int64_t &); | ||
63 | virtual Archive &operator&&(uint8_t &); | ||
64 | virtual Archive &operator&&(uint16_t &); | ||
65 | virtual Archive &operator&&(uint32_t &); | ||
66 | virtual Archive &operator&&(uint64_t &); | ||
67 | virtual Archive &operator&&(float &); | ||
68 | virtual Archive &operator&&(double &); | ||
69 | virtual Archive &operator&&(long double &); | ||
70 | }; | ||
71 | |||
72 | Archive &operator<<(Archive &, class Bu::Archable &); | ||
73 | Archive &operator>>(Archive &, class Bu::Archable &); | ||
74 | //Archive &operator&&(Archive &s, class Bu::Archable &p); | ||
75 | |||
76 | Archive &operator<<(Archive &, std::string &); | ||
77 | Archive &operator>>(Archive &, std::string &); | ||
78 | //Archive &operator&&(Archive &, std::string &); | ||
79 | |||
80 | template<typename T> Archive &operator&&( Archive &ar, T &dat ) | ||
81 | { | ||
82 | if( ar.isLoading() ) | ||
83 | { | ||
84 | return ar >> dat; | ||
85 | } | ||
86 | else | ||
87 | { | ||
88 | return ar << dat; | ||
89 | } | ||
90 | } | ||
91 | } | ||
92 | |||
93 | #endif | ||