Changeset 2441 in Sophya for trunk/SophyaLib/BaseTools/ppersist.h
- Timestamp:
- Oct 3, 2003, 3:39:33 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/BaseTools/ppersist.h
r1202 r2441 17 17 #include <time.h> 18 18 19 #include <complex> 19 20 #include <string> 20 21 #include <map> … … 93 94 static void Initialize(); // Pour initialiser classList 94 95 96 int Version() {return version;} // PIn/OutPersist version number 95 97 string FileName() { return filename; } // Retourne le nom de fichier 96 98 … … 109 111 PPS_OBJECT = 2, // classId, data... 110 112 PPS_REFERENCE = 3, // objectId 111 PPS_ TAG = 4, // tag entries113 PPS_NAMETAG_TABLE = 4, // Name tag table (Written at the end of file/stream) 112 114 PPS_EOF = 5, // Just before tag infomation, offset to PPS_TAG 113 115 PPS_ENDOBJECT = 6, // marks the end of a given object information 114 PPS_TAG_MARK = 7, // To have a name tag, position marker in a file 116 PPS_NAMETAG_MARK = 7, // To have a name tag, position marker in a file 117 PPS_POSTAG_MARK = 8, // Position tag mark + 8 bytes (=stream position) 118 PPS_POSTAG_TABLE = 40, // Position tag table + 8 bytes (=stream position) 115 119 PPS_SIMPLE = 16, // 16 + number of bytes, up to 8 bytes 116 120 PPS_SIMPLE_ARRAY4 = 32, // 32 + number of bytes, up to 8 bytes, then 4 bytes of length … … 120 124 enum {PPS_DATATYPE_CHAR = 0, // 0 : DataType=character 121 125 PPS_DATATYPE_FLOAT = 64, // 64 : DataType=float 126 PPS_DATATYPE_COMPLEX = 65, // 65 : DataType=complex 122 127 PPS_DATATYPE_INTEGER = 128, // 128 :DataType=integer 123 128 PPS_DATATYPE_UNSIGNED = 192 // 192 :DataType=Unsigned integer … … 126 131 map<string, int_8> tags; 127 132 string filename; 133 int version; // PPersist(In/Out) version 128 134 }; 129 135 130 136 131 137 // TBD : use hash tables instead of maps. Check hashtbl status in STL. 132 138 133 139 //! Input stream for PPersit objects. … … 137 143 ~PInPersist(); 138 144 139 bool GotoTag(string const& name); 145 // Gestion des tags 146 bool GotoPositionTag(int_8 pos); 147 bool GotoNameTag(string const& name); 148 inline bool GotoTag(string const& name) { return GotoNameTag(name); } 140 149 int NbTags(); 141 150 bool GotoTagNum(int itag); // 0..NbTags-1 … … 144 153 vector<string> const & GetTagNames(); 145 154 155 // Lecture donnees de base et tableaux de donnees de base 156 // Basic data type (and corresponding arrays) reading 146 157 void GetByte (char& c); 147 158 void GetBytes(void* ptr, size_t bytes); … … 150 161 void GetR8 (r_8&); 151 162 void GetR8s (r_8*, size_t); 163 void GetI1 (int_1&); 164 void GetI1s (int_1*, size_t); 165 void GetU1 (uint_1&); 166 void GetU1s (uint_1*, size_t); 152 167 void GetI2 (int_2&); 153 168 void GetI2s (int_2*, size_t); … … 164 179 void GetLine (char* ptr, size_t len); 165 180 void GetStr (string&); 166 167 void Get(char& c) {GetByte(c);} 168 void Get(r_4& x) {GetR4(x);} 169 void Get(r_8& x) {GetR8(x);} 170 void Get(uint_2& x) {GetU2(x);} 171 void Get(int_2& x) {GetI2(x);} 172 void Get(uint_4& x) {GetU4(x);} 173 void Get(int_4& x) {GetI4(x);} 174 void Get(uint_8& x) {GetU8(x);} 175 void Get(int_8& x) {GetI8(x);} 176 void Get(r_4* x, size_t n) {GetR4s(x,n);} 177 void Get(r_8* x, size_t n) {GetR8s(x,n);} 178 void Get(uint_2* x, size_t n) {GetU2s(x,n);} 179 void Get(int_2* x, size_t n) {GetI2s(x,n);} 180 void Get(uint_4* x, size_t n) {GetU4s(x,n);} 181 void Get(int_4* x, size_t n) {GetI4s(x,n);} 182 void Get(uint_8* x, size_t n) {GetU8s(x,n);} 183 void Get(int_8* x, size_t n) {GetI8s(x,n);} 184 void Get(string& x) {GetStr(x);} 185 181 void GetZ4 (complex<r_4> &); 182 void GetZ4s (complex<r_4> *, size_t); 183 void GetZ8 (complex<r_8> &); 184 void GetZ8s (complex<r_8> *, size_t); 185 186 inline void Get(char& c) {GetByte(c);} 187 inline void Get(r_4& x) {GetR4(x);} 188 inline void Get(r_8& x) {GetR8(x);} 189 inline void Get(uint_1& x) {GetU1(x);} 190 inline void Get(int_1& x) {GetI1(x);} 191 inline void Get(uint_2& x) {GetU2(x);} 192 inline void Get(int_2& x) {GetI2(x);} 193 inline void Get(uint_4& x) {GetU4(x);} 194 inline void Get(int_4& x) {GetI4(x);} 195 inline void Get(uint_8& x) {GetU8(x);} 196 inline void Get(int_8& x) {GetI8(x);} 197 inline void Get(complex<r_4> & x) {GetZ4(x);} 198 inline void Get(complex<r_8> & x) {GetZ8(x);} 199 200 inline void Get(r_4* x, size_t n) {GetR4s(x,n);} 201 inline void Get(r_8* x, size_t n) {GetR8s(x,n);} 202 inline void Get(uint_1* x, size_t n) {GetU1s(x,n);} 203 inline void Get(int_1* x, size_t n) {GetI1s(x,n);} 204 inline void Get(uint_2* x, size_t n) {GetU2s(x,n);} 205 inline void Get(int_2* x, size_t n) {GetI2s(x,n);} 206 inline void Get(uint_4* x, size_t n) {GetU4s(x,n);} 207 inline void Get(int_4* x, size_t n) {GetI4s(x,n);} 208 inline void Get(uint_8* x, size_t n) {GetU8s(x,n);} 209 inline void Get(int_8* x, size_t n) {GetI8s(x,n);} 210 inline void Get(string& x) {GetStr(x);} 211 inline void Get(complex<r_4> * x, size_t n) { GetZ4s(x, n); } 212 inline void Get(complex<r_8> * x, size_t n) { GetZ8s(x, n); } 213 214 // Reading a list (table) of position tags 215 void GetPosTagTable(int_8*, size_t); 216 void GetPosTagTable(vector<int_8>&); 217 186 218 // Object Reading 187 219 PPersist* ReadObject(); … … 190 222 PPersist* GetPPObject(AnyDataObj * po=NULL); 191 223 192 int Version() {return version;}193 224 time_t CreationDate() { return creationdate; } 194 225 string CreationDateStr(); … … 219 250 220 251 bool bigEndian; 221 int version;222 252 223 253 time_t creationdate; … … 237 267 ~POutPersist(); 238 268 239 void WriteTag(string const& name); 269 // Ecriture de tags 270 int_8 WritePositionTag(); 271 void WriteNameTag(string const& name); 272 inline void WriteTag(string const& name) { WriteNameTag(name); } 240 273 241 274 void PutByte (char c); … … 245 278 void PutR8 (r_8); 246 279 void PutR8s (r_8 const*, size_t); 280 void PutI1 (int_1); 281 void PutI1s (int_1 const*, size_t); 282 void PutU1 (uint_1); 283 void PutU1s (uint_1 const*, size_t); 247 284 void PutI2 (int_2); 248 285 void PutI2s (int_2 const*, size_t); … … 259 296 void PutLine (char const* ptr, size_t len=0); // deprecated ? 260 297 void PutStr (string const&); 261 void PutPPObject (PPersist const*); // Like doing Write(stream) on PPersist object 262 263 void PutObject(AnyDataObj & o); // Creates the corresponding PPersist Object and call Write() 264 void PutObject(AnyDataObj & o, string tagname); 298 void PutZ4 (complex<r_4>); 299 void PutZ4s (complex<r_4> const*, size_t); 300 void PutZ8 (complex<r_8>); 301 void PutZ8s (complex<r_8> const*, size_t); 302 265 303 266 304 void Put(char c) {PutByte(c);} 267 305 void Put(r_4 x) {PutR4(x);} 268 306 void Put(r_8 x) {PutR8(x);} 307 void Put(complex<r_4> x) {PutZ4(x);} 308 void Put(complex<r_8> x) {PutZ8(x);} 309 void Put(uint_1 x) {PutU1(x);} 310 void Put(int_1 x) {PutI1(x);} 269 311 void Put(uint_2 x) {PutU2(x);} 270 312 void Put(int_2 x) {PutI2(x);} … … 275 317 void Put(r_4 const* x, size_t n) {PutR4s(x,n);} 276 318 void Put(r_8 const* x, size_t n) {PutR8s(x,n);} 319 void Put(complex<r_4> const* x, size_t n) {PutZ4s(x,n);} 320 void Put(complex<r_8> const* x, size_t n) {PutZ8s(x,n);} 321 void Put(uint_1 const* x, size_t n) {PutU1s(x,n);} 322 void Put(int_1 const* x, size_t n) {PutI1s(x,n);} 277 323 void Put(uint_2 const* x, size_t n) {PutU2s(x,n);} 278 324 void Put(int_2 const* x, size_t n) {PutI2s(x,n);} … … 283 329 void Put(string const& s) {PutStr(s);} 284 330 void Put(PPersist const* x) {PutPPObject(x);} 331 332 // Writing a list of position tag table 333 void PutPosTagTable(int_8 const *, size_t); 334 void PutPosTagTable(vector<int_8> const&); 335 336 // Objet Write - Ecriture des objets 337 void PutPPObject (PPersist const*); // Like doing Write(stream) on PPersist object 338 339 void PutObject(AnyDataObj & o); // Creates the corresponding PPersist Object and call Write() 340 void PutObject(AnyDataObj & o, string tagname); 285 341 286 342 … … 310 366 }; 311 367 312 368 369 // Le macro suivant permettent de simplifier la declaration 370 // des operateurs >> << sur les POutPersist et PInPersist 313 371 #define RAWPERSISTIO(_Type_,_xtyp_) \ 314 372 inline POutPersist& operator << (POutPersist& c, _Type_ const& data) \ … … 324 382 } 325 383 384 // On utilise le macro RAWPERSISTIO pour declarer POutPersist << et PInPersist >> 385 // pour les types de base r_4 r_8 int_4 int_8 ... 326 386 RAWPERSISTIO(int_4,I4); 327 387 RAWPERSISTIO(uint_4,U4); … … 331 391 RAWPERSISTIO(r_4,R4); 332 392 RAWPERSISTIO(r_8,R8); 393 RAWPERSISTIO(complex<r_4>,Z4); 394 RAWPERSISTIO(complex<r_8>,Z8); 395 RAWPERSISTIO(string,Str); 333 396 334 397 #if 0
Note:
See TracChangeset
for help on using the changeset viewer.