Index: trunk/SophyaExt/FitsIOServer/fitsfile.cc
===================================================================
--- trunk/SophyaExt/FitsIOServer/fitsfile.cc	(revision 1193)
+++ trunk/SophyaExt/FitsIOServer/fitsfile.cc	(revision 1209)
@@ -80,5 +80,5 @@
 }
 
-string FitsFile::getErrStatus(int status) 
+string FitsFile::GetErrStatus(int status) 
 {
   char text[31];
@@ -131,14 +131,14 @@
 }
 
-void FitsInFile::getBlockType(char flnm[], int hdunum, string& typeOfExtension, int& naxis, vector<int>& naxisn, string& dataType, DVList& dvl )
+void FitsInFile::GetBlockType(char flnm[], int hdunum, string& typeOfExtension, int& naxis, vector<int>& naxisn, string& dataType, DVList& dvl )
 {
   int status = 0;
   fitsfile* fileptr; 
   fits_open_file(&fileptr,flnm,READONLY,&status);
-  if( status ) printerror( status, "getBlockType: erreur ouverture fichier" );
+  if( status ) printerror( status, "GetBlockType: erreur ouverture fichier" );
   // move to the specified HDU number
   int hdutype = 0;
   fits_movabs_hdu(fileptr,hdunum,&hdutype,&status);
-  if( status ) printerror( status,"getBlockType: erreur movabs");
+  if( status ) printerror( status,"GetBlockType: erreur movabs");
   if(hdutype == IMAGE_HDU) 
     {
@@ -154,5 +154,5 @@
 	    {
 	      cout << " bitpix= " << bitpix << endl;
-	      throw PException(" FitsFile::getBlockType : unsupprted FITS data type");
+	      throw PException(" FitsFile::GetBlockType : unsupprted FITS data type");
 	    }
       
@@ -186,5 +186,5 @@
 		    {
 		      cout << " types[0]= " << types[0] << endl;
-		      throw PException(" FitsFile::getBlockType : unsupprted FITS data type");
+		      throw PException(" FitsFile::GetBlockType : unsupprted FITS data type");
 	    }
 	  }
@@ -193,5 +193,5 @@
       {
 	cout << " hdutype= " << hdutype << endl;
-	throw IOExc("FitsFile::getBlockType: this HDU type is unknown");
+	throw IOExc("FitsFile::GetBlockType: this HDU type is unknown");
       }
   
@@ -968,23 +968,23 @@
 
 }
-void FitsOutFile::putImageToFits(int nbData, double* map) const
+void FitsOutFile::PutImageToFits(int nbData, double* map) const
 {
   int status = 0;
   long npix= nbData;
   fits_write_img(fptr_,TDOUBLE,1,npix,map,&status); 
-  if( status ) printerror( status, "erreur ecriture putImageToFits" );
+  if( status ) printerror( status, "erreur ecriture PutImageToFits" );
   //  writeSignatureOnFits();
 }
 
-void FitsOutFile::putImageToFits(int nbData, float* map) const
+void FitsOutFile::PutImageToFits(int nbData, float* map) const
 {
   int status = 0;
   long npix= nbData;
   fits_write_img(fptr_,TFLOAT,1,npix, map,&status); 
-  if( status ) printerror( status, "erreur ecriture putImageToFits" );
+  if( status ) printerror( status, "erreur ecriture PutImageToFits" );
   //  writeSignatureOnFits();
 
 }
-void FitsOutFile::putImageToFits( int nbData, int* map) const
+void FitsOutFile::PutImageToFits( int nbData, int* map) const
 {
   int status = 0;
@@ -992,5 +992,5 @@
   long npix= nbData;
   fits_write_img(fptr_,TINT,1,npix,map,&status); 
-  if( status ) printerror( status, "erreur ecriture putImageToFits" );
+  if( status ) printerror( status, "erreur ecriture PutImageToFits" );
   //  writeSignatureOnFits();
 }
