Index: /trunk/SophyaExt/FitsIOServer/fitsblkrw.h
===================================================================
--- /trunk/SophyaExt/FitsIOServer/fitsblkrw.h	(revision 2845)
+++ /trunk/SophyaExt/FitsIOServer/fitsblkrw.h	(revision 2846)
@@ -9,5 +9,5 @@
   \ingroup FitsIOServer
   \brief Template class with static methods for handling bloc data 
-  read from / write to fits files
+  read from / write to fits filesz
 */
 
@@ -114,31 +114,43 @@
 };
 
+DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
+class FitsBlockRW<std::string> {
+public:
+//! Write image HDU with string data type not supported (throws exception) 
+static void WriteImageData(FitsInOutFile& fios, const std::string * d, size_t sz, 
+			   long * fpixel=NULL)
+{
+  throw FitsIOException(
+    "FitsBlockRW<string>::WriteImageData() string data type Unsupported for image HDU");
+}
+//! Read image HDU with string data type not supported (throws exception) 
+static void ReadImageData(FitsInOutFile& fios,  std::string * d, size_t sz, 
+			  long * fpixel=NULL)
+{
+  throw FitsIOException(
+    "FitsBlockRW<string>::ReadImageData() string data type Unsupported for image HDU");
+}
 
-/*! 
-  Write character string data to binary/ascii HDU data in a fits file. 
-  See cfitsio function fits_write_col() for more detail.
-  \param colnum : table column number (starting from 1)
-  \param firstrow : the write operation starting row (starting from 1)
-  \param firstelem : the firstelem (for vector type columns)
-  \param d : pointer to string type array to be written
-  \param sz : number of data elements to be written
-  \param width : column width
-*/
-void WriteStringColumnData(FitsInOutFile& fios, int colnum, long firstrow,
-			   long firstelem, const string * d, size_t sz, 
-			   long width=0)
+//! Write character string data to binary/ascii HDU data in a fits file. 
+static void WriteColumnData(FitsInOutFile& fios, int colnum, long firstrow,
+			    long firstelem, const std::string * d, size_t sz)
 {
   int status = 0;
-  if (width < 1) width = 16;
+  char sbuff[1024];
+  char * cp[4] = {sbuff, sbuff+256, sbuff+512, sbuff+768};
+  //cout << " --- Getting in WriteColumnData<string>() colnum=" << colnum << endl;
   for(size_t kk=0; kk<sz; kk++) {
-    char * cp = const_cast<char *>(d[kk].c_str());
+    strncpy(sbuff, d[kk].c_str(), 1023);
+    //    char * cp = const_cast<char *>(d[kk].c_str());
+    sbuff[1023] = '\0';
     status = 0;
-    fits_write_col(fios.FitsPtr(), FitsTypes::DataType(cp), colnum,
-		   firstrow+kk, firstelem, 1, &cp, &status);
+    //cout <<"DBG-Write2Fits : appel a fits_write_col() kk=" << kk << " / sz=" << sz << endl;
+    fits_write_col(fios.FitsPtr(), FitsTypes::DataType(sbuff), colnum,
+		   firstrow+kk, firstelem, 1, cp, &status);
     if ( status ) {
       fits_report_error(stderr, status);
       char buff[32];
       fits_get_errstatus(status, buff);
-      string msg = "WriteStringColumnData Error: " ;
+      string msg = "FitsBlockRW<std::string>::WriteColumnData() Error: " ;
       msg += buff;
       sprintf(buff," kk=%ld",kk);  msg += buff;
@@ -149,29 +161,24 @@
 }
 
-/*! 
-  Read character string data to binary/ascii HDU data in a fits file. 
-  See cfitsio function fits_read_col() for more detail.
-  \param colnum : table column number (starting from 1)
-  \param firstrow : the read operation starting point (row) (starting from 1)
-  \param firstelem : the firstelem (for vector type columns)
-  \param d : pointer to string type array to be read
-  \param sz : number of data elements to be read
-  \param width : column width
-*/
-void ReadStringColumnData(FitsInOutFile& fios, int colnum, long firstrow,
-			  long firstelem, string * d, size_t sz, long width)
+
+//! Read character string data to binary/ascii HDU data in a fits file. 
+static void ReadColumnData(FitsInOutFile& fios, int colnum, long firstrow,
+			   long firstelem, std::string * d, size_t sz)
 {
   int status = 0;
   int anynul = 0;
-  char buff[1024];
+  char sbuff[1024];
+  char * cp[4] = {sbuff, sbuff+256, sbuff+512, sbuff+768};
+  //  cout << " --- Getting in ReadColumnData<string>() colnum=" << colnum << endl;
   for(size_t kk=0; kk<sz; kk++) {
-    fits_read_col(fios.FitsPtr(), FitsTypes::DataType(buff), colnum,
-		 firstrow, firstelem+kk, 1, NULL, &buff, &anynul, &status);
-    d[kk] = buff;
+    //    cout <<"DBG-ReadFrFits : appel a fits_read_col() kk=" << kk << " / sz=" << sz << endl;
+    fits_read_col(fios.FitsPtr(), FitsTypes::DataType(sbuff), colnum,
+		 firstrow+kk, firstelem, 1, NULL, cp, &anynul, &status);
+    sbuff[1023] = '\0'; d[kk] = sbuff;
     if ( status ) {
       fits_report_error(stderr, status);
       char buff[32];
       fits_get_errstatus(status, buff);
-      string msg = "ReadStringColumnData Error: " ;
+      string msg = "FitsBlockRW<std::string>::ReadColumnData() Error: " ;
       msg += buff;
       sprintf(buff," kk=%ld",kk);  msg += buff;
@@ -182,4 +189,6 @@
 }
 
+};  // Fin classe   FitsBlockRW<std::string>
+
 } // Fin du namespace
 
Index: /trunk/SophyaExt/FitsIOServer/fitshdtable.cc
===================================================================
--- /trunk/SophyaExt/FitsIOServer/fitshdtable.cc	(revision 2845)
+++ /trunk/SophyaExt/FitsIOServer/fitshdtable.cc	(revision 2846)
@@ -25,8 +25,18 @@
   
   int tbltyp = os.GetDef_TableType();
+  string strcoltag;
+  long strwidth = os.GetDef_StrColWidth(); 
+  if (strwidth < 1) strwidth = 16;
+  char buff[32];
+  if (tbltyp == ASCII_TBL) 
+    sprintf(buff, "A%ld",strwidth);
+  else 
+    sprintf(buff, "%ldA",strwidth);
+  strcoltag = buff;
+
   vector<string> colnames, tform, tunit;
   for(sa_size_t k=0; k<dobj->NVar(); k++) { 
-    colnames.push_back(dobj->GetColumName(k));
-    tunit.push_back("");
+    bool fgoknm = true;
+    bool fgoktun = true;
     switch ( dobj->GetColumType(k) ) {
     case BaseDataTable::IntegerField :
@@ -43,9 +53,30 @@
       break;
     case BaseDataTable::DoubleField :
+    case BaseDataTable::DateTimeField :
       if (tbltyp == ASCII_TBL) tform.push_back("D15.8");
       else tform.push_back("D");
+      if (dobj->GetColumType(k) == BaseDataTable::DateTimeField ) {
+	tunit.push_back("Days (DateTimeField)");
+	fgoktun = false;
+      }
+      break;
+    case BaseDataTable::ComplexField :
+      if (tbltyp == ASCII_TBL) { 
+	cout << "FitsHandler<BaseDataTable>::Write()/Warning ComplexField not supported for ASCII_TBL " 
+	     << endl;
+	fgoknm = false;
+      }
+      else   tform.push_back("C");
+      break;
+    case BaseDataTable::DoubleComplexField :
+      if (tbltyp == ASCII_TBL) {
+	cout << "FitsHandler<BaseDataTable>::Write()/Warning DoubleComplexField not supported for ASCII_TBL " 
+	     << endl;
+	fgoknm = false;
+      }
+      else   tform.push_back("M");
       break;
     case BaseDataTable::StringField :
-      cout << "FitsHandler<BaseDataTable>::Write() / Warning StringField not yet supported " << endl;
+      tform.push_back(strcoltag);
       break;
     default:
@@ -53,8 +84,12 @@
       break;
     }
+    if (fgoknm) {
+      colnames.push_back(dobj->GetColumName(k));
+      if (fgoktun) tunit.push_back("");
+    }
   }
 
   // On cree la table  
-  string extname = "";
+  string extname = os.NextExtensionName();
   os.CreateTable(os.GetDef_TableType(), extname, colnames, tform, tunit);
 
@@ -67,4 +102,6 @@
     for(sa_size_t k=0; k<dobj->NVar(); k++) { 
       sa_size_t sk = dobj->mNames[k].ser;
+      //DBG cout << "DBG-A k= " << k << " nom=" << dobj->mNames[k].nom << " ser=" << sk
+      //DBG   << " type=" << dobj->GetColumType(k) << endl;
       switch ( dobj->GetColumType(k) ) {
       case BaseDataTable::IntegerField :
@@ -84,9 +121,28 @@
 	break;
       case BaseDataTable::DoubleField :
+      case BaseDataTable::DateTimeField :
 	icol++;
 	FitsBlockRW<r_8>::WriteColumnData(os, icol, l+1, 1, 
 					  dt->mDCols[sk].GetCstSegment(iseg), sz);
 	break;
-	// case BaseDataTable::StringField :
+      case BaseDataTable::ComplexField :
+	if (tbltyp == BINARY_TBL) { 
+	  icol++;
+	  FitsBlockRW< complex<r_4> >::WriteColumnData(os, icol, l+1, 1, 
+						       dt->mYCols[sk].GetCstSegment(iseg), sz);
+	}
+	break;
+      case BaseDataTable::DoubleComplexField :
+	if (tbltyp == BINARY_TBL) { 
+	  icol++;
+	  FitsBlockRW< complex<r_8> >::WriteColumnData(os, icol, l+1, 1, 
+						       dt->mZCols[sk].GetCstSegment(iseg), sz);
+	}
+	break;
+      case BaseDataTable::StringField :
+	icol++;
+	FitsBlockRW<std::string>::WriteColumnData(os, icol, l+1, 1, 
+						  dt->mSCols[sk].GetCstSegment(iseg), sz);
+	break;
       default:
 	break;
@@ -99,4 +155,6 @@
   MuTyV mtv = dobj->SegmentSize();
   os.WriteKey("SEGMSIZE",mtv," SOPHYA::DataTable SegmentSize");
+  mtv = "SOPHYA::DataTable";
+  os.WriteKey("SOPCLSNM",mtv," Object class name "); 
 }
 
@@ -114,6 +172,7 @@
   if (segsz > 2048) segsz = 2048;
   string key = "SEGMSIZE";
-  string ssegsz = is.KeyValue(key);
-  if (ssegsz.length() > 0)  segsz = atoi(ssegsz.c_str());
+  bool knex = false;
+  string ssegsz = is.KeyValue(key, knex);
+  if (!knex && (ssegsz.length() > 0))  segsz = atoi(ssegsz.c_str());
   if (segsz < 16) segsz = 16;
 
@@ -163,4 +222,16 @@
       colpos.push_back(k+1);
       break;
+    case TCOMPLEX :
+      dt->AddComplexColumn(colnames[k]);
+      colpos.push_back(k+1);
+      break;
+    case TDBLCOMPLEX :
+      dt->AddDoubleComplexColumn(colnames[k]);
+      colpos.push_back(k+1);
+      break;
+    case TSTRING :
+      dt->AddStringColumn(colnames[k]);
+      colpos.push_back(k+1);
+      break;
     default:
       cout << "FitsHandler<BaseDataTable>::Read() NOT handled field type " 
@@ -174,6 +245,6 @@
   while ((dobj->SegmentSize()*dobj->NbSegments()) < dobj->NEntry())
     dobj->Extend();
-  //  cout << " DBG2 -- dobj->mNSeg = " << dobj->NbSegments() << " SegSize=" 
-  //   << dobj->SegmentSize() << " NEntry=" << dobj->NEntry() << endl;
+  //DBG  cout << " DBG2 -- dobj->mNSeg = " << dobj->NbSegments() << " SegSize=" 
+  //DBG   << dobj->SegmentSize() << " NEntry=" << dobj->NEntry() << endl;
 
   // Lecture des donnees des colonnes
@@ -201,8 +272,20 @@
 	break;
       case BaseDataTable::DoubleField :
+      case BaseDataTable::DateTimeField :
 	FitsBlockRW<r_8>::ReadColumnData(is, icol, l+1, 1, 
 					 dt->mDCols[sk].GetSegment(iseg), sz);
 	break;
-	// case BaseDataTable::StringField :
+      case BaseDataTable::ComplexField :
+	FitsBlockRW< complex<r_4> >::ReadColumnData(is, icol, l+1, 1, 
+						    dt->mYCols[sk].GetSegment(iseg), sz);
+	break;
+      case BaseDataTable::DoubleComplexField :
+	FitsBlockRW< complex<r_8> >::ReadColumnData(is, icol, l+1, 1, 
+						    dt->mZCols[sk].GetSegment(iseg), sz);
+	break;
+      case BaseDataTable::StringField :
+	FitsBlockRW<std::string>::ReadColumnData(is, icol, l+1, 1, 
+						 dt->mSCols[sk].GetSegment(iseg), sz);
+	break;
       default:
 	break;
@@ -217,13 +300,4 @@
 
 
-/*
-int toto()
-{
-  DataTable xx;
-  FitsInOutFile fio("dtoto.fits", FitsInOutFile::Fits_Create);
-  FitsHandler<BaseDataTable> fh(xx);
-  //  fio << xx;
-}
-*/
-
-
+
+
