Index: /trunk/SophyaExt/FitsIOServer/fitsbntbllinereader.cc
===================================================================
--- /trunk/SophyaExt/FitsIOServer/fitsbntbllinereader.cc	(revision 1192)
+++ /trunk/SophyaExt/FitsIOServer/fitsbntbllinereader.cc	(revision 1193)
@@ -1,4 +1,5 @@
 #include "pexceptions.h"
 #include "fitsbntbllinereader.h"
+#include "utils.h"
 ///////////////////////////////////////////////////////////
 //    
@@ -64,59 +65,24 @@
       }
     }
-  ColName_ = new char*[nbcols];
+  vector<string> ColN(nbcols);
   int compt=0;
   for (k=0; k<DfitsCol.size(); k++)
     {
-      ColName_[compt] = new char[LONNOM+1]; 
-      //      strncpy(ColName_[compt], fn->ColNameFromFits(DfitsCol[k]).c_str(), LONNOM);
-      strncpy(ColName_[compt], inFits_->ColNameFromFits(DfitsCol[k]).c_str(), LONNOM);
-      ColName_[compt++][ LONNOM] =  '\0';
+      ColN[compt] = inFits_->ColNameFromFits(DfitsCol[k]);
     }
   for (k=0; k<FfitsCol.size(); k++)
     {
-      ColName_[compt] = new char[LONNOM+1]; 
-      //      strncpy(ColName_[compt], fn->ColNameFromFits(FfitsCol[k]).c_str(), LONNOM);
-      strncpy(ColName_[compt], inFits_->ColNameFromFits(FfitsCol[k]).c_str(), LONNOM);
-      ColName_[compt++][ LONNOM] =  '\0';
+      ColN[compt] =  inFits_->ColNameFromFits(FfitsCol[k]);
     }
   for (k=0; k<IfitsCol.size(); k++)
     {
-      ColName_[compt] = new char[LONNOM+1]; 
-      //      strncpy(ColName_[compt], fn->ColNameFromFits(IfitsCol[k]).c_str(), LONNOM);
-      strncpy(ColName_[compt], inFits_->ColNameFromFits(IfitsCol[k]).c_str(), LONNOM);
-      ColName_[compt++][ LONNOM] =  '\0';
+      ColN[compt] =  inFits_->ColNameFromFits(IfitsCol[k]);
     }
   for (k=0; k<SfitsCol.size(); k++)
     {
-      ColName_[compt] = new char[LONNOM+1]; 
-      //      strncpy(ColName_[compt], fn->ColNameFromFits(SfitsCol[k]).c_str(), LONNOM);
-      strncpy(ColName_[compt], inFits_->ColNameFromFits(SfitsCol[k]).c_str(), LONNOM);
-      ColName_[compt++][LONNOM] =  '\0';
+      ColN[compt] = inFits_->ColNameFromFits(SfitsCol[k]);
     }
 
-  if (DfitsCol.size()>0)
-    {
-      dcount_ = DfitsCol.size();
-      ddata_ = new double[dcount_];
-    }
-  if (FfitsCol.size()>0)
-    {
-      fcount_ = FfitsCol.size();
-      fdata_ = new float[fcount_];
-    }
-  if (IfitsCol.size()>0)
-    {
-      icount_ = IfitsCol.size();
-      idata_ = new int[icount_];
-    }
-  if (SfitsCol.size()>0) 
-    {
-      ccount_ = SfitsCol.size();
-      cdata_ = new char*[ccount_];
-      taille_des_chaines_ = 0;
-      //      for (k=0; k< ccount_; k++)  taille_des_chaines_ = max( taille_des_chaines_, fn->ColStringLengthFromFits(SfitsCol[k]) );
-      for (k=0; k< ccount_; k++)  taille_des_chaines_ = max( taille_des_chaines_, inFits_->ColStringLengthFromFits(SfitsCol[k]) );
-      for (k=0; k<ccount_; k++) cdata_[k]=new char[taille_des_chaines_+1];
-    }
+  ligne_.setFormat(DfitsCol.size(), FfitsCol.size(), IfitsCol.size(), SfitsCol.size(), ColN);
 }
 