@@ -1000,6 +1000,9 @@
 void FitsOutFile::makeHeaderBntblOnFits( string fieldType, vector<string> Noms, int nentries, int tfields, DVList &dvl, string extname, vector<int> taille_des_chaines) 
 { 
+  int k;
   int status = 0;
   long nrows;
+  // verifications de coherence
+
   if (fieldType.length() != tfields)
     {
@@ -1007,4 +1010,21 @@
       throw ParmError("FitsFile:: fields and types don't match");
 
+    }
+  if (tfields >  Noms.size())
+    {
+      cout << " WARNING: FitsOutFile::makeHeaderBntblOnFits, length of vector of column names not equal to total number of columns" << endl;
+      for (k=0; k<(tfields-Noms.size()); k++) Noms.push_back( string(" "));
+    }
+  
+  // nombre de variables "chaines de caracteres"
+  int nbString = 0;
+  for (k=0; k<tfields;k++) if (fieldType[k] == 'A') nbString++;
+  // coherence de la longueur du vecteur des tailles 
+  if (nbString >  taille_des_chaines.size())
+    {
+      cout << " WARNING: FitsOutFile::makeHeaderBntblOnFits, length of vector of string lengths  not equal to total number of columns" << endl;
+      int strSz=0;
+      for (k=0; k<taille_des_chaines.size(); k++) if ( taille_des_chaines[k] > strSz) strSz = taille_des_chaines[k];
+      for (k=0; k<(nbString-taille_des_chaines.size()); k++) taille_des_chaines.push_back(strSz);
     }
   char ** ttype= new char*[tfields];
@@ -1012,5 +1032,4 @@
   char largeur[FLEN_VALUE];
   int noColString=0;
-  int k;
   for (k=0; k<tfields;k++)
     {
@@ -1073,15 +1092,15 @@
 }
 
-void FitsOutFile::putColToFits(int nocol, int nentries, double* donnees) const
+void FitsOutFile::PutColToFits(int nocol, int nentries, double* donnees) const
 {
   int status = 0;
   int hdutype;
   fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
-  if( status ) printerror(status,"putColToFits: le movabs a foire");
+  if( status ) printerror(status,"PutColToFits: le movabs a foire");
   fits_get_hdu_type(fptr_, &hdutype, &status);
     if(hdutype != ASCII_TBL && hdutype != BINARY_TBL)
         {
             cout << " hdunum= " << hdunum_ << " hdutype= " << hdutype << endl;
-     throw IOExc("FitsFile::putColToFits, this HDU is not an ASCII table nor a binary table");
+     throw IOExc("FitsFile::PutColToFits, this HDU is not an ASCII table nor a binary table");
           }
   int code; 
@@ -1090,24 +1109,24 @@
   if( code != TDOUBLE)
     {
-      cout << " WARNING : types don't match (putColToFits) : on fits file= " << code << " to be written= DOUBLE " << endl;
+      cout << " WARNING : types don't match (PutColToFits) : on fits file= " << code << " to be written= DOUBLE " << endl;
     } 
   fits_write_col(fptr_,TDOUBLE,nocol+1,1,1,nentries, donnees ,&status);
   if( status )  printerror( status,"erreur ecriture du fichier fits" );
 }
-void FitsOutFile::putColToFits(int nocol, int nentries, float* donnees) const
+void FitsOutFile::PutColToFits(int nocol, int nentries, float* donnees) const
 {
   int status = 0;
   int hdutype;
   fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
-  if( status ) printerror(status,"putColToFits: le movabs a foire");
+  if( status ) printerror(status,"PutColToFits: le movabs a foire");
   fits_get_hdu_type(fptr_, &hdutype, &status);
   if(hdutype != ASCII_TBL && hdutype != BINARY_TBL)
     {
       cout << " hdunum= " << hdunum_ << " hdutype= " << hdutype << endl;
-      throw IOExc("FitsFile::putColToFits, this HDU is not an ASCII table nor a binary table");
+      throw IOExc("FitsFile::PutColToFits, this HDU is not an ASCII table nor a binary table");
     }
   if(hdutype == ASCII_TBL && nocol>0)
     {
-      throw IOExc("FitsFile::putColToFits, this HDU is an ASCII table, nocol>0  forbidden");
+      throw IOExc("FitsFile::PutColToFits, this HDU is an ASCII table, nocol>0  forbidden");
     }
   int code; 
@@ -1116,24 +1135,24 @@
   if( code != TFLOAT)
     {
-      cout << " WARNING : types don't match (putColToFits) : on fits file= " << code << " (FITS code), to be written= FLOAT " << endl;
+      cout << " WARNING : types don't match (PutColToFits) : on fits file= " << code << " (FITS code), to be written= FLOAT " << endl;
     } 
   fits_write_col(fptr_,TFLOAT,nocol+1,1,1,nentries, donnees ,&status);
   if( status )  printerror( status,"erreur ecriture du fichier fits" );
 }
-void FitsOutFile::putColToFits(int nocol, int nentries, int* donnees) const
+void FitsOutFile::PutColToFits(int nocol, int nentries, int* donnees) const
 {
   int status = 0;
   int hdutype;
   fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
-  if( status ) printerror(status,"putColToFits: le movabs a foire");
+  if( status ) printerror(status,"PutColToFits: le movabs a foire");
   fits_get_hdu_type(fptr_, &hdutype, &status);
   if(hdutype != ASCII_TBL && hdutype != BINARY_TBL)
     {
       cout << " hdunum= " << hdunum_ << " hdutype= " << hdutype << endl;
-      throw IOExc("FitsFile::putColToFits, this HDU is not an ASCII table nor a binary table");
+      throw IOExc("FitsFile::PutColToFits, this HDU is not an ASCII table nor a binary table");
     }
   if(hdutype == ASCII_TBL && nocol>0)
     {
-      throw IOExc("FitsFile::putColToFits, this HDU is an ASCII table, nocol>0  forbidden");
+      throw IOExc("FitsFile::PutColToFits, this HDU is an ASCII table, nocol>0  forbidden");
     }
   int code; 
@@ -1142,24 +1161,24 @@
   if( code != TLONG &&  code != TINT &&  code != TSHORT ) 
     {
-      cout << " WARNING : types don't match (putColToFits) : on fits file= " << code << " (FITS code), to be written= INT " << endl;
+      cout << " WARNING : types don't match (PutColToFits) : on fits file= " << code << " (FITS code), to be written= INT " << endl;
     } 
   fits_write_col(fptr_,TINT,nocol+1,1,1,nentries, donnees ,&status);
   if( status )  printerror( status," ecriture du fichier fits" );
 }
-void FitsOutFile::putColToFits(int nocol, int nentries, char** donnees) const
+void FitsOutFile::PutColToFits(int nocol, int nentries, char** donnees) const
 {
   int status = 0;
   int hdutype;
   fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
-  if( status ) printerror(status,"putColToFits: le movabs a foire");
+  if( status ) printerror(status,"PutColToFits: le movabs a foire");
   fits_get_hdu_type(fptr_, &hdutype, &status);
   if(hdutype != ASCII_TBL && hdutype != BINARY_TBL)
     {
       cout << " hdunum= " << hdunum_ << " hdutype= " << hdutype << endl;
-      throw IOExc("FitsFile::putColToFits, this HDU is not an ASCII table nor a binary table");
+      throw IOExc("FitsFile::PutColToFits, this HDU is not an ASCII table nor a binary table");
     }
   if(hdutype == ASCII_TBL && nocol>0)
     {
-      throw IOExc("FitsFile::putColToFits, this HDU is an ASCII table, nocol>0  forbidden");
+      throw IOExc("FitsFile::PutColToFits, this HDU is an ASCII table, nocol>0  forbidden");
     }
   int code; 
@@ -1168,5 +1187,5 @@
   if( code != TSTRING)
     {
-      cout << " WARNING : types don't match (putColToFits) : on fits file= " << code << " (FITS code), to be written= char** " << endl;
+      cout << " WARNING : types don't match (PutColToFits) : on fits file= " << code << " (FITS code), to be written= char** " << endl;
     } 
   fits_write_col(fptr_,TSTRING,nocol+1,1,1,nentries, donnees ,&status);
@@ -1174,48 +1193,35 @@
 }
 
-void FitsOutFile::putBinTabLine(int NoLine, double* ddata, float* fdata, int* idata, char ** cdata) const
-{
+void FitsOutFile::PutBinTabLine(long NoLine,  BnTblLine& ligne) const
+{
+  // on ne fait pas de verification de type, ni de dimension ici, pour 
+  // des raisons de performances
+  int k;
   int status= 0;
   int    anull;
-  int dcount = 0.;
-  int fcount = 0.;
-  int icount = 0;
-  int ccount =0;
-  int ncol;
+  int ncol=0;
   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;
-	}
+  //  int nbcols;
+  //  fits_get_num_cols(fptr_, &nbcols,&status);
+  for (k=0; k<ligne.ddata_.size(); k++, ncol++)
+    {
+      fits_write_col(fptr_,TDOUBLE,ncol+1,NoLine+1,1,1, &ligne.ddata_[k] ,&status);
+      if( status ) printerror( status, "PutBinTabLine : erreur ecriture double"  );
+    }
+  for (k=0; k<ligne.fdata_.size(); k++, ncol++)
+    {
+      fits_write_col(fptr_,TFLOAT,ncol+1,NoLine+1,1,1, &ligne.fdata_[k] ,&status);
+      if( status ) printerror( status, "PutBinTabLine : erreur ecriture float"  );
+    }
+  for (k=0; k<ligne.idata_.size(); k++, ncol++)
+    {
+      fits_write_col(fptr_,TINT,ncol+1,NoLine+1,1,1, &ligne.idata_[k] ,&status);
+      if( status ) printerror( status, "PutBinTabLine : erreur ecriture entier"  );
+    }
+  
+  for (k=0; k<ligne.cdata_.size(); k++, ncol++)
+    {
+      fits_write_col(fptr_,TSTRING,ncol+1,NoLine+1,1,1, strdup(ligne.cdata_[k].c_str()) ,&status);
+      if( status ) printerror( status, "PutBinTabLine : erreur ecriture caracteres"  );
     }
 }
