FACT++  1.0
vector< MyColumn > FitsDumper::InitColumns ( vector< string >  list)
private

Definition at line 203 of file fitsdump.cc.

References first, fits::GetColumns(), and fits::SetPtrAddress().

Referenced by Exec().

204 {
205  static const boost::regex expr("([[:word:].]+)(\\[([[:digit:]]+)?(:)?([[:digit:]]+)?\\])?");
206 
207  const fits::Table::Columns &fColMap = GetColumns();
208 
209  if (names.empty())
210  for (auto it=fColMap.begin(); it!=fColMap.end(); it++)
211  if (it->second.num>0)
212  names.push_back(it->first);
213 
214  vector<MyColumn> vec;
215 
216  for (auto it=names.begin(); it!=names.end(); it++)
217  {
218  boost::smatch what;
219  if (!boost::regex_match(*it, what, expr, boost::match_extra))
220  {
221  cerr << "Couldn't parse expression '" << *it << "' " << endl;
222  return vector<MyColumn>();
223  }
224 
225  const string name = what[1];
226 
227  const auto iter = fColMap.find(name);
228  if (iter==fColMap.end())
229  {
230  cerr << "ERROR - Column '" << name << "' not found in table." << endl;
231  return vector<MyColumn>();
232  }
233 
234  const fits::Table::Column &col = iter->second;
235 
236  const string val0 = what[3];
237  const string delim = what[4];
238  const string val1 = what[5];
239 
240  const uint32_t first = atol(val0.c_str());
241  const uint32_t last = (val0.empty() && delim.empty()) ? col.num-1 : (val1.empty() ? first : atoi(val1.c_str()));
242 
243  if (first>=col.num)
244  {
245  cerr << "ERROR - First index " << first << " for column " << name << " exceeds number of elements " << col.num << endl;
246  return vector<MyColumn>();
247  }
248 
249  if (last>=col.num)
250  {
251  cerr << "ERROR - Last index " << last << " for column " << name << " exceeds number of elements " << col.num << endl;
252  return vector<MyColumn>();
253  }
254 
255  if (first>last)
256  {
257  cerr << "ERROR - Last index " << last << " for column " << name << " exceeds first index " << first << endl;
258  return vector<MyColumn>();
259  }
260 
261  MyColumn mycol;
262 
263  mycol.name = name;
264  mycol.col = col;
265  mycol.first = first;
266  mycol.last = last;
267  mycol.ptr = SetPtrAddress(name);
268 
269  vec.push_back(mycol);
270  }
271 
272  return vec;
273 }
void * SetPtrAddress(const std::string &name)
Definition: fits.h:886
std::map< std::string, Column > Columns
Definition: fits.h:113
int64_t first
Size of this column in the tile.
Definition: zofits.h:26
const Table::Columns & GetColumns() const
Definition: fits.h:1004

+ Here is the call graph for this function:

+ Here is the caller graph for this function: