FACT++  1.0
void FitsLoader::writeValuesFromFits ( vector< int > &  offsets,
ofstream &  targetFile,
unsigned char *  fitsBuffer 
)
private

Write a single row of the selected data.

Writes a single row of the selected FITS data to the output file.

Parameters
offsetsa vector containing the offsets to the columns (in bytes)
targetFilethe ofstream where to write to
fitsBufferthe memory were the row has been loaded by cfitsio

Definition at line 164 of file fitsloader.cc.

References MessageImp::Error(), fColMap, fDumpList, and fStreamPrecision.

Referenced by DoDumpPlease().

165 {
166  targetFile.precision(fStreamPrecision);
167  map<string, CCfits::Column*>::iterator it;
168  for (it=fColMap.begin(); it != fColMap.end(); it++)
169  {
170  bool found = false;
171  for (vector<string>::iterator jt=fDumpList.begin(); jt != fDumpList.end(); jt++)
172  {
173  if (it->first == *jt)
174  {
175  found = true;
176  break;
177  }
178  }
179  if (!found)
180  continue;
181  int offset = offsets[it->second->index()-1];
182  const char* charSrc = reinterpret_cast<char*>(&fitsBuffer[offset]);
183  unsigned char copyBuffer[30];//max size of a single variable
184  for (int width = 0; width<it->second->width(); width++)
185  {
186  switch (it->second->type())
187  {
188  case CCfits::Tbyte:
189  targetFile << *charSrc;
190  charSrc += sizeof(char);
191  break;
192  case CCfits::Tushort:
193  targetFile << *reinterpret_cast<const unsigned short*>(charSrc);
194  charSrc += sizeof(char);
195  break;
196  case CCfits::Tshort:
197  targetFile << *reinterpret_cast<const short*>(charSrc);
198  charSrc += sizeof(char);
199  break;
200  case CCfits::Tuint:
201  reverse_copy(charSrc, charSrc+sizeof(unsigned int), copyBuffer);
202  //warning suppressed in gcc4.0.2
203  targetFile << *reinterpret_cast<unsigned int*>(copyBuffer);
204  charSrc += sizeof(int);
205  break;
206  case CCfits::Tint:
207  reverse_copy(charSrc, charSrc+sizeof(int), copyBuffer);
208  targetFile << *reinterpret_cast<int*>(copyBuffer);
209  charSrc += sizeof(int);
210  break;
211  case CCfits::Tulong:
212  reverse_copy(charSrc, charSrc+sizeof(unsigned long), copyBuffer);
213  targetFile << *reinterpret_cast<unsigned long*>(copyBuffer);
214  charSrc += sizeof(int);
215  break;
216  case CCfits::Tlong:
217  reverse_copy(charSrc, charSrc+sizeof(long), copyBuffer);
218  targetFile << *reinterpret_cast<long*>(copyBuffer);
219  charSrc += sizeof(int);
220  break;
221  case CCfits::Tlonglong:
222  reverse_copy(charSrc, charSrc+sizeof(long long), copyBuffer);
223  targetFile << *reinterpret_cast<long long*>(copyBuffer);
224  charSrc += sizeof(long long);
225  break;
226  case CCfits::Tfloat:
227  reverse_copy(charSrc, charSrc+sizeof(float), copyBuffer);
228  targetFile << *reinterpret_cast<float*>(copyBuffer);
229  charSrc += sizeof(float);
230  break;
231  case CCfits::Tdouble:
232  reverse_copy(charSrc, charSrc+sizeof(double), copyBuffer);
233  targetFile << *reinterpret_cast<double*>(copyBuffer);
234  charSrc += sizeof(double);
235  break;
236  case CCfits::Tnull:
237  case CCfits::Tbit:
238  case CCfits::Tlogical:
239  case CCfits::Tstring:
240  case CCfits::Tcomplex:
241  case CCfits::Tdblcomplex:
242  case CCfits::VTbit:
243  case CCfits::VTbyte:
244  case CCfits::VTlogical:
245  case CCfits::VTushort:
246  case CCfits::VTshort:
247  case CCfits::VTuint:
248  case CCfits::VTint:
249  case CCfits::VTulong:
250  case CCfits::VTlong:
251  case CCfits::VTlonglong:
252  case CCfits::VTfloat:
253  case CCfits::VTdouble:
254  case CCfits::VTcomplex:
255  case CCfits::VTdblcomplex:
256  Error("Data type not implemented yet.");
257  return;
258  break;
259  default:
260  Error("THIS SHOULD NEVER BE REACHED");
261  return;
262  }//switch
263  targetFile << " ";
264  }//width loop
265  }//iterator over the columns
266  targetFile << endl;
267 }
map< string, CCfits::Column * > fColMap
map between the column names and their CCfits objects
Definition: fitsloader.cc:82
int Error(const std::string &str)
Definition: MessageImp.h:49
vector< string > fDumpList
List of the column names to be dumped.
Definition: fitsloader.cc:84
int fStreamPrecision
Precision of the ofstream. Used to output a given number of significant digits for floats or doubles...
Definition: fitsloader.cc:78

+ Here is the call graph for this function:

+ Here is the caller graph for this function: