FACT++  1.0
void CompressedFitsFile::HeaderEntry::buildFitsString ( )
inlineprivate

Construct the FITS header string from the key, value and comment

Definition at line 134 of file fitsDecompressor.cc.

References i, and str.

135  {
136  ostringstream str;
137  unsigned int totSize = 0;
138 
139  // Tuncate the key if required
140  if (_key.length() > 8)
141  {
142  str << _key.substr(0, 8);
143  totSize += 8;
144  }
145  else
146  {
147  str << _key;
148  totSize += _key.length();
149  }
150 
151  // Append space if key is less than 8 chars long
152  for (int i=totSize; i<8;i++)
153  {
154  str << " ";
155  totSize++;
156  }
157 
158  // Add separator
159  str << "= ";
160  totSize += 2;
161 
162  // Format value
163  if (_value.length() < 20)
164  for (;totSize<30-_value.length();totSize++)
165  str << " ";
166 
167  if (_value.length() > 70)
168  {
169  str << _value.substr(0,70);
170  totSize += 70;
171  }
172  else
173  {
174  str << _value;
175  totSize += _value.size();
176  }
177 
178  // If there is space remaining, add comment area
179  if (totSize < 77)
180  {
181  str << " / ";
182  totSize += 3;
183  if (totSize < 80)
184  {
185  unsigned int commentSize = 80 - totSize;
186  if (_comment.length() > commentSize)
187  {
188  str << _comment.substr(0,commentSize);
189  totSize += commentSize;
190  }
191  else
192  {
193  str << _comment;
194  totSize += _comment.length();
195  }
196  }
197  }
198 
199  // If there is yet some free space, fill up the entry with spaces
200  for (int i=totSize; i<80;i++)
201  str << " ";
202 
203  _fitsString = str.str();
204 
205  // Check for correct completion
206  if (_fitsString.length() != 80)
207  cout << "Error |" << _fitsString << "| is not of length 80" << endl;
208  }
string _comment
the comment associated to the header entry
string _value
the value of the header entry
int i
Definition: db_dim_client.c:21
char str[80]
Definition: test_client.c:7
string _key
the key (name) of the header entry
string _fitsString
the string that will be written to the fits file