@@ -125,33 +91,12 @@
 {
   if (inFits_ != NULL) delete inFits_;
-  if (ddata_ != NULL) delete [] ddata_;
-  if (fdata_ != NULL) delete [] fdata_;
-  if (idata_ != NULL) delete [] idata_;
-  if (cdata_ != NULL)
-    {
-      if (ccount_ != 0)
-	{
-	  for (int k=0; k< ccount_; k++)
-	    { 
-	      delete [] cdata_[k];
-	      delete [] ColName_[k];
-	    }
-	  delete [] cdata_;
-	  delete [] ColName_;
-	}
-      else
-	{
-	  cout << "FITS_BntblLineReader, destructeur: bizarre, cdata non vide, avec ccount=0 ?" << endl;;  	}
-    }
 }
 
+BnTblLine& FITS_BntblLineReader::ReadNextLine()
+{
+  inFits_->GetBinTabLine(nextLineToBeRead_++, ligne_);
+  return ligne_;
+}
 
-XNTuple FITS_BntblLineReader::ReadNextLine()
-{
-  inFits_->GetBinTabLine(nextLineToBeRead_++, ddata_, fdata_, idata_, cdata_ );
-  XNTuple xnt(dcount_, fcount_, icount_,ccount_, ColName_); 
-  xnt.Fill(ddata_, fdata_, idata_, cdata_);    
-  return xnt;
-}
 
 void  FITS_BntblLineReader::ReadFromFits(FitsInFile&)
Index: /trunk/SophyaExt/FitsIOServer/fitsbntbllinereader.h
===================================================================
--- /trunk/SophyaExt/FitsIOServer/fitsbntbllinereader.h	(revision 1192)
+++ /trunk/SophyaExt/FitsIOServer/fitsbntbllinereader.h	(revision 1193)
@@ -5,5 +5,5 @@
 #define FITSBntblLineReader_SEEN
 #include "fitsfile.h"
-#include "xntuple.h"
+//#include "xntuple.h"
 
 namespace SOPHYA {
@@ -21,5 +21,6 @@
 ~FITS_BntblLineReader();
 
-XNTuple ReadNextLine();
+//XNTuple ReadNextLineX();
+BnTblLine& ReadNextLine();
  inline long GetNextLineIndex() const {return nextLineToBeRead_;}
  inline  void SetStartingLineIndex(long n)  { nextLineToBeRead_ = n;}
@@ -43,14 +44,4 @@
      inFits_ = NULL;
      nextLineToBeRead_= 0;
-     dcount_ = 0;
-     fcount_ = 0;
-     icount_ = 0;
-     ccount_ = 0;
-     taille_des_chaines_ = 0;
-     ddata_ = NULL;
-     fdata_ = NULL;
-     idata_ = NULL;
-     cdata_ = NULL;
-     ColName_ = NULL;
    }
   // attributs de classe
@@ -58,15 +49,8 @@
  FitsInFile* inFits_;
   long nextLineToBeRead_;
-  int dcount_;
-  int fcount_;
-  int icount_;
-  int ccount_;
-  int  taille_des_chaines_;
-  double* ddata_;
-  float*  fdata_;
-  int*    idata_;
-  char**  cdata_;
-  char ** ColName_;
+  BnTblLine ligne_;
 };
+
+
 //////////////////////////////////////////////////////////////////
 
Index: /trunk/SophyaExt/FitsIOServer/fitsfile.cc
===================================================================
--- /trunk/SophyaExt/FitsIOServer/fitsfile.cc	(revision 1192)
+++ /trunk/SophyaExt/FitsIOServer/fitsfile.cc	(revision 1193)
@@ -21,9 +21,8 @@
 
 
-void FitsIOHandler::Write(char flnm[], string WriteMode) 
-
-{
-
-  FitsOutFile of(flnm,  WriteMode);
+void FitsIOHandler::Write(char flnm[]) 
+
+{
+  FitsOutFile of(flnm, unknown);
   Write(of);
 }
@@ -366,5 +365,5 @@
   return  taille_des_chaines_[index];
 }
