Index: trunk/SophyaLib/BaseTools/ppersist.cc
===================================================================
--- trunk/SophyaLib/BaseTools/ppersist.cc	(revision 2459)
+++ trunk/SophyaLib/BaseTools/ppersist.cc	(revision 2475)
@@ -6,13 +6,16 @@
 #include "ppersist.h"
 #include "anydataobj.h"
-#include <fstream>
 #include <iostream>
 #include <typeinfo>
 
-
-#ifdef __mac__
-#include "unixmac.h"
-#include <SIOUX.h>
-#endif
+// ------------------------- Historique ---------------------------
+// Le code de ppersist a ete separe en deux en Decembre 2003
+// a partir de la version CVS (1.26 - ppersist.cc) et 
+// (1.19 - ppersist.h) .  
+// la partie sur l'ecriture des donnees de base et leurs tableaux
+// a ete mis dans les fichiers ppfbinstream.h .cc 
+// (Classes PPFBinaryInputStream et PPFBinaryOutputStream
+// -----------------------------------------------------------------
+
 
 //  strptime n'est pas defini sous Linux  - Reza Mars 2000
@@ -64,5 +67,5 @@
 //
 //	Register a new persistence handler (PPersist) class.
-//	The classId is usually a hash of the class name, and
+//	The classId is usually a hash of the class< name, and
 //	ppclass_name is typeid(PPersistClass).name() .
 //	This method is called only through the PPersistRegistrar template
@@ -178,32 +181,4 @@
 
 
-static inline void bswap8(void* p)
-{
-  uint_8 tmp = *(uint_8*)p;
-  *(uint_8*)p = ((tmp >> (7*8)) & 0x000000FF) | 
-                ((tmp >> (5*8)) & 0x0000FF00) |
-                ((tmp >> (3*8)) & 0x00FF0000) |
-                ((tmp >> (1*8)) & 0xFF000000) |
-                ((tmp & 0xFF000000) << (1*8))  |
-                ((tmp & 0x00FF0000) << (3*8))  |
-                ((tmp & 0x0000FF00) << (5*8))  |
-                ((tmp & 0x000000FF) << (7*8));
-}
-
-static inline void bswap4(void* p)
-{
-  uint_4 tmp = *(uint_4*)p;
-  *(uint_4*)p = ((tmp >> 24) & 0x000000FF) | 
-                ((tmp >> 8)  & 0x0000FF00) |
-                ((tmp & 0x0000FF00) << 8)  |
-                ((tmp & 0x000000FF) << 24);
-}
-
-static inline void bswap2(void* p)
-{
-  uint_2 tmp = *(uint_2*)p;
-  *(uint_2*)p = ((tmp >> 8) & 0x00FF) | 
-                ((tmp & 0x00FF) << 8);
-}
 
 
@@ -397,52 +372,9 @@
 //++
 PInPersist::PInPersist(string const& flnm, bool scan)
+  : PPFBinaryInputStream(flnm, scan)
 //
 //	Constructeur. Ouvre le fichier.
 //--
 {
-  s = new RawInFileStream(flnm.c_str());
-
-  // Read and check header
-
-  char rbuf[36];
-  GetRawBytes(rbuf, 32);
-  if (strncmp(rbuf,"SOS-SOPHYA-PPersistFile", 23) != 0)  {
-    throw FileFormatExc("PInPersist::PInPersist  bad header");
-  }
-  rbuf[32] = '\0';
-  version = atoi(rbuf+25);
-  if (version < 2) {
-    cerr << "PInPersist::PInPersist(" << flnm << ") Version(=" << version 
-	 << ") < 2 not supported !" << endl;
-    throw FileFormatExc("PInPersist::PInPersist() - Unsupported (Old) Version");
-  }
-  // read endianness
-  GetRawBytes(rbuf, 32);
-  if (strncmp(rbuf,"BIG-ENDIAN",10) == 0)
-    bigEndian = true;
-  else if (strncmp(rbuf,"LITTLE-ENDIAN",13) == 0)
-    bigEndian = false;
-  else {
-    throw FileFormatExc("PInPersist::PInPersist  bad header - endianness");
-  }
-
-  // read creation date
-  GetRawBytes(rbuf, 32);
-  rbuf[32] = '\0'; 
-  struct tm tm;
-  /*  #if !(defined(__MWERKS__) || defined(OS_MACOSX))  RZ-DEL */
-  strptime(rbuf,"%d/%m/%Y %H:%M:%S GMT",&tm);
-  /*  #else
-  sscanf(rbuf,"%2d/%2d/%4d %2d:%2d:%2d GMT",&tm.tm_mday,&tm.tm_mon,&tm.tm_year,
-                                            &tm.tm_hour,&tm.tm_min,&tm.tm_sec);
-
-  tm.tm_mon  --;
-  tm.tm_year -= 1900;
-  #endif    RZ-DEL */
-
-  creationdate = mktime(&tm);
-  filename = flnm;  // keep the filename
-  seqread = true;   // To flag non sequential reads
-  if (scan && s->isSeekable()) Scan();
 }
 
@@ -454,112 +386,7 @@
   for(i=objList.begin(); i!= objList.end(); i++)  
     if ((*i).second)  delete (*i).second;
