diff options
Diffstat (limited to '')
| -rw-r--r-- | src/stable/archivebinary.h | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/src/stable/archivebinary.h b/src/stable/archivebinary.h index d28e5e7..d917249 100644 --- a/src/stable/archivebinary.h +++ b/src/stable/archivebinary.h | |||
| @@ -20,51 +20,6 @@ namespace Bu | |||
| 20 | class Stream; | 20 | class Stream; |
| 21 | 21 | ||
| 22 | /** | 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 | */ | 23 | */ |
| 69 | class ArchiveBinary : public Archive | 24 | class ArchiveBinary : public Archive |
| 70 | { | 25 | { |
| @@ -116,39 +71,12 @@ namespace Bu | |||
| 116 | virtual void read( Bu::Blob &rData ); | 71 | virtual void read( Bu::Blob &rData ); |
| 117 | virtual void read( Bu::Text &rData ); | 72 | virtual void read( Bu::Text &rData ); |
| 118 | 73 | ||
| 119 | /** | ||
| 120 | * For storage, get an ID for the pointer to the object you're going to | ||
| 121 | * write. | ||
| 122 | */ | ||
| 123 | uint32_t getID( const void *ptr ); | ||
| 124 | |||
| 125 | /** | ||
| 126 | * For loading. Assosiates an empty pointer with an id. When you wind | ||
| 127 | * up loading an id reference to a pointer for an object that may or | ||
| 128 | * may not have loaded yet, call this with the id, if it has been loaded | ||
| 129 | * already, you'll immediately get a pointer, if not, it will write one | ||
| 130 | * for you when the time comes. | ||
| 131 | */ | ||
| 132 | void assocPtrID( void **ptr, uint32_t id ); | ||
| 133 | |||
| 134 | /** | ||
| 135 | * For loading. Call this when you load an object that other things may | ||
| 136 | * have pointers to. It will assosiate every pointer that's been | ||
| 137 | * registered with assocPtrID to the pointer passed in, and id passed | ||
| 138 | * in. It will also set things up so future calls to assocPtrID will | ||
| 139 | * automatically succeed immediately. | ||
| 140 | */ | ||
| 141 | void readID( const void *ptr, uint32_t id ); | ||
| 142 | |||
| 143 | virtual void setProperty( const Bu::Blob &rKey, | 74 | virtual void setProperty( const Bu::Blob &rKey, |
| 144 | const Bu::Variant &rValue ); | 75 | const Bu::Variant &rValue ); |
| 145 | virtual Bu::Variant getProperty( const Bu::Blob &rKey ) const; | 76 | virtual Bu::Variant getProperty( const Bu::Blob &rKey ) const; |
| 146 | 77 | ||
| 147 | private: | 78 | private: |
| 148 | Stream &rStream; | 79 | Stream &rStream; |
| 149 | uint32_t nNextID; | ||
| 150 | Hash<uint32_t,ptrdiff_t> hPtrID; | ||
| 151 | Hash<uint32_t,List<void **> > hPtrDest; | ||
| 152 | Hash<Bu::Blob, Variant> hProps; | 80 | Hash<Bu::Blob, Variant> hProps; |
| 153 | }; | 81 | }; |
| 154 | } | 82 | } |
