Index: trunk/external-alma/atnf/PKSIO/NROFITSDataset.cc
===================================================================
--- trunk/external-alma/atnf/PKSIO/NROFITSDataset.cc	(revision 2784)
+++ trunk/external-alma/atnf/PKSIO/NROFITSDataset.cc	(revision 2812)
@@ -67,8 +67,4 @@
   // field names, units, and sizes
   readHeader( numField_, "TFIELDS" ) ;
-  names_.resize( numField_ ) ;
-  units_.resize( numField_ ) ;
-  sizes_.resize( numField_ ) ;
-  offsets_.resize( numField_ ) ;
   getField() ;
 
@@ -1494,9 +1490,8 @@
       return ;
     }
-    //names_[i] = string( tmp ) ;
-    names_[i] = tmp ;
-    spos = names_[i].find( " " ) ;
+    string name = tmp ;
+    spos = tmp.find( " " ) ;
     if ( spos != string::npos )
-      names_[i] = names_[i].substr( 0, spos ) ;
+      name = tmp.substr( 0, spos ) ;
     //strcpy( tmp, "         " ) ;
     if ( form.find( "A" ) != string::npos ) {
@@ -1512,12 +1507,11 @@
       }
     }
-    //units_[i] = string( tmp ) ;
-    units_[i] = tmp ;
-    spos = units_[i].find( " " ) ;
-    if ( spos != string::npos )
-      units_[i] = units_[i].substr( 0, spos ) ;
-    //cout << "i = " << i << ": name=" << form << " type=" << names_[i] << " unit=" << units_[i] << endl ;
-
-    offsets_[i] = offset ;
+    //string unit = string( tmp ) ;
+    //unit = tmp ;
+    //spos = tmp.find( " " ) ;
+    //if ( spos != string::npos )
+    //  unit = unit.substr( 0, spos ) ;
+    //cout << "i = " << i << ": name=" << form << " type=" << name << " unit=" << unit << endl ;
+
     string substr1 = form.substr( 0, form.size()-1 ) ;
     string substr2 = form.substr( form.size()-1, 1 ) ;
@@ -1533,6 +1527,11 @@
     else if ( substr2 == "D" )
       o2 = sizeof(double) ;
-    sizes_[i] = o1 * o2 ;
-    offset += sizes_[i] ;
+
+    FieldProperty property;
+    property.offset = offset;
+    property.size = o1 * o2;
+    properties_[name] = property;
+
+    offset += property.size ;
   }  
 }
@@ -1714,19 +1713,8 @@
   }
 