-  delete s;
-}
-
-
-string 
-PInPersist::CreationDateStr()
-{
-  time_t cdt = CreationDate();
-  string cdate = ctime(&cdt);
-  return(cdate);
-}
-
-void
-PInPersist::Scan()
-{
-  // On cherche la liste des tags, a la fin du fichier
-
-  unsigned char ppstype;
-  int_8 debut;
-  debut = s->tellg();
-
-  s->seekg(-(sizeof(int_8)+1), ios::end);
-
-  GetTypeTag(ppstype);
-  if (ppstype != PPS_EOF)
-    throw FileFormatExc("PInPersist::Scan   corrupted file, no eof entry at end of file");
-
-  int_8 pos;
-  GetRawI8(pos);
-  if (pos < 0) {  // no tags
-    s->seekg(debut);
-    return;
-  }
-
-  char buffer[MAXTAGLEN+1];
-  s->seekg(pos);
-  while (true) {
-    GetTypeTag(ppstype);
-    if (ppstype == PPS_EOF) break;
-    
-    if (ppstype != PPS_NAMETAG_TABLE)
-      throw FileFormatExc("PInPersist::Scan   corrupted file, bad tag entry");
-
-    GetRawI8(pos);
-    int_4 len;
-    GetRawI4(len);
-    if (len > MAXTAGLEN) 
-      throw FileFormatExc("PInPersist::Scan   corrupted file, tag name too long");
-    GetRawBytes(buffer, len);
-    buffer[len] = '\0';
-
-    tags[buffer] = pos;
-  }
-  s->seekg(debut);
-}
-
-
-int
-PInPersist::NbNameTags()
-{
-  return tags.size();
-}
-
-bool 
-PInPersist::GotoPositionTag(int_8 pos)
-{
-  s->seekg(pos);
-  int_8 tpos;
-  GetRawI8(tpos);
-  if (tpos != pos) 
-    throw FileFormatExc("PInPersist::GotoPositionTag() - Wrong tag position!");
-  return true;
-}
-
-bool 
-PInPersist::GotoNameTag(string const& name)
-{
-  map<string, int_8>::iterator i = tags.find(name);
-  if (i == tags.end()) 
-    return false;
-      //    throw NotFoundExc("PInPersist::GotoNameTag   tag not found");
-  s->seekg((*i).second);
-  seqread = false;
-  //  objList.clear(); $CHECK$ EA 171199 Ne pas faire ? Reza 03/2000 ?
-  return(true); 
-}
-
-
-bool
-PInPersist::GotoNameTagNum(int itag)
-{
-  if (itag<0 || itag >= (int)tags.size()) return false;
-  map<string, int_8>::iterator i = tags.begin();
-  for (int j=0; j<itag; j++) i++;
-  s->seekg((*i).second);
-  seqread = false;
-  // objList.clear();  $CHECK$ EA 171199  Ne pas faire ? Reza 03/2000 ?
-  return(true);
-}
-
-string
-PInPersist::GetTagName(int itag)
-{
-  if (itag<0 || itag >= (int)tags.size()) return "";
-  map<string, int_8>::iterator i = tags.begin();
-  for (int j=0; j<itag; j++) i++;
-  return((*i).first);
-}
+}
+
+
 
 string
@@ -573,483 +400,4 @@
 //   return(GetClassName(cid));
   return("");
