Index: trunk/SophyaLib/BaseTools/Makefile
===================================================================
--- trunk/SophyaLib/BaseTools/Makefile	(revision 2462)
+++ trunk/SophyaLib/BaseTools/Makefile	(revision 2475)
@@ -3,7 +3,7 @@
 all: $(LIB)libBaseTools.a
 clean:
-	rm -f $(OBJ)datatype.o $(OBJ)dvlist.o $(OBJ)fiondblock.o $(OBJ)mutyv.o $(OBJ)ndatablock.o $(OBJ)pexceptions.o $(OBJ)ppersist.o $(OBJ)rawstream.o $(OBJ)sophyainit.o $(OBJ)gnumd5.o $(OBJ)srandgen.o
+	rm -f $(OBJ)datatype.o $(OBJ)dvlist.o $(OBJ)fiondblock.o $(OBJ)mutyv.o $(OBJ)ndatablock.o $(OBJ)pexceptions.o $(OBJ)ppersist.o $(OBJ)ppfbinstream.o $(OBJ)rawstream.o $(OBJ)sophyainit.o $(OBJ)gnumd5.o $(OBJ)srandgen.o
 	rm -f $(LIB)libBaseTools.a
-$(LIB)libBaseTools.a : $(OBJ)datatype.o $(OBJ)dvlist.o $(OBJ)fiondblock.o $(OBJ)gnumd5.o $(OBJ)mutyv.o $(OBJ)ndatablock.o $(OBJ)pexceptions.o $(OBJ)ppersist.o $(OBJ)rawstream.o $(OBJ)sophyainit.o $(OBJ)srandgen.o
+$(LIB)libBaseTools.a : $(OBJ)datatype.o $(OBJ)dvlist.o $(OBJ)fiondblock.o $(OBJ)gnumd5.o $(OBJ)mutyv.o $(OBJ)ndatablock.o $(OBJ)pexceptions.o $(OBJ)ppersist.o $(OBJ)ppfbinstream.o $(OBJ)rawstream.o $(OBJ)sophyainit.o $(OBJ)srandgen.o
 	$(ARCXX) $(ARCXXFLAGS) $@ $($(ARARGS))
 ifeq ($(CXX),cxx)
@@ -14,8 +14,8 @@
  $(INC)machdefs.h
 $(OBJ)dvlist.o: dvlist.cc $(INC)machdefs.h dvlist.h \
- objfio.h anydataobj.h ppersist.h pexceptions.h gnumd5.h mutyv.h \
- $(INC)strutil.h
+ objfio.h anydataobj.h ppersist.h pexceptions.h gnumd5.h rawstream.h \
+ mutyv.h $(INC)strutil.h
 $(OBJ)fiondblock.o: fiondblock.cc $(INC)machdefs.h \
- pexceptions.h datatype.h fiondblock.h ppersist.h gnumd5.h \
+ pexceptions.h datatype.h fiondblock.h ppersist.h gnumd5.h rawstream.h \
  ndatablock.h anydataobj.h
 $(OBJ)mutyv.o: mutyv.cc mutyv.h $(INC)machdefs.h
@@ -25,10 +25,14 @@
  $(INC)machdefs.h
 $(OBJ)ppersist.o: ppersist.cc $(INC)machdefs.h \
- pexceptions.h ppersist.h gnumd5.h anydataobj.h
+ pexceptions.h ppersist.h gnumd5.h rawstream.h anydataobj.h
+$(OBJ)ppfbinstream.o: ppfbinstream.cc \
+ $(INC)machdefs.h ppfbinstream.h rawstream.h \
+ pexceptions.h
 $(OBJ)rawstream.o: rawstream.cc rawstream.h \
  $(INC)machdefs.h pexceptions.h
 $(OBJ)sophyainit.o: sophyainit.cc $(INC)machdefs.h \
- sophyainit.h pexceptions.h ppersist.h gnumd5.h fiondblock.h \
- ndatablock.h anydataobj.h dvlist.h objfio.h mutyv.h sversion.h
+ sophyainit.h pexceptions.h ppersist.h gnumd5.h rawstream.h \
+ fiondblock.h ndatablock.h anydataobj.h dvlist.h objfio.h mutyv.h \
+ sversion.h
 $(OBJ)gnumd5.o: gnumd5.c $(INC)machdefs.h bithelp.h \
  gnumd5.h
Index: trunk/SophyaLib/BaseTools/objlist.list
===================================================================
--- trunk/SophyaLib/BaseTools/objlist.list	(revision 2462)
+++ trunk/SophyaLib/BaseTools/objlist.list	(revision 2475)
@@ -7,4 +7,5 @@
 pexceptions.o
 ppersist.o
+ppfbinstream.o
 rawstream.o
 sophyainit.o
Index: trunk/SophyaLib/BaseTools/ppersist.cc
===================================================================
--- trunk/SophyaLib/BaseTools/ppersist.cc	(revision 2462)
+++ 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
Index: trunk/SophyaLib/BaseTools/ppersist.h
===================================================================
--- trunk/SophyaLib/BaseTools/ppersist.h	(revision 2462)
+++ trunk/SophyaLib/BaseTools/ppersist.h	(revision 2475)
@@ -9,14 +9,15 @@
 // R. Ansari      LAL IN2P3/CNRS  03/2000
 
+// -------------------- Historique -----------------------
+//  Separe en deux (CVS version 1.19 - ppersist.h)  
+//  Classes PPFBinaryIn/OutputStream ds ppfbinstream.h
+// -------------------------------------------------------
+
 
 #include "machdefs.h"
 #include "pexceptions.h"
 #include "gnumd5.h"
-#include "rawstream.h"
-
-
-#include <time.h>
-
-#include <complex>
+#include "ppfbinstream.h"
+
 #include <string>
 #include <map>
