diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/stable/archival.cpp | 35 | ||||
-rw-r--r-- | src/stable/archival.h | 52 | ||||
-rw-r--r-- | src/stable/archive.cpp | 200 | ||||
-rw-r--r-- | src/stable/archive.h | 159 | ||||
-rw-r--r-- | src/stable/archivebase.cpp | 197 | ||||
-rw-r--r-- | src/stable/archivebase.h | 80 | ||||
-rw-r--r-- | src/stable/archivebinary.cpp | 98 | ||||
-rw-r--r-- | src/stable/archivebinary.h | 120 | ||||
-rw-r--r-- | src/stable/array.h | 6 | ||||
-rw-r--r-- | src/stable/hash.h | 6 | ||||
-rw-r--r-- | src/stable/list.h | 6 | ||||
-rw-r--r-- | src/stable/string.cpp | 4 | ||||
-rw-r--r-- | src/stable/string.h | 6 | ||||
-rw-r--r-- | src/tests/cache.cpp | 28 | ||||
-rw-r--r-- | src/tests/cachedel.cpp | 28 | ||||
-rw-r--r-- | src/unit/archive.unit | 20 | ||||
-rw-r--r-- | src/unit/myriad.unit | 16 | ||||
-rw-r--r-- | src/unstable/archivestream.cpp | 2 | ||||
-rw-r--r-- | src/unstable/archivestream.h | 6 | ||||
-rw-r--r-- | src/unstable/cachebase.h | 6 | ||||
-rw-r--r-- | src/unstable/myriadcache.h | 4 | ||||
-rw-r--r-- | src/unstable/uuid.cpp | 4 | ||||
-rw-r--r-- | src/unstable/uuid.h | 8 |
23 files changed, 501 insertions, 590 deletions
diff --git a/src/stable/archival.cpp b/src/stable/archival.cpp deleted file mode 100644 index 227e25d..0000000 --- a/src/stable/archival.cpp +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2019 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #include "bu/archival.h" | ||
9 | |||
10 | Bu::Archival::Archival() | ||
11 | { | ||
12 | } | ||
13 | |||
14 | Bu::Archival::~Archival() | ||
15 | { | ||
16 | } | ||
17 | |||
18 | Bu::ArchiveBase &Bu::operator<<(Bu::ArchiveBase &s, const Bu::Archival &p) | ||
19 | { | ||
20 | const_cast<Bu::Archival &>(p).archive( s ); | ||
21 | return s; | ||
22 | } | ||
23 | |||
24 | Bu::ArchiveBase &Bu::operator<<(Bu::ArchiveBase &s, Bu::Archival &p) | ||
25 | { | ||
26 | p.archive( s ); | ||
27 | return s; | ||
28 | } | ||
29 | |||
30 | Bu::ArchiveBase &Bu::operator>>(Bu::ArchiveBase &s, Bu::Archival &p) | ||
31 | { | ||
32 | p.archive( s ); | ||
33 | return s; | ||
34 | } | ||
35 | |||
diff --git a/src/stable/archival.h b/src/stable/archival.h deleted file mode 100644 index f7122bc..0000000 --- a/src/stable/archival.h +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2019 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #ifndef BU_ARCHIVAL_H | ||
9 | #define BU_ARCHIVAL_H | ||
10 | |||
11 | #include "bu/archivebase.h" | ||
12 | |||
13 | namespace Bu | ||
14 | { | ||
15 | /** | ||
16 | * The base class for any class you want to archive. Simply include this as | ||
17 | * a base class, implement the purely virtual archive function and you've | ||
18 | * got an easily archiveable class. | ||
19 | * | ||
20 | * Archival: "of or pertaining to archives or valuable records; contained | ||
21 | * in or comprising such archives or records." | ||
22 | */ | ||
23 | class Archival | ||
24 | { | ||
25 | public: | ||
26 | /** | ||
27 | * Does nothing, here for completeness. | ||
28 | */ | ||
29 | Archival(); | ||
30 | |||
31 | /** | ||
32 | * Here to ensure the deconstructor is virtual. | ||
33 | */ | ||
34 | virtual ~Archival(); | ||
35 | |||
36 | /** | ||
37 | * This is the main workhorse of the archive system, just override and | ||
38 | * you've got a archiveable class. A reference to the Archive | ||
39 | * used is passed in as your only parameter, query it to discover if | ||
40 | * you are loading or saving. | ||
41 | * @param ar A reference to the Archive object to use. | ||
42 | */ | ||
43 | virtual void archive( class ArchiveBase &ar )=0; | ||
44 | }; | ||
45 | |||
46 | ArchiveBase &operator<<(ArchiveBase &, const class Bu::Archival &); | ||
47 | ArchiveBase &operator<<(ArchiveBase &, class Bu::Archival &); | ||
48 | ArchiveBase &operator>>(ArchiveBase &, class Bu::Archival &); | ||
49 | |||
50 | } | ||
51 | |||
52 | #endif | ||
diff --git a/src/stable/archive.cpp b/src/stable/archive.cpp index 69447fb..df9b1ff 100644 --- a/src/stable/archive.cpp +++ b/src/stable/archive.cpp | |||
@@ -6,15 +6,8 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include "bu/archive.h" | 8 | #include "bu/archive.h" |
9 | #include "bu/stream.h" | ||
10 | #include "bu/archival.h" | ||
11 | 9 | ||
12 | #include "bu/sio.h" | 10 | Bu::Archive::Archive() |
13 | |||
14 | Bu::Archive::Archive( Stream &rStream, bool bLoading ) : | ||
15 | bLoading( bLoading ), | ||
16 | rStream( rStream ), | ||
17 | nNextID( 1 ) | ||
18 | { | 11 | { |
19 | } | 12 | } |
20 | 13 | ||
@@ -22,78 +15,183 @@ Bu::Archive::~Archive() | |||
22 | { | 15 | { |
23 | } | 16 | } |
24 | 17 | ||
25 | void Bu::Archive::write( const void *pData, size_t nSize ) | 18 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, bool p) |
19 | { | ||
20 | ar.write( &p, sizeof(p) ); | ||
21 | return ar; | ||
22 | } | ||
23 | |||
24 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, char p) | ||
25 | { | ||
26 | ar.write( &p, sizeof(p) ); | ||
27 | return ar; | ||
28 | } | ||
29 | |||
30 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, signed char p) | ||
31 | { | ||
32 | ar.write( &p, sizeof(p) ); | ||
33 | return ar; | ||
34 | } | ||
35 | |||
36 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, unsigned char p) | ||
37 | { | ||
38 | ar.write( &p, sizeof(p) ); | ||
39 | return ar; | ||
40 | } | ||
41 | |||
42 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, signed short p) | ||
43 | { | ||
44 | ar.write( &p, sizeof(p) ); | ||
45 | return ar; | ||
46 | } | ||
47 | |||
48 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, unsigned short p) | ||
26 | { | 49 | { |
27 | if( nSize == 0 || pData == NULL ) | 50 | ar.write( &p, sizeof(p) ); |
28 | return; | 51 | return ar; |
52 | } | ||
29 | 53 | ||
30 | rStream.write( (const char *)pData, nSize ); | 54 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, signed int p) |
55 | { | ||
56 | ar.write( &p, sizeof(p) ); | ||
57 | return ar; | ||
31 | } | 58 | } |
32 | 59 | ||
33 | void Bu::Archive::read( void *pData, size_t nSize ) | 60 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, unsigned int p) |
34 | { | 61 | { |
35 | if( nSize == 0 || pData == NULL ) | 62 | ar.write( &p, sizeof(p) ); |
36 | return; | 63 | return ar; |
64 | } | ||
37 | 65 | ||
38 | if( (size_t)rStream.read( (char *)pData, nSize ) < nSize ) | 66 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, signed long p) |
39 | throw Bu::ExceptionBase("Insufficient data to unarchive object."); | 67 | { |
68 | ar.write( &p, sizeof(p) ); | ||
69 | return ar; | ||
40 | } | 70 | } |
41 | 71 | ||
42 | void Bu::Archive::close() | 72 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, unsigned long p) |
43 | { | 73 | { |
44 | rStream.close(); | 74 | ar.write( &p, sizeof(p) ); |
75 | return ar; | ||
45 | } | 76 | } |
46 | 77 | ||
47 | bool Bu::Archive::isLoading() | 78 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, signed long long p) |
48 | { | 79 | { |
49 | return bLoading; | 80 | ar.write( &p, sizeof(p) ); |
81 | return ar; | ||
50 | } | 82 | } |
51 | 83 | ||
52 | uint32_t Bu::Archive::getID( const void *ptr ) | 84 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, unsigned long long p) |
53 | { | 85 | { |
54 | if( hPtrID.has( (ptrdiff_t)ptr ) ) | 86 | ar.write( &p, sizeof(p) ); |
55 | return hPtrID.get( (ptrdiff_t)ptr ); | 87 | return ar; |
56 | hPtrID.insert( (ptrdiff_t)ptr, nNextID ); | ||
57 | return nNextID++; | ||
58 | } | 88 | } |
59 | 89 | ||
60 | void Bu::Archive::assocPtrID( void **ptr, uint32_t id ) | 90 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, float p) |
61 | { | 91 | { |
62 | if( hPtrID.has( id ) ) | 92 | ar.write( &p, sizeof(p) ); |
63 | { | 93 | return ar; |
64 | *ptr = (void *)hPtrID.get( id ); | 94 | } |
65 | return; | ||
66 | } | ||
67 | 95 | ||
68 | if( !hPtrDest.has( id ) ) | 96 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, double p) |
69 | hPtrDest.insert( id, List<void **>() ); | 97 | { |
70 | 98 | ar.write( &p, sizeof(p) ); | |
71 | hPtrDest[id].getValue().append( ptr ); | 99 | return ar; |
72 | } | 100 | } |
73 | 101 | ||
74 | void Bu::Archive::readID( const void *ptr, uint32_t id ) | 102 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, long double p) |
75 | { | 103 | { |
76 | hPtrID.insert( id, (ptrdiff_t)ptr ); | 104 | ar.write( &p, sizeof(p) ); |
105 | return ar; | ||
106 | } | ||
77 | 107 | ||
78 | if( hPtrDest.has( id ) ) | 108 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, bool &p) |
79 | { | 109 | { |
80 | Bu::List<void **> &l = hPtrDest.get( id ); | 110 | ar.read( &p, sizeof(p) ); |
81 | for( Bu::List<void **>::iterator i = l.begin(); i != l.end(); i++ ) | 111 | return ar; |
82 | { | 112 | } |
83 | *(*i) = (void *)ptr; | ||
84 | } | ||
85 | 113 | ||
86 | hPtrDest.erase( id ); | 114 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, char &p) |
87 | } | 115 | { |
116 | ar.read( &p, sizeof(p) ); | ||
117 | return ar; | ||
118 | } | ||
119 | |||
120 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, signed char &p) | ||
121 | { | ||
122 | ar.read( &p, sizeof(p) ); | ||
123 | return ar; | ||
124 | } | ||
125 | |||
126 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, unsigned char &p) | ||
127 | { | ||
128 | ar.read( &p, sizeof(p) ); | ||
129 | return ar; | ||
130 | } | ||
131 | |||
132 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, signed short &p) | ||
133 | { | ||
134 | ar.read( &p, sizeof(p) ); | ||
135 | return ar; | ||
136 | } | ||
137 | |||
138 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, unsigned short &p) | ||
139 | { | ||
140 | ar.read( &p, sizeof(p) ); | ||
141 | return ar; | ||
142 | } | ||
143 | |||
144 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, signed int &p) | ||
145 | { | ||
146 | ar.read( &p, sizeof(p) ); | ||
147 | return ar; | ||
148 | } | ||
149 | |||
150 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, unsigned int &p) | ||
151 | { | ||
152 | ar.read( &p, sizeof(p) ); | ||
153 | return ar; | ||
154 | } | ||
155 | |||
156 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, signed long &p) | ||
157 | { | ||
158 | ar.read( &p, sizeof(p) ); | ||
159 | return ar; | ||
160 | } | ||
161 | |||
162 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, unsigned long &p) | ||
163 | { | ||
164 | ar.read( &p, sizeof(p) ); | ||
165 | return ar; | ||
166 | } | ||
167 | |||
168 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, signed long long &p) | ||
169 | { | ||
170 | ar.read( &p, sizeof(p) ); | ||
171 | return ar; | ||
172 | } | ||
173 | |||
174 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, unsigned long long &p) | ||
175 | { | ||
176 | ar.read( &p, sizeof(p) ); | ||
177 | return ar; | ||
178 | } | ||
179 | |||
180 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, float &p) | ||
181 | { | ||
182 | ar.read( &p, sizeof(p) ); | ||
183 | return ar; | ||
88 | } | 184 | } |
89 | 185 | ||
90 | void Bu::Archive::setProperty( const Bu::Blob &rKey, const Bu::Variant &rValue ) | 186 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, double &p) |
91 | { | 187 | { |
92 | hProps.insert( rKey, rValue ); | 188 | ar.read( &p, sizeof(p) ); |
189 | return ar; | ||
93 | } | 190 | } |
94 | 191 | ||
95 | Bu::Variant Bu::Archive::getProperty( const Bu::Blob &rKey ) const | 192 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, long double &p) |
96 | { | 193 | { |
97 | return hProps.get( rKey ); | 194 | ar.read( &p, sizeof(p) ); |
195 | return ar; | ||
98 | } | 196 | } |
99 | 197 | ||
diff --git a/src/stable/archive.h b/src/stable/archive.h index b6cc2a9..45d9af6 100644 --- a/src/stable/archive.h +++ b/src/stable/archive.h | |||
@@ -5,123 +5,82 @@ | |||
5 | * terms of the license contained in the file LICENSE. | 5 | * terms of the license contained in the file LICENSE. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #ifndef BU_ARCHIVE_H | 8 | #ifndef BU_ARCHIVE_BASE_H |
9 | #define BU_ARCHIVE_H | 9 | #define BU_ARCHIVE_BASE_H |
10 | 10 | ||
11 | #include <stdint.h> | 11 | #include <stdint.h> |
12 | #include "bu/archivebase.h" | 12 | #include <unistd.h> |
13 | #include "bu/hash.h" | 13 | |
14 | #include "bu/util.h" | ||
15 | #include "bu/variant.h" | 14 | #include "bu/variant.h" |
16 | #include "bu/blob.h" | 15 | #include "bu/blob.h" |
17 | 16 | ||
18 | namespace Bu | 17 | namespace Bu |
19 | { | 18 | { |
20 | class Archival; | 19 | class Archive |
21 | class Stream; | ||
22 | |||
23 | /** | ||
24 | * Provides a framework for serialization of objects and primitives. The | ||
25 | * archive will handle any basic primitive, a few special types, like char * | ||
26 | * strings, as well as STL classes and anything that inherits from the | ||
27 | * Archival class. Each Archive operates on a Stream, so you can send the | ||
28 | * data using an Archive almost anywhere. | ||
29 | * | ||
30 | * In order to use an Archive to store something to a file, try something | ||
31 | * like: | ||
32 | *@code | ||
33 | * File sOut("output", "wb"); // This is a stream subclass | ||
34 | * Archive ar( sOut, Archive::save ); | ||
35 | * ar << myClass; | ||
36 | @endcode | ||
37 | * In this example myClass is any class that inherits from Archival. When | ||
38 | * the storage operator is called, the Archival::archive() function in the | ||
39 | * myClass object is called with a reference to the Archive. This can be | ||
40 | * handled in one of two ways: | ||
41 | *@code | ||
42 | * void MyClass::archive( Archive &ar ) | ||
43 | * { | ||
44 | * ar && sName && nAge && sJob; | ||
45 | * } | ||
46 | @endcode | ||
47 | * Here we don't worry about weather we're loading or saving by using the | ||
48 | * smart && operator. This allows us to write very consistent, very simple | ||
49 | * archive functions that really do a lot of work. If we wanted to do | ||
50 | * something different in the case of loading or saving we would do: | ||
51 | *@code | ||
52 | * void MyClass::archive( Archive &ar ) | ||
53 | * { | ||
54 | * if( ar.isLoading() ) | ||
55 | * { | ||
56 | * ar >> sName >> nAge >> sJob; | ||
57 | * } else | ||
58 | * { | ||
59 | * ar << sName << nAge << sJob; | ||
60 | * } | ||
61 | * } | ||
62 | @endcode | ||
63 | * Archive currently does not provide facility to make fully portable | ||
64 | * archives. For example, it will not convert between endianness for you, | ||
65 | * nor will it take into account differences between primitive sizes on | ||
66 | * different platforms. This, at the moment, is up to the user to ensure. | ||
67 | * One way of dealing with the latter problem is to make sure and use | ||
68 | * explicit primitive types from the stdint.h header, i.e. int32_t. | ||
69 | */ | ||
70 | class Archive : public ArchiveBase | ||
71 | { | 20 | { |
72 | private: | ||
73 | bool bLoading; | ||
74 | public: | 21 | public: |
75 | bool isLoading(); | 22 | Archive(); |
76 | 23 | virtual ~Archive(); | |
24 | |||
77 | enum | 25 | enum |
78 | { | 26 | { |
79 | load = true, | 27 | load = true, |
80 | save = false | 28 | save = false |
81 | }; | 29 | }; |
82 | 30 | ||
83 | Archive( Stream &rStream, bool bLoading ); | 31 | virtual void close()=0; |
84 | virtual ~Archive(); | 32 | virtual void write( const void *pData, size_t iLength )=0; |
85 | virtual void close(); | 33 | virtual void read( void *pData, size_t iLength )=0; |
86 | 34 | virtual bool isLoading()=0; | |
87 | virtual void write( const void *pData, size_t iSize ); | ||
88 | virtual void read( void *pData, size_t iSize ); | ||
89 | |||
90 | /** | ||
91 | * For storage, get an ID for the pointer to the object you're going to | ||
92 | * write. | ||
93 | */ | ||
94 | uint32_t getID( const void *ptr ); | ||
95 | |||
96 | /** | ||
97 | * For loading. Assosiates an empty pointer with an id. When you wind | ||
98 | * up loading an id reference to a pointer for an object that may or | ||
99 | * may not have loaded yet, call this with the id, if it has been loaded | ||
100 | * already, you'll immediately get a pointer, if not, it will write one | ||
101 | * for you when the time comes. | ||
102 | */ | ||
103 | void assocPtrID( void **ptr, uint32_t id ); | ||
104 | |||
105 | /** | ||
106 | * For loading. Call this when you load an object that other things may | ||
107 | * have pointers to. It will assosiate every pointer that's been | ||
108 | * registered with assocPtrID to the pointer passed in, and id passed | ||
109 | * in. It will also set things up so future calls to assocPtrID will | ||
110 | * automatically succeed immediately. | ||
111 | */ | ||
112 | void readID( const void *ptr, uint32_t id ); | ||
113 | 35 | ||
114 | virtual void setProperty( const Bu::Blob &rKey, | 36 | virtual void setProperty( const Bu::Blob &rKey, |
115 | const Bu::Variant &rValue ); | 37 | const Bu::Variant &rValue )=0; |
116 | virtual Bu::Variant getProperty( const Bu::Blob &rKey ) const; | 38 | virtual Bu::Variant getProperty( const Bu::Blob &rKey ) const=0; |
117 | |||
118 | private: | ||
119 | Stream &rStream; | ||
120 | uint32_t nNextID; | ||
121 | Hash<uint32_t,ptrdiff_t> hPtrID; | ||
122 | Hash<uint32_t,List<void **> > hPtrDest; | ||
123 | Hash<Bu::Blob, Variant> hProps; | ||
124 | }; | 39 | }; |
125 | } | 40 | |
41 | template<typename T> Archive &operator&&( Archive &ar, T &dat ) | ||
42 | { | ||
43 | if( ar.isLoading() ) | ||
44 | { | ||
45 | return ar >> dat; | ||
46 | } | ||
47 | else | ||
48 | { | ||
49 | return ar << dat; | ||
50 | } | ||
51 | } | ||
52 | |||
53 | Archive &operator<<( Archive &ar, bool p ); | ||
54 | Archive &operator<<( Archive &ar, char p ); | ||
55 | Archive &operator<<( Archive &ar, signed char p ); | ||
56 | Archive &operator<<( Archive &ar, unsigned char p ); | ||
57 | Archive &operator<<( Archive &ar, signed short p ); | ||
58 | Archive &operator<<( Archive &ar, unsigned short p ); | ||
59 | Archive &operator<<( Archive &ar, signed int p ); | ||
60 | Archive &operator<<( Archive &ar, unsigned int p ); | ||
61 | Archive &operator<<( Archive &ar, signed long p ); | ||
62 | Archive &operator<<( Archive &ar, unsigned long p ); | ||
63 | Archive &operator<<( Archive &ar, signed long long p ); | ||
64 | Archive &operator<<( Archive &ar, unsigned long long p ); | ||
65 | Archive &operator<<( Archive &ar, float p ); | ||
66 | Archive &operator<<( Archive &ar, double p ); | ||
67 | Archive &operator<<( Archive &ar, long double p ); | ||
68 | |||
69 | Archive &operator>>( Archive &ar, bool &p ); | ||
70 | Archive &operator>>( Archive &ar, char &p ); | ||
71 | Archive &operator>>( Archive &ar, signed char &p ); | ||
72 | Archive &operator>>( Archive &ar, unsigned char &p ); | ||
73 | Archive &operator>>( Archive &ar, signed short &p ); | ||
74 | Archive &operator>>( Archive &ar, unsigned short &p ); | ||
75 | Archive &operator>>( Archive &ar, signed int &p ); | ||
76 | Archive &operator>>( Archive &ar, unsigned int &p ); | ||
77 | Archive &operator>>( Archive &ar, signed long &p ); | ||
78 | Archive &operator>>( Archive &ar, unsigned long &p ); | ||
79 | Archive &operator>>( Archive &ar, signed long long &p ); | ||
80 | Archive &operator>>( Archive &ar, unsigned long long &p ); | ||
81 | Archive &operator>>( Archive &ar, float &p ); | ||
82 | Archive &operator>>( Archive &ar, double &p ); | ||
83 | Archive &operator>>( Archive &ar, long double &p ); | ||
84 | }; | ||
126 | 85 | ||
127 | #endif | 86 | #endif |
diff --git a/src/stable/archivebase.cpp b/src/stable/archivebase.cpp deleted file mode 100644 index d2d80a1..0000000 --- a/src/stable/archivebase.cpp +++ /dev/null | |||
@@ -1,197 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2019 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #include "bu/archivebase.h" | ||
9 | |||
10 | Bu::ArchiveBase::ArchiveBase() | ||
11 | { | ||
12 | } | ||
13 | |||
14 | Bu::ArchiveBase::~ArchiveBase() | ||
15 | { | ||
16 | } | ||
17 | |||
18 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, bool p) | ||
19 | { | ||
20 | ar.write( &p, sizeof(p) ); | ||
21 | return ar; | ||
22 | } | ||
23 | |||
24 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, char p) | ||
25 | { | ||
26 | ar.write( &p, sizeof(p) ); | ||
27 | return ar; | ||
28 | } | ||
29 | |||
30 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, signed char p) | ||
31 | { | ||
32 | ar.write( &p, sizeof(p) ); | ||
33 | return ar; | ||
34 | } | ||
35 | |||
36 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, unsigned char p) | ||
37 | { | ||
38 | ar.write( &p, sizeof(p) ); | ||
39 | return ar; | ||
40 | } | ||
41 | |||
42 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, signed short p) | ||
43 | { | ||
44 | ar.write( &p, sizeof(p) ); | ||
45 | return ar; | ||
46 | } | ||
47 | |||
48 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, unsigned short p) | ||
49 | { | ||
50 | ar.write( &p, sizeof(p) ); | ||
51 | return ar; | ||
52 | } | ||
53 | |||
54 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, signed int p) | ||
55 | { | ||
56 | ar.write( &p, sizeof(p) ); | ||
57 | return ar; | ||
58 | } | ||
59 | |||
60 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, unsigned int p) | ||
61 | { | ||
62 | ar.write( &p, sizeof(p) ); | ||
63 | return ar; | ||
64 | } | ||
65 | |||
66 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, signed long p) | ||
67 | { | ||
68 | ar.write( &p, sizeof(p) ); | ||
69 | return ar; | ||
70 | } | ||
71 | |||
72 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, unsigned long p) | ||
73 | { | ||
74 | ar.write( &p, sizeof(p) ); | ||
75 | return ar; | ||
76 | } | ||
77 | |||
78 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, signed long long p) | ||
79 | { | ||
80 | ar.write( &p, sizeof(p) ); | ||
81 | return ar; | ||
82 | } | ||
83 | |||
84 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, unsigned long long p) | ||
85 | { | ||
86 | ar.write( &p, sizeof(p) ); | ||
87 | return ar; | ||
88 | } | ||
89 | |||
90 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, float p) | ||
91 | { | ||
92 | ar.write( &p, sizeof(p) ); | ||
93 | return ar; | ||
94 | } | ||
95 | |||
96 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, double p) | ||
97 | { | ||
98 | ar.write( &p, sizeof(p) ); | ||
99 | return ar; | ||
100 | } | ||
101 | |||
102 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, long double p) | ||
103 | { | ||
104 | ar.write( &p, sizeof(p) ); | ||
105 | return ar; | ||
106 | } | ||
107 | |||
108 | Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, bool &p) | ||
109 | { | ||
110 | ar.read( &p, sizeof(p) ); | ||
111 | return ar; | ||
112 | } | ||
113 | |||
114 | Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, char &p) | ||
115 | { | ||
116 | ar.read( &p, sizeof(p) ); | ||
117 | return ar; | ||
118 | } | ||
119 | |||
120 | Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, signed char &p) | ||
121 | { | ||
122 | ar.read( &p, sizeof(p) ); | ||
123 | return ar; | ||
124 | } | ||
125 | |||
126 | Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, unsigned char &p) | ||
127 | { | ||
128 | ar.read( &p, sizeof(p) ); | ||
129 | return ar; | ||
130 | } | ||
131 | |||
132 | Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, signed short &p) | ||
133 | { | ||
134 | ar.read( &p, sizeof(p) ); | ||
135 | return ar; | ||
136 | } | ||
137 | |||
138 | Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, unsigned short &p) | ||
139 | { | ||
140 | ar.read( &p, sizeof(p) ); | ||
141 | return ar; | ||
142 | } | ||
143 | |||
144 | Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, signed int &p) | ||
145 | { | ||
146 | ar.read( &p, sizeof(p) ); | ||
147 | return ar; | ||
148 | } | ||
149 | |||
150 | Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, unsigned int &p) | ||
151 | { | ||
152 | ar.read( &p, sizeof(p) ); | ||
153 | return ar; | ||
154 | } | ||
155 | |||
156 | Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, signed long &p) | ||
157 | { | ||
158 | ar.read( &p, sizeof(p) ); | ||
159 | return ar; | ||
160 | } | ||
161 | |||
162 | Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, unsigned long &p) | ||
163 | { | ||
164 | ar.read( &p, sizeof(p) ); | ||
165 | return ar; | ||
166 | } | ||
167 | |||
168 | Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, signed long long &p) | ||
169 | { | ||
170 | ar.read( &p, sizeof(p) ); | ||
171 | return ar; | ||
172 | } | ||
173 | |||
174 | Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, unsigned long long &p) | ||
175 | { | ||
176 | ar.read( &p, sizeof(p) ); | ||
177 | return ar; | ||
178 | } | ||
179 | |||
180 | Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, float &p) | ||
181 | { | ||
182 | ar.read( &p, sizeof(p) ); | ||
183 | return ar; | ||
184 | } | ||
185 | |||
186 | Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, double &p) | ||
187 | { | ||
188 | ar.read( &p, sizeof(p) ); | ||
189 | return ar; | ||
190 | } | ||
191 | |||
192 | Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, long double &p) | ||
193 | { | ||
194 | ar.read( &p, sizeof(p) ); | ||
195 | return ar; | ||
196 | } | ||
197 | |||
diff --git a/src/stable/archivebase.h b/src/stable/archivebase.h deleted file mode 100644 index d846c27..0000000 --- a/src/stable/archivebase.h +++ /dev/null | |||
@@ -1,80 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2019 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #ifndef BU_ARCHIVE_BASE_H | ||
9 | #define BU_ARCHIVE_BASE_H | ||
10 | |||
11 | #include <stdint.h> | ||
12 | #include <unistd.h> | ||
13 | |||
14 | #include "bu/variant.h" | ||
15 | #include "bu/blob.h" | ||
16 | |||
17 | namespace Bu | ||
18 | { | ||
19 | class ArchiveBase | ||
20 | { | ||
21 | public: | ||
22 | ArchiveBase(); | ||
23 | virtual ~ArchiveBase(); | ||
24 | |||
25 | virtual void close()=0; | ||
26 | virtual void write( const void *pData, size_t iLength )=0; | ||
27 | virtual void read( void *pData, size_t iLength )=0; | ||
28 | virtual bool isLoading()=0; | ||
29 | |||
30 | virtual void setProperty( const Bu::Blob &rKey, | ||
31 | const Bu::Variant &rValue )=0; | ||
32 | virtual Bu::Variant getProperty( const Bu::Blob &rKey ) const=0; | ||
33 | }; | ||
34 | |||
35 | template<typename T> ArchiveBase &operator&&( ArchiveBase &ar, T &dat ) | ||
36 | { | ||
37 | if( ar.isLoading() ) | ||
38 | { | ||
39 | return ar >> dat; | ||
40 | } | ||
41 | else | ||
42 | { | ||
43 | return ar << dat; | ||
44 | } | ||
45 | } | ||
46 | |||
47 | ArchiveBase &operator<<( ArchiveBase &ar, bool p ); | ||
48 | ArchiveBase &operator<<( ArchiveBase &ar, char p ); | ||
49 | ArchiveBase &operator<<( ArchiveBase &ar, signed char p ); | ||
50 | ArchiveBase &operator<<( ArchiveBase &ar, unsigned char p ); | ||
51 | ArchiveBase &operator<<( ArchiveBase &ar, signed short p ); | ||
52 | ArchiveBase &operator<<( ArchiveBase &ar, unsigned short p ); | ||
53 | ArchiveBase &operator<<( ArchiveBase &ar, signed int p ); | ||
54 | ArchiveBase &operator<<( ArchiveBase &ar, unsigned int p ); | ||
55 | ArchiveBase &operator<<( ArchiveBase &ar, signed long p ); | ||
56 | ArchiveBase &operator<<( ArchiveBase &ar, unsigned long p ); | ||
57 | ArchiveBase &operator<<( ArchiveBase &ar, signed long long p ); | ||
58 | ArchiveBase &operator<<( ArchiveBase &ar, unsigned long long p ); | ||
59 | ArchiveBase &operator<<( ArchiveBase &ar, float p ); | ||
60 | ArchiveBase &operator<<( ArchiveBase &ar, double p ); | ||
61 | ArchiveBase &operator<<( ArchiveBase &ar, long double p ); | ||
62 | |||
63 | ArchiveBase &operator>>( ArchiveBase &ar, bool &p ); | ||
64 | ArchiveBase &operator>>( ArchiveBase &ar, char &p ); | ||
65 | ArchiveBase &operator>>( ArchiveBase &ar, signed char &p ); | ||
66 | ArchiveBase &operator>>( ArchiveBase &ar, unsigned char &p ); | ||
67 | ArchiveBase &operator>>( ArchiveBase &ar, signed short &p ); | ||
68 | ArchiveBase &operator>>( ArchiveBase &ar, unsigned short &p ); | ||
69 | ArchiveBase &operator>>( ArchiveBase &ar, signed int &p ); | ||
70 | ArchiveBase &operator>>( ArchiveBase &ar, unsigned int &p ); | ||
71 | ArchiveBase &operator>>( ArchiveBase &ar, signed long &p ); | ||
72 | ArchiveBase &operator>>( ArchiveBase &ar, unsigned long &p ); | ||
73 | ArchiveBase &operator>>( ArchiveBase &ar, signed long long &p ); | ||
74 | ArchiveBase &operator>>( ArchiveBase &ar, unsigned long long &p ); | ||
75 | ArchiveBase &operator>>( ArchiveBase &ar, float &p ); | ||
76 | ArchiveBase &operator>>( ArchiveBase &ar, double &p ); | ||
77 | ArchiveBase &operator>>( ArchiveBase &ar, long double &p ); | ||
78 | }; | ||
79 | |||
80 | #endif | ||
diff --git a/src/stable/archivebinary.cpp b/src/stable/archivebinary.cpp new file mode 100644 index 0000000..3f05947 --- /dev/null +++ b/src/stable/archivebinary.cpp | |||
@@ -0,0 +1,98 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2019 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #include "bu/archivebinary.h" | ||
9 | #include "bu/stream.h" | ||
10 | |||
11 | #include "bu/sio.h" | ||
12 | |||
13 | Bu::ArchiveBinary::ArchiveBinary( Stream &rStream, bool bLoading ) : | ||
14 | bLoading( bLoading ), | ||
15 | rStream( rStream ), | ||
16 | nNextID( 1 ) | ||
17 | { | ||
18 | } | ||
19 | |||
20 | Bu::ArchiveBinary::~ArchiveBinary() | ||
21 | { | ||
22 | } | ||
23 | |||
24 | void Bu::ArchiveBinary::write( const void *pData, size_t nSize ) | ||
25 | { | ||
26 | if( nSize == 0 || pData == NULL ) | ||
27 | return; | ||
28 | |||
29 | rStream.write( (const char *)pData, nSize ); | ||
30 | } | ||
31 | |||
32 | void Bu::ArchiveBinary::read( void *pData, size_t nSize ) | ||
33 | { | ||
34 | if( nSize == 0 || pData == NULL ) | ||
35 | return; | ||
36 | |||
37 | if( (size_t)rStream.read( (char *)pData, nSize ) < nSize ) | ||
38 | throw Bu::ExceptionBase("Insufficient data to unarchive object."); | ||
39 | } | ||
40 | |||
41 | void Bu::ArchiveBinary::close() | ||
42 | { | ||
43 | rStream.close(); | ||
44 | } | ||
45 | |||
46 | bool Bu::ArchiveBinary::isLoading() | ||
47 | { | ||
48 | return bLoading; | ||
49 | } | ||
50 | |||
51 | uint32_t Bu::ArchiveBinary::getID( const void *ptr ) | ||
52 | { | ||
53 | if( hPtrID.has( (ptrdiff_t)ptr ) ) | ||
54 | return hPtrID.get( (ptrdiff_t)ptr ); | ||
55 | hPtrID.insert( (ptrdiff_t)ptr, nNextID ); | ||
56 | return nNextID++; | ||
57 | } | ||
58 | |||
59 | void Bu::ArchiveBinary::assocPtrID( void **ptr, uint32_t id ) | ||
60 | { | ||
61 | if( hPtrID.has( id ) ) | ||
62 | { | ||
63 | *ptr = (void *)hPtrID.get( id ); | ||
64 | return; | ||
65 | } | ||
66 | |||
67 | if( !hPtrDest.has( id ) ) | ||
68 | hPtrDest.insert( id, List<void **>() ); | ||
69 | |||
70 | hPtrDest[id].getValue().append( ptr ); | ||
71 | } | ||
72 | |||
73 | void Bu::ArchiveBinary::readID( const void *ptr, uint32_t id ) | ||
74 | { | ||
75 | hPtrID.insert( id, (ptrdiff_t)ptr ); | ||
76 | |||
77 | if( hPtrDest.has( id ) ) | ||
78 | { | ||
79 | Bu::List<void **> &l = hPtrDest.get( id ); | ||
80 | for( Bu::List<void **>::iterator i = l.begin(); i != l.end(); i++ ) | ||
81 | { | ||
82 | *(*i) = (void *)ptr; | ||
83 | } | ||
84 | |||
85 | hPtrDest.erase( id ); | ||
86 | } | ||
87 | } | ||
88 | |||
89 | void Bu::ArchiveBinary::setProperty( const Bu::Blob &rKey, const Bu::Variant &rValue ) | ||
90 | { | ||
91 | hProps.insert( rKey, rValue ); | ||
92 | } | ||
93 | |||
94 | Bu::Variant Bu::ArchiveBinary::getProperty( const Bu::Blob &rKey ) const | ||
95 | { | ||
96 | return hProps.get( rKey ); | ||
97 | } | ||
98 | |||
diff --git a/src/stable/archivebinary.h b/src/stable/archivebinary.h new file mode 100644 index 0000000..4c12e02 --- /dev/null +++ b/src/stable/archivebinary.h | |||
@@ -0,0 +1,120 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2019 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #ifndef BU_ARCHIVE_BINARY_H | ||
9 | #define BU_ARCHIVE_BINARY_H | ||
10 | |||
11 | #include <stdint.h> | ||
12 | #include "bu/archive.h" | ||
13 | #include "bu/hash.h" | ||
14 | #include "bu/util.h" | ||
15 | #include "bu/variant.h" | ||
16 | #include "bu/blob.h" | ||
17 | |||
18 | namespace Bu | ||
19 | { | ||
20 | class Stream; | ||
21 | |||
22 | /** | ||
23 | * Provides a framework for serialization of objects and primitives. The | ||
24 | * archive will handle any basic primitive, a few special types, like char * | ||
25 | * strings, as well as STL classes and anything that inherits from the | ||
26 | * Archival class. Each ArchiveBinary operates on a Stream, so you can send the | ||
27 | * data using an ArchiveBinary almost anywhere. | ||
28 | * | ||
29 | * In order to use an ArchiveBinary to store something to a file, try something | ||
30 | * like: | ||
31 | *@code | ||
32 | * File sOut("output", "wb"); // This is a stream subclass | ||
33 | * ArchiveBinary ar( sOut, ArchiveBinary::save ); | ||
34 | * ar << myClass; | ||
35 | @endcode | ||
36 | * In this example myClass is any class that inherits from Archival. When | ||
37 | * the storage operator is called, the Archival::archive() function in the | ||
38 | * myClass object is called with a reference to the ArchiveBinary. This can be | ||
39 | * handled in one of two ways: | ||
40 | *@code | ||
41 | * void MyClass::archive( ArchiveBinary &ar ) | ||
42 | * { | ||
43 | * ar && sName && nAge && sJob; | ||
44 | * } | ||
45 | @endcode | ||
46 | * Here we don't worry about weather we're loading or saving by using the | ||
47 | * smart && operator. This allows us to write very consistent, very simple | ||
48 | * archive functions that really do a lot of work. If we wanted to do | ||
49 | * something different in the case of loading or saving we would do: | ||
50 | *@code | ||
51 | * void MyClass::archive( ArchiveBinary &ar ) | ||
52 | * { | ||
53 | * if( ar.isLoading() ) | ||
54 | * { | ||
55 | * ar >> sName >> nAge >> sJob; | ||
56 | * } else | ||
57 | * { | ||
58 | * ar << sName << nAge << sJob; | ||
59 | * } | ||
60 | * } | ||
61 | @endcode | ||
62 | * ArchiveBinary currently does not provide facility to make fully portable | ||
63 | * archives. For example, it will not convert between endianness for you, | ||
64 | * nor will it take into account differences between primitive sizes on | ||
65 | * different platforms. This, at the moment, is up to the user to ensure. | ||
66 | * One way of dealing with the latter problem is to make sure and use | ||
67 | * explicit primitive types from the stdint.h header, i.e. int32_t. | ||
68 | */ | ||
69 | class ArchiveBinary : public Archive | ||
70 | { | ||
71 | private: | ||
72 | bool bLoading; | ||
73 | public: | ||
74 | bool isLoading(); | ||
75 | |||
76 | ArchiveBinary( Stream &rStream, bool bLoading ); | ||
77 | virtual ~ArchiveBinary(); | ||
78 | virtual void close(); | ||
79 | |||
80 | virtual void write( const void *pData, size_t iSize ); | ||
81 | virtual void read( void *pData, size_t iSize ); | ||
82 | |||
83 | /** | ||
84 | * For storage, get an ID for the pointer to the object you're going to | ||
85 | * write. | ||
86 | */ | ||
87 | uint32_t getID( const void *ptr ); | ||
88 | |||
89 | /** | ||
90 | * For loading. Assosiates an empty pointer with an id. When you wind | ||
91 | * up loading an id reference to a pointer for an object that may or | ||
92 | * may not have loaded yet, call this with the id, if it has been loaded | ||
93 | * already, you'll immediately get a pointer, if not, it will write one | ||
94 | * for you when the time comes. | ||
95 | */ | ||
96 | void assocPtrID( void **ptr, uint32_t id ); | ||
97 | |||
98 | /** | ||
99 | * For loading. Call this when you load an object that other things may | ||
100 | * have pointers to. It will assosiate every pointer that's been | ||
101 | * registered with assocPtrID to the pointer passed in, and id passed | ||
102 | * in. It will also set things up so future calls to assocPtrID will | ||
103 | * automatically succeed immediately. | ||
104 | */ | ||
105 | void readID( const void *ptr, uint32_t id ); | ||
106 | |||
107 | virtual void setProperty( const Bu::Blob &rKey, | ||
108 | const Bu::Variant &rValue ); | ||
109 | virtual Bu::Variant getProperty( const Bu::Blob &rKey ) const; | ||
110 | |||
111 | private: | ||
112 | Stream &rStream; | ||
113 | uint32_t nNextID; | ||
114 | Hash<uint32_t,ptrdiff_t> hPtrID; | ||
115 | Hash<uint32_t,List<void **> > hPtrDest; | ||
116 | Hash<Bu::Blob, Variant> hProps; | ||
117 | }; | ||
118 | } | ||
119 | |||
120 | #endif | ||
diff --git a/src/stable/array.h b/src/stable/array.h index ca66213..6069832 100644 --- a/src/stable/array.h +++ b/src/stable/array.h | |||
@@ -10,7 +10,7 @@ | |||
10 | 10 | ||
11 | #include <memory> | 11 | #include <memory> |
12 | #include "bu/exceptionbase.h" | 12 | #include "bu/exceptionbase.h" |
13 | #include "bu/archivebase.h" | 13 | #include "bu/archive.h" |
14 | #include "bu/sharedcore.h" | 14 | #include "bu/sharedcore.h" |
15 | 15 | ||
16 | namespace Bu | 16 | namespace Bu |
@@ -761,7 +761,7 @@ namespace Bu | |||
761 | } | 761 | } |
762 | 762 | ||
763 | template<typename value, int inc, typename valuealloc> | 763 | template<typename value, int inc, typename valuealloc> |
764 | ArchiveBase &operator<<( ArchiveBase &ar, | 764 | Archive &operator<<( Archive &ar, |
765 | const Array<value, inc, valuealloc> &h ) | 765 | const Array<value, inc, valuealloc> &h ) |
766 | { | 766 | { |
767 | ar << h.getSize(); | 767 | ar << h.getSize(); |
@@ -775,7 +775,7 @@ namespace Bu | |||
775 | } | 775 | } |
776 | 776 | ||
777 | template<typename value, int inc, typename valuealloc> | 777 | template<typename value, int inc, typename valuealloc> |
778 | ArchiveBase &operator>>(ArchiveBase &ar, Array<value, inc, valuealloc> &h ) | 778 | Archive &operator>>(Archive &ar, Array<value, inc, valuealloc> &h ) |
779 | { | 779 | { |
780 | h.clear(); | 780 | h.clear(); |
781 | long nSize; | 781 | long nSize; |
diff --git a/src/stable/hash.h b/src/stable/hash.h index 0c5bd9e..e515088 100644 --- a/src/stable/hash.h +++ b/src/stable/hash.h | |||
@@ -12,7 +12,7 @@ | |||
12 | #include "bu/exceptionbase.h" | 12 | #include "bu/exceptionbase.h" |
13 | #include "bu/list.h" | 13 | #include "bu/list.h" |
14 | #include "bu/util.h" | 14 | #include "bu/util.h" |
15 | #include "bu/archivebase.h" | 15 | #include "bu/archive.h" |
16 | #include "bu/sharedcore.h" | 16 | #include "bu/sharedcore.h" |
17 | 17 | ||
18 | namespace Bu | 18 | namespace Bu |
@@ -1319,7 +1319,7 @@ namespace Bu | |||
1319 | 1319 | ||
1320 | template<typename key, typename value, typename a, typename b, | 1320 | template<typename key, typename value, typename a, typename b, |
1321 | typename c, typename d> | 1321 | typename c, typename d> |
1322 | ArchiveBase &operator<<( ArchiveBase &ar, const Hash<key,value,a,b,c,d> &h ) | 1322 | Archive &operator<<( Archive &ar, const Hash<key,value,a,b,c,d> &h ) |
1323 | { | 1323 | { |
1324 | long iSize = h.getSize(); | 1324 | long iSize = h.getSize(); |
1325 | ar << iSize; | 1325 | ar << iSize; |
@@ -1334,7 +1334,7 @@ namespace Bu | |||
1334 | 1334 | ||
1335 | template<typename key, typename value, typename a, typename b, | 1335 | template<typename key, typename value, typename a, typename b, |
1336 | typename c, typename d> | 1336 | typename c, typename d> |
1337 | ArchiveBase &operator>>( ArchiveBase &ar, Hash<key,value,a,b,c,d> &h ) | 1337 | Archive &operator>>( Archive &ar, Hash<key,value,a,b,c,d> &h ) |
1338 | { | 1338 | { |
1339 | h.clear(); | 1339 | h.clear(); |
1340 | long nSize; | 1340 | long nSize; |
diff --git a/src/stable/list.h b/src/stable/list.h index c1a5559..5ef7ce0 100644 --- a/src/stable/list.h +++ b/src/stable/list.h | |||
@@ -11,7 +11,7 @@ | |||
11 | #include <memory> | 11 | #include <memory> |
12 | #include "bu/exceptionbase.h" | 12 | #include "bu/exceptionbase.h" |
13 | #include "bu/sharedcore.h" | 13 | #include "bu/sharedcore.h" |
14 | #include "bu/archivebase.h" | 14 | #include "bu/archive.h" |
15 | #include "bu/heap.h" | 15 | #include "bu/heap.h" |
16 | 16 | ||
17 | namespace Bu | 17 | namespace Bu |
@@ -1042,7 +1042,7 @@ namespace Bu | |||
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | template<typename value, typename a, typename b> | 1044 | template<typename value, typename a, typename b> |
1045 | ArchiveBase &operator<<( ArchiveBase &ar, const List<value,a,b> &h ) | 1045 | Archive &operator<<( Archive &ar, const List<value,a,b> &h ) |
1046 | { | 1046 | { |
1047 | ar << h.getSize(); | 1047 | ar << h.getSize(); |
1048 | for( typename List<value>::const_iterator i = h.begin(); i != h.end(); i++ ) | 1048 | for( typename List<value>::const_iterator i = h.begin(); i != h.end(); i++ ) |
@@ -1054,7 +1054,7 @@ namespace Bu | |||
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | template<typename value, typename a, typename b> | 1056 | template<typename value, typename a, typename b> |
1057 | ArchiveBase &operator>>( ArchiveBase &ar, List<value,a,b> &h ) | 1057 | Archive &operator>>( Archive &ar, List<value,a,b> &h ) |
1058 | { | 1058 | { |
1059 | h.clear(); | 1059 | h.clear(); |
1060 | long nSize; | 1060 | long nSize; |
diff --git a/src/stable/string.cpp b/src/stable/string.cpp index ed4e58b..c36b768 100644 --- a/src/stable/string.cpp +++ b/src/stable/string.cpp | |||
@@ -1520,7 +1520,7 @@ Bu::String &Bu::operator<<( Bu::String &dst, const Bu::String &sIn ) | |||
1520 | return dst; | 1520 | return dst; |
1521 | } | 1521 | } |
1522 | 1522 | ||
1523 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, const Bu::String &s ) | 1523 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, const Bu::String &s ) |
1524 | { | 1524 | { |
1525 | long n = s.getSize(); | 1525 | long n = s.getSize(); |
1526 | ar << n; | 1526 | ar << n; |
@@ -1528,7 +1528,7 @@ Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, const Bu::String &s ) | |||
1528 | return ar; | 1528 | return ar; |
1529 | } | 1529 | } |
1530 | 1530 | ||
1531 | Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, Bu::String &s ) | 1531 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, Bu::String &s ) |
1532 | { | 1532 | { |
1533 | long n; | 1533 | long n; |
1534 | ar >> n; | 1534 | ar >> n; |
diff --git a/src/stable/string.h b/src/stable/string.h index c469580..b4768bb 100644 --- a/src/stable/string.h +++ b/src/stable/string.h | |||
@@ -14,7 +14,7 @@ | |||
14 | #include "bu/util.h" | 14 | #include "bu/util.h" |
15 | #include "bu/sharedcore.h" | 15 | #include "bu/sharedcore.h" |
16 | #include "bu/exceptionbase.h" | 16 | #include "bu/exceptionbase.h" |
17 | #include "bu/archivebase.h" | 17 | #include "bu/archive.h" |
18 | #include "bu/list.h" | 18 | #include "bu/list.h" |
19 | #include "bu/fmt.h" | 19 | #include "bu/fmt.h" |
20 | #include "bu/variant.h" | 20 | #include "bu/variant.h" |
@@ -1051,8 +1051,8 @@ namespace Bu | |||
1051 | return ret; | 1051 | return ret; |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | ArchiveBase &operator<<( ArchiveBase &ar, const String &s ); | 1054 | Archive &operator<<( Archive &ar, const String &s ); |
1055 | ArchiveBase &operator>>( ArchiveBase &ar, String &s ); | 1055 | Archive &operator>>( Archive &ar, String &s ); |
1056 | 1056 | ||
1057 | template<typename T> | 1057 | template<typename T> |
1058 | uint32_t __calcHashCode( const T &k ); | 1058 | uint32_t __calcHashCode( const T &k ); |
diff --git a/src/tests/cache.cpp b/src/tests/cache.cpp index 4751559..3b32daf 100644 --- a/src/tests/cache.cpp +++ b/src/tests/cache.cpp | |||
@@ -5,8 +5,8 @@ | |||
5 | 5 | ||
6 | class Something : public Bu::CacheObject<Bu::Uuid, Something> | 6 | class Something : public Bu::CacheObject<Bu::Uuid, Something> |
7 | { | 7 | { |
8 | friend Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, Something &s ); | 8 | friend Bu::Archive &operator>>( Bu::Archive &ar, Something &s ); |
9 | friend Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const Something &s ); | 9 | friend Bu::Archive &operator<<( Bu::Archive &ar, const Something &s ); |
10 | public: | 10 | public: |
11 | Something() | 11 | Something() |
12 | { | 12 | { |
@@ -47,8 +47,8 @@ private: | |||
47 | 47 | ||
48 | class SubSomethingA : public Something | 48 | class SubSomethingA : public Something |
49 | { | 49 | { |
50 | friend Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, SubSomethingA &s ); | 50 | friend Bu::Archive &operator>>( Bu::Archive &ar, SubSomethingA &s ); |
51 | friend Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const SubSomethingA &s ); | 51 | friend Bu::Archive &operator<<( Bu::Archive &ar, const SubSomethingA &s ); |
52 | public: | 52 | public: |
53 | SubSomethingA() | 53 | SubSomethingA() |
54 | { | 54 | { |
@@ -71,8 +71,8 @@ private: | |||
71 | 71 | ||
72 | class SubSomethingB : public Something | 72 | class SubSomethingB : public Something |
73 | { | 73 | { |
74 | friend Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, SubSomethingB &s ); | 74 | friend Bu::Archive &operator>>( Bu::Archive &ar, SubSomethingB &s ); |
75 | friend Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const SubSomethingB &s ); | 75 | friend Bu::Archive &operator<<( Bu::Archive &ar, const SubSomethingB &s ); |
76 | public: | 76 | public: |
77 | SubSomethingB() | 77 | SubSomethingB() |
78 | { | 78 | { |
@@ -93,32 +93,32 @@ private: | |||
93 | Bu::String sString; | 93 | Bu::String sString; |
94 | }; | 94 | }; |
95 | 95 | ||
96 | Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, Something &s ) | 96 | Bu::Archive &operator>>( Bu::Archive &ar, Something &s ) |
97 | { | 97 | { |
98 | return ar >> s.uId >> s.sName; | 98 | return ar >> s.uId >> s.sName; |
99 | } | 99 | } |
100 | 100 | ||
101 | Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const Something &s ) | 101 | Bu::Archive &operator<<( Bu::Archive &ar, const Something &s ) |
102 | { | 102 | { |
103 | return ar << s.uId << s.sName; | 103 | return ar << s.uId << s.sName; |
104 | } | 104 | } |
105 | 105 | ||
106 | Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, SubSomethingA &s ) | 106 | Bu::Archive &operator>>( Bu::Archive &ar, SubSomethingA &s ) |
107 | { | 107 | { |
108 | return ar >> (Something &)s >> s.iNumber; | 108 | return ar >> (Something &)s >> s.iNumber; |
109 | } | 109 | } |
110 | 110 | ||
111 | Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const SubSomethingA &s ) | 111 | Bu::Archive &operator<<( Bu::Archive &ar, const SubSomethingA &s ) |
112 | { | 112 | { |
113 | return ar << (Something &)s << s.iNumber; | 113 | return ar << (Something &)s << s.iNumber; |
114 | } | 114 | } |
115 | 115 | ||
116 | Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, SubSomethingB &s ) | 116 | Bu::Archive &operator>>( Bu::Archive &ar, SubSomethingB &s ) |
117 | { | 117 | { |
118 | return ar >> (Something &)s >> s.sString; | 118 | return ar >> (Something &)s >> s.sString; |
119 | } | 119 | } |
120 | 120 | ||
121 | Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const SubSomethingB &s ) | 121 | Bu::Archive &operator<<( Bu::Archive &ar, const SubSomethingB &s ) |
122 | { | 122 | { |
123 | return ar << (Something &)s << s.sString; | 123 | return ar << (Something &)s << s.sString; |
124 | } | 124 | } |
@@ -128,7 +128,7 @@ namespace Bu | |||
128 | template<> | 128 | template<> |
129 | void _cacheObjectSave<const Something>( Bu::Stream &s, const Something *pObject ) | 129 | void _cacheObjectSave<const Something>( Bu::Stream &s, const Something *pObject ) |
130 | { | 130 | { |
131 | Bu::Archive ar( s, Bu::Archive::save ); | 131 | Bu::ArchiveBinary ar( s, Bu::ArchiveBinary::save ); |
132 | if( typeid(*pObject) == typeid(SubSomethingA) ) | 132 | if( typeid(*pObject) == typeid(SubSomethingA) ) |
133 | { | 133 | { |
134 | ar << (uint8_t)1 << (SubSomethingA &)*pObject; | 134 | ar << (uint8_t)1 << (SubSomethingA &)*pObject; |
@@ -147,7 +147,7 @@ namespace Bu | |||
147 | template<> | 147 | template<> |
148 | Something *_cacheObjectLoad<Bu::Uuid, Something>( Bu::CacheObject<Bu::Uuid, Something>::Initializer &initObj, const Bu::Uuid &rKey, Bu::Stream &s ) | 148 | Something *_cacheObjectLoad<Bu::Uuid, Something>( Bu::CacheObject<Bu::Uuid, Something>::Initializer &initObj, const Bu::Uuid &rKey, Bu::Stream &s ) |
149 | { | 149 | { |
150 | Bu::Archive ar( s, Bu::Archive::load ); | 150 | Bu::ArchiveBinary ar( s, Bu::ArchiveBinary::load ); |
151 | uint8_t uType; | 151 | uint8_t uType; |
152 | ar >> uType; | 152 | ar >> uType; |
153 | switch( uType ) | 153 | switch( uType ) |
diff --git a/src/tests/cachedel.cpp b/src/tests/cachedel.cpp index 817757c..fd40994 100644 --- a/src/tests/cachedel.cpp +++ b/src/tests/cachedel.cpp | |||
@@ -6,8 +6,8 @@ | |||
6 | 6 | ||
7 | class Something : public Bu::CacheObject<Bu::Uuid, Something> | 7 | class Something : public Bu::CacheObject<Bu::Uuid, Something> |
8 | { | 8 | { |
9 | friend Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, Something &s ); | 9 | friend Bu::Archive &operator>>( Bu::Archive &ar, Something &s ); |
10 | friend Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const Something &s ); | 10 | friend Bu::Archive &operator<<( Bu::Archive &ar, const Something &s ); |
11 | public: | 11 | public: |
12 | Something() | 12 | Something() |
13 | { | 13 | { |
@@ -48,8 +48,8 @@ private: | |||
48 | 48 | ||
49 | class SubSomethingA : public Something | 49 | class SubSomethingA : public Something |
50 | { | 50 | { |
51 | friend Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, SubSomethingA &s ); | 51 | friend Bu::Archive &operator>>( Bu::Archive &ar, SubSomethingA &s ); |
52 | friend Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const SubSomethingA &s ); | 52 | friend Bu::Archive &operator<<( Bu::Archive &ar, const SubSomethingA &s ); |
53 | public: | 53 | public: |
54 | SubSomethingA() | 54 | SubSomethingA() |
55 | { | 55 | { |
@@ -72,8 +72,8 @@ private: | |||
72 | 72 | ||
73 | class SubSomethingB : public Something | 73 | class SubSomethingB : public Something |
74 | { | 74 | { |
75 | friend Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, SubSomethingB &s ); | 75 | friend Bu::Archive &operator>>( Bu::Archive &ar, SubSomethingB &s ); |
76 | friend Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const SubSomethingB &s ); | 76 | friend Bu::Archive &operator<<( Bu::Archive &ar, const SubSomethingB &s ); |
77 | public: | 77 | public: |
78 | SubSomethingB() | 78 | SubSomethingB() |
79 | { | 79 | { |
@@ -94,32 +94,32 @@ private: | |||
94 | Bu::String sString; | 94 | Bu::String sString; |
95 | }; | 95 | }; |
96 | 96 | ||
97 | Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, Something &s ) | 97 | Bu::Archive &operator>>( Bu::Archive &ar, Something &s ) |
98 | { | 98 | { |
99 | return ar >> s.uId >> s.sName; | 99 | return ar >> s.uId >> s.sName; |
100 | } | 100 | } |
101 | 101 | ||
102 | Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const Something &s ) | 102 | Bu::Archive &operator<<( Bu::Archive &ar, const Something &s ) |
103 | { | 103 | { |
104 | return ar << s.uId << s.sName; | 104 | return ar << s.uId << s.sName; |
105 | } | 105 | } |
106 | 106 | ||
107 | Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, SubSomethingA &s ) | 107 | Bu::Archive &operator>>( Bu::Archive &ar, SubSomethingA &s ) |
108 | { | 108 | { |
109 | return ar >> (Something &)s >> s.iNumber; | 109 | return ar >> (Something &)s >> s.iNumber; |
110 | } | 110 | } |
111 | 111 | ||
112 | Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const SubSomethingA &s ) | 112 | Bu::Archive &operator<<( Bu::Archive &ar, const SubSomethingA &s ) |
113 | { | 113 | { |
114 | return ar << (Something &)s << s.iNumber; | 114 | return ar << (Something &)s << s.iNumber; |
115 | } | 115 | } |
116 | 116 | ||
117 | Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, SubSomethingB &s ) | 117 | Bu::Archive &operator>>( Bu::Archive &ar, SubSomethingB &s ) |
118 | { | 118 | { |
119 | return ar >> (Something &)s >> s.sString; | 119 | return ar >> (Something &)s >> s.sString; |
120 | } | 120 | } |
121 | 121 | ||
122 | Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const SubSomethingB &s ) | 122 | Bu::Archive &operator<<( Bu::Archive &ar, const SubSomethingB &s ) |
123 | { | 123 | { |
124 | return ar << (Something &)s << s.sString; | 124 | return ar << (Something &)s << s.sString; |
125 | } | 125 | } |
@@ -129,7 +129,7 @@ namespace Bu | |||
129 | template<> | 129 | template<> |
130 | void _cacheObjectSave<const Something>( Bu::Stream &s, const Something *pObject ) | 130 | void _cacheObjectSave<const Something>( Bu::Stream &s, const Something *pObject ) |
131 | { | 131 | { |
132 | Bu::Archive ar( s, Bu::Archive::save ); | 132 | Bu::ArchiveBinary ar( s, Bu::ArchiveBinary::save ); |
133 | if( typeid(*pObject) == typeid(SubSomethingA) ) | 133 | if( typeid(*pObject) == typeid(SubSomethingA) ) |
134 | { | 134 | { |
135 | ar << (uint8_t)1 << (SubSomethingA &)*pObject; | 135 | ar << (uint8_t)1 << (SubSomethingA &)*pObject; |
@@ -148,7 +148,7 @@ namespace Bu | |||
148 | template<> | 148 | template<> |
149 | Something *_cacheObjectLoad<Bu::Uuid, Something>( Bu::CacheObject<Bu::Uuid, Something>::Initializer &initObj, const Bu::Uuid &rKey, Bu::Stream &s ) | 149 | Something *_cacheObjectLoad<Bu::Uuid, Something>( Bu::CacheObject<Bu::Uuid, Something>::Initializer &initObj, const Bu::Uuid &rKey, Bu::Stream &s ) |
150 | { | 150 | { |
151 | Bu::Archive ar( s, Bu::Archive::load ); | 151 | Bu::ArchiveBinary ar( s, Bu::ArchiveBinary::load ); |
152 | uint8_t uType; | 152 | uint8_t uType; |
153 | ar >> uType; | 153 | ar >> uType; |
154 | switch( uType ) | 154 | switch( uType ) |
diff --git a/src/unit/archive.unit b/src/unit/archive.unit index 58f7d2b..6b975ac 100644 --- a/src/unit/archive.unit +++ b/src/unit/archive.unit | |||
@@ -8,17 +8,17 @@ | |||
8 | 8 | ||
9 | #include "bu/membuf.h" | 9 | #include "bu/membuf.h" |
10 | #include "bu/array.h" | 10 | #include "bu/array.h" |
11 | #include "bu/archive.h" | 11 | #include "bu/archivebinary.h" |
12 | 12 | ||
13 | using namespace Bu; | 13 | using namespace Bu; |
14 | 14 | ||
15 | suite Archive | 15 | suite ArchiveBinary |
16 | { | 16 | { |
17 | test primitives | 17 | test primitives |
18 | { | 18 | { |
19 | MemBuf mb; | 19 | MemBuf mb; |
20 | { | 20 | { |
21 | Archive ar( mb, Archive::save ); | 21 | ArchiveBinary ar( mb, ArchiveBinary::save ); |
22 | ar << (int8_t)1; | 22 | ar << (int8_t)1; |
23 | ar << (uint8_t)2; | 23 | ar << (uint8_t)2; |
24 | ar << (int16_t)3; | 24 | ar << (int16_t)3; |
@@ -41,7 +41,7 @@ suite Archive | |||
41 | } | 41 | } |
42 | mb.setPos( 0 ); | 42 | mb.setPos( 0 ); |
43 | { | 43 | { |
44 | Archive ar( mb, Archive::load ); | 44 | ArchiveBinary ar( mb, ArchiveBinary::load ); |
45 | int8_t p1; | 45 | int8_t p1; |
46 | uint8_t p2; | 46 | uint8_t p2; |
47 | int16_t p3; | 47 | int16_t p3; |
@@ -104,7 +104,7 @@ suite Archive | |||
104 | { | 104 | { |
105 | MemBuf mb; | 105 | MemBuf mb; |
106 | { | 106 | { |
107 | Archive ar( mb, Archive::save ); | 107 | ArchiveBinary ar( mb, ArchiveBinary::save ); |
108 | String sStr("This is a test string."); | 108 | String sStr("This is a test string."); |
109 | List<int> lList; | 109 | List<int> lList; |
110 | lList.append( 10 ); | 110 | lList.append( 10 ); |
@@ -117,7 +117,7 @@ suite Archive | |||
117 | } | 117 | } |
118 | mb.setPos( 0 ); | 118 | mb.setPos( 0 ); |
119 | { | 119 | { |
120 | Archive ar( mb, Archive::load ); | 120 | ArchiveBinary ar( mb, ArchiveBinary::load ); |
121 | String sStr; | 121 | String sStr; |
122 | List<int> lList; | 122 | List<int> lList; |
123 | ar >> sStr; | 123 | ar >> sStr; |
@@ -137,7 +137,7 @@ suite Archive | |||
137 | { | 137 | { |
138 | MemBuf mb; | 138 | MemBuf mb; |
139 | { | 139 | { |
140 | Archive ar( mb, Archive::save ); | 140 | ArchiveBinary ar( mb, ArchiveBinary::save ); |
141 | String sStr("This is a test string."); | 141 | String sStr("This is a test string."); |
142 | Array<int> lArray; | 142 | Array<int> lArray; |
143 | lArray.append( 10 ); | 143 | lArray.append( 10 ); |
@@ -150,7 +150,7 @@ suite Archive | |||
150 | } | 150 | } |
151 | mb.setPos( 0 ); | 151 | mb.setPos( 0 ); |
152 | { | 152 | { |
153 | Archive ar( mb, Archive::load ); | 153 | ArchiveBinary ar( mb, ArchiveBinary::load ); |
154 | String sStr; | 154 | String sStr; |
155 | Array<int> lArray; | 155 | Array<int> lArray; |
156 | ar >> sStr; | 156 | ar >> sStr; |
@@ -170,7 +170,7 @@ suite Archive | |||
170 | { | 170 | { |
171 | MemBuf mb; | 171 | MemBuf mb; |
172 | { | 172 | { |
173 | Archive ar( mb, Archive::save ); | 173 | ArchiveBinary ar( mb, ArchiveBinary::save ); |
174 | Array<String> lArray; | 174 | Array<String> lArray; |
175 | lArray.append( "10" ); | 175 | lArray.append( "10" ); |
176 | lArray.append( "20" ); | 176 | lArray.append( "20" ); |
@@ -181,7 +181,7 @@ suite Archive | |||
181 | } | 181 | } |
182 | mb.setPos( 0 ); | 182 | mb.setPos( 0 ); |
183 | { | 183 | { |
184 | Archive ar( mb, Archive::load ); | 184 | ArchiveBinary ar( mb, ArchiveBinary::load ); |
185 | Array<String> lArray; | 185 | Array<String> lArray; |
186 | ar >> lArray; | 186 | ar >> lArray; |
187 | unitTest( lArray.getSize() == 4 ); | 187 | unitTest( lArray.getSize() == 4 ); |
diff --git a/src/unit/myriad.unit b/src/unit/myriad.unit index 91a89c9..09d92a3 100644 --- a/src/unit/myriad.unit +++ b/src/unit/myriad.unit | |||
@@ -13,7 +13,7 @@ | |||
13 | #include "bu/array.h" | 13 | #include "bu/array.h" |
14 | 14 | ||
15 | #include "bu/sio.h" | 15 | #include "bu/sio.h" |
16 | #include "bu/archive.h" | 16 | #include "bu/archivebinary.h" |
17 | #include "bu/md5.h" | 17 | #include "bu/md5.h" |
18 | #include "bu/unitsuite.h" | 18 | #include "bu/unitsuite.h" |
19 | 19 | ||
@@ -23,8 +23,8 @@ using namespace Bu; | |||
23 | 23 | ||
24 | class VerifyObject | 24 | class VerifyObject |
25 | { | 25 | { |
26 | friend Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const VerifyObject &vo ); | 26 | friend Bu::Archive &operator<<( Bu::Archive &ar, const VerifyObject &vo ); |
27 | friend Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, VerifyObject &vo ); | 27 | friend Bu::Archive &operator>>( Bu::Archive &ar, VerifyObject &vo ); |
28 | public: | 28 | public: |
29 | VerifyObject( int iUnits ) : | 29 | VerifyObject( int iUnits ) : |
30 | iUnits( iUnits ), | 30 | iUnits( iUnits ), |
@@ -46,7 +46,7 @@ private: | |||
46 | mutable int iBytesWritten; | 46 | mutable int iBytesWritten; |
47 | }; | 47 | }; |
48 | 48 | ||
49 | Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const VerifyObject &vo ) | 49 | Bu::Archive &operator<<( Bu::Archive &ar, const VerifyObject &vo ) |
50 | { | 50 | { |
51 | Md5 sum; | 51 | Md5 sum; |
52 | ar << vo.iUnits; | 52 | ar << vo.iUnits; |
@@ -70,7 +70,7 @@ Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const VerifyObject &vo ) | |||
70 | return ar; | 70 | return ar; |
71 | } | 71 | } |
72 | 72 | ||
73 | Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, VerifyObject &vo ) | 73 | Bu::Archive &operator>>( Bu::Archive &ar, VerifyObject &vo ) |
74 | { | 74 | { |
75 | Md5 sum; | 75 | Md5 sum; |
76 | ar >> vo.iUnits; | 76 | ar >> vo.iUnits; |
@@ -347,7 +347,7 @@ suite Myriad | |||
347 | VerifyObject vo( random()%1024 ); | 347 | VerifyObject vo( random()%1024 ); |
348 | { | 348 | { |
349 | MyriadStream ms = m.openStream( iStream ); | 349 | MyriadStream ms = m.openStream( iStream ); |
350 | Archive ar( ms, Archive::save ); | 350 | ArchiveBinary ar( ms, ArchiveBinary::save ); |
351 | ar << vo; | 351 | ar << vo; |
352 | unitTest( ms.tell() == vo.getBytesWritten() ); | 352 | unitTest( ms.tell() == vo.getBytesWritten() ); |
353 | ms.setSize( ms.tell() ); | 353 | ms.setSize( ms.tell() ); |
@@ -366,12 +366,12 @@ suite Myriad | |||
366 | VerifyObject vo( random()%1024 ); | 366 | VerifyObject vo( random()%1024 ); |
367 | { | 367 | { |
368 | MyriadStream ms = m.openStream( *i ); | 368 | MyriadStream ms = m.openStream( *i ); |
369 | Archive ar( ms, Archive::load ); | 369 | ArchiveBinary ar( ms, ArchiveBinary::load ); |
370 | ar >> vo; | 370 | ar >> vo; |
371 | } | 371 | } |
372 | { | 372 | { |
373 | MyriadStream ms = m.openStream( *i ); | 373 | MyriadStream ms = m.openStream( *i ); |
374 | Archive ar( ms, Archive::save ); | 374 | ArchiveBinary ar( ms, ArchiveBinary::save ); |
375 | ar << vo; | 375 | ar << vo; |
376 | unitTest( ms.tell() == vo.getBytesWritten() ); | 376 | unitTest( ms.tell() == vo.getBytesWritten() ); |
377 | ms.setSize( ms.tell() ); | 377 | ms.setSize( ms.tell() ); |
diff --git a/src/unstable/archivestream.cpp b/src/unstable/archivestream.cpp index 437c183..90a9599 100644 --- a/src/unstable/archivestream.cpp +++ b/src/unstable/archivestream.cpp | |||
@@ -7,7 +7,7 @@ | |||
7 | 7 | ||
8 | #include "bu/archivestream.h" | 8 | #include "bu/archivestream.h" |
9 | 9 | ||
10 | Bu::ArchiveStream::ArchiveStream( Bu::ArchiveBase &ar ) : | 10 | Bu::ArchiveStream::ArchiveStream( Bu::Archive &ar ) : |
11 | ar( ar ), | 11 | ar( ar ), |
12 | iPos( 0 ) | 12 | iPos( 0 ) |
13 | { | 13 | { |
diff --git a/src/unstable/archivestream.h b/src/unstable/archivestream.h index c694037..da6c6b0 100644 --- a/src/unstable/archivestream.h +++ b/src/unstable/archivestream.h | |||
@@ -7,7 +7,7 @@ | |||
7 | #ifndef BU_ARCHIVE_STREAM_H | 7 | #ifndef BU_ARCHIVE_STREAM_H |
8 | #define BU_ARCHIVE_STREAM_H | 8 | #define BU_ARCHIVE_STREAM_H |
9 | 9 | ||
10 | #include "bu/archivebase.h" | 10 | #include "bu/archive.h" |
11 | #include "bu/stream.h" | 11 | #include "bu/stream.h" |
12 | 12 | ||
13 | namespace Bu | 13 | namespace Bu |
@@ -15,7 +15,7 @@ namespace Bu | |||
15 | class ArchiveStream : public Stream | 15 | class ArchiveStream : public Stream |
16 | { | 16 | { |
17 | public: | 17 | public: |
18 | ArchiveStream( Bu::ArchiveBase &ar ); | 18 | ArchiveStream( Bu::Archive &ar ); |
19 | virtual ~ArchiveStream(); | 19 | virtual ~ArchiveStream(); |
20 | 20 | ||
21 | virtual void close(); | 21 | virtual void close(); |
@@ -41,7 +41,7 @@ namespace Bu | |||
41 | virtual Bu::String getLocation() const; | 41 | virtual Bu::String getLocation() const; |
42 | 42 | ||
43 | private: | 43 | private: |
44 | Bu::ArchiveBase &ar; | 44 | Bu::Archive &ar; |
45 | size iPos; | 45 | size iPos; |
46 | }; | 46 | }; |
47 | } | 47 | } |
diff --git a/src/unstable/cachebase.h b/src/unstable/cachebase.h index 7a54465..f986a89 100644 --- a/src/unstable/cachebase.h +++ b/src/unstable/cachebase.h | |||
@@ -9,7 +9,7 @@ | |||
9 | #define BU_CACHE_BASE_H | 9 | #define BU_CACHE_BASE_H |
10 | 10 | ||
11 | #include "bu/string.h" | 11 | #include "bu/string.h" |
12 | #include "bu/archive.h" | 12 | #include "bu/archivebinary.h" |
13 | #include "bu/hash.h" | 13 | #include "bu/hash.h" |
14 | #include "bu/readwritemutex.h" | 14 | #include "bu/readwritemutex.h" |
15 | #include "bu/mutexlocker.h" | 15 | #include "bu/mutexlocker.h" |
@@ -659,7 +659,7 @@ namespace Bu | |||
659 | template<typename obtype> | 659 | template<typename obtype> |
660 | void _cacheObjectSave( Bu::Stream &s, obtype *pObject ) | 660 | void _cacheObjectSave( Bu::Stream &s, obtype *pObject ) |
661 | { | 661 | { |
662 | Bu::Archive ar( s, Bu::Archive::save ); | 662 | Bu::ArchiveBinary ar( s, Bu::Archive::save ); |
663 | ar << *pObject; | 663 | ar << *pObject; |
664 | } | 664 | } |
665 | 665 | ||
@@ -670,7 +670,7 @@ namespace Bu | |||
670 | Bu::Stream &s | 670 | Bu::Stream &s |
671 | ) | 671 | ) |
672 | { | 672 | { |
673 | Bu::Archive ar( s, Bu::Archive::load ); | 673 | Bu::ArchiveBinary ar( s, Bu::Archive::load ); |
674 | obtype *ret = initObject(new obtype()); | 674 | obtype *ret = initObject(new obtype()); |
675 | ar >> *ret; | 675 | ar >> *ret; |
676 | return ret; | 676 | return ret; |
diff --git a/src/unstable/myriadcache.h b/src/unstable/myriadcache.h index 7bba93b..8a1f9db 100644 --- a/src/unstable/myriadcache.h +++ b/src/unstable/myriadcache.h | |||
@@ -29,7 +29,7 @@ namespace Bu | |||
29 | { | 29 | { |
30 | Bu::ReadWriteMutex::ReadLocker l( rwStore ); | 30 | Bu::ReadWriteMutex::ReadLocker l( rwStore ); |
31 | Bu::MyriadStream ms = mStore.openStream( 1 ); | 31 | Bu::MyriadStream ms = mStore.openStream( 1 ); |
32 | Bu::Archive ar( ms, Bu::Archive::load ); | 32 | Bu::ArchiveBinary ar( ms, Bu::ArchiveBinary::load ); |
33 | uint8_t uVer; | 33 | uint8_t uVer; |
34 | ar >> uVer; | 34 | ar >> uVer; |
35 | switch( uVer ) | 35 | switch( uVer ) |
@@ -118,7 +118,7 @@ namespace Bu | |||
118 | return; | 118 | return; |
119 | 119 | ||
120 | Bu::MyriadStream ms = mStore.openStream( 1 ); | 120 | Bu::MyriadStream ms = mStore.openStream( 1 ); |
121 | Bu::Archive ar( ms, Bu::Archive::save ); | 121 | Bu::ArchiveBinary ar( ms, Bu::ArchiveBinary::save ); |
122 | ar << (uint8_t)0 << hIndex; | 122 | ar << (uint8_t)0 << hIndex; |
123 | ar.close(); | 123 | ar.close(); |
124 | ms.setSize( ms.tell() ); | 124 | ms.setSize( ms.tell() ); |
diff --git a/src/unstable/uuid.cpp b/src/unstable/uuid.cpp index c5ff943..6642d75 100644 --- a/src/unstable/uuid.cpp +++ b/src/unstable/uuid.cpp | |||
@@ -170,13 +170,13 @@ template<> bool Bu::__cmpHashKeys<Bu::Uuid>( const Bu::Uuid &a, const Bu::Uuid & | |||
170 | return a == b; | 170 | return a == b; |
171 | } | 171 | } |
172 | 172 | ||
173 | Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, Bu::Uuid &u ) | 173 | Bu::Archive &Bu::operator>>( Bu::Archive &ar, Bu::Uuid &u ) |
174 | { | 174 | { |
175 | ar.read( u.data, 16 ); | 175 | ar.read( u.data, 16 ); |
176 | return ar; | 176 | return ar; |
177 | } | 177 | } |
178 | 178 | ||
179 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, const Bu::Uuid &u ) | 179 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, const Bu::Uuid &u ) |
180 | { | 180 | { |
181 | ar.write( u.data, 16 ); | 181 | ar.write( u.data, 16 ); |
182 | return ar; | 182 | return ar; |
diff --git a/src/unstable/uuid.h b/src/unstable/uuid.h index 07ec333..d61a928 100644 --- a/src/unstable/uuid.h +++ b/src/unstable/uuid.h | |||
@@ -15,8 +15,8 @@ namespace Bu | |||
15 | { | 15 | { |
16 | class Uuid | 16 | class Uuid |
17 | { | 17 | { |
18 | friend Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, Uuid &u ); | 18 | friend Bu::Archive &operator>>( Bu::Archive &ar, Uuid &u ); |
19 | friend Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const Uuid &u ); | 19 | friend Bu::Archive &operator<<( Bu::Archive &ar, const Uuid &u ); |
20 | public: | 20 | public: |
21 | Uuid(); | 21 | Uuid(); |
22 | Uuid( const Uuid &src ); | 22 | Uuid( const Uuid &src ); |
@@ -65,8 +65,8 @@ namespace Bu | |||
65 | const Uuid &a, const Uuid &b ); | 65 | const Uuid &a, const Uuid &b ); |
66 | 66 | ||
67 | class Formatter; | 67 | class Formatter; |
68 | Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, Uuid &u ); | 68 | Bu::Archive &operator>>( Bu::Archive &ar, Uuid &u ); |
69 | Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const Uuid &u ); | 69 | Bu::Archive &operator<<( Bu::Archive &ar, const Uuid &u ); |
70 | Bu::Formatter &operator<<( Bu::Formatter &f, const Uuid &u ); | 70 | Bu::Formatter &operator<<( Bu::Formatter &f, const Uuid &u ); |
71 | }; | 71 | }; |
72 | 72 | ||