Index: trunk/SophyaExt/FitsIOServer/fitshdtable.cc
===================================================================
--- trunk/SophyaExt/FitsIOServer/fitshdtable.cc	(revision 2843)
+++ 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;
-}
-*/
-
-
+
+