-void FitsInFile::GetBinTabLine(int NoLine, double* ddata, float* fdata, int* idata, char ** cdata) 
+void  FitsInFile::GetBinTabLine(int NoLine, double* ddata, float* fdata, int* idata, char ** cdata) 
 {
   int status= 0;
@@ -396,4 +395,46 @@
 	case 'S' :
 	  fits_read_col(fptr_,TSTRING,ncol+1,NoLine+1,1,1,cnull,&cdata[ccount++],&anull,&status);
+	  break;
+	}
+      if (status)
+	{
+	  ResetStatus(status);
+	  break;
+	}
+    }
+}
+
+void   FitsInFile::GetBinTabLine(long NoLine,  BnTblLine& ligne) 
+{
+  int status= 0;
+  int    anull;
+  double dnull= 0.;
+  float fnull= 0.;
+  int inull= 0;
+  char* cnull= "";
+  int dcount = 0.;
+  int fcount = 0.;
+  int icount = 0;
+  int ccount =0;
+  int ncol;
+  long nels=1;
+  for (ncol=0; ncol<nbcols_; ncol++)
+    {
+      switch (types_[ncol])
+	{ 
+	case 'D' :
+	  fits_read_col(fptr_,TDOUBLE,ncol+1,NoLine+1,1,1,&dnull,&ligne.ddata_[dcount++],&anull,&status);
+	    break;
+	case 'E' :
+	  fits_read_col(fptr_,TFLOAT,ncol+1,NoLine+1,1,1,&fnull,&ligne.fdata_[fcount++],&anull,&status);
+	  break;
+	case 'I' :
+	  fits_read_col(fptr_,TINT,ncol+1,NoLine+1,1,1,&inull,&ligne.idata_[icount++],
+			&anull,&status);
+	  break;
+	case 'S' :
+	  char* chaine = new char[taille_des_chaines_[ccount]];
+	  fits_read_col(fptr_,TSTRING,ncol+1,NoLine+1,1,1,cnull,&chaine,&anull,&status);
+	  ligne.cdata_[ccount++] = string(chaine);
 	  break;
 	}
@@ -827,8 +868,8 @@
 FitsOutFile::FitsOutFile()
 {
-  InitNull();
-}
-
-FitsOutFile::FitsOutFile(char flnm[], string WriteMode)
+  InitNull(); 
+}
+
+FitsOutFile::FitsOutFile(char flnm[], WriteMode wrm)
 {
 
@@ -841,7 +882,9 @@
   if( status )
     {
+
+      switch (wrm)
+	{
       // si on veut ecrire a la fin de ce fichier
-      if (WriteMode == string("append"))
-	{
+	case append :
 	  status = 0;
 	  fits_open_file(&fptr_,flnm,READWRITE,&status);
@@ -856,7 +899,7 @@
 	  fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
 	  if( status ) printerror( status,":FitsFile::WriteF : erreur movabs");
-	}
-      else 
-	if (WriteMode == string("clear")) 
+	  break;
+       
+	case clear :
 	  {
 	    status = 0;
@@ -867,4 +910,5 @@
 	    strcat(newname, flnm);
 	    fits_create_file(&fptr_,newname,&status);
+	    delete [] newname;
 	    if (status)
 	      {
@@ -872,12 +916,12 @@
 		printerror(status, "unable to open file, supposed to exist");
 	      }
-	    else  cout << " file " << flnm << " will be overwrited " << endl;
-	      
+	    else  cout << "  WARNING : file " << flnm << " is overwritten " << endl;
+	    break;
 	  }
-	else 
-	  if  (WriteMode == string("unknown")) printerror(status, " file seems already to exist");
-
-	  else  printerror(status, "open file failed");
+	case unknown : 
+	  printerror(status, " file seems already to exist");
+	  break;
       
+	}
     }
 }
@@ -954,11 +998,11 @@
 
 
-void FitsOutFile::makeHeaderBntblOnFits( char* fieldType, char** Noms, int nentries, int tfields, DVList &dvl, char* extname, vector<int> taille_des_chaines) 
+void FitsOutFile::makeHeaderBntblOnFits( string fieldType, vector<string> Noms, int nentries, int tfields, DVList &dvl, string extname, vector<int> taille_des_chaines) 
 { 
   int status = 0;
   long nrows;
-  if (strlen(fieldType) != tfields)
-    {
-      cout << " nombre de champs :" << tfields << "nombre de types: " << strlen(fieldType) << endl;
+  if (fieldType.length() != tfields)
+    {
+      cout << " nombre de champs :" << tfields << "nombre de types: " << fieldType.length() << endl;
       throw ParmError("FitsFile:: fields and types don't match");
 
@@ -1002,12 +1046,9 @@
 	  strcat(format,largeur);
 	}
-      ttype[k]= new char[FLEN_VALUE];
-      strcpy(ttype[k],Noms[k]);
+      ttype[k] =  const_cast<char*>(Noms[k].c_str());
       tform[k]= new char[FLEN_VALUE];
       strcpy(tform[k],format);
     }
-  // value of the EXTNAME keyword
-  char extn[FLEN_VALUE];
-  strncpy(extn,extname,FLEN_VALUE);
+  char* extn = const_cast<char*>(extname.c_str());
 
   // create a new empty binary table onto the FITS file
@@ -1023,5 +1064,4 @@
   for(ii = 0; ii < tfields; ii++)
     {
-      delete [] ttype[ii];
       delete [] tform[ii];
     }
@@ -1031,5 +1071,4 @@
   // write supplementary keywords
   addKeywordsOfDVList(dvl);
-
 }
 
@@ -1134,4 +1173,52 @@
   if( status )  printerror( status,"erreur ecriture du fichier fits" );
 }
