diff options
-rw-r--r-- | src/archive.cpp | 14 | ||||
-rw-r--r-- | src/archive.h | 25 |
2 files changed, 38 insertions, 1 deletions
diff --git a/src/archive.cpp b/src/archive.cpp index 7208bae..11c632a 100644 --- a/src/archive.cpp +++ b/src/archive.cpp | |||
@@ -325,6 +325,20 @@ Bu::Archive &Bu::operator>>(Bu::Archive &s, Bu::Archival &p) | |||
325 | return s; | 325 | return s; |
326 | } | 326 | } |
327 | 327 | ||
328 | Bu::Archive &Bu::operator<<(Bu::Archive &ar, class Bu::Archival *p ) | ||
329 | { | ||
330 | printf("Writing a pointer to an archive...\n"); | ||
331 | ar << *p; | ||
332 | return ar; | ||
333 | } | ||
334 | |||
335 | Bu::Archive &Bu::operator>>(Bu::Archive &ar, class Bu::Archival *p ) | ||
336 | { | ||
337 | printf("Reading a pointer to an archive...\n"); | ||
338 | ar >> *p; | ||
339 | return ar; | ||
340 | } | ||
341 | |||
328 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, std::string &s ) | 342 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, std::string &s ) |
329 | { | 343 | { |
330 | ar << (uint32_t)s.length(); | 344 | ar << (uint32_t)s.length(); |
diff --git a/src/archive.h b/src/archive.h index b5477bb..dfaf327 100644 --- a/src/archive.h +++ b/src/archive.h | |||
@@ -120,8 +120,28 @@ namespace Bu | |||
120 | virtual Archive &operator&&(double &); | 120 | virtual Archive &operator&&(double &); |
121 | virtual Archive &operator&&(long double &); | 121 | virtual Archive &operator&&(long double &); |
122 | 122 | ||
123 | /** | ||
124 | * For storage, get an ID for the pointer to the object you're going to | ||
125 | * write. | ||
126 | */ | ||
123 | uint32_t getID( const void *ptr ); | 127 | uint32_t getID( const void *ptr ); |
128 | |||
129 | /** | ||
130 | * For loading. Assosiates an empty pointer with an id. When you wind | ||
131 | * up loading an id reference to a pointer for an object that may or | ||
132 | * may not have loaded yet, call this with the id, if it has been loaded | ||
133 | * already, you'll immediately get a pointer, if not, it will write one | ||
134 | * for you when the time comes. | ||
135 | */ | ||
124 | void assocPtrID( void **ptr, uint32_t id ); | 136 | void assocPtrID( void **ptr, uint32_t id ); |
137 | |||
138 | /** | ||
139 | * For loading. Call this when you load an object that other things may | ||
140 | * have pointers to. It will assosiate every pointer that's been | ||
141 | * registered with assocPtrID to the pointer passed in, and id passed | ||
142 | * in. It will also set things up so future calls to assocPtrID will | ||
143 | * automatically succeed immediately. | ||
144 | */ | ||
125 | void readID( const void *ptr, uint32_t id ); | 145 | void readID( const void *ptr, uint32_t id ); |
126 | 146 | ||
127 | private: | 147 | private: |
@@ -134,7 +154,7 @@ namespace Bu | |||
134 | Archive &operator<<(Archive &, class Bu::Archival &); | 154 | Archive &operator<<(Archive &, class Bu::Archival &); |
135 | Archive &operator>>(Archive &, class Bu::Archival &); | 155 | Archive &operator>>(Archive &, class Bu::Archival &); |
136 | //Archive &operator&&(Archive &s, class Bu::Archival &p); | 156 | //Archive &operator&&(Archive &s, class Bu::Archival &p); |
137 | 157 | ||
138 | Archive &operator<<(Archive &, std::string &); | 158 | Archive &operator<<(Archive &, std::string &); |
139 | Archive &operator>>(Archive &, std::string &); | 159 | Archive &operator>>(Archive &, std::string &); |
140 | //Archive &operator&&(Archive &, std::string &); | 160 | //Archive &operator&&(Archive &, std::string &); |
@@ -178,6 +198,9 @@ namespace Bu | |||
178 | 198 | ||
179 | return ar; | 199 | return ar; |
180 | } | 200 | } |
201 | |||
202 | Archive &operator<<(Archive &, class Bu::Archival *p); | ||
203 | Archive &operator>>(Archive &, class Bu::Archival *p); | ||
181 | 204 | ||
182 | template<typename key, typename value> | 205 | template<typename key, typename value> |
183 | Archive &operator<<( Archive &ar, Hash<key,value> &h ) | 206 | Archive &operator<<( Archive &ar, Hash<key,value> &h ) |