-}
-
-static vector<string> * ret_tag_names = NULL;
-vector<string> const &
-PInPersist::GetNameTags()
-{
-if (ret_tag_names) delete ret_tag_names;
-ret_tag_names = new vector<string> ;
-map<string, int_8>::iterator i;
-for(i=tags.begin(); i!=tags.end(); i++) ret_tag_names->push_back((*i).first);
-return(*ret_tag_names);  
-}
-
-bool
-PInPersist::SkipToNextObject()
-{
-  // A FAIRE NOV 2003 - REZA
-  return true;
-}
-
-//++
-// void PInPersist::GetByte(char& c)
-// void PInPersist::GetBytes(void* ptr, size_t bytes)
-// void PInPersist::GetR4   (r_4& result)
-// void PInPersist::GetR4s  (r_4* tab, size_t n)
-// void PInPersist::GetR8   (r_8& result)
-// void PInPersist::GetR8s  (r_8* tab, size_t n)
-// void PInPersist::GetI2   (int_2& result)
-// void PInPersist::GetI2s  (int_2* tab, size_t n)
-// void PInPersist::GetU2   (uint_2& result)
-// void PInPersist::GetU2s  (uint_2* tab, size_t n)
-// void PInPersist::GetI4   (int_4& result)
-// void PInPersist::GetI4s  (int_4* tab, size_t n)
-// void PInPersist::GetU4   (uint_4& result)
-// void PInPersist::GetU4s  (uint_4* tab, size_t n)
-// void PInPersist::GetI8   (int_8& result)
-// void PInPersist::GetI8s  (int_8* tab, size_t n)
-// void PInPersist::GetU8   (uint_8& result)
-// void PInPersist::GetU8s  (uint_8* tab, size_t n)
-//	Lecture de données portables depuis le fichier PPersist. Pour chaque type
-//	de données, on peut lire une valeur, ou un tableau de valeurs.
-// void PInPersist::GetLine(char* ptr, size_t len)
-//	Lecture d'une ligne de texte depuis le fichier PPersist.
-//--
-
-
-void
-PInPersist::GetTypeTag(unsigned char& c) 
-{
-  int_8 tpos;
-  c = PPS_NAMETAG_MARK;
-  while ( (c == PPS_NAMETAG_MARK) || (c == PPS_POSTAG_MARK) ) {
-    GetRawUByte(c);
-    if (c == PPS_POSTAG_MARK)  GetRawI8(tpos);
-  } 
-  //  while (c == PPS_NAMETAG_MARK) {    Il ne faut plus faire ca !
-  //    objList.clear();             $CHECK$ Reza 03/2000
-  //    GetRawByte(c);
-  //  }
-}
-
-
-void
-PInPersist::GetRawByte(char& c)
-{
-  GetRawBytes(&c, 1);
-}
-
-void
-PInPersist::GetRawUByte(unsigned char& c)
-{
-  GetRawBytes(&c, 1);
-}
-
-void
-PInPersist::GetRawBytes(void* ptr, size_t bytes)
-{
-  s->read((char*)ptr, bytes);
-}
-
-void
-PInPersist::GetRawI2   (int_2& result)
-{
-  GetRawBytes(&result, sizeof(int_2));
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap2(&result);
-}
-
-void
-PInPersist::GetRawI4   (int_4& result)
-{
-  GetRawBytes(&result, sizeof(int_4));
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap4(&result);
-}
-
-void
-PInPersist::GetRawI8   (int_8& result)
-{
-  GetRawBytes(&result, sizeof(int_8));
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap8(&result);
-}
-
-void
-PInPersist::GetRawU8   (uint_8& result)
-{
-  GetRawBytes(&result, sizeof(uint_8));
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap8(&result);
-}
-
-void
-PInPersist::CheckTag(short datasz, short datatype)
-// datatype = PPS_DATATYPE_CHAR or PPS_DATATYPE_FLOAT or PPS_DATATYPE_INTEGER or PPS_DATATYPE_UNSIGNED
-{
-  unsigned char ppstype;
-  GetTypeTag(ppstype);
-  if (ppstype != PPS_SIMPLE + datasz + datatype)
-    throw FileFormatExc("PInPersist::CheckTag   bad type in ppersist file");
-}
-
-void
-PInPersist::CheckArrayTag(short datasz, size_t sz, short datatype)
-// datatype = PPS_DATATYPE_CHAR or PPS_DATATYPE_FLOAT or PPS_DATATYPE_INTEGER or PPS_DATATYPE_UNSIGNED
-{
-  unsigned char ppstype;
-  GetTypeTag(ppstype);
-  size_t filesz;
-  if (sz <= 0x7fffffff) {
-    if (ppstype != PPS_SIMPLE_ARRAY4 + datasz + datatype)
-      throw FileFormatExc("PInPersist::CheckArrayTag   bad type in ppersist file");
-    int_4 ff;
-    GetRawI4(ff); filesz=ff;
-  } else {
-    if (ppstype != PPS_SIMPLE_ARRAY8 + datasz + datatype)
-      throw FileFormatExc("PInPersist::CheckArrayTag   bad type in ppersist file");
-    uint_8 ff;
-    GetRawU8(ff); filesz=ff;
-  }
-  if (filesz != sz)
-    throw FileFormatExc("PInPersist::CheckArrayTag   bad array size in ppersist file");
-}
-
-void
-PInPersist::GetByte(char& c)
-{
-  CheckTag(1,PPS_DATATYPE_CHAR);
-  GetRawBytes(&c, 1);
-}
-
-
-void
-PInPersist::GetBytes(void* ptr, size_t bytes)
-{
-  CheckArrayTag(1, bytes, PPS_DATATYPE_CHAR);
-  GetRawBytes(ptr, bytes);
-}
-void
-PInPersist::GetR4   (r_4& result)
-{
-  CheckTag(4,PPS_DATATYPE_FLOAT);
-  GetRawBytes(&result, sizeof(r_4));
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap4(&result);
-}
-
-
-void
-PInPersist::GetR4s  (r_4* tab, size_t n)
-{
-  CheckArrayTag(4,n,PPS_DATATYPE_FLOAT);
-  GetRawBytes(tab, n*sizeof(r_4));
-  if (bigEndian == IS_BIG_ENDIAN) return;
-
-  for (unsigned int i=0; i<n; i++)
-    bswap4(tab+i);
-
-  return;
-}
-
-void
-PInPersist::GetR8   (r_8& result)
-{
-  CheckTag(8,PPS_DATATYPE_FLOAT);
-  GetRawBytes(&result, sizeof(r_8));
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap8(&result);
-}
-
-void
-PInPersist::GetR8s  (r_8* tab, size_t n)
-{
-  CheckArrayTag(8,n,PPS_DATATYPE_FLOAT);
-  GetRawBytes(tab, n*sizeof(r_8));
-  if (bigEndian == IS_BIG_ENDIAN) return;
-
-  for (unsigned int i=0; i<n; i++)
-    bswap8(tab+i);
-
-  return;
-}
-
-void
-PInPersist::GetI1   (int_1& result)
-{
-  CheckTag(1,PPS_DATATYPE_INTEGER);
-  GetRawBytes(&result, sizeof(int_1));
-}
-
-void
-PInPersist::GetI1s  (int_1* tab, size_t n)
-{
-  CheckArrayTag(1,n,PPS_DATATYPE_INTEGER);
-  GetRawBytes(tab, n*sizeof(int_1));
-}
-
-void
-PInPersist::GetU1   (uint_1& result)
-{
-  CheckTag(1,PPS_DATATYPE_UNSIGNED);
-  GetRawBytes(&result, sizeof(uint_1));
-}
-
-void
-PInPersist::GetU1s  (uint_1* tab, size_t n)
-{
-  CheckArrayTag(1,n,PPS_DATATYPE_UNSIGNED);
-  GetRawBytes(tab, n*sizeof(uint_1));
-}
-
-void
-PInPersist::GetI2   (int_2& result)
-{
-  CheckTag(2,PPS_DATATYPE_INTEGER);
-  GetRawBytes(&result, sizeof(int_2));
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap2(&result);
-}
-
-void
-PInPersist::GetI2s  (int_2* tab, size_t n)
-{
-  CheckArrayTag(2,n,PPS_DATATYPE_INTEGER);
-  GetRawBytes(tab, n*sizeof(int_2));
-  if (bigEndian == IS_BIG_ENDIAN) return;
-
-  for (unsigned int i=0; i<n; i++)
-    bswap2(tab+i);
-
-  return;
-}
-
-void
-PInPersist::GetU2   (uint_2& result)
-{
-  CheckTag(2,PPS_DATATYPE_UNSIGNED);
-  GetRawBytes(&result, sizeof(uint_2));
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap2(&result);
-}
-
-void
-PInPersist::GetU2s  (uint_2* tab, size_t n)
-{
-  CheckArrayTag(2,n,PPS_DATATYPE_UNSIGNED);
-  GetRawBytes(tab, n*sizeof(uint_2));
-  if (bigEndian == IS_BIG_ENDIAN) return;
-
-  for (unsigned int i=0; i<n; i++)
-    bswap2(tab+i);
-
-  return;
-}
-
-void
-PInPersist::GetI4   (int_4& result)
-{
-  CheckTag(4,PPS_DATATYPE_INTEGER);
-  GetRawBytes(&result, sizeof(int_4));
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap4(&result);
-}
-
-void
-PInPersist::GetI4s  (int_4* tab, size_t n)
-{
-  CheckArrayTag(4,n,PPS_DATATYPE_INTEGER);
-  GetRawBytes(tab, n*sizeof(int_4));
-  if (bigEndian == IS_BIG_ENDIAN) return;
-
-  for (unsigned int i=0; i<n; i++)
-    bswap4(tab+i);
-
-  return;
-}
-
-void
-PInPersist::GetU4   (uint_4& result)
-{
-  CheckTag(4,PPS_DATATYPE_UNSIGNED);
-  GetRawBytes(&result, sizeof(uint_4));
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap4(&result);
-}
-
-void
-PInPersist::GetU4s  (uint_4* tab, size_t n)
-{
-  CheckArrayTag(4,n,PPS_DATATYPE_UNSIGNED);
-  GetRawBytes(tab, n*sizeof(uint_4));
-  if (bigEndian == IS_BIG_ENDIAN) return;
-
-  for (unsigned int i=0; i<n; i++)
-    bswap4(tab+i);
-
-  return;
-}
-
-
-void
-PInPersist::GetI8   (int_8& result)
-{
-  CheckTag(8,PPS_DATATYPE_INTEGER);
-  GetRawBytes(&result, sizeof(int_8));
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap8(&result);
-}
-
-void
-PInPersist::GetI8s  (int_8* tab, size_t n)
-{
-  CheckArrayTag(8,n,PPS_DATATYPE_INTEGER);
-  GetRawBytes(tab, n*sizeof(int_8));
-  if (bigEndian == IS_BIG_ENDIAN) return;
-
-  for (unsigned int i=0; i<n; i++)
-    bswap8(tab+i);
-
-  return;
-}
-
-void
-PInPersist::GetU8   (uint_8& result)
-{
-  CheckTag(8,PPS_DATATYPE_UNSIGNED);
-  GetRawBytes(&result, sizeof(uint_8));
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap8(&result);
-}
-
-void
-PInPersist::GetU8s  (uint_8* tab, size_t n)
-{
-  CheckArrayTag(8,n,PPS_DATATYPE_UNSIGNED);
-  GetRawBytes(tab, n*sizeof(uint_8));
-  if (bigEndian == IS_BIG_ENDIAN) return;
-
-  for (unsigned int i=0; i<n; i++)
-    bswap8(tab+i);
-
-  return;
-}
-
-
-void
-PInPersist::GetLine(char* ptr, size_t len)
-{
-  string str;
-  GetStr(str);
-  strncpy(ptr, str.c_str(), len);
-  ptr[len] = '\0';
-}
-
-void
-PInPersist::GetStr(string& str)
-{
-  unsigned char ppstype;
-  GetTypeTag(ppstype);
-  if (ppstype != PPS_STRING) 
-    throw FileFormatExc("PInPersist::GetStr   bad type in ppersist file");
-  int_4 len;
-  GetRawI4(len);
-  char * buff = new char[len+1];
-  GetRawBytes(buff, len);
-  buff[len] = '\0';
-  str = buff;
-  delete[] buff;
-}
-
-void
-PInPersist::GetZ4   (complex<r_4>& result)
-{
-  CheckTag(4,PPS_DATATYPE_COMPLEX);
-  r_4 reim[2];
-  GetRawBytes(reim, 2*sizeof(r_4));
-  if (bigEndian != IS_BIG_ENDIAN) {
-    bswap4(reim);
-    bswap4(reim+1);
-  }
-  result = complex<r_4>(reim[0], reim[1]);
-}
-
-void
-PInPersist::GetZ4s  (complex<r_4>* tab, size_t n)
-{  
-  CheckArrayTag(4,n,PPS_DATATYPE_COMPLEX);
-  GetRawBytes(tab, n*2*sizeof(r_4));
-  if (bigEndian == IS_BIG_ENDIAN) return;
-
-  r_4 * p = (r_4 *)tab;
-  for (unsigned int i=0; i<n; i++) {
-    bswap4(p);  p++;
-    bswap4(p);  p++;
-  }
-  return;
-}
-
-void
-PInPersist::GetZ8   (complex<r_8>& result)
-{
-  CheckTag(8,PPS_DATATYPE_COMPLEX);
-  r_8 reim[2];
-  GetRawBytes(reim, 2*sizeof(r_8));
-  if (bigEndian != IS_BIG_ENDIAN) {
-    bswap8(reim);
-    bswap8(reim+1);
-  }
-  result = complex<r_8>(reim[0], reim[1]);
-}
-
-void
-PInPersist::GetZ8s  (complex<r_8>* tab, size_t n)
-{
-  CheckArrayTag(8,n,PPS_DATATYPE_COMPLEX);
-  GetRawBytes(tab, n*2*sizeof(r_8));
-  if (bigEndian == IS_BIG_ENDIAN) return;
-
-  r_8 * p = (r_8 *)tab;
-  for (unsigned int i=0; i<n; i++) {
-    bswap8(p);  p++;
-    bswap8(p);  p++;
-  }
-  return;
-}
-
-
-void
-PInPersist::GetPosTagTable(int_8* ptab, size_t sz)
-{
-  unsigned char ppstype;
-  GetTypeTag(ppstype);
-  if (ppstype != PPS_POSTAG_TABLE) 
-    throw FileFormatExc("PInPersist::GetPosTagTable  bad type in ppersist stream");
-  int_4 tsz;
-  GetRawI4(tsz);
-  if (tsz != sz)
-    throw FileFormatExc("PInPersist::GetPosTagTable Size mismatch ");
-  for(int kk=0; kk<tsz; kk++)
-    GetRawI8(ptab[kk]);
-  return;
-}
-
-void
-PInPersist::GetPosTagTable(vector<int_8>& ptab)
-{
-  unsigned char ppstype;
-  GetTypeTag(ppstype);
-  if (ppstype != PPS_POSTAG_TABLE) 
-    throw FileFormatExc("PInPersist::GetPosTagTable  bad type in ppersist stream");
-  ptab.clear();
-  int_4 tsz;
-  GetRawI4(tsz);
-  int_8 tpos;
-  for(int kk=0; kk<tsz; kk++) {
-    GetRawI8(tpos);
-    ptab.push_back(tpos);
-  }
-  return;
 }
 