+
+void FitsOutFile::putBinTabLine(int NoLine, double* ddata, float* fdata, int* idata, char ** cdata) const
+{
+  int status= 0;
+  int    anull;
+  int dcount = 0.;
+  int fcount = 0.;
+  int icount = 0;
+  int ccount =0;
+  int ncol;
+  long nels=1;
+  int nbcols;
+  fits_get_num_cols(fptr_, &nbcols,&status);
+  for (ncol=0; ncol<nbcols; ncol++)
+    {
+      int code; 
+      long repeat, width;
+      fits_get_coltype(fptr_, ncol+1, &code, &repeat,&width, &status);
+      switch (code)
+	{ 
+	case TDOUBLE :
+	  fits_write_col(fptr_,TDOUBLE,ncol+1,NoLine+1,1,1, &ddata[dcount++] ,&status);
+	    break;
+	case TFLOAT :
+	  fits_write_col(fptr_,TFLOAT,ncol+1,NoLine+1,1,1, &fdata[fcount++] ,&status);
+	  break;
+	case TINT :
+	  fits_write_col(fptr_,TINT,ncol+1,NoLine+1,1,1, &idata[icount++] ,&status);
+	  break;
+	case TLONG :
+	  fits_write_col(fptr_,TINT,ncol+1,NoLine+1,1,1, &idata[icount++] ,&status);
+	  break;
+	case TSHORT :
+	  fits_write_col(fptr_,TINT,ncol+1,NoLine+1,1,1, &idata[icount++] ,&status);
+	  break;
+	case TSTRING :
+	  fits_write_col(fptr_,TSTRING,ncol+1,NoLine+1,1,1, &cdata[ccount++] ,&status);
+	  break;
+	}
+      if (status)
+	{
+	  cout << " WARNING : unknown type (putBinTabLine) : on fits file= " << code << " (FITS code) " << endl;
+	  status = 0;
+	  break;
+	}
+    }
+}
+
 
 void  FitsOutFile::DVListIntoPrimaryHeader(DVList& dvl) const
