Changeset 802 in Sophya for trunk/SophyaLib/BaseTools/dvlist.cc


Ignore:
Timestamp:
Apr 3, 2000, 7:32:27 PM (25 years ago)
Author:
ansari
Message:

Mise au point du nouveau schema (Version=2) de PPersist - Mise en place

de tag complet pour toutes les donnees/objets ecrits - Gestion a peu
pres correct des objets references plusieurs fois, ecrit une seule fois.
Mecanisme d'enregistrement pour les DataObject associe et Methodes
(PutObject/GetObjet) facilitant l'ecriture/lecture de DataObject.
Separation du fichier de la classe FIO_NDataBlock<T>.

Reza03/04/2000

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/BaseTools/dvlist.cc

    r754 r802  
    270270//  ostream&    operator << (ostream& s, DVList& dvl)
    271271//      sortie sur flot "s" (Appel a "Print(s)").
    272 //  void  Write(string const& fn)
    273 //      Ecriture d'un fichier PPersist de nom "fn"
    274 //  void  Read(string const& fn)
    275 //      Lecture d'un fichier PPersist de nom "fn"
    276272//--
    277273
     
    350346{
    351347char buf[512];
     348string sfw;
    352349
    353350int lc = dobj->Comment().length();
    354 if (lc > 511) lc = 511;
    355351if (lc > 0) {
    356352  sprintf(buf,"Comment: ( %6d ) ", lc);
    357   s.PutLine(buf);
    358   s.PutBytes(dobj->Comment().c_str(), lc);
    359   }
    360 s.PutLine("----Variable-List---------------");
     353  sfw = buf;  s.PutStr(sfw);
     354  s.PutStr(dobj->Comment());
     355  }
     356sfw = "----Variable-List---------------";  s.PutStr(sfw);
    361357DVList::ValList::const_iterator it;
    362358for(it = dobj->Begin(); it != dobj->End(); it++)  {
     
    364360    case 'I' :
    365361      sprintf(buf,"I %s %d", (*it).first.substr(0,64).c_str(), (*it).second.elval.mtv.iv );
    366       s.PutLine(buf);
     362      sfw = buf;  s.PutStr(sfw);
    367363      break;
    368364    case 'D' :
    369365      sprintf(buf,"D %s %.20g", (*it).first.substr(0,64).c_str(), (*it).second.elval.mtv.dv );
    370       s.PutLine(buf);
     366      sfw = buf;  s.PutStr(sfw);
    371367      break;
    372368    case 'S' :
    373369      sprintf(buf,"S %s %s", (*it).first.substr(0,64).c_str(), (*it).second.elval.mtv.strv );
    374       s.PutLine(buf);
     370      sfw = buf;  s.PutStr(sfw);
    375371      break;
    376372    default :
     
    380376  if ((*it).second.elcomm.length() > 0) {
    381377    sprintf(buf,"# %s", (*it).second.elcomm.substr(0,256).c_str());
    382     s.PutLine(buf);
    383   }
    384 }
    385 
    386 s.PutLine("ZZZZZ--End-of-Varible-List------");
     378    sfw = buf;  s.PutStr(sfw);
     379  }
     380}
     381
     382sfw = "ZZZZZ--End-of-Varible-List------"; s.PutStr(sfw);
    387383}
    388384
     
    391387{
    392388char buf[512];
     389string sfr;
    393390int_8 j,iv;
    394391r_8 dv;
     
    397394dobj->Clear();
    398395
    399 s.GetLine(buf, 511);  // Pour lire les "------- "
    400 if (buf[0] != '-') {  // Il y a un champ commentaire a lire
    401   buf[18] ='\0';
    402   int lc = atoi(buf+11);
    403   if (lc > 511)  {
    404     cerr << "DVList::ReadSelf() Pb/Bug ??  CommentLength= " << lc << endl;
    405     lc = 511;
    406     }
    407   s.GetBytes(buf, lc);
    408   buf[lc] ='\0';
    409   dobj->Comment() = buf;
     396s.GetStr(sfr);  // Pour lire les "------- "
     397if (sfr[0] != '-') {  // Il y a un champ commentaire a lire
     398  s.GetStr(sfr);
     399  dobj->Comment() = sfr;
    410400  }
    411401
    412402string key="";
    413403while(ok) {
    414   s.GetLine(buf, 511);
     404  s.GetStr(sfr);
     405  strncpy(buf, sfr.c_str(), 512);
    415406  buf[511] = '\0';
    416407  if (strncmp(buf,"ZZZZZ",5) == 0)  { ok=false; break; }
Note: See TracChangeset for help on using the changeset viewer.