From da21dd5dc9cece281c83f3011eb9efbeb5ada45a Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 24 Oct 2007 02:41:56 +0000 Subject: Tried to get archive operators to recognize pointers, no luck so far. --- src/archive.cpp | 14 ++++++++++++++ src/archive.h | 25 ++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) 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) return s; } +Bu::Archive &Bu::operator<<(Bu::Archive &ar, class Bu::Archival *p ) +{ + printf("Writing a pointer to an archive...\n"); + ar << *p; + return ar; +} + +Bu::Archive &Bu::operator>>(Bu::Archive &ar, class Bu::Archival *p ) +{ + printf("Reading a pointer to an archive...\n"); + ar >> *p; + return ar; +} + Bu::Archive &Bu::operator<<( Bu::Archive &ar, std::string &s ) { 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 virtual Archive &operator&&(double &); virtual Archive &operator&&(long double &); + /** + * For storage, get an ID for the pointer to the object you're going to + * write. + */ uint32_t getID( const void *ptr ); + + /** + * For loading. Assosiates an empty pointer with an id. When you wind + * up loading an id reference to a pointer for an object that may or + * may not have loaded yet, call this with the id, if it has been loaded + * already, you'll immediately get a pointer, if not, it will write one + * for you when the time comes. + */ void assocPtrID( void **ptr, uint32_t id ); + + /** + * For loading. Call this when you load an object that other things may + * have pointers to. It will assosiate every pointer that's been + * registered with assocPtrID to the pointer passed in, and id passed + * in. It will also set things up so future calls to assocPtrID will + * automatically succeed immediately. + */ void readID( const void *ptr, uint32_t id ); private: @@ -134,7 +154,7 @@ namespace Bu Archive &operator<<(Archive &, class Bu::Archival &); Archive &operator>>(Archive &, class Bu::Archival &); //Archive &operator&&(Archive &s, class Bu::Archival &p); - + Archive &operator<<(Archive &, std::string &); Archive &operator>>(Archive &, std::string &); //Archive &operator&&(Archive &, std::string &); @@ -178,6 +198,9 @@ namespace Bu return ar; } + + Archive &operator<<(Archive &, class Bu::Archival *p); + Archive &operator>>(Archive &, class Bu::Archival *p); template Archive &operator<<( Archive &ar, Hash &h ) -- cgit v1.2.3