aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/stable/archive.cpp10
-rw-r--r--src/stable/archive.h21
-rw-r--r--src/stable/archivebase.h9
3 files changed, 22 insertions, 18 deletions
diff --git a/src/stable/archive.cpp b/src/stable/archive.cpp
index 31a4ba7..69447fb 100644
--- a/src/stable/archive.cpp
+++ b/src/stable/archive.cpp
@@ -87,3 +87,13 @@ void Bu::Archive::readID( const void *ptr, uint32_t id )
87 } 87 }
88} 88}
89 89
90void Bu::Archive::setProperty( const Bu::Blob &rKey, const Bu::Variant &rValue )
91{
92 hProps.insert( rKey, rValue );
93}
94
95Bu::Variant Bu::Archive::getProperty( const Bu::Blob &rKey ) const
96{
97 return hProps.get( rKey );
98}
99
diff --git a/src/stable/archive.h b/src/stable/archive.h
index 7f988eb..b6cc2a9 100644
--- a/src/stable/archive.h
+++ b/src/stable/archive.h
@@ -13,6 +13,7 @@
13#include "bu/hash.h" 13#include "bu/hash.h"
14#include "bu/util.h" 14#include "bu/util.h"
15#include "bu/variant.h" 15#include "bu/variant.h"
16#include "bu/blob.h"
16 17
17namespace Bu 18namespace Bu
18{ 19{
@@ -110,28 +111,16 @@ namespace Bu
110 */ 111 */
111 void readID( const void *ptr, uint32_t id ); 112 void readID( const void *ptr, uint32_t id );
112 113
113 template<typename t> 114 virtual void setProperty( const Bu::Blob &rKey,
114 void setProp( const Bu::String &sId, const t &val ) 115 const Bu::Variant &rValue );
115 { 116 virtual Bu::Variant getProperty( const Bu::Blob &rKey ) const;
116 if( !hProps.has( sId ) )
117 {
118 hProps.insert( sId, Variant() );
119 }
120 hProps.get( sId ) = val;
121 }
122
123 template<typename t>
124 t getProp( const Bu::String &sId )
125 {
126 return hProps.get( sId );
127 }
128 117
129 private: 118 private:
130 Stream &rStream; 119 Stream &rStream;
131 uint32_t nNextID; 120 uint32_t nNextID;
132 Hash<uint32_t,ptrdiff_t> hPtrID; 121 Hash<uint32_t,ptrdiff_t> hPtrID;
133 Hash<uint32_t,List<void **> > hPtrDest; 122 Hash<uint32_t,List<void **> > hPtrDest;
134 Hash<Bu::String, Variant> hProps; 123 Hash<Bu::Blob, Variant> hProps;
135 }; 124 };
136} 125}
137 126
diff --git a/src/stable/archivebase.h b/src/stable/archivebase.h
index e3d2b60..d846c27 100644
--- a/src/stable/archivebase.h
+++ b/src/stable/archivebase.h
@@ -11,6 +11,9 @@
11#include <stdint.h> 11#include <stdint.h>
12#include <unistd.h> 12#include <unistd.h>
13 13
14#include "bu/variant.h"
15#include "bu/blob.h"
16
14namespace Bu 17namespace Bu
15{ 18{
16 class ArchiveBase 19 class ArchiveBase
@@ -23,6 +26,10 @@ namespace Bu
23 virtual void write( const void *pData, size_t iLength )=0; 26 virtual void write( const void *pData, size_t iLength )=0;
24 virtual void read( void *pData, size_t iLength )=0; 27 virtual void read( void *pData, size_t iLength )=0;
25 virtual bool isLoading()=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;
26 }; 33 };
27 34
28 template<typename T> ArchiveBase &operator&&( ArchiveBase &ar, T &dat ) 35 template<typename T> ArchiveBase &operator&&( ArchiveBase &ar, T &dat )
@@ -68,8 +75,6 @@ namespace Bu
68 ArchiveBase &operator>>( ArchiveBase &ar, float &p ); 75 ArchiveBase &operator>>( ArchiveBase &ar, float &p );
69 ArchiveBase &operator>>( ArchiveBase &ar, double &p ); 76 ArchiveBase &operator>>( ArchiveBase &ar, double &p );
70 ArchiveBase &operator>>( ArchiveBase &ar, long double &p ); 77 ArchiveBase &operator>>( ArchiveBase &ar, long double &p );
71
72
73}; 78};
74 79
75#endif 80#endif