Index: trunk/SophyaLib/BaseTools/ppersist.h
===================================================================
--- trunk/SophyaLib/BaseTools/ppersist.h	(revision 2459)
+++ 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
