FACT++  1.0
bool ofits::CopyKeys ( const fits fin,
bool  update = false 
)
inline

Definition at line 466 of file ofits.h.

References ___err___, findkey(), fits::GetKeys(), gLog, FITS::IsReservedKeyWord(), ofits::Key::key, and ofits::Table::num_rows.

467  {
468  if (fTable.num_rows>0)
469  {
470 #ifdef __EXCEPTIONS
471  throw std::runtime_error("No header keys can be copied, rows were already written to the file... ignoring CopyKeys().");
472 #else
473  gLog << ___err___ << "ERROR - No header key can be copyied, rows were already written to the file... ignoring CopyKeys()." << std::endl;
474  return false;
475 #endif
476  }
477 
478  const auto &keys = fin.GetKeys();
479 
480  // We can assume that the keys are all valid
481  for (auto it=keys.cbegin(); it!=keys.cend(); it++)
482  {
483  const std::string &key = it->first;
484 
485  if (FITS::IsReservedKeyWord(key))
486  continue;
487 
488  const auto &entry = it->second;
489 
490  // If no delimit add the row no matter if it alread exists
491  if (entry.fitsString[9]=='=')
492  {
493  // if the row already exists: remove it
494  const auto it2 = findkey(key);
495  if (it2!=fKeys.end())
496  {
497  if (!update)
498  continue;
499 
500  fKeys.erase(it2);
501  }
502  }
503 
504  fKeys.emplace_back(entry.fitsString);
505  }
506 
507  return true;
508  }
static bool IsReservedKeyWord(const std::string &key)
Definition: FITS.h:26
#define gLog
Definition: fits.h:36
#define ___err___
Definition: fits.h:37
Table fTable
Definition: ofits.h:327
const Table::Keys & GetKeys() const
Definition: fits.h:1006
std::vector< Key > fKeys
Definition: ofits.h:249
std::vector< Key >::iterator findkey(const std::string &key)
Definition: ofits.h:251
size_t num_rows
Definition: ofits.h:307

+ Here is the call graph for this function: