r97: Converted Scanner and Projections to C++
[ctsim.git] / include / imagefile.h
index 70c3fe40b4f914b1364fd33c235a81f7cc1b83c1..ccf376905fe670c38a1233c52cbdb10e2260db25 100644 (file)
@@ -17,15 +17,16 @@ private:
     Array2dFileLabel& operator= (const Array2dFileLabel&);
 
 public:
-    kfloat64 calc_time;
-    kuint16 label_type;
-    kuint16 year;
-    kuint16 month;
-    kuint16 day;
-    kuint16 hour;
-    kuint16 minute;
-    kuint16 second;
-    string label_str;
+    kfloat64 m_calcTime;
+    kuint16 m_labelType;
+    kuint16 m_year;
+    kuint16 m_month;
+    kuint16 m_day;
+    kuint16 m_hour;
+    kuint16 m_minute;
+    kuint16 m_second;
+    string m_strLabel;
+    mutable string m_strDate;
 
     static const int L_EMPTY = 0;
     static const int L_HISTORY = 1;
@@ -39,22 +40,22 @@ public:
 
     ~Array2dFileLabel();
 
-    string getLabelString (void) const
-       { return label_str; }
+    const string& getLabelString (void) const
+       { return m_strLabel; }
 
     kfloat64 getCalcTime (void) const
-       { return calc_time; }
+       { return m_calcTime; }
 
     kfloat64 getLabelType (void) const
-       { return label_type; }
+       { return m_labelType; }
 
     string& setLabelString (const char* const str)
-       { label_str = str; return (label_str); }
+       { m_strLabel = str; return (m_strLabel); }
 
     string& setLabelString (const string& str)
-       { label_str = str; return (label_str); }
+       { m_strLabel = str; return (m_strLabel); }
 
-    void getDateString (string& str) const;
+    const string& getDateString () const;
 };
 
 
@@ -118,9 +119,9 @@ public:
 
   void labelAdd (const Array2dFileLabel& label);
 
-  void labelAdd (const char* const label_str, double calc_time=0.);
+  void labelAdd (const char* const m_strLabel, double calc_time=0.);
 
-  void labelAdd (int type, const char* const label_str, double calc_time=0.);
+  void labelAdd (int type, const char* const m_strLabel, double calc_time=0.);
 
   void labelsCopy (Array2dFile& file, const char* const idStr = NULL);
 
@@ -524,20 +525,21 @@ Array2dFile<T>::labelRead (Array2dFileLabel& label, unsigned int label_num)
     return (false);
   }
 
-  read_nint16 (&label.label_type, file_id);
-  read_nint16 (&label.year, file_id);
-  read_nint16 (&label.month, file_id);
-  read_nint16 (&label.day, file_id);
-  read_nint16 (&label.hour, file_id);
-  read_nint16 (&label.minute, file_id);
-  read_nint16 (&label.second, file_id);
-  read_nfloat64 (&label.calc_time, file_id);
+  read_nint16 (&label.m_labelType, file_id);
+  read_nint16 (&label.m_year, file_id);
+  read_nint16 (&label.m_month, file_id);
+  read_nint16 (&label.m_day, file_id);
+  read_nint16 (&label.m_hour, file_id);
+  read_nint16 (&label.m_minute, file_id);
+  read_nint16 (&label.m_second, file_id);
+  read_nfloat64 (&label.m_calcTime, file_id);
 
   kuint16 strlength;
   read_nint16 (&strlength, file_id);
-  char *str = new char [strlength+1];
+  char str [strlength+1];
   read (file_id, str, strlength);
-  label.label_str = str;
+  str[strlength] = 0;
+  label.m_strLabel = str;
 
   return (true);
 }
@@ -565,17 +567,17 @@ Array2dFile<T>::labelAdd (const Array2dFileLabel& label)
 {
   labelSeek (num_labels);
   
-  write_nint16 (&label.label_type, file_id);
-  write_nint16 (&label.year, file_id);
-  write_nint16 (&label.month, file_id);
-  write_nint16 (&label.day, file_id);
-  write_nint16 (&label.hour, file_id);
-  write_nint16 (&label.minute, file_id);
-  write_nint16 (&label.second, file_id);
-  write_nfloat64 (&label.calc_time, file_id);
-  kuint16 strlength = label.label_str.length();
+  write_nint16 (&label.m_labelType, file_id);
+  write_nint16 (&label.m_year, file_id);
+  write_nint16 (&label.m_month, file_id);
+  write_nint16 (&label.m_day, file_id);
+  write_nint16 (&label.m_hour, file_id);
+  write_nint16 (&label.m_minute, file_id);
+  write_nint16 (&label.m_second, file_id);
+  write_nfloat64 (&label.m_calcTime, file_id);
+  kuint16 strlength = label.m_strLabel.length();
   write_nint16 (&strlength, file_id);
-  write (file_id, static_cast<const void*>(label.label_str.c_str()), strlength);
+  write (file_id, static_cast<const void*>(label.m_strLabel.c_str()), strlength);
 
   num_labels++;