Changeset 2441 in Sophya for trunk/SophyaLib/BaseTools


Ignore:
Timestamp:
Oct 3, 2003, 3:39:33 PM (22 years ago)
Author:
ansari
Message:

1) Premiere serie des modifications et ajout fonctionalites pour les PPersist:

  • Ecriture/lecture complex<> et tableaux de complex
  • Ecriture/lecture int_1, uint_1 et tableaux de
  • Tag de positionnement et table de tag de positionnement

2) Adaptation de Read/Write NDataBlock et suppression du fichier piocmplx.h

Reza 03/10/2003

Location:
trunk/SophyaLib/BaseTools
Files:
1 deleted
4 edited

Legend:

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

    r2322 r2441  
    88#include <complex>
    99#include "pexceptions.h"
     10#include "datatype.h"
    1011#include "fiondblock.h"
    11 #include "datatype.h"
    1212#include <typeinfo>
    1313
     
    2424*/
    2525
    26 // Pour pouvoir ecrire des tableaux de complex, en attendant
    27 // PIn/POutPersist::Get/Put(complex<>)
    28 #include "piocmplx.h"
    2926
    3027template <class T>
     
    110107}
    111108
     109//---------------------------------------------------------------------------
     110// Pour compatibilite de lecture avec PPF V2
     111inline void PIOSReadArray(PInPersist & is, uint_1 * arr, size_t n)
     112{ is.GetBytes(arr, n); }
     113inline void PIOSReadArray(PInPersist & is, uint_2 * arr, size_t n)
     114{ is.Get(arr, n); }
     115inline void PIOSReadArray(PInPersist & is, int_2 * arr, size_t n)
     116{ is.Get(arr, n); }
     117inline void PIOSReadArray(PInPersist & is, uint_4 * arr, size_t n)
     118{ is.Get(arr, n); }
     119inline void PIOSReadArray(PInPersist & is, int_4 * arr, size_t n)
     120{ is.Get(arr, n); }
     121inline void PIOSReadArray(PInPersist & is, uint_8 * arr, size_t n)
     122{ is.Get(arr, n); }
     123inline void PIOSReadArray(PInPersist & is, int_8 * arr, size_t n)
     124{ is.Get(arr, n); }
     125inline void PIOSReadArray(PInPersist & is, r_4 * arr, size_t n)
     126{ is.Get(arr, n); }
     127inline void PIOSReadArray(PInPersist & is, r_8 * arr, size_t n)
     128{ is.Get(arr, n); }
     129inline void PIOSReadArray(PInPersist & is, complex<float> * arr, size_t n)
     130{ r_4 * pr = (r_4 *)arr; is.Get(pr, n*2); }
     131inline void PIOSReadArray(PInPersist & is, complex<double> * arr, size_t n)
     132{ r_8 * pr = (r_8 *)arr; is.Get(pr, n*2); }
     133//---------------------------------------------------------------------------
     134
    112135template <class T>
    113136void FIO_NDataBlock<T>::ReadSelf(PInPersist& is)
     
    119142else if (itab[1] != dobj->Size()) dobj->ReSize(itab[1]);
    120143// On lit le tableau de nombres
    121 PIOSReadArray(is, dobj->Data(), dobj->Size());
     144if (is.Version() <= 2)   // lecture ancienne version PPF
     145  PIOSReadArray(is, dobj->Data(), dobj->Size());
     146else is.Get(dobj->Data(), dobj->Size());
    122147}
    123148
     
    135160os.Put(itab, 3);
    136161//  On ecrit le tableau de nombres
    137 PIOSWriteArray(os, dobj->Data(), dobj->Size());
     162os.Put(dobj->Data(), dobj->Size());
    138163}
    139164
  • trunk/SophyaLib/BaseTools/ppersist.cc

    r2430 r2441  
    336336//--
    337337{
    338   s.WriteTag(tag);
     338  s.WriteNameTag(tag);
    339339  s.PutPPObject(this);
    340340}
     
    431431  rbuf[32] = '\0';
    432432  struct tm tm;
    433   #if !(defined(__MWERKS__) || defined(OS_MACOSX))
     433  /*  #if !(defined(__MWERKS__) || defined(OS_MACOSX))  RZ-DEL */
    434434  strptime(rbuf,"%d/%m/%Y %H:%M:%S GMT",&tm);
    435   #else
     435  /*  #else
    436436  sscanf(rbuf,"%2d/%2d/%4d %2d:%2d:%2d GMT",&tm.tm_mday,&tm.tm_mon,&tm.tm_year,
    437437                                            &tm.tm_hour,&tm.tm_min,&tm.tm_sec);
     438
    438439  tm.tm_mon  --;
    439440  tm.tm_year -= 1900;
    440   #endif
     441  #endif    RZ-DEL */
     442
    441443  creationdate = mktime(&tm);
    442444  filename = flnm;  // keep the filename
     
    516518    if (ppstype == PPS_EOF) break;
    517519   
    518     if (ppstype != PPS_TAG)
     520    if (ppstype != PPS_NAMETAG_TABLE)
    519521      throw FileFormatExc("PInPersist::Scan   corrupted file, bad tag entry");
    520522
     
    540542
    541543bool
    542 PInPersist::GotoTag(string const& name)
     544PInPersist::GotoPositionTag(int_8 pos)
     545{
     546  s->seekg(pos);
     547  int_8 tpos;
     548  GetRawI8(tpos);
     549  if (tpos != pos)
     550    throw FileFormatExc("PInPersist::GotoPositionTag() - Wrong tag position!");
     551  return true;
     552}
     553
     554bool
     555PInPersist::GotoNameTag(string const& name)
    543556{
    544557  map<string, int_8>::iterator i = tags.find(name);
    545558  if (i == tags.end())
    546559    return false;
    547       //    throw NotFoundExc("PInPersist::GotoTag   tag not found");
     560      //    throw NotFoundExc("PInPersist::GotoNameTag   tag not found");
    548561  s->seekg((*i).second);
    549562  seqread = false;
     
    551564  return(true);
    552565}
     566
    553567
    554568bool
     
    625639PInPersist::GetTypeTag(unsigned char& c)
    626640{
    627   c = PPS_TAG_MARK;
    628   while (c == PPS_TAG_MARK) GetRawUByte(c);
    629   //  while (c == PPS_TAG_MARK) {    Il ne faut plus faire ca !
     641  int_8 tpos;
     642  c = PPS_NAMETAG_MARK;
     643  while ( (c == PPS_NAMETAG_MARK) || (c == PPS_POSTAG_MARK) ) {
     644    GetRawUByte(c);
     645    if (c == PPS_POSTAG_MARK)  GetRawI8(tpos);
     646  }
     647  //  while (c == PPS_NAMETAG_MARK) {    Il ne faut plus faire ca !
    630648  //    objList.clear();             $CHECK$ Reza 03/2000
    631649  //    GetRawByte(c);
     
    776794
    777795void
     796PInPersist::GetI1   (int_1& result)
     797{
     798  CheckTag(1,PPS_DATATYPE_INTEGER);
     799  GetRawBytes(&result, sizeof(int_1));
     800}
     801
     802void
     803PInPersist::GetI1s  (int_1* tab, size_t n)
     804{
     805  CheckArrayTag(1,n,PPS_DATATYPE_INTEGER);
     806  GetRawBytes(tab, n*sizeof(int_1));
     807}
     808
     809void
     810PInPersist::GetU1   (uint_1& result)
     811{
     812  CheckTag(1,PPS_DATATYPE_UNSIGNED);
     813  GetRawBytes(&result, sizeof(uint_1));
     814}
     815
     816void
     817PInPersist::GetU1s  (uint_1* tab, size_t n)
     818{
     819  CheckArrayTag(1,n,PPS_DATATYPE_UNSIGNED);
     820  GetRawBytes(tab, n*sizeof(uint_1));
     821}
     822
     823void
    778824PInPersist::GetI2   (int_2& result)
    779825{
     
    934980}
    935981
     982void
     983PInPersist::GetZ4   (complex<r_4>& result)
     984{
     985  CheckTag(4,PPS_DATATYPE_COMPLEX);
     986  r_4 reim[2];
     987  GetRawBytes(reim, 2*sizeof(r_4));
     988  if (bigEndian != IS_BIG_ENDIAN) {
     989    bswap4(reim);
     990    bswap4(reim+1);
     991  }
     992  result = complex<r_4>(reim[0], reim[1]);
     993}
     994
     995void
     996PInPersist::GetZ4s  (complex<r_4>* tab, size_t n)
     997
     998  CheckArrayTag(4,n,PPS_DATATYPE_COMPLEX);
     999  GetRawBytes(tab, n*2*sizeof(r_4));
     1000  if (bigEndian == IS_BIG_ENDIAN) return;
     1001
     1002  r_4 * p = (r_4 *)tab;
     1003  for (unsigned int i=0; i<n; i++) {
     1004    bswap4(p);  p++;
     1005    bswap4(p);  p++;
     1006  }
     1007  return;
     1008}
     1009
     1010void
     1011PInPersist::GetZ8   (complex<r_8>& result)
     1012{
     1013  CheckTag(8,PPS_DATATYPE_COMPLEX);
     1014  r_8 reim[2];
     1015  GetRawBytes(reim, 2*sizeof(r_8));
     1016  if (bigEndian != IS_BIG_ENDIAN) {
     1017    bswap8(reim);
     1018    bswap8(reim+1);
     1019  }
     1020  result = complex<r_8>(reim[0], reim[1]);
     1021}
     1022
     1023void
     1024PInPersist::GetZ8s  (complex<r_8>* tab, size_t n)
     1025{
     1026  CheckArrayTag(8,n,PPS_DATATYPE_COMPLEX);
     1027  GetRawBytes(tab, n*2*sizeof(r_8));
     1028  if (bigEndian == IS_BIG_ENDIAN) return;
     1029
     1030  r_8 * p = (r_8 *)tab;
     1031  for (unsigned int i=0; i<n; i++) {
     1032    bswap8(p);  p++;
     1033    bswap8(p);  p++;
     1034  }
     1035  return;
     1036}
     1037
     1038
     1039void
     1040PInPersist::GetPosTagTable(int_8* ptab, size_t sz)
     1041{
     1042  unsigned char ppstype;
     1043  GetTypeTag(ppstype);
     1044  if (ppstype != PPS_POSTAG_TABLE)
     1045    throw FileFormatExc("PInPersist::GetPosTagTable  bad type in ppersist stream");
     1046  int_4 tsz;
     1047  GetRawI4(tsz);
     1048  if (tsz != sz)
     1049    throw FileFormatExc("PInPersist::GetPosTagTable Size mismatch ");
     1050  for(int kk=0; kk<tsz; kk++)
     1051    GetRawI8(ptab[kk]);
     1052  return;
     1053}
     1054
     1055void
     1056PInPersist::GetPosTagTable(vector<int_8>& ptab)
     1057{
     1058  unsigned char ppstype;
     1059  GetTypeTag(ppstype);
     1060  if (ppstype != PPS_POSTAG_TABLE)
     1061    throw FileFormatExc("PInPersist::GetPosTagTable  bad type in ppersist stream");
     1062  ptab.clear();
     1063  int_4 tsz;
     1064  GetRawI4(tsz);
     1065  int_8 tpos;
     1066  for(int kk=0; kk<tsz; kk++) {
     1067    GetRawI8(tpos);
     1068    ptab.push_back(tpos);
     1069  }
     1070  return;
     1071}
    9361072
    9371073PPersist*
     
    10101146{
    10111147  unsigned char ppstag=0;
    1012   unsigned char ppst1,ppst2,ppst3;
     1148  unsigned char ppst1,ppst2,ppst3,ppst30;
    10131149  uint_8 cpos,fsize;
    10141150  uint_8 ui8,cid,oid;
     
    10531189    ppst2 = ppstag&0x30;  // bits     45
    10541190    ppst3 = ppstag&0xc0;  // bits       67
     1191    ppst30 = ppstag&0xc1; // bits 0     67
    10551192    if ((ppst2 == 0) && (ppst3 == 0) ) {
    10561193      switch (ppst1) {
     
    10811218        break;
    10821219
    1083       case PPS_TAG_MARK :
    1084         cout << "<PPS_TAG_MARK> tag at position " << hex << cpos << dec << endl;
     1220      case PPS_NAMETAG_MARK :
     1221        cout << "<PPS_NAMETAG_MARK> tag at position " << hex << cpos << dec << endl;
     1222        break;
     1223
     1224      case PPS_POSTAG_MARK :
     1225        GetRawI8(i8);   
     1226        cout << "<PPS_POSTAG_MARK> tag at position " << hex << cpos
     1227             << " TPos=" << i8 << dec << endl;
    10851228        break;
    10861229     
     
    10911234        break;
    10921235
    1093       case PPS_TAG :
     1236      case PPS_POSTAG_TABLE :
     1237        GetRawI4(i4);
     1238        for(int kkt=0; kkt<i4; kkt++)  GetRawI8(i8);   
     1239        cout << "<PPS_POSTAG_TABLE> tag at position " << hex << cpos << dec << endl;
     1240        break;
     1241
     1242      case PPS_NAMETAG_TABLE :
    10941243        GetRawI8(i8);
    10951244        GetRawI4(i4);
     
    11171266    else {
    11181267      string dtype = "???? x";
    1119       if (ppst3 == PPS_DATATYPE_CHAR) dtype = "CHAR x";
     1268      if (ppst30 == PPS_DATATYPE_COMPLEX) dtype = "COMPLEX x";
     1269      else if (ppst3 == PPS_DATATYPE_CHAR) dtype = "CHAR x";
    11201270      else if (ppst3 == PPS_DATATYPE_FLOAT) dtype = "FLOAT x";
    11211271      else if (ppst3 == PPS_DATATYPE_INTEGER) dtype = "INTEGER x";
    11221272      else if (ppst3 == PPS_DATATYPE_UNSIGNED) dtype = "UNSIGNED x";
    11231273      int_4 dsize = ppst1;
     1274      int_4 dsizeskip = dsize;
     1275      if (ppst30 == PPS_DATATYPE_COMPLEX) {
     1276        dsize--;
     1277        dsizeskip = 2*dsize;
     1278      }
    11241279      char sb[16];
    11251280      sprintf(sb, "%d", dsize);
     
    11311286        if (lev > 2)  cout << "<PPS_SIMPLE> tag at position " << hex << cpos << dec
    11321287                           << " DataType=" << dtype << endl;
    1133         s->seekg(dsize, ios::cur);
     1288        s->seekg(dsizeskip, ios::cur);
    11341289        break;
    11351290
     
    11381293        if (lev > 0)  cout << "<PPS_SIMPLE_ARRAY4> tag at position " << hex << cpos << dec
    11391294                           << " DataType=" << dtype << " NElts= " << i4 << endl;
    1140         s->seekg((uint_8)dsize*(uint_8)i4, ios::cur);
     1295        s->seekg((uint_8)dsizeskip*(uint_8)i4, ios::cur);
    11411296        break;
    11421297
     
    11451300        if (lev > 0)  cout << "<PPS_SIMPLE_ARRAY8> tag at position " << hex << cpos << dec
    11461301                           << " DataType=" << dtype << " NElts= " << ui8 << endl;
    1147         s->seekg((uint_8)dsize*ui8, ios::cur);
     1302        s->seekg((uint_8)dsizeskip*ui8, ios::cur);
    11481303        break;
    11491304      }
     
    12471402  // Output stream creation
    12481403  s = new ofstream(flnm.c_str(),ios::out | IOS_BIN); 
    1249 
     1404  version = 3;
    12501405  // Header
    1251   PutRawBytes("SOS-SOPHYA-PPersistFile V2               ",32);
     1406  PutRawBytes("SOS-SOPHYA-PPersistFile V3               ",32);
    12521407  PutRawBytes(bigEndian
    12531408           ? "BIG-ENDIAN                             "
     
    12791434      string name = (*i).first;
    12801435      int_8 pos = (*i).second;
    1281       PutRawUByte(PPS_TAG);                       // This is a tag
     1436      PutRawUByte(PPS_NAMETAG_TABLE);                       // This is a tag
    12821437      PutRawI8(pos);                             // position of previous tag
    12831438      PutRawI4(name.length());                   // length of the name
     
    12911446}
    12921447
    1293 
    1294 void
    1295 POutPersist::WriteTag(string const& name)
     1448int_8
     1449POutPersist::WritePositionTag()
     1450{
     1451  int_8 tagpos;
     1452#ifdef STREAMPOS_IS_CLASS
     1453  tagpos = s->tellp().offset();
     1454#else
     1455  tagpos = s->tellp();
     1456#endif
     1457  PutRawByte(PPS_POSTAG_MARK);
     1458  PutI8(tagpos);
     1459  return(tagpos);
     1460}
     1461
     1462void
     1463POutPersist::WriteNameTag(string const& name)
    12961464{
    12971465  if (name.length() > MAXTAGLEN)
    1298     throw ParmError("POutPersist::WriteTag   tag name too long");
     1466    throw ParmError("POutPersist::WriteNameTag   tag name too long");
    12991467
    13001468  if (tags.find(name) != tags.end())
    1301     throw DuplicateIdExc("POutPersist::WriteTag   duplicate tag name");
     1469    throw DuplicateIdExc("POutPersist::WriteNameTag   duplicate tag name");
    13021470
    13031471  // Get current file position
     
    13111479
    13121480  tags[name] = tagPos;
    1313   PutRawUByte(PPS_TAG_MARK);                       // This is a tag
     1481  PutRawUByte(PPS_NAMETAG_MARK);                       // This is a tag
    13141482  //  objList.clear(); // $CHECK$ EA 171199  - Ne pas faire ? Reza 03/2000
    13151483}
     
    14821650
    14831651void
     1652POutPersist::PutI1   (int_1 val)
     1653{
     1654  PutRawUByte(PPS_SIMPLE + 1 + PPS_DATATYPE_INTEGER);
     1655  PutRawBytes(&val, sizeof(int_1));
     1656}
     1657
     1658void
     1659POutPersist::PutI1s  (int_1 const* tab, size_t n)
     1660{
     1661  PutArrayTag(1, n, PPS_DATATYPE_INTEGER);
     1662  PutRawBytes(tab, n*sizeof(int_1));
     1663}
     1664
     1665void
     1666POutPersist::PutU1   (uint_1 val)
     1667{
     1668  PutRawUByte(PPS_SIMPLE + 1 + PPS_DATATYPE_UNSIGNED);
     1669  PutRawBytes(&val, sizeof(uint_1));
     1670}
     1671
     1672void
     1673POutPersist::PutU1s  (uint_1 const* tab, size_t n)
     1674{
     1675  PutArrayTag(1, n, PPS_DATATYPE_UNSIGNED);
     1676  PutRawBytes(tab, n*sizeof(uint_1));
     1677}
     1678
     1679void
    14841680POutPersist::PutI2   (int_2 val)
    14851681{
     
    16601856
    16611857void
     1858POutPersist::PutZ4   (complex<r_4> val)
     1859{
     1860  PutRawUByte(PPS_SIMPLE + 4 + PPS_DATATYPE_COMPLEX);
     1861  r_4 reim[2];
     1862  reim[0] = val.real();
     1863  reim[1] = val.imag();
     1864  if (bigEndian != IS_BIG_ENDIAN) {
     1865    bswap4(reim);
     1866    bswap4(reim+1);
     1867  }
     1868  PutRawBytes(reim, 2*sizeof(r_4));
     1869}
     1870
     1871void
     1872POutPersist::PutZ4s  (complex<r_4> const* tab, size_t n)
     1873{
     1874  PutArrayTag(4, n, PPS_DATATYPE_COMPLEX);
     1875
     1876  if (bigEndian == IS_BIG_ENDIAN) {
     1877    PutRawBytes(tab, n*2*sizeof(r_4));
     1878  } else {
     1879    for (unsigned int i=0; i<n; i++) {
     1880      r_4 reim[2];
     1881      reim[0] = tab[i].real();
     1882      reim[1] = tab[i].imag();
     1883      bswap4(reim);
     1884      bswap4(reim+1);
     1885      PutRawBytes(reim, 2*sizeof(r_4));
     1886    }
     1887  }
     1888}
     1889
     1890void
     1891POutPersist::PutZ8   (complex<r_8> val)
     1892{
     1893  PutRawUByte(PPS_SIMPLE + 8 + PPS_DATATYPE_COMPLEX);
     1894  r_8 reim[2];
     1895  reim[0] = val.real();
     1896  reim[1] = val.imag();
     1897  if (bigEndian != IS_BIG_ENDIAN) {
     1898    bswap8(reim);
     1899    bswap8(reim+1);
     1900  }
     1901  PutRawBytes(reim, 2*sizeof(r_8));
     1902}
     1903
     1904void
     1905POutPersist::PutZ8s  (complex<r_8> const* tab, size_t n)
     1906{
     1907  PutArrayTag(8, n, PPS_DATATYPE_COMPLEX);
     1908
     1909  if (bigEndian == IS_BIG_ENDIAN) {
     1910    PutRawBytes(tab, n*2*sizeof(r_8));
     1911  } else {
     1912    for (unsigned int i=0; i<n; i++) {
     1913      r_8 reim[2];
     1914      reim[0] = tab[i].real();
     1915      reim[1] = tab[i].imag();
     1916      bswap8(reim);
     1917      bswap8(reim+1);
     1918      PutRawBytes(reim, 2*sizeof(r_8));
     1919    }
     1920  }
     1921}
     1922
     1923void
     1924POutPersist::PutPosTagTable(int_8 const * ptab, size_t sz)
     1925{
     1926  PutRawUByte(PPS_POSTAG_TABLE);
     1927  int_4 tsz = sz;
     1928  PutRawI4(tsz);
     1929  for(int kk=0; kk<tsz; kk++)
     1930    PutRawI8(ptab[kk]);
     1931  return;
     1932}
     1933
     1934void
     1935POutPersist::PutPosTagTable(vector<int_8> const& ptab)
     1936{
     1937  PutRawUByte(PPS_POSTAG_TABLE);
     1938  int_4 tsz = ptab.size();
     1939  PutRawI4(tsz);
     1940  for(int kk=0; kk<tsz; kk++)
     1941    PutRawI8(ptab[kk]);
     1942  return;
     1943}
     1944
     1945void
    16621946POutPersist::PutObject(AnyDataObj & o)
    16631947{
     
    16731957POutPersist::PutObject(AnyDataObj & o, string tagname)
    16741958{
    1675   WriteTag(tagname);
     1959  WriteNameTag(tagname);
    16761960  PutObject(o);
    16771961}
  • trunk/SophyaLib/BaseTools/ppersist.h

    r1202 r2441  
    1717#include <time.h>
    1818
     19#include <complex>
    1920#include <string>
    2021#include <map>
     
    9394    static void Initialize();   // Pour initialiser classList
    9495
     96    int    Version() {return version;}  // PIn/OutPersist version number
    9597    string FileName() { return filename; }   // Retourne le nom de fichier
    9698
     
    109111          PPS_OBJECT = 2,           // classId, data...
    110112          PPS_REFERENCE = 3,        // objectId
    111           PPS_TAG = 4,              // tag entries
     113          PPS_NAMETAG_TABLE = 4,    // Name tag table (Written at the end of file/stream)
    112114          PPS_EOF = 5,              // Just before tag infomation, offset to PPS_TAG
    113115          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)
    115119          PPS_SIMPLE = 16,          // 16 + number of bytes, up to 8 bytes
    116120          PPS_SIMPLE_ARRAY4 = 32,   // 32 + number of bytes, up to 8 bytes, then 4 bytes of length
     
    120124   enum  {PPS_DATATYPE_CHAR = 0,        // 0  : DataType=character
    121125          PPS_DATATYPE_FLOAT = 64,      // 64 : DataType=float
     126          PPS_DATATYPE_COMPLEX = 65,    // 65 : DataType=complex
    122127          PPS_DATATYPE_INTEGER = 128,   // 128 :DataType=integer
    123128          PPS_DATATYPE_UNSIGNED = 192   // 192 :DataType=Unsigned integer
     
    126131    map<string, int_8> tags;
    127132    string filename;
     133    int version;     // PPersist(In/Out) version
    128134  };
    129135
    130136
    131   // TBD : use hash tables instead of maps. Check hashtbl status in STL.
     137// TBD : use hash tables instead of maps. Check hashtbl status in STL.
    132138
    133139//! Input stream for PPersit objects.
     
    137143    ~PInPersist();
    138144
    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); }
    140149    int    NbTags();
    141150    bool   GotoTagNum(int itag);  // 0..NbTags-1
     
    144153    vector<string> const &  GetTagNames(); 
    145154
     155    // Lecture donnees de base et tableaux de donnees de base
     156    // Basic data type (and corresponding arrays) reading
    146157    void   GetByte (char& c);
    147158    void   GetBytes(void* ptr, size_t bytes);
     
    150161    void   GetR8   (r_8&);
    151162    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);
    152167    void   GetI2   (int_2&);
    153168    void   GetI2s  (int_2*, size_t);
     
    164179    void   GetLine (char* ptr, size_t len);
    165180    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
    186218    //   Object Reading
    187219    PPersist*  ReadObject();
     
    190222    PPersist*  GetPPObject(AnyDataObj * po=NULL);
    191223
    192     int    Version() {return version;}
    193224    time_t CreationDate() { return creationdate; }
    194225    string CreationDateStr();
     
    219250
    220251    bool bigEndian;
    221     int version;
    222252
    223253    time_t creationdate;
     
    237267    ~POutPersist();
    238268
    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); }
    240273 
    241274    void PutByte (char c);
     
    245278    void PutR8   (r_8);
    246279    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);
    247284    void PutI2   (int_2);
    248285    void PutI2s  (int_2 const*, size_t);
     
    259296    void PutLine (char const* ptr, size_t len=0); // deprecated ?
    260297    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
    265303
    266304    void   Put(char   c) {PutByte(c);}
    267305    void   Put(r_4    x) {PutR4(x);}
    268306    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);}
    269311    void   Put(uint_2 x) {PutU2(x);}
    270312    void   Put(int_2  x) {PutI2(x);}
     
    275317    void   Put(r_4 const*    x, size_t n) {PutR4s(x,n);}
    276318    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);}
    277323    void   Put(uint_2 const* x, size_t n) {PutU2s(x,n);}
    278324    void   Put(int_2 const*  x, size_t n) {PutI2s(x,n);}
     
    283329    void   Put(string const& s) {PutStr(s);}
    284330    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);
    285341
    286342
     
    310366  };
    311367 
    312  
     368
     369// Le macro suivant permettent de simplifier la declaration
     370// des operateurs >> << sur les POutPersist et  PInPersist
    313371#define RAWPERSISTIO(_Type_,_xtyp_)                                             \
    314372  inline POutPersist& operator << (POutPersist& c, _Type_ const& data)            \
     
    324382  }                                                                               
    325383
     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 ...
    326386  RAWPERSISTIO(int_4,I4);
    327387  RAWPERSISTIO(uint_4,U4);
     
    331391  RAWPERSISTIO(r_4,R4);
    332392  RAWPERSISTIO(r_8,R8);
     393  RAWPERSISTIO(complex<r_4>,Z4);
     394  RAWPERSISTIO(complex<r_8>,Z8);
     395  RAWPERSISTIO(string,Str);
    333396 
    334397#if 0
  • trunk/SophyaLib/BaseTools/sversion.h

    r2434 r2441  
    22#define SVERSION_H
    33
    4 #define SOPHYA_VERSION   1.7
     4#define SOPHYA_VERSION   1.8
    55#define SOPHYA_REVISION  0
    6 #define SOPHYA_TAG       "V_Sep2003"
     6#define SOPHYA_TAG       "V_Oct2003"
    77
    88#endif
Note: See TracChangeset for help on using the changeset viewer.