Changeset 1310 in Sophya for trunk/SophyaLib/BaseTools/dvlist.cc
- Timestamp:
- Nov 9, 2000, 4:39:19 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/BaseTools/dvlist.cc
r1245 r1310 158 158 for(it = dvl.mvlist.begin(); it != dvl.mvlist.end(); it++) 159 159 { 160 switch ((*it).second.elval. typ)160 switch ((*it).second.elval.Type()) 161 161 { 162 case 'I':162 case MuTyV::MTVInteger : 163 163 SetI((*it).first, (*it).second.elval.iv); 164 164 break; 165 case 'D':165 case MuTyV::MTVFloat : 166 166 SetD((*it).first, (*it).second.elval.dv); 167 167 break; 168 case 'Z':168 case MuTyV::MTVComplex : 169 169 SetZ((*it).first, complex<r_8>((*it).second.elval.dv, (*it).second.elval.dv_im)); 170 170 break; 171 case 'S':171 case MuTyV::MTVString : 172 172 SetS((*it).first, *((*it).second.elval.strv)); 173 173 break; … … 398 398 os << "DVList::Print() - NVar= " << (int)mvlist.size() << "\n"; 399 399 if (comment.length() > 0) os << comment << endl; 400 char buff[ 256];400 char buff[1024]; 401 401 ValList::const_iterator it; 402 402 for(it = mvlist.begin(); it != mvlist.end(); it++) { 403 switch ((*it).second.elval. typ)403 switch ((*it).second.elval.Type()) 404 404 { 405 case 'I':405 case MuTyV::MTVInteger : 406 406 sprintf(buff, "%s = %ld (int) %s\n", (*it).first.substr(0,64).c_str(), 407 407 (long)((*it).second.elval.iv), (*it).second.elcomm.substr(0,128).c_str()); 408 408 break; 409 case 'D':409 case MuTyV::MTVFloat : 410 410 sprintf(buff, "%s = %.20g (double) %s\n", (*it).first.substr(0,64).c_str(), 411 411 (*it).second.elval.dv, (*it).second.elcomm.substr(0,128).c_str()); 412 412 break; 413 case 'Z':413 case MuTyV::MTVComplex : 414 414 sprintf(buff, "%s = %.20g %.20g i (complex) %s\n", (*it).first.substr(0,64).c_str(), 415 415 (*it).second.elval.dv, (*it).second.elval.dv_im, (*it).second.elcomm.substr(0,128).c_str()); 416 416 break; 417 case 'S':417 case MuTyV::MTVString : 418 418 sprintf(buff, "%s = %s (string) %s\n", (*it).first.substr(0,64).c_str(), 419 (*it).second.elval.strv-> c_str(), (*it).second.elcomm.substr(0,128).c_str());419 (*it).second.elval.strv->substr(0,800).c_str(), (*it).second.elcomm.substr(0,128).c_str()); 420 420 break; 421 421 default : … … 469 469 void ObjFileIO<DVList>::WriteSelf(POutPersist& s) const 470 470 { 471 char buf[ 512];471 char buf[1024]; 472 472 string sfw; 473 474 473 int lc = dobj->Comment().length(); 475 if (lc > 0) { 476 sprintf(buf,"Comment: ( %6d ) ", lc); 477 sfw = buf; s.PutStr(sfw); 478 s.PutStr(dobj->Comment()); 479 } 480 sfw = "----Variable-List---------------"; s.PutStr(sfw); 474 // itab - 0 : Version, 1 : NVar, 2 : Comment length, 3 reserved 475 uint_4 itab[4]; 476 itab[0] = 2; // Version number = 2 477 itab[1] = dobj->Size(); 478 itab[2] = lc; 479 itab[3] = 0; 480 s.Put(itab, 4); 481 482 if (lc > 0) s.PutStr(dobj->Comment()); 483 sfw = "\n----Variable-List---------------\n"; 484 s.PutStr(sfw); 485 481 486 DVList::ValList::const_iterator it; 482 487 for(it = dobj->Begin(); it != dobj->End(); it++) { 483 switch ((*it).second.elval. typ) {484 case 'I':485 sprintf(buf,"I %s %ld ", (*it).first.substr(0,64).c_str(), (long)((*it).second.elval.iv) );488 switch ((*it).second.elval.Type()) { 489 case MuTyV::MTVInteger : 490 sprintf(buf,"I %s %ld\n", (*it).first.substr(0,64).c_str(), (long)((*it).second.elval.iv) ); 486 491 sfw = buf; s.PutStr(sfw); 487 492 break; 488 case 'D':489 sprintf(buf," D %s %.20g", (*it).first.substr(0,64).c_str(), (*it).second.elval.dv );493 case MuTyV::MTVFloat : 494 sprintf(buf,"F %s %.20g\n", (*it).first.substr(0,64).c_str(), (*it).second.elval.dv ); 490 495 sfw = buf; s.PutStr(sfw); 491 496 break; 492 case 'Z':493 sprintf(buf,"Z %s %.20g %.20g ", (*it).first.substr(0,64).c_str(), (*it).second.elval.dv,497 case MuTyV::MTVComplex : 498 sprintf(buf,"Z %s %.20g %.20g\n", (*it).first.substr(0,64).c_str(), (*it).second.elval.dv, 494 499 (*it).second.elval.dv_im); 495 500 sfw = buf; s.PutStr(sfw); 496 501 break; 497 case 'S':498 sprintf(buf,"S %s %s ", (*it).first.substr(0,64).c_str(), (*it).second.elval.strv->c_str() );502 case MuTyV::MTVString : 503 sprintf(buf,"S %s %s\n", (*it).first.substr(0,64).c_str(), (*it).second.elval.strv->substr(0,960).c_str() ); 499 504 sfw = buf; s.PutStr(sfw); 500 505 break; … … 515 520 void ObjFileIO<DVList>::ReadSelf(PInPersist& s) 516 521 { 517 char buf[ 512];522 char buf[1024]; 518 523 string sfr; 519 524 int_8 j,iv,k; … … 524 529 dobj->Clear(); 525 530 526 s.GetStr(sfr); // Pour lire les "------- " 527 if (sfr[0] != '-') { // Il y a un champ commentaire a lire 531 // itab - 0 : Version, 1 : NVar, 2 : Comment length, 3 reserved 532 uint_4 itab[4]; 533 s.Get(itab, 4); 534 if (itab[2] > 0) { // Il y a un champ commentaire a lire 528 535 s.GetStr(sfr); 529 536 dobj->Comment() = sfr; 530 537 } 538 539 s.GetStr(sfr); // Pour lire les "------- " 531 540 532 541 string key=""; 533 542 while(ok) { 534 543 s.GetStr(sfr); 535 strncpy(buf, sfr.c_str(), 512); 536 buf[511] = '\0'; 544 strncpy(buf, sfr.c_str(), 1024); 545 buf[1023] = '\0'; 546 j = strlen(buf)-1; 547 if ( (j >= 0) && (buf[j] == '\n') ) buf[j] = '\0'; 537 548 if (strncmp(buf,"ZZZZZ",5) == 0) { ok=false; break; } 538 549 if (buf[0] == '#') { … … 548 559 dobj->SetI(key, iv); 549 560 break; 550 case ' D' :561 case 'F' : 551 562 dv = atof(buf+j+1); 552 563 key = buf+2; … … 562 573 dobj->SetZ(key, z); 563 574 break; 564 case 'S' :575 case 'S' : 565 576 key = buf+2; 566 577 dobj->SetS(key, buf+j+1); … … 569 580 break; 570 581 } 571 } 582 } 583 if (dobj->Size() != itab[1]) // Probleme !!! 584 throw FileFormatExc("ObjFileIO<DVList>::ReadSelf() Error in Nb. Variables !"); 572 585 } 573 586
Note:
See TracChangeset
for help on using the changeset viewer.