FACT++  1.0
void writeValuesFromFits ( vector< int > &  offsets,
ofstream &  targetFile,
unsigned char *  fitsBuffer,
vector< string >  dumpList,
map< string, CCfits::Column * > &  colMap 
)

Definition at line 10 of file simpleFitsDumper.cc.

Referenced by main().

11 {
12  targetFile.precision(20);
13  map<string, CCfits::Column*>::iterator it;
14  for (it=colMap.begin(); it != colMap.end(); it++)
15  {
16  bool found = false;
17  for (vector<string>::iterator jt=dumpList.begin(); jt != dumpList.end(); jt++)
18  {
19  if (it->first == *jt)
20  {
21  found = true;
22  break;
23  }
24  }
25  if (!found)
26  continue;
27  int offset = offsets[it->second->index()-1];
28  const char* charSrc = reinterpret_cast<char*>(&fitsBuffer[offset]);
29  unsigned char copyBuffer[30];//max size of a single variable
30  for (int width = 0; width<it->second->width(); width++)
31  {
32  switch (it->second->type())
33  {
34  case CCfits::Tbyte:
35  targetFile << *charSrc;
36  charSrc += sizeof(char);
37  break;
38  case CCfits::Tushort:
39  reverse_copy(charSrc, charSrc+sizeof(unsigned short), copyBuffer);
40  targetFile << *reinterpret_cast<const unsigned short*>(copyBuffer);
41  charSrc += sizeof(char);
42  break;
43  case CCfits::Tshort:
44  reverse_copy(charSrc, charSrc+sizeof(short), copyBuffer);
45  targetFile << *reinterpret_cast<const short*>(copyBuffer);
46  charSrc += sizeof(char);
47  break;
48  case CCfits::Tuint:
49  reverse_copy(charSrc, charSrc+sizeof(unsigned int), copyBuffer);
50  //warning suppressed in gcc4.0.2
51  targetFile << *reinterpret_cast<unsigned int*>(copyBuffer);
52  charSrc += sizeof(int);
53  break;
54  case CCfits::Tint:
55  reverse_copy(charSrc, charSrc+sizeof(int), copyBuffer);
56  targetFile << *reinterpret_cast<int*>(copyBuffer);
57  charSrc += sizeof(int);
58  break;
59  case CCfits::Tulong:
60  reverse_copy(charSrc, charSrc+sizeof(unsigned long), copyBuffer);
61  targetFile << *reinterpret_cast<unsigned long*>(copyBuffer);
62  charSrc += sizeof(int);
63  break;
64  case CCfits::Tlong:
65  reverse_copy(charSrc, charSrc+sizeof(long), copyBuffer);
66  targetFile << *reinterpret_cast<long*>(copyBuffer);
67  charSrc += sizeof(int);
68  break;
69  case CCfits::Tlonglong:
70  reverse_copy(charSrc, charSrc+sizeof(long long), copyBuffer);
71  targetFile << *reinterpret_cast<long long*>(copyBuffer);
72  charSrc += sizeof(long long);
73  break;
74  case CCfits::Tfloat:
75  reverse_copy(charSrc, charSrc+sizeof(float), copyBuffer);
76  targetFile << *reinterpret_cast<float*>(copyBuffer);
77  charSrc += sizeof(float);
78  break;
79  case CCfits::Tdouble:
80  reverse_copy(charSrc, charSrc+sizeof(double), copyBuffer);
81  targetFile << *reinterpret_cast<double*>(copyBuffer);
82  charSrc += sizeof(double);
83  break;
84  case CCfits::Tnull:
85  case CCfits::Tbit:
86  case CCfits::Tlogical:
87  case CCfits::Tstring:
88  case CCfits::Tcomplex:
89  case CCfits::Tdblcomplex:
90  case CCfits::VTbit:
91  case CCfits::VTbyte:
92  case CCfits::VTlogical:
93  case CCfits::VTushort:
94  case CCfits::VTshort:
95  case CCfits::VTuint:
96  case CCfits::VTint:
97  case CCfits::VTulong:
98  case CCfits::VTlong:
99  case CCfits::VTlonglong:
100  case CCfits::VTfloat:
101  case CCfits::VTdouble:
102  case CCfits::VTcomplex:
103  case CCfits::VTdblcomplex:
104  cout << "Data type not implemented yet." << endl;
105  return;
106  break;
107  default:
108  cout << "THIS SHOULD NEVER BE REACHED" << endl;
109  return;
110  }//switch
111  targetFile << " ";
112  }//width loop
113  }//iterator over the columns
114  targetFile << endl;
115 }

+ Here is the caller graph for this function: