Index: /trunk/SophyaLib/BaseTools/SysTools.o.list
===================================================================
--- /trunk/SophyaLib/BaseTools/SysTools.o.list	(revision 255)
+++ /trunk/SophyaLib/BaseTools/SysTools.o.list	(revision 256)
@@ -1,4 +1,5 @@
 ctimer.o
 md5.o
+ndatablock.o
 pdlmgr.o
 peidainit.o
Index: /trunk/SophyaLib/BaseTools/pexceptions.h
===================================================================
--- /trunk/SophyaLib/BaseTools/pexceptions.h	(revision 255)
+++ /trunk/SophyaLib/BaseTools/pexceptions.h	(revision 256)
@@ -4,5 +4,4 @@
 
 #include "machdefs.h"
-//#include <exception>
 #include <string>
 
@@ -12,98 +11,127 @@
 
   // Ancestor for PError and PException
-  class PThrowable { // : public exception {
-	public:
-		explicit PThrowable(const string& m) : msg(m) {}
-                virtual ~PThrowable() { }
-		virtual string const& Msg() const  {return msg;}
-	private:
-		string msg;
+  // It has a message, and an id to give more
+  // information on the exception.
+  class PThrowable {
+  public:
+    explicit PThrowable(const string& m, int ident=0) 
+      : msg(m), id(ident) {}
+    virtual ~PThrowable() { }
+    virtual string const& Msg() const  {return msg;}
+  private:
+    string msg;
+    int    id;
   };
-
+  
   // A PError is a serious logic error. Usually not caught...
   class PError : public PThrowable {
-	public:
-        explicit PError(const string& m) : PThrowable(m) {}
+  public:
+    explicit PError(const string& m, int id=0) : PThrowable(m,id) {}
   };
   
   // A PException is not as serious... Can be caught.
   class PException : public PThrowable {
-	public:
-        explicit PException(const string& m) : PThrowable(m) {}
+  public:
+    explicit PException(const string& m, int id=0) : PThrowable(m,id) {}
+  };
+  
+  // Errors
+  // Memory allocation failure
+  class AllocationError : public PError {
+  public:
+    explicit AllocationError(const string& m, int id=0) : PError(m,id) {}
+  };
+  
+  // Null pointer error
+  class NullPtrError : public PError {
+  public:
+    explicit NullPtrError(const string& m, int id=0) : PError(m,id) {}
+  };
+  
+  // Size mismatch between objects
+  class SzMismatchError : public PError {
+  public:
+    explicit SzMismatchError(const string& m, int id=0) : PError(m,id) {}
+  };
+  
+  // Out of bounds for array, matrix, etc.
+  class RangeCheckError : public PError {
+  public:
+    explicit RangeCheckError(const string& m, int id=0) : PError(m,id) {}
+  };
+  
+  // Invalid parameter to method/constructor...
+  class ParmError : public PError {
+  public:
+    explicit ParmError(const string& m, int id=0) : PError(m,id) {}
+  };
+  
+  // Calling a forbidden method, trying a forbidden operation
+  class ForbiddenError : public PError {
+  public:
+    explicit ForbiddenError(const string& m, int id=0) : PError(m,id) {}
+  };
+  
+  // ASSERT macro failure. The message is the assertion...
+  class AssertionFailedError : public PError {
+  public:
+    explicit AssertionFailedError(const string& m, int id=0) : PError(m,id) {}
+  };
+  
+  // Standard exceptions
+  //
+  // PException
+  //   IOExc
+  //     FileFormatExc
+  //   TypeMismatchExc
+  //   DuplicateIdExc
+  //   NotFoundExc
+  //   MathExc
+  //     SingMatxExc
+  
+  // generic IO Exception
+  class IOExc : public PException {
+  public:
+    explicit IOExc(const string& m, int id=0) : PException(m,id) {}
   };
 
-  // Errors
-  class AllocationError : public PError {
-    public:
-        explicit AllocationError(const string& m) : PError(m) {}
+  // Bad type -> keep ?
+  class TypeMismatchExc : public PException {
+  public:
+    explicit TypeMismatchExc(const string& m, int id=0) : PException(m,id) {}
   };
   
-  class NullPtrError : public PError {
-    public:
-        explicit NullPtrError(const string& m) : PError(m) {}
+  class MathExc : public PException {
+  public:
+    explicit MathExc(const string& m, int id=0) : PException(m,id) {}
+  };
+  
+  class DuplicateIdExc : public PException {
+  public:
+    explicit DuplicateIdExc(const string& m, int id=0) : PException(m,id) {}
+  };
+  
+  class NotFoundExc : public PException {
+  public:
+    explicit NotFoundExc(const string& m, int id=0) : PException(m,id) {}
+  };
+  
+  class CaughtSignalExc : public PException {
+  public:
+    explicit CaughtSignalExc(const string& m, int id=0) : PException(m,id) {}
   };
 
-  class SzMismatchError : public PError {
-    public:
-        explicit SzMismatchError(const string& m) : PError(m) {}
-  };
-
-  class RangeCheckError : public PError {
-    public:
-        explicit RangeCheckError(const string& m) : PError(m) {}
-  };
-
-  class ParmError : public PError {
-    public:
-        explicit ParmError(const string& m) : PError(m) {}
-  };
-
-  class ForbiddenError : public PError {
-    public:
-        explicit ForbiddenError(const string& m) : PError(m) {}
-  };
-
-  class AssertionFailedError : public PError {
-    public:
-        explicit AssertionFailedError(const string& m) : PError(m) {}
-  };
-
-  // Standard exceptions
-  class TypeMismatchExc : public PException {
-    public:
-        explicit TypeMismatchExc(const string& m) : PException(m) {}
-  };
-
-  class FileExc : public PException {
-    public:
-        explicit FileExc(const string& m) : PException(m) {}
-  };
-
-  class FileFormatExc : public PException {
-    public:
-        explicit FileFormatExc(const string& m) : PException(m) {}
-  };
-
-  class DuplicateIdExc : public PException {
-    public:
-        explicit DuplicateIdExc(const string& m) : PException(m) {}
-  };
-
-  class NotFoundExc : public PException {
-    public:
-        explicit NotFoundExc(const string& m) : PException(m) {}
-  };
-
-  class CaughtSignalExc : public PException {
-    public:
-        explicit CaughtSignalExc(const string& m) : PException(m) {}
+  // Bad file format
+  class FileFormatExc : public IOExc {
+  public:
+    explicit FileFormatExc(const string& m, int id=0) : IOExc(m,id) {}
   };
   
-  class SingMatrixExc : public PException {
-    public:
-        explicit SingMatrixExc(const string& m) : PException(m) {}
+  class SingMatrixExc : public MathExc {
+  public:
+    explicit SingMatrixExc(const string& m, int id=0) : MathExc(m,id) {}
   };
   
-
+  
 }
 
@@ -149,5 +177,5 @@
 #define inconsistentErr  ParmError("")
 #define sizeMismatchErr  SzMismatchError("")
-#define fileErr          FileExc("")
+#define fileErr          IOExc("")
 #define nullPtrErr       NullPtrError("")
 #define singMatxErr      SingMatrixExc("")
Index: /trunk/SophyaLib/BaseTools/ppersist.cc
===================================================================
--- /trunk/SophyaLib/BaseTools/ppersist.cc	(revision 255)
+++ /trunk/SophyaLib/BaseTools/ppersist.cc	(revision 256)
@@ -150,5 +150,5 @@
   s.GetRawByte(ppstype);
   if (ppstype != PInPersist::PPS_OBJECT) {
-    throw TypeMismatchExc("PPersist::Read : not an object in flow");
+    throw FileFormatExc("PPersist::Read : not an object in flow");
   }
   
@@ -157,5 +157,5 @@
   s.GetRawU8(classId);
   if (classId != PIOPersist::Hash(typeid(*this).name())) {
-    throw TypeMismatchExc("PPersist::Read : not the same object type");
+    throw FileFormatExc("PPersist::Read : not the same object type");
   }
 
@@ -302,4 +302,10 @@
 
 
+int
+PInPersist::NbTags()
+{
+  return tags.size();
+}
+
 bool 
 PInPersist::GotoTag(string const& name)
@@ -312,4 +318,15 @@
   return(true); 
 }
+
+bool
+PInPersist::GotoTagNum(int itag)
+{
+  if (itag<0 || itag >= tags.size()) return false;
+  map<string, int_8>::iterator i = tags.begin();
+  for (int j=0; j<itag; j++) i++;
+  s->seekg((*i).second);
+  return(true);
+}
+
 
 //++
@@ -419,5 +436,5 @@
   GetRawByte(ppstype);
   if (ppstype != PPS_SIMPLE + datasz)
-    throw TypeMismatchExc("PInPersist::CheckTag   bad type in ppersist file");
+    throw FileFormatExc("PInPersist::CheckTag   bad type in ppersist file");
 }
 
@@ -430,20 +447,20 @@
   if (sz <= 0x7fff) {
     if (ppstype != PPS_SIMPLE_ARRAY + datasz)
-      throw TypeMismatchExc("PInPersist::CheckTag   bad type in ppersist file");
+      throw FileFormatExc("PInPersist::CheckTag   bad type in ppersist file");
     int_2 ff;
     GetRawI2(ff); filesz=ff;
   } else if (sz <= 0x7fffffff) {
     if (ppstype != PPS_SIMPLE_ARRAY4 + datasz)
-      throw TypeMismatchExc("PInPersist::CheckTag   bad type in ppersist file");
+      throw FileFormatExc("PInPersist::CheckTag   bad type in ppersist file");
     int_4 ff;
     GetRawI4(ff); filesz=ff;
   } else {
     if (ppstype != PPS_SIMPLE_ARRAY8 + datasz)
-      throw TypeMismatchExc("PInPersist::CheckTag   bad type in ppersist file");
+      throw FileFormatExc("PInPersist::CheckTag   bad type in ppersist file");
     uint_8 ff;
     GetRawU8(ff); filesz=ff;
   }
   if (filesz != sz)
-    throw TypeMismatchExc("PInPersist::CheckTag   bad array size in ppersist file");
+    throw FileFormatExc("PInPersist::CheckTag   bad array size in ppersist file");
 }
 
@@ -646,5 +663,5 @@
   GetRawByte(ppstype);
   if (ppstype != PPS_LINE) 
-    throw TypeMismatchExc("PInPersist::GetLine   bad type in ppersist file");
+    throw FileFormatExc("PInPersist::GetLine   bad type in ppersist file");
   s->getline(ptr, len, '\n');
 }
@@ -656,5 +673,5 @@
   GetRawByte(ppstype);
   if (ppstype != PPS_STRING) 
-    throw TypeMismatchExc("PInPersist::GetLine   bad type in ppersist file");
+    throw FileFormatExc("PInPersist::GetLine   bad type in ppersist file");
   int_2 len;
   GetRawI2(len);
@@ -673,5 +690,5 @@
   GetRawByte(ppstype);
   if (ppstype != PPS_OBJECT && ppstype != PPS_REFERENCE && ppstype != PPS_NULL) {
-    throw TypeMismatchExc("PInPersist::ReadObject : not an object in flow");
+    throw FileFormatExc("PInPersist::ReadObject : not an object in flow");
   }
 
Index: /trunk/SophyaLib/BaseTools/ppersist.h
===================================================================
--- /trunk/SophyaLib/BaseTools/ppersist.h	(revision 255)
+++ /trunk/SophyaLib/BaseTools/ppersist.h	(revision 256)
@@ -107,4 +107,6 @@
 
     bool   GotoTag(string const& name);
+    int    NbTags();
+    bool   GotoTagNum(int itag);  // 0..NbTags-1
 
     void   GetByte (char& c);
