Changeset 278 in Sophya for trunk/SophyaLib/NTools/dvlist.cc
- Timestamp:
- Apr 28, 1999, 3:36:50 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/NTools/dvlist.cc
r244 r278 39 39 40 40 41 using namespace PlanckDPC; 42 41 43 char MuTyV::myStrBuf[64]; // Declare static ds le .h 42 44 … … 74 76 { 75 77 PInPersist s(flnm); 76 Read(s); 78 ObjFileIO<DVList> fiodvl(this); 79 fiodvl.Read(s); 77 80 } 78 81 … … 279 282 } 280 283 281 282 /* --Methode-- */ 283 void DVList::WriteSelf(POutPersist& s) const 284 { 285 char buf[320]; 286 287 int lc = comment.length(); 288 if (lc > 319) lc = 319; 289 if (lc > 0) { 290 sprintf(buf,"Comment: ( %6d ) ", lc); 291 s.PutLine(buf); 292 s.PutBytes(comment.c_str(), lc); 293 } 294 s.PutLine("----Variable-List---------------"); 295 ValList::const_iterator it; 296 for(it = mvlist.begin(); it != mvlist.end(); it++) { 297 switch ((*it).second.typ) 298 { 299 case 'I' : 300 sprintf(buf,"I %s %d", (*it).first.substr(0,64).c_str(), (*it).second.mtv.iv ); 301 s.PutLine(buf); 302 break; 303 case 'D' : 304 sprintf(buf,"D %s %.20g", (*it).first.substr(0,64).c_str(), (*it).second.mtv.dv ); 305 s.PutLine(buf); 306 break; 307 case 'S' : 308 sprintf(buf,"S %s %s", (*it).first.substr(0,64).c_str(), (*it).second.mtv.strv ); 309 s.PutLine(buf); 310 break; 311 default : 312 break; 313 } 314 } 315 316 s.PutLine("ZZZZZ--End-of-Varible-List------"); 317 } 318 319 /* --Methode-- */ 320 void DVList::ReadSelf(PInPersist& s) 321 { 322 char buf[320]; 323 int_4 j,iv; 324 double dv; 325 bool ok=true; 326 buf[0] = '\0'; 327 Clear(); 328 329 s.GetLine(buf, 319); // Pour lire les "------- " 330 if (buf[0] != '-') { // Il y a un champ commentaire a lire 331 buf[18] ='\0'; 332 int lc = atoi(buf+11); 333 if (lc > 319) { 334 cerr << "DVList::ReadSelf() Pb/Bug ?? CommentLength= " << lc << endl; 335 lc = 319; 336 } 337 s.GetBytes(buf, lc); 338 buf[lc] ='\0'; 339 comment = buf; 340 } 341 342 while(ok) { 343 s.GetLine(buf, 319); 344 buf[319] = '\0'; 345 if (strncmp(buf,"ZZZZZ",5) == 0) { ok=false; break; } 346 j = posc(buf+2, ' ')+2; 347 buf[j] = '\0'; 348 switch (buf[0]) 349 { 350 case 'I' : 351 iv = (int_4)atol(buf+j+1); 352 SetI(buf+2, iv); 353 break; 354 case 'D' : 355 dv = atof(buf+j+1); 356 SetD(buf+2, dv); 357 break; 358 case 'S' : 359 SetS(buf+2, buf+j+1); 360 break; 361 default : 362 break; 363 } 364 } 365 366 } 284 // Classe pour la gestion de persistance 285 // ObjFileIO<DVList> 286 367 287 368 288 //++ … … 397 317 //| int m = dvlr["hello"] ; // m = 88 398 318 //-- 319 320 321 322 /* --Methode-- */ 323 void ObjFileIO<DVList>::WriteSelf(POutPersist& s) const 324 { 325 char buf[320]; 326 327 int lc = dobj->Comment().length(); 328 if (lc > 319) lc = 319; 329 if (lc > 0) { 330 sprintf(buf,"Comment: ( %6d ) ", lc); 331 s.PutLine(buf); 332 s.PutBytes(dobj->Comment().c_str(), lc); 333 } 334 s.PutLine("----Variable-List---------------"); 335 DVList::ValList::const_iterator it; 336 for(it = dobj->Begin(); it != dobj->End(); it++) { 337 switch ((*it).second.typ) 338 { 339 case 'I' : 340 sprintf(buf,"I %s %d", (*it).first.substr(0,64).c_str(), (*it).second.mtv.iv ); 341 s.PutLine(buf); 342 break; 343 case 'D' : 344 sprintf(buf,"D %s %.20g", (*it).first.substr(0,64).c_str(), (*it).second.mtv.dv ); 345 s.PutLine(buf); 346 break; 347 case 'S' : 348 sprintf(buf,"S %s %s", (*it).first.substr(0,64).c_str(), (*it).second.mtv.strv ); 349 s.PutLine(buf); 350 break; 351 default : 352 break; 353 } 354 } 355 356 s.PutLine("ZZZZZ--End-of-Varible-List------"); 357 } 358 359 /* --Methode-- */ 360 void ObjFileIO<DVList>::ReadSelf(PInPersist& s) 361 { 362 char buf[320]; 363 int_4 j,iv; 364 double dv; 365 bool ok=true; 366 buf[0] = '\0'; 367 dobj->Clear(); 368 369 s.GetLine(buf, 319); // Pour lire les "------- " 370 if (buf[0] != '-') { // Il y a un champ commentaire a lire 371 buf[18] ='\0'; 372 int lc = atoi(buf+11); 373 if (lc > 319) { 374 cerr << "DVList::ReadSelf() Pb/Bug ?? CommentLength= " << lc << endl; 375 lc = 319; 376 } 377 s.GetBytes(buf, lc); 378 buf[lc] ='\0'; 379 dobj->Comment() = buf; 380 } 381 382 while(ok) { 383 s.GetLine(buf, 319); 384 buf[319] = '\0'; 385 if (strncmp(buf,"ZZZZZ",5) == 0) { ok=false; break; } 386 j = posc(buf+2, ' ')+2; 387 buf[j] = '\0'; 388 switch (buf[0]) 389 { 390 case 'I' : 391 iv = (int_4)atol(buf+j+1); 392 dobj->SetI(buf+2, iv); 393 break; 394 case 'D' : 395 dv = atof(buf+j+1); 396 dobj->SetD(buf+2, dv); 397 break; 398 case 'S' : 399 dobj->SetS(buf+2, buf+j+1); 400 break; 401 default : 402 break; 403 } 404 } 405 } 406 407 #ifdef __CXX_PRAGMA_TEMPLATES__ 408 #pragma define_template ObjFileIO<DVList> 409 #endif 410 411 #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES) 412 template class ObjFileIO<DVList>; 413 #endif
Note:
See TracChangeset
for help on using the changeset viewer.