Index: /trunk/SophyaExt/FitsIOServer/fitsfile.h
===================================================================
--- /trunk/SophyaExt/FitsIOServer/fitsfile.h	(revision 1192)
+++ /trunk/SophyaExt/FitsIOServer/fitsfile.h	(revision 1193)
@@ -12,8 +12,51 @@
 namespace SOPHYA {
 
+struct BnTblLine 
+ {
+BnTblLine() {}
+void setFormat(int dc, int fc, int ic, int cc, vector<string> names)
+   {
+    int nbcols = dc + fc + ic + cc;
+    ColName_ = vector<string>(nbcols);
+     for (int k=0; k < nbcols; k++) ColName_ = names;
+    if (dc >0) ddata_ = vector<double>(dc);
+    if (fc >0) fdata_ = vector<float>(fc);
+    if (ic >0) idata_ = vector<int>(fc);
+    if (cc >0) cdata_ = vector<string>(fc);
+   }
+   void Print()
+   {
+     int k;
+     int compt = 0;
+     cout << " ********* ligne ************* " << endl;
+     cout << " *** noms de variables  " << endl;
+     for (k=0; k < compt + ColName_.size(); k++) cout << ColName_[k] << " ";
+     cout << endl;
+     cout << " *** variables doubles  " << endl;
+     for (k=0; k < ddata_.size(); k++) cout << ddata_[k] << " ";
+     cout << endl;
+     cout << " *** variables float  " << endl;
+     for (k=0; k < fdata_.size(); k++) cout << fdata_[k] << " ";
+     cout << endl;
+     cout << " *** variables int  " << endl;
+     for (k=0; k < idata_.size(); k++) cout << idata_[k] << " ";
+     cout << endl;
+     cout << " *** variables string  " << endl;
+     for (k=0; k < cdata_.size(); k++) cout << cdata_[k] << " ";
+     cout << endl;
+     cout << " ***************************** " << endl;
+   }
+  vector<double> ddata_;
+  vector<float>  fdata_;
+  vector<int>    idata_;
+  vector<string>  cdata_;
+  vector<string> ColName_;
+
+ };
+
  class FitsFile;
  class FitsInFile;
  class FitsOutFile;
-
+ enum WriteMode {append, clear, unknown};
 
 
@@ -88,9 +131,6 @@
 calls the method 'WriteToFits' from the inherited  object
 
-\param <WriteMode>  string , WriteMode = "clear" -> if alreadyy exists, the file will be overwrited (else created) ; WriteMode = "append" -> further objects will be appended to the file if it exists (else : file created). Otherwise, file created if does not exist, else : exception. (the last situation is the default)
-
-
 */ 
-  void   Write(char flnm[], string WriteMode= string("unknown")) ;
+  void   Write(char flnm[]) ;
 
   /*!
@@ -106,5 +146,5 @@
   friend class FitsInFile;
   friend class FitsOutFile;
-
+  private :
   };
 
@@ -262,4 +302,8 @@
   void GetBinTabLine(int NoLine, double* ddata, float* fdata, int* idata, char
 ** cdata) ;
+  /*!
+get the NoLine-th 'line'  from the current BINTABLE extension on FITS file,
+  */
+  void GetBinTabLine(long NoLine, BnTblLine& ligne) ;
 
   /*!
@@ -358,6 +402,12 @@
 
  public:
+
+
    FitsOutFile();
-   FitsOutFile(char flnm[], string WriteMode= string("unknown"));
+   /*!
+\param <WriteMode>  enum , WriteMode = clear -> if alreadyy exists, the file will be overwritten (else created) ; WriteMode = append -> further objects will be appended to the file if it exists (else : file created). WriteMode = unknown -> file created if does not exist, else : exception. (the last situation is the default)
+
+   */
+   FitsOutFile(char flnm[], WriteMode wrm = unknown );
    ~FitsOutFile() { ;};
    inline void InitNull() {imageOnPrimary_=false;}
@@ -414,5 +464,5 @@
 \param <taille_des_chaines> vector containing the number of characters of  data  for each char* typed column, with order of appearance in 'fieldType'
    */
-  void makeHeaderBntblOnFits ( char* fieldType, char** Noms, int nentries, int tfields, DVList &dvl, char* extname,  vector<int> taille_des_chaines) ;
+   void makeHeaderBntblOnFits ( string fieldType, vector<string> Noms, int nentries, int tfields, DVList &dvl, string extname,  vector<int> taille_des_chaines) ;
 
   /*! write double data from array 'donnees ' on column number 'nocol' of a BINTABLE  extension.
@@ -430,4 +480,7 @@
   /*! same as previous method with char* data */
   void putColToFits(int nocol, int nentries, char** donnees) const;
+
+  void putBinTabLine(int NoLine, double* ddata, float* fdata, int* idata, char ** cdata) const;
+
 
 /////////////////////////////////////////////////////////////