@@ -1125,162 +473,4 @@
 
 
-void
-PInPersist::AnalyseTags(int lev)
-{
-  unsigned char ppstag=0;
-  unsigned char ppst1,ppst2,ppst3,ppst30;
-  int_8 cpos,fsize;
-  uint_8 ui8,cid,oid;
-  int_4 i4;
-  int_8 i8;
-  char * buff;
-  string str;
-  
-  cout << "\n ---------------------------------------------------------- " << endl;
-  cout << " PInPersist::AnalyseTags(Level= " << lev << ")" << endl; 
-
-
-  cpos = s->tellg();
-  s->seekg(0,ios::end);
-  fsize = s->tellg();
-  s->seekg(cpos,ios::beg);
-
-  cout << "   Version= " << Version() << " FileSize= " << fsize 
-       << " Creation Date= " << CreationDateStr() <<  endl;
-  
-  uint_8 totntags = 0;
-  bool eofok = false;
-
-  while ( (ppstag != PPS_EOF) &&  (cpos < fsize) ) {
-    cpos = s->tellg();
-    GetRawUByte(ppstag);
-    totntags++;
-
-    ppst1 = ppstag&0x0f;  // bits 0123
-    ppst2 = ppstag&0x30;  // bits     45
-    ppst3 = ppstag&0xc0;  // bits       67
-    ppst30 = ppstag&0xc1; // bits 0     67
-    if ((ppst2 == 0) && (ppst3 == 0) ) {
-      switch (ppst1) {
-
-      case PPS_NULL :
-	if (lev > 1)  cout << "<PPS_NULL> tag at position " << hex << cpos << dec << endl;
-	break;
-
-      case PPS_STRING :
-	GetRawI4(i4);
-	if (lev > 1)  cout << "<PPS_STRING> tag at position " << hex << cpos << dec 
-			   << " Length=" << i4 << endl;
-	s->seekg(i4,ios::cur);
-	break;
-
-      case PPS_OBJECT :
-	GetRawU8(cid);
-	GetRawU8(oid);
-	cout << "<PPS_OBJECT> tag at position " << hex << cpos << " ClassId= " << cid 
-	     << "  ObjectId= " << oid << dec << endl;
-	break;
-
-      case PPS_REFERENCE :
-	GetRawU8(oid);
-	GetRawI8(i8);
-	cout << "<PPS_REFERENCE> tag at position " << hex << cpos << "  ObjectId= " 
-	     << oid << "  OrigPos=" << i8 << dec << endl;
-	break;
-
-      case PPS_NAMETAG_MARK :
-	cout << "<PPS_NAMETAG_MARK> tag at position " << hex << cpos << dec << endl; 
-	break;
-
-      case PPS_POSTAG_MARK :
-	GetRawI8(i8);	
-	cout << "<PPS_POSTAG_MARK> tag at position " << hex << cpos 
-	     << " TPos=" << i8 << dec << endl; 
-	break;
-     
-      case PPS_ENDOBJECT :
-	GetRawU8(oid);
-	cout << "<PPS_ENDOBJECT> tag at position " << hex << cpos << "  ObjectId= " 
-	     << oid << dec << endl;
-	break;
-
-      case PPS_POSTAG_TABLE :
-	GetRawI4(i4);
-	for(int kkt=0; kkt<i4; kkt++)  GetRawI8(i8);	
-	cout << "<PPS_POSTAG_TABLE> tag at position " << hex << cpos << dec << endl; 
-	break;
-
-      case PPS_NAMETAG_TABLE :
-	GetRawI8(i8);
-	GetRawI4(i4);
-	buff = new char[i4+1];
-	GetRawBytes(buff, i4); 
-        buff[i4] = '\0';  str = buff;
-	delete[] buff;
-	cout << "<PPS_TAG> tag at position " << hex << cpos << dec 
-	     << " Name= " << str << endl; 
-	break;
-
-      case PPS_EOF :
-	GetRawI8(i8);	
-	cout << "<PPS_EOF> tag at position " << hex << cpos  
-	     << " TagPos=" << i8 << dec << endl;
-	eofok = true;
-	break;
-
-      default :
-	cerr << " ERROR : Unexpected tag value " << hex << ppstag 
-	     << " At position" << cpos << dec << endl;
-	throw FileFormatExc("PInPersist::AnalyseTags() - Unexpected tag value !");
-      }
-    }
-    else {
-      string dtype = "???? x";
-      if (ppst30 == PPS_DATATYPE_COMPLEX) dtype = "COMPLEX x";
-      else if (ppst3 == PPS_DATATYPE_CHAR) dtype = "CHAR x";
-      else if (ppst3 == PPS_DATATYPE_FLOAT) dtype = "FLOAT x";
-      else if (ppst3 == PPS_DATATYPE_INTEGER) dtype = "INTEGER x";
-      else if (ppst3 == PPS_DATATYPE_UNSIGNED) dtype = "UNSIGNED x";
-      int_4 dsize = ppst1;
-      int_4 dsizeskip = dsize;
-      if (ppst30 == PPS_DATATYPE_COMPLEX) { 
-	dsize--;
-	dsizeskip = 2*dsize;
-      }
-      char sb[16];
-      sprintf(sb, "%d", dsize);
-      dtype += sb;
-
-      switch (ppst2) {
-
-      case PPS_SIMPLE :
-	if (lev > 2)  cout << "<PPS_SIMPLE> tag at position " << hex << cpos << dec 
-			   << " DataType=" << dtype << endl;
-	s->seekg(dsizeskip, ios::cur);
-	break;
-
-      case PPS_SIMPLE_ARRAY4 :
-	GetRawI4(i4);
-	if (lev > 0)  cout << "<PPS_SIMPLE_ARRAY4> tag at position " << hex << cpos << dec 
-			   << " DataType=" << dtype << " NElts= " << i4 << endl;
-	s->seekg((int_8)dsizeskip*(int_8)i4, ios::cur);
-	break;
-
-      case PPS_SIMPLE_ARRAY8 :
-	GetRawU8(ui8);
-	if (lev > 0)  cout << "<PPS_SIMPLE_ARRAY8> tag at position " << hex << cpos << dec 
-			   << " DataType=" << dtype << " NElts= " << ui8 << endl;
-	s->seekg((int_8)dsizeskip*ui8, ios::cur);
-	break;
-      }
-    }
-  }
-  if (!eofok) 
-    throw FileFormatExc("PInPersist::AnalyseTags() - Not found <PPS_EOF> tag ");
-
-  cout << " PInPersist::AnalyseTags() - End - Total Number of Tags= " << totntags << endl; 
-  cout << " ---------------------------------------------------------- \n" << endl;
-  return;
-}
 
 void