@@ -67,10 +68,9 @@
 
 
-//! Ancestor for PInPersist and POutPersist PPF streams.
+//! Ancestor for PInPersist and POutPersist object serialisation streams.
 // Handles (statically) the registration of classes.
 
   class PIOPersist {
   public:
-    enum                         {PPS_NATIVE = -1, PPS_LITTLE_ENDIAN = 0, PPS_BIG_ENDIAN = 1};
     typedef PPersist*            (*ClassCreatorFunc)();
   
@@ -92,6 +92,4 @@
     static void Initialize();   // Pour initialiser classList
 
-    int    Version() {return version;}  // PIn/OutPersist version number
-    string FileName() { return filename; }   // Retourne le nom de fichier
 
   private:
@@ -103,31 +101,4 @@
     static map<string, uint_8> * dobjclassNameList;  // PPersist classId = f(DataObjClassName)
 
-  protected:
-
-    enum {PPS_NULL = 0,             // this is a null object
-	  PPS_STRING = 1,           // string, length (4b) + data
-	  PPS_OBJECT = 2,           // classId, data...
-	  PPS_REFERENCE = 3,        // objectId
-          PPS_NAMETAG_TABLE = 4,    // Name tag table (Written at the end of file/stream) 
-	  PPS_EOF = 5,              // Just before tag infomation, offset to PPS_TAG
-	  PPS_ENDOBJECT = 6,        // marks the end of a given object information
-          PPS_NAMETAG_MARK = 7,     // To have a name tag, position marker in a file
-          PPS_POSTAG_MARK = 8,      // Position tag mark + 8 bytes (=stream position)
-          PPS_POSTAG_TABLE = 9,     // Position tag table + 8 bytes (=stream position)
-          PPS_SIMPLE = 16,          // 16 + number of bytes, up to 8 bytes
-          PPS_SIMPLE_ARRAY4 = 32,   // 32 + number of bytes, up to 8 bytes, then 4 bytes of length
-          PPS_SIMPLE_ARRAY8 = 48    // 48 + number of bytes, up to 8 bytes, then 8 bytes of length
-    };
-  // The following values are used with PPS_SIMPLE and PPS_SIMPLE_ARRAY (Using OR)
-   enum  {PPS_DATATYPE_CHAR = 0,        // 0  : DataType=character
-          PPS_DATATYPE_FLOAT = 64,      // 64 : DataType=float 
-          PPS_DATATYPE_COMPLEX = 65,    // 65 : DataType=complex 
-          PPS_DATATYPE_INTEGER = 128,   // 128 :DataType=integer 
-          PPS_DATATYPE_UNSIGNED = 192   // 192 :DataType=Unsigned integer 
-   };
-
-    map<string, int_8> tags;
-    string filename;
-    int version;     // PPersist(In/Out) version 
   };
 
@@ -136,84 +107,11 @@
 
 //! Input stream for PPersit objects.
