aboutsummaryrefslogtreecommitdiff
path: root/src/archivebase.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-11-12 17:05:30 +0000
committerMike Buland <eichlan@xagasoft.com>2009-11-12 17:05:30 +0000
commit509d136e9adb60c56369565b9545e613cac3678e (patch)
treef118d676edeae2d5e17f48b32b180d4761b60520 /src/archivebase.h
parent3166bd631a093f42ea44a4b0f4d914cf51518bd4 (diff)
downloadlibbu++-509d136e9adb60c56369565b9545e613cac3678e.tar.gz
libbu++-509d136e9adb60c56369565b9545e613cac3678e.tar.bz2
libbu++-509d136e9adb60c56369565b9545e613cac3678e.tar.xz
libbu++-509d136e9adb60c56369565b9545e613cac3678e.zip
I've started my campaign to clean up all of the header files in libbu++ as far
as includes go. This required a little bit of reworking as far as archive goes, but I've been planning on changing it aronud for a bit anyway. The final result here is that you may need to add some more includes in your own code, libbu++ doesn't include as many random things you didn't ask for anymore, most of these seem to be bu/hash.h, unistd.h, and time.h. Also, any Archive functions and operators should use ArchiveBase when they can instead of Archive, archivebase.h is a much lighterweight include that will be used everywhere in core that it can be, there are a few classes that actually want a specific archiver to be used, they will use it (such as the nids storage class). So far, except for adding header files, nothing has changed in functionality, and no other code changes should be required, although the above mentioned archive changeover is reccomended.
Diffstat (limited to 'src/archivebase.h')
-rw-r--r--src/archivebase.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/archivebase.h b/src/archivebase.h
new file mode 100644
index 0000000..f421efb
--- /dev/null
+++ b/src/archivebase.h
@@ -0,0 +1,67 @@
1#ifndef BU_ARCHIVE_BASE_H
2#define BU_ARCHIVE_BASE_H
3
4#include <stdint.h>
5
6namespace Bu
7{
8 class ArchiveBase
9 {
10 public:
11 ArchiveBase();
12 virtual ~ArchiveBase();
13
14 virtual void close()=0;
15 virtual void write( const void *pData, int32_t iLength )=0;
16 virtual void read( void *pData, int32_t iLength )=0;
17 virtual bool isLoading()=0;
18 };
19
20 template<typename T> ArchiveBase &operator&&( ArchiveBase &ar, T &dat )
21 {
22 if( ar.isLoading() )
23 {
24 return ar >> dat;
25 }
26 else
27 {
28 return ar << dat;
29 }
30 }
31
32 ArchiveBase &operator<<( ArchiveBase &ar, bool p );
33 ArchiveBase &operator<<( ArchiveBase &ar, char p );
34 ArchiveBase &operator<<( ArchiveBase &ar, signed char p );
35 ArchiveBase &operator<<( ArchiveBase &ar, unsigned char p );
36 ArchiveBase &operator<<( ArchiveBase &ar, signed short p );
37 ArchiveBase &operator<<( ArchiveBase &ar, unsigned short p );
38 ArchiveBase &operator<<( ArchiveBase &ar, signed int p );
39 ArchiveBase &operator<<( ArchiveBase &ar, unsigned int p );
40 ArchiveBase &operator<<( ArchiveBase &ar, signed long p );
41 ArchiveBase &operator<<( ArchiveBase &ar, unsigned long p );
42 ArchiveBase &operator<<( ArchiveBase &ar, signed long long p );
43 ArchiveBase &operator<<( ArchiveBase &ar, unsigned long long p );
44 ArchiveBase &operator<<( ArchiveBase &ar, float p );
45 ArchiveBase &operator<<( ArchiveBase &ar, double p );
46 ArchiveBase &operator<<( ArchiveBase &ar, long double p );
47
48 ArchiveBase &operator>>( ArchiveBase &ar, bool &p );
49 ArchiveBase &operator>>( ArchiveBase &ar, char &p );
50 ArchiveBase &operator>>( ArchiveBase &ar, signed char &p );
51 ArchiveBase &operator>>( ArchiveBase &ar, unsigned char &p );
52 ArchiveBase &operator>>( ArchiveBase &ar, signed short &p );
53 ArchiveBase &operator>>( ArchiveBase &ar, unsigned short &p );
54 ArchiveBase &operator>>( ArchiveBase &ar, signed int &p );
55 ArchiveBase &operator>>( ArchiveBase &ar, unsigned int &p );
56 ArchiveBase &operator>>( ArchiveBase &ar, signed long &p );
57 ArchiveBase &operator>>( ArchiveBase &ar, unsigned long &p );
58 ArchiveBase &operator>>( ArchiveBase &ar, signed long long &p );
59 ArchiveBase &operator>>( ArchiveBase &ar, unsigned long long &p );
60 ArchiveBase &operator>>( ArchiveBase &ar, float &p );
61 ArchiveBase &operator>>( ArchiveBase &ar, double &p );
62 ArchiveBase &operator>>( ArchiveBase &ar, long double &p );
63
64
65};
66
67#endif