aboutsummaryrefslogtreecommitdiff
path: root/src/archive.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-04-03 04:50:36 +0000
committerMike Buland <eichlan@xagasoft.com>2007-04-03 04:50:36 +0000
commitda89e6d30e57bd6dbb10b4d36b093ce9bbf5c666 (patch)
tree0c8d31d13521011dc52a3fbadbf9e7e27929308f /src/archive.h
parentf4c20290509d7ed3a8fd5304577e7a4cc0b9d974 (diff)
downloadlibbu++-da89e6d30e57bd6dbb10b4d36b093ce9bbf5c666.tar.gz
libbu++-da89e6d30e57bd6dbb10b4d36b093ce9bbf5c666.tar.bz2
libbu++-da89e6d30e57bd6dbb10b4d36b093ce9bbf5c666.tar.xz
libbu++-da89e6d30e57bd6dbb10b4d36b093ce9bbf5c666.zip
The first batch seem to have made it alright. Unfortunately the Archive class
isn't done yet, I'm going to make it rely on streams, so those will be next, then we can make it work all sortsa' well.
Diffstat (limited to 'src/archive.h')
-rw-r--r--src/archive.h93
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
8namespace 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