-  class PInPersist : public PIOPersist {
+  class PInPersist : public PPFBinaryInputStream, public PIOPersist  {
   public:
     PInPersist(string const& flnm, bool scan=true);
-    ~PInPersist();
-
-    // Gestion des tags
-    bool   GotoPositionTag(int_8 pos);
-    bool   GotoNameTag(string const& name);
-    int    NbNameTags(); 
-    bool   GotoNameTagNum(int itag);  // 0..NbTags-1
-    string GetTagName(int itag);  // 0..NbTags-1
-    string GetTagClassName(int itag);  // 0..NbTags-1
-    vector<string> const &  GetNameTags();  
-
-    // Saut jusqu'au prochain objet 
-    bool   SkipToNextObject();
-
-    // Lecture donnees de base et tableaux de donnees de base
-    // Basic data type (and corresponding arrays) reading
-    void   GetByte (char& c);
-    void   GetBytes(void* ptr, size_t bytes);
-    void   GetR4   (r_4&);
-    void   GetR4s  (r_4*, size_t);
-    void   GetR8   (r_8&);
-    void   GetR8s  (r_8*, size_t);
-    void   GetI1   (int_1&);
-    void   GetI1s  (int_1*, size_t);
-    void   GetU1   (uint_1&);
-    void   GetU1s  (uint_1*, size_t);
-    void   GetI2   (int_2&);
-    void   GetI2s  (int_2*, size_t);
-    void   GetU2   (uint_2&);
-    void   GetU2s  (uint_2*, size_t);
-    void   GetI4   (int_4&);
-    void   GetI4s  (int_4*, size_t);
-    void   GetU4   (uint_4&);
-    void   GetU4s  (uint_4*, size_t);
-    void   GetI8   (int_8&);
-    void   GetI8s  (int_8*, size_t);
-    void   GetU8   (uint_8&);
-    void   GetU8s  (uint_8*, size_t);
-    void   GetLine (char* ptr, size_t len);
-    void   GetStr  (string&);
-    void   GetZ4   (complex<r_4> &);
-    void   GetZ4s  (complex<r_4> *, size_t);
-    void   GetZ8   (complex<r_8> &);
-    void   GetZ8s  (complex<r_8> *, size_t);
-
-    inline void   Get(char&   c) {GetByte(c);}
-    inline void   Get(r_4&    x) {GetR4(x);}
-    inline void   Get(r_8&    x) {GetR8(x);}
-    inline void   Get(uint_1& x) {GetU1(x);}
-    inline void   Get(int_1&  x) {GetI1(x);}
-    inline void   Get(uint_2& x) {GetU2(x);}
-    inline void   Get(int_2&  x) {GetI2(x);}
-    inline void   Get(uint_4& x) {GetU4(x);}
-    inline void   Get(int_4&  x) {GetI4(x);}
-    inline void   Get(uint_8& x) {GetU8(x);}
-    inline void   Get(int_8&  x) {GetI8(x);}
-    inline void   Get(complex<r_4> & x) {GetZ4(x);}
-    inline void   Get(complex<r_8> & x) {GetZ8(x);}
-
-    inline void   Get(r_4*    x, size_t n) {GetR4s(x,n);}
-    inline void   Get(r_8*    x, size_t n) {GetR8s(x,n);}
-    inline void   Get(uint_1* x, size_t n) {GetU1s(x,n);}
-    inline void   Get(int_1*  x, size_t n) {GetI1s(x,n);}
-    inline void   Get(uint_2* x, size_t n) {GetU2s(x,n);}
-    inline void   Get(int_2*  x, size_t n) {GetI2s(x,n);}
-    inline void   Get(uint_4* x, size_t n) {GetU4s(x,n);}
-    inline void   Get(int_4*  x, size_t n) {GetI4s(x,n);}
-    inline void   Get(uint_8* x, size_t n) {GetU8s(x,n);}
-    inline void   Get(int_8*  x, size_t n) {GetI8s(x,n);}
-    inline void   Get(string& x) {GetStr(x);}
-    inline void   Get(complex<r_4> * x, size_t n) { GetZ4s(x, n); }
-    inline void   Get(complex<r_8> * x, size_t n) { GetZ8s(x, n); }
-
-    // Reading a list (table) of position tags
-    void    GetPosTagTable(int_8*, size_t);
-    void    GetPosTagTable(vector<int_8>&);
-
+    virtual ~PInPersist();
+
+    // A faire - Reza Dec 2003
+    string     GetTagClassName(int itag);
     //   Object Reading 
     PPersist*  ReadObject();
@@ -222,9 +120,4 @@
     PPersist*  GetPPObject(AnyDataObj * po=NULL);
 
-    time_t CreationDate() { return creationdate; }
-    string CreationDateStr(); 
-
-    void   AnalyseTags(int lev=0);   // List (all or some) tags ...
-
     //  Reza 03/2000
     //  Methodes qui pourraient etre protected, mais doivent etre utilisables par PPersist 
@@ -234,103 +127,18 @@
 
   protected:
-    void   CheckTag   (short datasz, short datatype);
-    void   CheckArrayTag(short datasz, size_t sz, short datatype);
-    void   GetTypeTag (unsigned char& c);
-    void   GetRawByte (char& c);
-    void   GetRawUByte (unsigned char& c);
-    void   GetRawBytes(void* ptr, size_t bytes);
-    void   GetRawI2   (int_2&);
-    void   GetRawI4   (int_4&);
-    void   GetRawI8   (int_8&);
-    void   GetRawU8   (uint_8&);
-
-    void   Scan();
-
-    RawInOutStream* s;
-
-    bool bigEndian;
-
-    time_t creationdate;
 
     // already read objects 
     typedef map<uint_8, PPersist * > ObjList;
     ObjList objList;
-    // Si on a fait une lecture non sequentielle  -> seqread = false
-    bool seqread;
     friend class PPersist;
   };
 
 //! Output stream for PPersit objects.
-  class POutPersist : public PIOPersist {
+  class POutPersist : public PPFBinaryOutputStream, public PIOPersist  {
   public:
     POutPersist(string const& flnm, int endianness = PPS_NATIVE);
-    ~POutPersist();
-
-    // Ecriture de tags
-    int_8 WritePositionTag();
-    void  WriteNameTag(string const& name);
-    inline void WriteTag(string const& name) { WriteNameTag(name); }
-  
-    void PutByte (char c);
-    void PutBytes(void const* ptr, size_t bytes);
-    void PutR4   (r_4);
-    void PutR4s  (r_4 const*, size_t);
-    void PutR8   (r_8);
-    void PutR8s  (r_8 const*, size_t);
-    void PutI1   (int_1);
-    void PutI1s  (int_1 const*, size_t);
-    void PutU1   (uint_1);
-    void PutU1s  (uint_1 const*, size_t);
-    void PutI2   (int_2);
-    void PutI2s  (int_2 const*, size_t);
-    void PutU2   (uint_2);
-    void PutU2s  (uint_2 const*, size_t);
-    void PutI4   (int_4);
-    void PutI4s  (int_4 const*, size_t);
-    void PutU4   (uint_4);
-    void PutU4s  (uint_4 const*, size_t);
-    void PutI8   (int_8);
-    void PutI8s  (int_8 const*, size_t);
-    void PutU8   (uint_8);
-    void PutU8s  (uint_8 const*, size_t);
-    void PutLine (char const* ptr, size_t len=0); // deprecated ?
-    void PutStr  (string const&);
-    void PutZ4   (complex<r_4>);
-    void PutZ4s  (complex<r_4> const*, size_t);
-    void PutZ8   (complex<r_8>);
-    void PutZ8s  (complex<r_8> const*, size_t);
-
-
-    void   Put(char   c) {PutByte(c);}
-    void   Put(r_4    x) {PutR4(x);}
-    void   Put(r_8    x) {PutR8(x);}
-    void   Put(complex<r_4>   x) {PutZ4(x);}
-    void   Put(complex<r_8>   x) {PutZ8(x);}
-    void   Put(uint_1 x) {PutU1(x);}
-    void   Put(int_1  x) {PutI1(x);}
-    void   Put(uint_2 x) {PutU2(x);}
-    void   Put(int_2  x) {PutI2(x);}
-    void   Put(uint_4 x) {PutU4(x);}
-    void   Put(int_4  x) {PutI4(x);}
-    void   Put(uint_8 x) {PutU8(x);}
-    void   Put(int_8  x) {PutI8(x);}
-    void   Put(r_4 const*    x, size_t n) {PutR4s(x,n);}
-    void   Put(r_8 const*    x, size_t n) {PutR8s(x,n);}
-    void   Put(complex<r_4> const*    x, size_t n) {PutZ4s(x,n);}
-    void   Put(complex<r_8> const*    x, size_t n) {PutZ8s(x,n);}
-    void   Put(uint_1 const* x, size_t n) {PutU1s(x,n);}
-    void   Put(int_1 const*  x, size_t n) {PutI1s(x,n);}
-    void   Put(uint_2 const* x, size_t n) {PutU2s(x,n);}
-    void   Put(int_2 const*  x, size_t n) {PutI2s(x,n);}
-    void   Put(uint_4 const* x, size_t n) {PutU4s(x,n);}
-    void   Put(int_4 const*  x, size_t n) {PutI4s(x,n);}
-    void   Put(uint_8 const* x, size_t n) {PutU8s(x,n);}
-    void   Put(int_8 const*  x, size_t n) {PutI8s(x,n);}
-    void   Put(string const& s) {PutStr(s);}
-    void   Put(PPersist const* x) {PutPPObject(x);}
-
-    // Writing a list of position tag table
-    void   PutPosTagTable(int_8 const *, size_t);
-    void   PutPosTagTable(vector<int_8> const&);
+    virtual ~POutPersist();
+
+    //    void   Put(PPersist const* x) {PutPPObject(x);}
 
     // Objet Write - Ecriture des objets
@@ -342,15 +150,4 @@
 
   protected:
-    RawInOutStream* s;
-    bool bigEndian;
-
-    void     PutArrayTag(short datasz, size_t sz, short datatype);
-    void     PutRawByte (char);
-    void     PutRawUByte (unsigned char);
-    void     PutRawI2   (int_2);
-    void     PutRawI4   (int_4);
-    void     PutRawI8   (int_8);
-    void     PutRawU8   (uint_8);
-    void     PutRawBytes(void const* ptr, size_t bytes);
     bool     serializeNullAndRepeat(PPersist const* x);
     uint_8   findObjectId(PPersist const* x, int_8 & pos);
@@ -444,5 +241,10 @@
 #define DObjRegister(ppclassName, className) PIOPersist::RegisterDataObjClass(PIOPersist::Hash(#ppclassName), typeid(className).name());
 
-} // namespace
+} // namespace SOPHYA
+
+// La classe PPFNameTag facilite la manipulation des Nametag ds les fichiers
+// PPersist - definie ds ppfnametag.h
+#include "ppfnametag.h"
+
 
 #endif
Index: trunk/SophyaLib/BaseTools/ppfbinstream.cc
===================================================================
--- trunk/SophyaLib/BaseTools/ppfbinstream.cc	(revision 2475)
+++ trunk/SophyaLib/BaseTools/ppfbinstream.cc	(revision 2475)
@@ -0,0 +1,1432 @@
+#include "machdefs.h"
+#include <stdio.h>
+#include <sys/types.h>
+#include <time.h>
+#include "ppfbinstream.h"
+#include "pexceptions.h"
+#include <iostream>
+
+
+/*
+//  strptime n'est pas defini sous Linux  - Reza Mars 2000
+#if defined(OS_LINUX) || defined(OS_MACOSX)
+extern "C" {
+char *strptime(const char *buf, const char *format, struct tm *tm);
+}
+#endif
+*/
+
+#define MAXTAGLEN_V2 255
+
+
+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);
+}
+
+
+PPFBinaryInputStream::PPFBinaryInputStream()
+{
+  s = NULL;
+  version = 0;
+  bigEndian = true;
+}
+
+//++
+PPFBinaryInputStream::PPFBinaryInputStream(string const& flnm, bool 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("PPFBinaryInputStream::PPFBinaryInputStream  bad header");
+  }
+  rbuf[32] = '\0';
+  version = atoi(rbuf+25);
+  if (version < 2) {
+    cerr << "PPFBinaryInputStream::PPFBinaryInputStream(" << flnm << ") Version(=" << version 
+	 << ") < 2 not supported !" << endl;
+    throw FileFormatExc("PPFBinaryInputStream::PPFBinaryInputStream() - 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("PPFBinaryInputStream::PPFBinaryInputStream  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();
+}
+
+
+
+PPFBinaryInputStream::~PPFBinaryInputStream()
+{
+  if (s) delete s;
+}
+
+
+string 
+PPFBinaryInputStream::CreationDateStr()
+{
+  time_t cdt = CreationDate();
+  string cdate = ctime(&cdt);
+  return(cdate);
+}
+
+void
+PPFBinaryInputStream::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("PPFBinaryInputStream::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_V2+1];
+  s->seekg(pos);
+  while (true) {
+    GetTypeTag(ppstype);
+    if (ppstype == PPS_EOF) break;
+    
+    if (ppstype != PPS_NAMETAG_TABLE)
+      throw FileFormatExc("PPFBinaryInputStream::Scan   corrupted file, bad tag entry");
+
+    GetRawI8(pos);
+    int_4 len;
+    GetRawI4(len);
+    if (len > MAXTAGLEN_V2) 
+      throw FileFormatExc("PPFBinaryInputStream::Scan   corrupted file, tag name too long");
+    GetRawBytes(buffer, len);
+    buffer[len] = '\0';
+
+    tags[buffer] = pos;
+  }
+  s->seekg(debut);
+}
+
+
+int
+PPFBinaryInputStream::NbNameTags()
+{
+  return tags.size();
+}
+
+bool 
+PPFBinaryInputStream::GotoPositionTag(int_8 pos)
+{
+  s->seekg(pos);
+  int_8 tpos;
+  GetRawI8(tpos);
+  if (tpos != pos) 
+    throw FileFormatExc("PPFBinaryInputStream::GotoPositionTag() - Wrong tag position!");
+  return true;
+}
+
+bool 
+PPFBinaryInputStream::GotoNameTag(string const& name)
+{
+  map<string, int_8>::iterator i = tags.find(name);
+  if (i == tags.end()) 
+    return false;
+      //    throw NotFoundExc("PPFBinaryInputStream::GotoNameTag   tag not found");
+  s->seekg((*i).second);
+  seqread = false;
+  //  objList.clear(); $CHECK$ EA 171199 Ne pas faire ? Reza 03/2000 ?
+  return(true); 
+}
+
+
+bool
+PPFBinaryInputStream::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
+PPFBinaryInputStream::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);
+}
+
+
+static vector<string> * ret_tag_names = NULL;
+vector<string> const &
+PPFBinaryInputStream::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
+PPFBinaryInputStream::SkipToNextObject()
+{
+  // A FAIRE NOV 2003 - REZA
+  return true;
+}
+
+bool
+PPFBinaryInputStream::SkipItem()
+{
+  // A FAIRE NOV 2003 - REZA
+  return true;
+}
+
+//++
+// void PPFBinaryInputStream::GetByte(char& c)
+// void PPFBinaryInputStream::GetBytes(void* ptr, size_t bytes)
+// void PPFBinaryInputStream::GetR4   (r_4& result)
+// void PPFBinaryInputStream::GetR4s  (r_4* tab, size_t n)
+// void PPFBinaryInputStream::GetR8   (r_8& result)
+// void PPFBinaryInputStream::GetR8s  (r_8* tab, size_t n)
+// void PPFBinaryInputStream::GetI2   (int_2& result)
+// void PPFBinaryInputStream::GetI2s  (int_2* tab, size_t n)
+// void PPFBinaryInputStream::GetU2   (uint_2& result)
+// void PPFBinaryInputStream::GetU2s  (uint_2* tab, size_t n)
+// void PPFBinaryInputStream::GetI4   (int_4& result)
+// void PPFBinaryInputStream::GetI4s  (int_4* tab, size_t n)
+// void PPFBinaryInputStream::GetU4   (uint_4& result)
+// void PPFBinaryInputStream::GetU4s  (uint_4* tab, size_t n)
+// void PPFBinaryInputStream::GetI8   (int_8& result)
+// void PPFBinaryInputStream::GetI8s  (int_8* tab, size_t n)
+// void PPFBinaryInputStream::GetU8   (uint_8& result)
+// void PPFBinaryInputStream::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 PPFBinaryInputStream::GetLine(char* ptr, size_t len)
+//	Lecture d'une ligne de texte depuis le fichier PPersist.
+//--
+
+
+void
+PPFBinaryInputStream::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
+PPFBinaryInputStream::GetRawByte(char& c)
+{
+  GetRawBytes(&c, 1);
+}
+
+void
+PPFBinaryInputStream::GetRawUByte(unsigned char& c)
+{
+  GetRawBytes(&c, 1);
+}
+
+void
+PPFBinaryInputStream::GetRawBytes(void* ptr, size_t bytes)
+{
+  s->read((char*)ptr, bytes);
+}
+
+void
+PPFBinaryInputStream::GetRawI2   (int_2& result)
+{
+  GetRawBytes(&result, sizeof(int_2));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap2(&result);
+}
+
+void
+PPFBinaryInputStream::GetRawI4   (int_4& result)
+{
+  GetRawBytes(&result, sizeof(int_4));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&result);
+}
+
+void
+PPFBinaryInputStream::GetRawI8   (int_8& result)
+{
+  GetRawBytes(&result, sizeof(int_8));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&result);
+}
+
+void
+PPFBinaryInputStream::GetRawU8   (uint_8& result)
+{
+  GetRawBytes(&result, sizeof(uint_8));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&result);
+}
+
+void
+PPFBinaryInputStream::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("PPFBinaryInputStream::CheckTag   bad type in ppersist file");
+}
+
+void
+PPFBinaryInputStream::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("PPFBinaryInputStream::CheckArrayTag   bad type in ppersist file");
+    int_4 ff;
+    GetRawI4(ff); filesz=ff;
+  } else {
+    if (ppstype != PPS_SIMPLE_ARRAY8 + datasz + datatype)
+      throw FileFormatExc("PPFBinaryInputStream::CheckArrayTag   bad type in ppersist file");
+    uint_8 ff;
+    GetRawU8(ff); filesz=ff;
+  }
+  if (filesz != sz)
+    throw FileFormatExc("PPFBinaryInputStream::CheckArrayTag   bad array size in ppersist file");
+}
+
+void
+PPFBinaryInputStream::GetByte(char& c)
+{
+  CheckTag(1,PPS_DATATYPE_CHAR);
+  GetRawBytes(&c, 1);
+}
+
+
+void
+PPFBinaryInputStream::GetBytes(void* ptr, size_t bytes)
+{
+  CheckArrayTag(1, bytes, PPS_DATATYPE_CHAR);
+  GetRawBytes(ptr, bytes);
+}
+void
+PPFBinaryInputStream::GetR4   (r_4& result)
+{
+  CheckTag(4,PPS_DATATYPE_FLOAT);
+  GetRawBytes(&result, sizeof(r_4));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&result);
+}
+
+
+void
+PPFBinaryInputStream::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
+PPFBinaryInputStream::GetR8   (r_8& result)
+{
+  CheckTag(8,PPS_DATATYPE_FLOAT);
+  GetRawBytes(&result, sizeof(r_8));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&result);
+}
+
+void
+PPFBinaryInputStream::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
+PPFBinaryInputStream::GetI1   (int_1& result)
+{
+  CheckTag(1,PPS_DATATYPE_INTEGER);
+  GetRawBytes(&result, sizeof(int_1));
+}
+
+void
+PPFBinaryInputStream::GetI1s  (int_1* tab, size_t n)
+{
+  CheckArrayTag(1,n,PPS_DATATYPE_INTEGER);
+  GetRawBytes(tab, n*sizeof(int_1));
+}
+
+void
+PPFBinaryInputStream::GetU1   (uint_1& result)
+{
+  CheckTag(1,PPS_DATATYPE_UNSIGNED);
+  GetRawBytes(&result, sizeof(uint_1));
+}
+
+void
+PPFBinaryInputStream::GetU1s  (uint_1* tab, size_t n)
+{
+  CheckArrayTag(1,n,PPS_DATATYPE_UNSIGNED);
+  GetRawBytes(tab, n*sizeof(uint_1));
+}
+
+void
+PPFBinaryInputStream::GetI2   (int_2& result)
+{
+  CheckTag(2,PPS_DATATYPE_INTEGER);
+  GetRawBytes(&result, sizeof(int_2));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap2(&result);
+}
+
+void
+PPFBinaryInputStream::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
+PPFBinaryInputStream::GetU2   (uint_2& result)
+{
+  CheckTag(2,PPS_DATATYPE_UNSIGNED);
+  GetRawBytes(&result, sizeof(uint_2));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap2(&result);
+}
+
+void
+PPFBinaryInputStream::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
+PPFBinaryInputStream::GetI4   (int_4& result)
+{
+  CheckTag(4,PPS_DATATYPE_INTEGER);
+  GetRawBytes(&result, sizeof(int_4));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&result);
+}
+
+void
+PPFBinaryInputStream::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
+PPFBinaryInputStream::GetU4   (uint_4& result)
+{
+  CheckTag(4,PPS_DATATYPE_UNSIGNED);
+  GetRawBytes(&result, sizeof(uint_4));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&result);
+}
+
+void
+PPFBinaryInputStream::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
+PPFBinaryInputStream::GetI8   (int_8& result)
+{
+  CheckTag(8,PPS_DATATYPE_INTEGER);
+  GetRawBytes(&result, sizeof(int_8));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&result);
+}
+
+void
+PPFBinaryInputStream::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
+PPFBinaryInputStream::GetU8   (uint_8& result)
+{
+  CheckTag(8,PPS_DATATYPE_UNSIGNED);
+  GetRawBytes(&result, sizeof(uint_8));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&result);
+}
+
+void
+PPFBinaryInputStream::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
+PPFBinaryInputStream::GetLine(char* ptr, size_t len)
+{
+  string str;
+  GetStr(str);
+  strncpy(ptr, str.c_str(), len);
+  ptr[len] = '\0';
+}
+
+void
+PPFBinaryInputStream::GetStr(string& str)
+{
+  unsigned char ppstype;
+  GetTypeTag(ppstype);
+  if (ppstype != PPS_STRING) 
+    throw FileFormatExc("PPFBinaryInputStream::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
+PPFBinaryInputStream::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
+PPFBinaryInputStream::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
+PPFBinaryInputStream::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
+PPFBinaryInputStream::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
+PPFBinaryInputStream::GetPosTagTable(int_8* ptab, size_t sz)
+{
+  unsigned char ppstype;
+  GetTypeTag(ppstype);
+  if (ppstype != PPS_POSTAG_TABLE) 
+    throw FileFormatExc("PPFBinaryInputStream::GetPosTagTable  bad type in ppersist stream");
+  int_4 tsz;
+  GetRawI4(tsz);
+  if (tsz != sz)
+    throw FileFormatExc("PPFBinaryInputStream::GetPosTagTable Size mismatch ");
+  for(int kk=0; kk<tsz; kk++)
+    GetRawI8(ptab[kk]);
+  return;
+}
+
+void
+PPFBinaryInputStream::GetPosTagTable(vector<int_8>& ptab)
+{
+  unsigned char ppstype;
+  GetTypeTag(ppstype);
+  if (ppstype != PPS_POSTAG_TABLE) 
+    throw FileFormatExc("PPFBinaryInputStream::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;
+}
+
+
+void
+PPFBinaryInputStream::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 << " PPFBinaryInputStream::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("PPFBinaryInputStream::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("PPFBinaryInputStream::AnalyseTags() - Not found <PPS_EOF> tag ");
+
+  cout << " PPFBinaryInputStream::AnalyseTags() - End - Total Number of Tags= " << totntags << endl; 
+  cout << " ---------------------------------------------------------- \n" << endl;
+  return;
+}
+
+
+//++
+// Class	POutPersist
+// Lib		Outils++
+// include	ppersist.h
+//
+//	Fichier d'objets persistants, en écriture.
+//--
+
+
+//++
+//  POutPersist(string const& flnm, int endianness = PPersist::PPS_NATIVE)
+//
+//	Crée un nouveau fichier ppersist. Par défaut, il est petit=boutien
+//	sur machines petit-boutiennes, et gros-boutien sur machines
+//	gros-boutiennes. On peut explicitement spécifier PPersist::PPS_LITTLE_ENDIAN
+//	ou PPersist::PPS_BIG_ENDIAN.
+//--
+
+PPFBinaryOutputStream::PPFBinaryOutputStream()
+{
+  s = NULL;
+  version = 0;
+}
+
+PPFBinaryOutputStream::PPFBinaryOutputStream(string const& flnm, int endianness)
+{
+  if (endianness == -1)
+    bigEndian = IS_BIG_ENDIAN;
+  else
+    bigEndian = endianness;
+
+  // 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;
+}
+
+PPFBinaryOutputStream::~PPFBinaryOutputStream()
+{
+  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
+PPFBinaryOutputStream::WritePositionTag()
+{
+  int_8 tagpos;
+  tagpos = s->tellp();
+  PutRawByte(PPS_POSTAG_MARK);
+  PutI8(tagpos);
+  return(tagpos);
+}
+
+void
+PPFBinaryOutputStream::WriteNameTag(string const& name)
+{
+  //  if (name.length() > MAXTAGLEN_V2) 
+  //  throw ParmError("PPFBinaryOutputStream::WriteNameTag   tag name too long");
+
+  if (tags.find(name) != tags.end())
+    throw DuplicateIdExc("PPFBinaryOutputStream::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 PPFBinaryOutputStream::PutByte(char& c)
+// void PPFBinaryOutputStream::PutBytes(void const* ptr, size_t bytes)
+// void PPFBinaryOutputStream::PutR4   (r_4 result)
+// void PPFBinaryOutputStream::PutR4s  (r_4 const* tab, size_t n)
+// void PPFBinaryOutputStream::PutR8   (r_8 result)
+// void PPFBinaryOutputStream::PutR8s  (r_8 const* tab, size_t n)
+// void PPFBinaryOutputStream::PutI2   (int_2 result)
+// void PPFBinaryOutputStream::PutI2s  (int_2 const* tab, size_t n)
+// void PPFBinaryOutputStream::PutU2   (uint_2 result)
+// void PPFBinaryOutputStream::PutU2s  (uint_2 const* tab, size_t n)
+// void PPFBinaryOutputStream::PutI4   (int_4 result)
+// void PPFBinaryOutputStream::PutI4s  (int_4 const* tab, size_t n)
+// void PPFBinaryOutputStream::PutU4   (uint_4 result)
+// void PPFBinaryOutputStream::PutU4s  (uint_4 const* tab, size_t n)
+// void PPFBinaryOutputStream::PutI8   (int_8 result)
+// void PPFBinaryOutputStream::PutI8s  (int_8 const* tab, size_t n)
+// void PPFBinaryOutputStream::PutU8   (uint_8 result)
+// void PPFBinaryOutputStream::PutU8s  (uint_8 const* tab, size_t n)
+// void PPFBinaryOutputStream::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 PPFBinaryOutputStream::PutLine(char const* ptr, size_t len)
+//	Ecriture d'une ligne de texte dans le fichier PPersist.
+//--
+
+
+
+
+void
+PPFBinaryOutputStream::PutRawBytes(void const* ptr, size_t bytes)
+{
+  s->write((char const*)ptr, bytes);
+}
+
+void
+PPFBinaryOutputStream::PutRawByte(char c)
+{
+  PutRawBytes(&c, 1);
+}
+
+void
+PPFBinaryOutputStream::PutRawUByte(unsigned char c)
+{
+  PutRawBytes(&c, 1);
+}
+
+void
+PPFBinaryOutputStream::PutRawI2   (int_2 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap2(&val);
+
+  PutRawBytes(&val, sizeof(int_2));
+}
+
+void
+PPFBinaryOutputStream::PutRawI4   (int_4 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&val);
+
+  PutRawBytes(&val, sizeof(int_4));
+}
+
+void
+PPFBinaryOutputStream::PutRawI8   (int_8 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&val);
+
+  PutRawBytes(&val, sizeof(int_8));
+}
+
+void
+PPFBinaryOutputStream::PutRawU8   (uint_8 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&val);
+
+  PutRawBytes(&val, sizeof(uint_8));
+}
+
+void
+PPFBinaryOutputStream::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
+PPFBinaryOutputStream::PutByte(char c)
+{
+  PutRawByte(PPS_SIMPLE + 1 + PPS_DATATYPE_CHAR);
+  PutRawBytes(&c, 1);
+}
+
+
+
+void
+PPFBinaryOutputStream::PutBytes(void const* ptr, size_t bytes)
+{
+  PutArrayTag(1, bytes, PPS_DATATYPE_CHAR);
+  PutRawBytes(ptr, bytes);
+}
+
+void
+PPFBinaryOutputStream::PutR4   (r_4 val)
+{
+  PutRawUByte(PPS_SIMPLE + 4 + PPS_DATATYPE_FLOAT);
+  
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&val);
+
+  PutRawBytes(&val, sizeof(r_4));
+}
+
+void
+PPFBinaryOutputStream::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
+PPFBinaryOutputStream::PutR8   (r_8 val)
+{
+  PutRawUByte(PPS_SIMPLE + 8 + PPS_DATATYPE_FLOAT);
+
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&val);
+
+  PutRawBytes(&val, sizeof(r_8));
+}
+
+void
+PPFBinaryOutputStream::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
+PPFBinaryOutputStream::PutI1   (int_1 val)
+{
+  PutRawUByte(PPS_SIMPLE + 1 + PPS_DATATYPE_INTEGER);
+  PutRawBytes(&val, sizeof(int_1));
+}
+
+void
+PPFBinaryOutputStream::PutI1s  (int_1 const* tab, size_t n)
+{
+  PutArrayTag(1, n, PPS_DATATYPE_INTEGER);
+  PutRawBytes(tab, n*sizeof(int_1));
+}
+
+void
+PPFBinaryOutputStream::PutU1   (uint_1 val)
+{
+  PutRawUByte(PPS_SIMPLE + 1 + PPS_DATATYPE_UNSIGNED);
+  PutRawBytes(&val, sizeof(uint_1));
+}
+
+void
+PPFBinaryOutputStream::PutU1s  (uint_1 const* tab, size_t n)
+{
+  PutArrayTag(1, n, PPS_DATATYPE_UNSIGNED);
+  PutRawBytes(tab, n*sizeof(uint_1));
+}
+
+void
+PPFBinaryOutputStream::PutI2   (int_2 val)
+{
+  PutRawUByte(PPS_SIMPLE + 2 + PPS_DATATYPE_INTEGER);
+
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap2(&val);
+
+  PutRawBytes(&val, sizeof(int_2));
+}
+
+void
+PPFBinaryOutputStream::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
+PPFBinaryOutputStream::PutU2   (uint_2 val)
+{
+  PutRawUByte(PPS_SIMPLE + 2 + PPS_DATATYPE_UNSIGNED);
+
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap2(&val);
+
+  PutRawBytes(&val, sizeof(uint_2));
+}
+
+void
+PPFBinaryOutputStream::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
+PPFBinaryOutputStream::PutI4   (int_4 val)
+{
+  PutRawUByte(PPS_SIMPLE + 4 + PPS_DATATYPE_INTEGER);
+
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&val);
+
+  PutRawBytes(&val, sizeof(int_4));
+}
+
+void
+PPFBinaryOutputStream::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
+PPFBinaryOutputStream::PutU4   (uint_4 val)
+{
+  PutRawUByte(PPS_SIMPLE + 4 + PPS_DATATYPE_UNSIGNED);
+
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&val);
+
+  PutRawBytes(&val, sizeof(uint_4));
+}
+
+void
+PPFBinaryOutputStream::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
+PPFBinaryOutputStream::PutI8   (int_8 val)
+{
+  PutRawUByte(PPS_SIMPLE + 8 + PPS_DATATYPE_INTEGER);
+
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&val);
+
+  PutRawBytes(&val, sizeof(int_8));
+}
+
+void
+PPFBinaryOutputStream::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
+PPFBinaryOutputStream::PutU8   (uint_8 val)
+{
+  PutRawUByte(PPS_SIMPLE + 8 + PPS_DATATYPE_UNSIGNED);
+
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&val);
+
+  PutRawBytes(&val, sizeof(uint_8));
+}
+
+void
+PPFBinaryOutputStream::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
+PPFBinaryOutputStream::PutStr(string const& str) 
+{
+  PutRawUByte(PPS_STRING);
+  PutRawI4(str.length());
+  PutRawBytes(str.c_str(), str.length());
+}
+
+void
+PPFBinaryOutputStream::PutLine(char const* ptr, size_t len)
+{
+  string str = ptr;
+  PutStr(str);
+}
+
+
+void
+PPFBinaryOutputStream::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
+PPFBinaryOutputStream::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
+PPFBinaryOutputStream::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
+PPFBinaryOutputStream::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
+PPFBinaryOutputStream::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
+PPFBinaryOutputStream::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;
+}
+
Index: trunk/SophyaLib/BaseTools/ppfbinstream.h
===================================================================
--- trunk/SophyaLib/BaseTools/ppfbinstream.h	(revision 2475)
+++ trunk/SophyaLib/BaseTools/ppfbinstream.h	(revision 2475)
@@ -0,0 +1,273 @@
+// This may look like C code, but it is really -*- C++ -*-
+
+#ifndef PPFBINSTREAM_H_SEEN
+#define PPFBINSTREAM_H_SEEN
+
+// PPF (Portable Persistence Format) Input/Output streams
+//
+// E. Aubourg     CEA DAPNIA/SPP  1999
+// R. Ansari      LAL IN2P3/CNRS  2000-2003
+
+
+#include "machdefs.h"
+#include "rawstream.h"
+
+#include <time.h>
+
+#include <complex>
+#include <string>
+#include <map>
+#include <vector>
+
+
+
+namespace SOPHYA {
+  
+class PPFBinaryIOStream {
+public:
+
+  enum  PPFByteOrdering  {PPS_NATIVE = -1, PPS_LITTLE_ENDIAN = 0, PPS_BIG_ENDIAN = 1};
+
+  // Value of item identification tags in PPF binary streams   
+  enum  PPFItemTag {
+    PPS_NULL = 0,             // this is a null object
+    PPS_STRING = 1,           // string, length (4b) + data
+    PPS_OBJECT = 2,           // classId, data...
+    PPS_REFERENCE = 3,        // objectId
+    PPS_NAMETAG_TABLE = 4,    // Name tag table (Written at the end of file/stream) 
+    PPS_EOF = 5,              // Just before tag infomation, offset to PPS_TAG
+    PPS_ENDOBJECT = 6,        // marks the end of a given object information
+    PPS_NAMETAG_MARK = 7,     // To have a name tag, position marker in a file
+    PPS_POSTAG_MARK = 8,      // Position tag mark + 8 bytes (=stream position)
+    PPS_POSTAG_TABLE = 9,     // Position tag table + 8 bytes (=stream position)
+    PPS_SIMPLE = 16,          // 16 + number of bytes, up to 8 bytes
+    PPS_SIMPLE_ARRAY4 = 32,   // 32 + number of bytes, up to 8 bytes, then 4 bytes of length
+    PPS_SIMPLE_ARRAY8 = 48    // 48 + number of bytes, up to 8 bytes, then 8 bytes of length
+  };
+
+  // The following values are used with PPS_SIMPLE and PPS_SIMPLE_ARRAY (Using OR)
+  enum   PPFItemTagDataType {  
+    PPS_DATATYPE_CHAR = 0,        // 0  : DataType=character
+    PPS_DATATYPE_FLOAT = 64,      // 64 : DataType=float 
+    PPS_DATATYPE_COMPLEX = 65,    // 65 : DataType=complex 
+    PPS_DATATYPE_INTEGER = 128,   // 128 :DataType=integer 
+    PPS_DATATYPE_UNSIGNED = 192   // 192 :DataType=Unsigned integer 
+  };
+  
+  PPFBinaryIOStream();
+  virtual ~PPFBinaryIOStream();
+  int    Version() {return version;}  // PIn/OutPersist version number
+  string FileName() { return filename; }   // Retourne le nom de fichier
+  
+protected:
+  
+  map<string, int_8> tags;
+  string filename;
+  int version;     // PPersist(In/Out) version 
+};
+  
+  
+//! Input PPF (Portable Persist Format) streams 
+class PPFBinaryInputStream : public PPFBinaryIOStream {
+public:
+  PPFBinaryInputStream();
+  PPFBinaryInputStream(string const& flnm, bool scan=true);
+  virtual  ~PPFBinaryInputStream();
+  
+  // Gestion des tags
+  bool   GotoPositionTag(int_8 pos);
+  bool   GotoNameTag(string const& name);
+  int    NbNameTags(); 
+  bool   GotoNameTagNum(int itag);  // 0..NbTags-1
+  string GetTagName(int itag);  // 0..NbTags-1
+  vector<string> const &  GetNameTags();  
+  
+  // Saut jusqu'au prochain objet 
+  bool   SkipToNextObject();
+  // Saut d'un item de base (tag+donnees correspondantes)
+  bool   SkipItem();
+  
+  // Lecture donnees de base et tableaux de donnees de base
+  // Basic data type (and corresponding arrays) reading
+  void   GetByte (char& c);
+  void   GetBytes(void* ptr, size_t bytes);
+  void   GetR4   (r_4&);
+  void   GetR4s  (r_4*, size_t);
+  void   GetR8   (r_8&);
+  void   GetR8s  (r_8*, size_t);
+  void   GetI1   (int_1&);
+  void   GetI1s  (int_1*, size_t);
+  void   GetU1   (uint_1&);
+  void   GetU1s  (uint_1*, size_t);
+  void   GetI2   (int_2&);
+  void   GetI2s  (int_2*, size_t);
+  void   GetU2   (uint_2&);
+  void   GetU2s  (uint_2*, size_t);
+  void   GetI4   (int_4&);
+  void   GetI4s  (int_4*, size_t);
+  void   GetU4   (uint_4&);
+  void   GetU4s  (uint_4*, size_t);
+  void   GetI8   (int_8&);
+  void   GetI8s  (int_8*, size_t);
+  void   GetU8   (uint_8&);
+  void   GetU8s  (uint_8*, size_t);
+  void   GetLine (char* ptr, size_t len);
+  void   GetStr  (string&);
+  void   GetZ4   (complex<r_4> &);
+  void   GetZ4s  (complex<r_4> *, size_t);
+  void   GetZ8   (complex<r_8> &);
+  void   GetZ8s  (complex<r_8> *, size_t);
+  
+  inline void   Get(char&   c) {GetByte(c);}
+  inline void   Get(r_4&    x) {GetR4(x);}
+  inline void   Get(r_8&    x) {GetR8(x);}
+  inline void   Get(uint_1& x) {GetU1(x);}
+  inline void   Get(int_1&  x) {GetI1(x);}
+  inline void   Get(uint_2& x) {GetU2(x);}
+  inline void   Get(int_2&  x) {GetI2(x);}
+  inline void   Get(uint_4& x) {GetU4(x);}
+  inline void   Get(int_4&  x) {GetI4(x);}
+  inline void   Get(uint_8& x) {GetU8(x);}
+  inline void   Get(int_8&  x) {GetI8(x);}
+  inline void   Get(complex<r_4> & x) {GetZ4(x);}
+  inline void   Get(complex<r_8> & x) {GetZ8(x);}
+  
+  inline void   Get(r_4*    x, size_t n) {GetR4s(x,n);}
+  inline void   Get(r_8*    x, size_t n) {GetR8s(x,n);}
+  inline void   Get(uint_1* x, size_t n) {GetU1s(x,n);}
+  inline void   Get(int_1*  x, size_t n) {GetI1s(x,n);}
+  inline void   Get(uint_2* x, size_t n) {GetU2s(x,n);}
+  inline void   Get(int_2*  x, size_t n) {GetI2s(x,n);}
+  inline void   Get(uint_4* x, size_t n) {GetU4s(x,n);}
+  inline void   Get(int_4*  x, size_t n) {GetI4s(x,n);}
+  inline void   Get(uint_8* x, size_t n) {GetU8s(x,n);}
+  inline void   Get(int_8*  x, size_t n) {GetI8s(x,n);}
+  inline void   Get(string& x) {GetStr(x);}
+  inline void   Get(complex<r_4> * x, size_t n) { GetZ4s(x, n); }
+  inline void   Get(complex<r_8> * x, size_t n) { GetZ8s(x, n); }
+  
+  // Reading a list (table) of position tags
+  void    GetPosTagTable(int_8*, size_t);
+  void    GetPosTagTable(vector<int_8>&);
+  
+  time_t CreationDate() { return creationdate; }
+  string CreationDateStr(); 
+  
+  void   AnalyseTags(int lev=0);   // List (all or some) tags ...
+  
+protected:
+  void   CheckTag   (short datasz, short datatype);
+  void   CheckArrayTag(short datasz, size_t sz, short datatype);
+  void   GetTypeTag (unsigned char& c);
+  void   GetRawByte (char& c);
+  void   GetRawUByte (unsigned char& c);
+  void   GetRawBytes(void* ptr, size_t bytes);
+  void   GetRawI2   (int_2&);
+  void   GetRawI4   (int_4&);
+  void   GetRawI8   (int_8&);
+  void   GetRawU8   (uint_8&);
+  
+  void   Scan();
+  
+  RawInOutStream* s;
+  
+  bool bigEndian;
+  time_t creationdate;
+  // Si on a fait une lecture non sequentielle  -> seqread = false
+  bool seqread;
+};
+
+//! Output stream for PPersit objects.
+class PPFBinaryOutputStream : public PPFBinaryIOStream {
+public:
+  PPFBinaryOutputStream();
+  PPFBinaryOutputStream(string const& flnm, int endianness = PPS_NATIVE);
+  virtual ~PPFBinaryOutputStream();
+  
+  // Ecriture de tags
+  int_8 WritePositionTag();
+  void  WriteNameTag(string const& name);
+  inline void WriteTag(string const& name) { WriteNameTag(name); }
+  
+  void PutByte (char c);
+  void PutBytes(void const* ptr, size_t bytes);
+  void PutR4   (r_4);
+  void PutR4s  (r_4 const*, size_t);
+  void PutR8   (r_8);
+  void PutR8s  (r_8 const*, size_t);
+  void PutI1   (int_1);
+  void PutI1s  (int_1 const*, size_t);
+  void PutU1   (uint_1);
+  void PutU1s  (uint_1 const*, size_t);
+  void PutI2   (int_2);
+  void PutI2s  (int_2 const*, size_t);
+  void PutU2   (uint_2);
+  void PutU2s  (uint_2 const*, size_t);
+  void PutI4   (int_4);
+  void PutI4s  (int_4 const*, size_t);
+  void PutU4   (uint_4);
+  void PutU4s  (uint_4 const*, size_t);
+  void PutI8   (int_8);
+  void PutI8s  (int_8 const*, size_t);
+  void PutU8   (uint_8);
+  void PutU8s  (uint_8 const*, size_t);
+  void PutLine (char const* ptr, size_t len=0); // deprecated ?
+  void PutStr  (string const&);
+  void PutZ4   (complex<r_4>);
+  void PutZ4s  (complex<r_4> const*, size_t);
+  void PutZ8   (complex<r_8>);
+  void PutZ8s  (complex<r_8> const*, size_t);
+  
+  
+  void   Put(char   c) {PutByte(c);}
+  void   Put(r_4    x) {PutR4(x);}
+  void   Put(r_8    x) {PutR8(x);}
+  void   Put(complex<r_4>   x) {PutZ4(x);}
+  void   Put(complex<r_8>   x) {PutZ8(x);}
+  void   Put(uint_1 x) {PutU1(x);}
+  void   Put(int_1  x) {PutI1(x);}
+  void   Put(uint_2 x) {PutU2(x);}
+  void   Put(int_2  x) {PutI2(x);}
+  void   Put(uint_4 x) {PutU4(x);}
+  void   Put(int_4  x) {PutI4(x);}
+  void   Put(uint_8 x) {PutU8(x);}
+  void   Put(int_8  x) {PutI8(x);}
+  void   Put(r_4 const*    x, size_t n) {PutR4s(x,n);}
+  void   Put(r_8 const*    x, size_t n) {PutR8s(x,n);}
+  void   Put(complex<r_4> const*    x, size_t n) {PutZ4s(x,n);}
+  void   Put(complex<r_8> const*    x, size_t n) {PutZ8s(x,n);}
+  void   Put(uint_1 const* x, size_t n) {PutU1s(x,n);}
+  void   Put(int_1 const*  x, size_t n) {PutI1s(x,n);}
+  void   Put(uint_2 const* x, size_t n) {PutU2s(x,n);}
+  void   Put(int_2 const*  x, size_t n) {PutI2s(x,n);}
+  void   Put(uint_4 const* x, size_t n) {PutU4s(x,n);}
+  void   Put(int_4 const*  x, size_t n) {PutI4s(x,n);}
+  void   Put(uint_8 const* x, size_t n) {PutU8s(x,n);}
+  void   Put(int_8 const*  x, size_t n) {PutI8s(x,n);}
+  void   Put(string const& s) {PutStr(s);}
+  
+  // Writing a list of position tag table
+  void   PutPosTagTable(int_8 const *, size_t);
+  void   PutPosTagTable(vector<int_8> const&);
+    
+  
+protected:
+  RawInOutStream* s;
+  bool bigEndian;
+  
+  void     PutArrayTag(short datasz, size_t sz, short datatype);
+  void     PutRawByte (char);
+  void     PutRawUByte (unsigned char);
+  void     PutRawI2   (int_2);
+  void     PutRawI4   (int_4);
+  void     PutRawI8   (int_8);
+  void     PutRawU8   (uint_8);
+  void     PutRawBytes(void const* ptr, size_t bytes);
+  
+};
+  
+
+
+} // namespace
+
+#endif