@@ -1359,541 +549,14 @@
 //--
 POutPersist::POutPersist(string const& flnm, int endianness)
-{
-  if (endianness == -1)
-    bigEndian = IS_BIG_ENDIAN;
-  else
-    bigEndian = endianness;
-
+  : PPFBinaryOutputStream(flnm, endianness)
+{
   // PPS (POutPersist stream) Object Id initialisation
   pps_OId = 0;
-  // Output stream creation
-  s = new RawOutFileStream(flnm.c_str());
-  version = 3;
-  // Header
-  PutRawBytes("SOS-SOPHYA-PPersistFile V3               ",32);
-  PutRawBytes(bigEndian 
-	   ? "BIG-ENDIAN                             "
-	   : "LITTLE-ENDIAN                          ",32);
-
-// ---- GMT creation date of the file
-  time_t tm = time(NULL);
-  char datestring[33];
-  int l=strftime(datestring,32,"%d/%m/%Y %H:%M:%S GMT",gmtime(&tm));
-  for(int i=l; i<32; i++)  datestring[i] = ' ';
-  datestring[32] = '\0'; 
-  PutRawBytes(datestring, 32);
-  filename = flnm;
 }
 
 POutPersist::~POutPersist()
 {
-  if (tags.size() == 0) {
-    PutRawUByte(PPS_EOF);
-    PutRawI8(-1);
-  } else {
-    int_8 tagPos;
-    tagPos = s->tellp();
-    for (map<string,int_8>::iterator i = tags.begin(); i != tags.end(); i++) {
-      string name = (*i).first;
-      int_8 pos = (*i).second;
-      PutRawUByte(PPS_NAMETAG_TABLE);                       // This is a tag
-      PutRawI8(pos);                             // position of previous tag
-      PutRawI4(name.length());                   // length of the name
-      PutRawBytes(name.c_str(), name.length());  // name, without final "0".
-    }
-    PutRawUByte(PPS_EOF);
-    PutRawI8(tagPos);
-  }
-
-  delete s;   // Close the stream
-}
-
-int_8
-POutPersist::WritePositionTag()
-{
-  int_8 tagpos;
-  tagpos = s->tellp();
-  PutRawByte(PPS_POSTAG_MARK);
-  PutI8(tagpos);
-  return(tagpos);
-}
-
-void
-POutPersist::WriteNameTag(string const& name)
-{
-  if (name.length() > MAXTAGLEN) 
-    throw ParmError("POutPersist::WriteNameTag   tag name too long");
-
-  if (tags.find(name) != tags.end())
-    throw DuplicateIdExc("POutPersist::WriteNameTag   duplicate tag name");
-
-  // Get current file position
-  int_8 tagPos;
-  tagPos = s->tellp();
-
-  tags[name] = tagPos;
-  PutRawUByte(PPS_NAMETAG_MARK);                       // This is a tag
-  //  objList.clear(); // $CHECK$ EA 171199  - Ne pas faire ? Reza 03/2000
-}
-
-//++
-// void POutPersist::PutByte(char& c)
-// void POutPersist::PutBytes(void const* ptr, size_t bytes)
-// void POutPersist::PutR4   (r_4 result)
-// void POutPersist::PutR4s  (r_4 const* tab, size_t n)
-// void POutPersist::PutR8   (r_8 result)
-// void POutPersist::PutR8s  (r_8 const* tab, size_t n)
-// void POutPersist::PutI2   (int_2 result)
-// void POutPersist::PutI2s  (int_2 const* tab, size_t n)
-// void POutPersist::PutU2   (uint_2 result)
-// void POutPersist::PutU2s  (uint_2 const* tab, size_t n)
-// void POutPersist::PutI4   (int_4 result)
-// void POutPersist::PutI4s  (int_4 const* tab, size_t n)
-// void POutPersist::PutU4   (uint_4 result)
-// void POutPersist::PutU4s  (uint_4 const* tab, size_t n)
-// void POutPersist::PutI8   (int_8 result)
-// void POutPersist::PutI8s  (int_8 const* tab, size_t n)
-// void POutPersist::PutU8   (uint_8 result)
-// void POutPersist::PutU8s  (uint_8 const* tab, size_t n)
-// void POutPersist::PutStr  (string const&)
-//	Ecriture de données portables.. Pour chaque type
-//	de données, on peut écrire une valeur, ou un tableau de valeurs.
-// void POutPersist::PutLine(char const* ptr, size_t len)
-//	Ecriture d'une ligne de texte dans le fichier PPersist.
-//--
-
-
-
-
-void
-POutPersist::PutRawBytes(void const* ptr, size_t bytes)
-{
-  s->write((char const*)ptr, bytes);
-}
-
-void
-POutPersist::PutRawByte(char c)
-{
-  PutRawBytes(&c, 1);
-}
-
-void
-POutPersist::PutRawUByte(unsigned char c)
-{
-  PutRawBytes(&c, 1);
-}
-
-void
-POutPersist::PutRawI2   (int_2 val)
-{
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap2(&val);
-
-  PutRawBytes(&val, sizeof(int_2));
-}
-
-void
-POutPersist::PutRawI4   (int_4 val)
-{
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap4(&val);
-
-  PutRawBytes(&val, sizeof(int_4));
-}
-
-void
-POutPersist::PutRawI8   (int_8 val)
-{
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap8(&val);
-
-  PutRawBytes(&val, sizeof(int_8));
-}
-
-void
-POutPersist::PutRawU8   (uint_8 val)
-{
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap8(&val);
-
-  PutRawBytes(&val, sizeof(uint_8));
-}
-
-void
-POutPersist::PutArrayTag(short datasz, size_t sz, short datatype) 
-// datatype = PPS_DATATYPE_CHAR or PPS_DATATYPE_FLOAT or PPS_DATATYPE_INTEGER or PPS_DATATYPE_UNSIGNED
-{
-  if (sz <= 0x7fffffff) {
-    PutRawUByte(PPS_SIMPLE_ARRAY4 + datasz + datatype);
-    PutRawI4(sz);
-  } else {
-    PutRawUByte(PPS_SIMPLE_ARRAY8 + datasz + datatype);
-    PutRawU8(sz);
-  } 
-}
-
-void
-POutPersist::PutByte(char c)
-{
-  PutRawByte(PPS_SIMPLE + 1 + PPS_DATATYPE_CHAR);
-  PutRawBytes(&c, 1);
-}
-
-
-
-void
-POutPersist::PutBytes(void const* ptr, size_t bytes)
-{
-  PutArrayTag(1, bytes, PPS_DATATYPE_CHAR);
-  PutRawBytes(ptr, bytes);
-}
-
-void
-POutPersist::PutR4   (r_4 val)
-{
-  PutRawUByte(PPS_SIMPLE + 4 + PPS_DATATYPE_FLOAT);
-  
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap4(&val);
-
-  PutRawBytes(&val, sizeof(r_4));
-}
-
-void
-POutPersist::PutR4s  (r_4 const* tab, size_t n)
-{
-  PutArrayTag(4, n, PPS_DATATYPE_FLOAT);
-
-  if (bigEndian == IS_BIG_ENDIAN) {
-    PutRawBytes(tab, n*sizeof(r_4));
-  } else {
-    for (unsigned int i=0; i<n; i++) {
-      r_4 val = tab[i];
-      bswap4(&val);
-      PutRawBytes(&val, sizeof(r_4));
-    }
-  }
-}
-
-void
-POutPersist::PutR8   (r_8 val)
-{
-  PutRawUByte(PPS_SIMPLE + 8 + PPS_DATATYPE_FLOAT);
-
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap8(&val);
-
-  PutRawBytes(&val, sizeof(r_8));
-}
-
-void
-POutPersist::PutR8s  (r_8 const* tab, size_t n)
-{
-  PutArrayTag(8, n, PPS_DATATYPE_FLOAT);
-
-  if (bigEndian == IS_BIG_ENDIAN) {
-    PutRawBytes(tab, n*sizeof(r_8));
-  } else {
-    for (unsigned int i=0; i<n; i++) {
-      r_8 val = tab[i];
-      bswap8(&val);
-      PutRawBytes(&val, sizeof(r_8));
-    }
-  }
-}
-
-void
-POutPersist::PutI1   (int_1 val)
-{
-  PutRawUByte(PPS_SIMPLE + 1 + PPS_DATATYPE_INTEGER);
-  PutRawBytes(&val, sizeof(int_1));
-}
-
-void
-POutPersist::PutI1s  (int_1 const* tab, size_t n)
-{
-  PutArrayTag(1, n, PPS_DATATYPE_INTEGER);
-  PutRawBytes(tab, n*sizeof(int_1));
-}
-
-void
-POutPersist::PutU1   (uint_1 val)
-{
-  PutRawUByte(PPS_SIMPLE + 1 + PPS_DATATYPE_UNSIGNED);
-  PutRawBytes(&val, sizeof(uint_1));
-}
-
-void
-POutPersist::PutU1s  (uint_1 const* tab, size_t n)
-{
-  PutArrayTag(1, n, PPS_DATATYPE_UNSIGNED);
-  PutRawBytes(tab, n*sizeof(uint_1));
-}
-
-void
-POutPersist::PutI2   (int_2 val)
-{
-  PutRawUByte(PPS_SIMPLE + 2 + PPS_DATATYPE_INTEGER);
-
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap2(&val);
-
-  PutRawBytes(&val, sizeof(int_2));
-}
-
-void
-POutPersist::PutI2s  (int_2 const* tab, size_t n)
-{
-  PutArrayTag(2, n, PPS_DATATYPE_INTEGER);
-  
-  if (bigEndian == IS_BIG_ENDIAN) {
-    PutRawBytes(tab, n*sizeof(int_2));
-  } else {
-    for (unsigned int i=0; i<n; i++) {
-      int_2 val = tab[i];
-      bswap2(&val);
-      PutRawBytes(&val, sizeof(int_2));
-    }
-  }
-}
-
-void
-POutPersist::PutU2   (uint_2 val)
-{
-  PutRawUByte(PPS_SIMPLE + 2 + PPS_DATATYPE_UNSIGNED);
-
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap2(&val);
-
-  PutRawBytes(&val, sizeof(uint_2));
-}
-
-void
-POutPersist::PutU2s  (uint_2 const* tab, size_t n)
-{
-  PutArrayTag(2, n, PPS_DATATYPE_UNSIGNED);
-
-  if (bigEndian == IS_BIG_ENDIAN) {
-    PutRawBytes(tab, n*sizeof(uint_2));
-  } else {
-    for (unsigned int i=0; i<n; i++) {
-      uint_2 val = tab[i];
-      bswap2(&val);
-      PutRawBytes(&val, sizeof(uint_2));
-    }
-  }
-}
-
-void
-POutPersist::PutI4   (int_4 val)
-{
-  PutRawUByte(PPS_SIMPLE + 4 + PPS_DATATYPE_INTEGER);
-
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap4(&val);
-
-  PutRawBytes(&val, sizeof(int_4));
-}
-
-void
-POutPersist::PutI4s  (int_4 const* tab, size_t n)
-{
-  PutArrayTag(4, n, PPS_DATATYPE_INTEGER);
-
-  if (bigEndian == IS_BIG_ENDIAN) {
-    PutRawBytes(tab, n*sizeof(int_4));
-  } else {
-    for (unsigned int i=0; i<n; i++) {
-      int_4 val = tab[i];
-      bswap4(&val);
-      PutRawBytes(&val, sizeof(int_4));
-    }
-  }
-}
-
-void
-POutPersist::PutU4   (uint_4 val)
-{
-  PutRawUByte(PPS_SIMPLE + 4 + PPS_DATATYPE_UNSIGNED);
-
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap4(&val);
-
-  PutRawBytes(&val, sizeof(uint_4));
-}
-
-void
-POutPersist::PutU4s  (uint_4 const* tab, size_t n)
-{
-  PutArrayTag(4, n, PPS_DATATYPE_UNSIGNED);
-
-  if (bigEndian == IS_BIG_ENDIAN) {
-    PutRawBytes(tab, n*sizeof(uint_4));
-  } else {
-    for (unsigned int i=0; i<n; i++) {
-      uint_4 val = tab[i];
-      bswap4(&val);
-      PutRawBytes(&val, sizeof(uint_4));
-    }
-  }
-}
-
-void
-POutPersist::PutI8   (int_8 val)
-{
-  PutRawUByte(PPS_SIMPLE + 8 + PPS_DATATYPE_INTEGER);
-
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap8(&val);
-
-  PutRawBytes(&val, sizeof(int_8));
-}
-
-void
-POutPersist::PutI8s  (int_8 const* tab, size_t n)
-{
-  PutArrayTag(8, n, PPS_DATATYPE_INTEGER);
-
-  if (bigEndian == IS_BIG_ENDIAN) {
-    PutRawBytes(tab, n*sizeof(int_8));
-  } else {
-    for (unsigned int i=0; i<n; i++) {
-      int_8 val = tab[i];
-      bswap8(&val);
-      PutRawBytes(&val, sizeof(int_8));
-    }
-  }
-}
-
-void
-POutPersist::PutU8   (uint_8 val)
-{
-  PutRawUByte(PPS_SIMPLE + 8 + PPS_DATATYPE_UNSIGNED);
-
-  if (bigEndian != IS_BIG_ENDIAN)
-    bswap8(&val);
-
-  PutRawBytes(&val, sizeof(uint_8));
-}
-
-void
-POutPersist::PutU8s  (uint_8 const* tab, size_t n)
-{
-  PutArrayTag(8, n, PPS_DATATYPE_UNSIGNED);
-
-  if (bigEndian == IS_BIG_ENDIAN) {
-    PutRawBytes(tab, n*sizeof(uint_8));
-  } else {
-    for (unsigned int i=0; i<n; i++) {
-      uint_8 val = tab[i];
-      bswap8(&val);
-      PutRawBytes(&val, sizeof(uint_8));
-    }
-  }
-}
-
-void
-POutPersist::PutStr(string const& str) 
-{
-  PutRawUByte(PPS_STRING);
-  PutRawI4(str.length());
-  PutRawBytes(str.c_str(), str.length());
-}
-
-void
-POutPersist::PutLine(char const* ptr, size_t len)
-{
-  string str = ptr;
-  PutStr(str);
-}
-
-
-void
-POutPersist::PutZ4   (complex<r_4> val)
-{
-  PutRawUByte(PPS_SIMPLE + 4 + PPS_DATATYPE_COMPLEX);
-  r_4 reim[2];
-  reim[0] = val.real();
-  reim[1] = val.imag();
-  if (bigEndian != IS_BIG_ENDIAN) {
-    bswap4(reim);
-    bswap4(reim+1);
-  }
-  PutRawBytes(reim, 2*sizeof(r_4));
-}
-
-void
-POutPersist::PutZ4s  (complex<r_4> const* tab, size_t n)
-{
-  PutArrayTag(4, n, PPS_DATATYPE_COMPLEX);
-
-  if (bigEndian == IS_BIG_ENDIAN) {
-    PutRawBytes(tab, n*2*sizeof(r_4));
-  } else {
-    for (unsigned int i=0; i<n; i++) {
-      r_4 reim[2];
-      reim[0] = tab[i].real();
-      reim[1] = tab[i].imag();
-      bswap4(reim);
-      bswap4(reim+1);
-      PutRawBytes(reim, 2*sizeof(r_4));
-    }
-  }
-}
-
-void
-POutPersist::PutZ8   (complex<r_8> val)
-{
-  PutRawUByte(PPS_SIMPLE + 8 + PPS_DATATYPE_COMPLEX);
-  r_8 reim[2];
-  reim[0] = val.real();
-  reim[1] = val.imag();
-  if (bigEndian != IS_BIG_ENDIAN) {
-    bswap8(reim);
-    bswap8(reim+1);
-  }
-  PutRawBytes(reim, 2*sizeof(r_8));
-}
-
-void
-POutPersist::PutZ8s  (complex<r_8> const* tab, size_t n)
-{
-  PutArrayTag(8, n, PPS_DATATYPE_COMPLEX);
-
-  if (bigEndian == IS_BIG_ENDIAN) {
-    PutRawBytes(tab, n*2*sizeof(r_8));
-  } else {
-    for (unsigned int i=0; i<n; i++) {
-      r_8 reim[2];
-      reim[0] = tab[i].real();
-      reim[1] = tab[i].imag();
-      bswap8(reim);
-      bswap8(reim+1);
-      PutRawBytes(reim, 2*sizeof(r_8));
-    }
-  }
-}
-
-void
-POutPersist::PutPosTagTable(int_8 const * ptab, size_t sz)
-{
-  PutRawUByte(PPS_POSTAG_TABLE);
-  int_4 tsz = sz;
-  PutRawI4(tsz);
-  for(int kk=0; kk<tsz; kk++)
-    PutRawI8(ptab[kk]);
-  return;
-}
-
-void
-POutPersist::PutPosTagTable(vector<int_8> const& ptab)
-{
-  PutRawUByte(PPS_POSTAG_TABLE);
-  int_4 tsz = ptab.size();
-  PutRawI4(tsz);
-  for(int kk=0; kk<tsz; kk++)
-    PutRawI8(ptab[kk]);
-  return;
-}
+}
+
 
 void