-long NROFITSDataset::getOffset( char *name ) 
-{
-  long offset = 0 ;
-  string sname( name ) ;
-  long j = -1 ;
-  for ( long i = 0 ; i < numField_ ; i++ ) {
-    // escape if name is found
-    //cout << "names_[" << i << "] = " << names_[i] << "  sname = " << sname << endl ;
-    if ( names_[i] == sname ) {
-      j = i ;
-      break ;
-    }
-  }
-
-  offset = (j >= 0) ? offsets_[j] : j ;
+long NROFITSDataset::getOffset( const char *name ) 
+{
+  map<string, FieldProperty>::iterator iter = properties_.find(string(name));
+  long offset = (iter != properties_.end()) ? iter->second.offset : -1;
 
   return offset ;
@@ -1767,5 +1755,5 @@
 }
 
-int NROFITSDataset::readHeader( string &v, char *name ) 
+int NROFITSDataset::readHeader( string &v, const char *name ) 
 {
   //
@@ -1802,5 +1790,5 @@
 }
 
-int NROFITSDataset::readHeader( int &v, char *name ) 
+int NROFITSDataset::readHeader( int &v, const char *name ) 
 {
   //
@@ -1838,5 +1826,5 @@
 
 
-int NROFITSDataset::readHeader( float &v, char *name ) 
+int NROFITSDataset::readHeader( float &v, const char *name ) 
 {
   //
@@ -1872,5 +1860,5 @@
 }
 
-int NROFITSDataset::readHeader( double &v, char *name ) 
+int NROFITSDataset::readHeader( double &v, const char *name ) 
 {
   //
@@ -1907,5 +1895,5 @@
 }
 
-int NROFITSDataset::readTable( char *v, char *name, int clen, int idx ) 
+int NROFITSDataset::readTable( char *v, const char *name, int clen, int idx ) 
 {
   //
@@ -1917,14 +1905,9 @@
     return status ;
 
-  // get length of char
-  int index = -1 ;
-  for ( int i = 0 ; i < numField_ ; i++ ) {
-    if ( names_[i] == name ) {
-      index = i ;
-      break ;
-    }
-  }
-
-  int xsize = sizes_[index] ;
+  map<string, FieldProperty>::iterator iter = properties_.find(string(name));
+  if (iter == properties_.end())
+    return -1;
+
+  int xsize = iter->second.size;
 
   // read data
@@ -1941,5 +1924,5 @@
 }
 
-int NROFITSDataset::readTable( int &v, char *name, int b, int idx ) 
+int NROFITSDataset::readTable( int &v, const char *name, int b, int idx ) 
 {
   //
@@ -1959,5 +1942,5 @@
 }
 
-int NROFITSDataset::readTable( float &v, char *name, int b, int idx ) 
+int NROFITSDataset::readTable( float &v, const char *name, int b, int idx ) 
 {
   //
@@ -1977,5 +1960,5 @@
 }
 
-int NROFITSDataset::readTable( double &v, char *name, int b, int idx ) 
+int NROFITSDataset::readTable( double &v, const char *name, int b, int idx ) 
 {
   //
@@ -1995,5 +1978,5 @@
 }
 
-int NROFITSDataset::readTable( vector<char *> &v, char *name, int idx ) 
+int NROFITSDataset::readTable( vector<char *> &v, const char *name, int idx ) 
 {
   //
@@ -2004,14 +1987,9 @@
     return status ;
 
-  // get length of char
-  int index = -1 ;
-  for ( int i = 0 ; i < numField_ ; i++ ) {
-    if ( names_[i] == name ) {
-      index = i ;
-      break ;
-    }
-  }
-
-  int xsize = sizes_[index] ;
+  map<string, FieldProperty>::iterator iter = properties_.find(string(name));
+  if (iter == properties_.end())
+    return -1;
+
+  int xsize = iter->second.size;
 
   for ( unsigned int i = 0 ; i < v.size() ; i++ ) {
@@ -2031,5 +2009,5 @@
 }
 
-int NROFITSDataset::readTable( vector<int> &v, char *name, int b, int idx ) 
+int NROFITSDataset::readTable( vector<int> &v, const char *name, int b, int idx ) 
 {
   //
@@ -2050,5 +2028,5 @@
 }
 
-int NROFITSDataset::readTable( vector<float> &v, char *name, int b, int idx ) 
+int NROFITSDataset::readTable( vector<float> &v, const char *name, int b, int idx ) 
 {
   //
@@ -2069,5 +2047,5 @@
 }
 
-int NROFITSDataset::readTable( vector<double> &v, char *name, int b, int idx ) 
+int NROFITSDataset::readTable( vector<double> &v, const char *name, int b, int idx ) 
 {
   //
@@ -2088,5 +2066,5 @@
 }
 
-int NROFITSDataset::readColumn( vector<string> &v, char *name, int idx )
+int NROFITSDataset::readColumn( vector<string> &v, const char *name, int idx )
 {
   // 
@@ -2098,14 +2076,9 @@
     return status ;
 
-  // get length of char
-  int index = -1 ;
-  for ( int i = 0 ; i < numField_ ; i++ ) {
-    if ( names_[i] == name ) {
-      index = i ;
-      break ;
-    }
-  }
-
-  int xsize = sizes_[index] ;
+  map<string, FieldProperty>::iterator iter = properties_.find(string(name));
+  if (iter == properties_.end())
+    return -1;
+
+  int xsize = iter->second.size;
 
   for ( unsigned int i = 0 ; i < v.size() ; i++ ) {
@@ -2132,5 +2105,5 @@
 }
 
-int NROFITSDataset::readColumn( vector<int> &v, char *name, int b, int idx )
+int NROFITSDataset::readColumn( vector<int> &v, const char *name, int b, int idx )
 {
   // 
@@ -2155,5 +2128,5 @@
 }
 
-int NROFITSDataset::readColumn( vector<float> &v, char *name, int b, int idx ) 
+int NROFITSDataset::readColumn( vector<float> &v, const char *name, int b, int idx ) 
 {
   // 
@@ -2178,5 +2151,5 @@
 }
 
-int NROFITSDataset::readColumn( vector<double> &v, char *name, int b, int idx ) 
+int NROFITSDataset::readColumn( vector<double> &v, const char *name, int b, int idx ) 
 {
   // 
@@ -2244,5 +2217,5 @@
 }
 
-int NROFITSDataset::movePointer( char *name, int idx ) 
+int NROFITSDataset::movePointer( const char *name, int idx ) 
 {
   // find offset
@@ -2260,7 +2233,2 @@
   return 0 ;
 }
-
-// double NROFITSDataset::toLSR( double v, double t, double x, double y ) 
-// {
-//   return v ;
-// }
