FACT++  1.0
bool ofits::Set ( const std::string &  key = "",
bool  delim = false,
const std::string &  value = "",
const std::string &  comment = "" 
)
inlineprivate

Definition at line 260 of file ofits.h.

References ___err___, ofits::Key::check(), ofits::Key::comment, ofits::Key::delim, fCommentTrimming, findkey(), fTable, gLog, ofits::Key::key, ofits::Table::num_rows, and ofits::Key::value.

Referenced by AddComment(), AddEmpty(), AddHistory(), End(), SetBool(), SetFloat(), SetInt(), SetRaw(), and SetStr().

261  {
262  // If no delimit add the row no matter if it alread exists
263  if (delim)
264  {
265  // if the row already exists: update it
266  auto it = findkey(key);
267  if (it!=fKeys.end())
268  {
269  it->value = value;
270  it->changed = true;
271  return true;
272  }
273  }
274 
275  if (fTable.num_rows>0)
276  {
277  std::ostringstream sout;
278  sout << "No new header key can be defined, rows were already written to the file... ignoring new key '" << key << "'";
279 #ifdef __EXCEPTIONS
280  throw std::runtime_error(sout.str());
281 #else
282  gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
283  return false;
284 #endif
285  }
286 
287  Key entry;
288 
289  entry.key = key;
290  entry.delim = delim;
291  entry.value = value;
292  entry.comment = comment;
293 
294  if (!entry.check(fCommentTrimming))
295  return false;
296 
297  fKeys.emplace_back(entry);
298  return true;
299  }
#define gLog
Definition: fits.h:36
#define ___err___
Definition: fits.h:37
Table fTable
Definition: ofits.h:327
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
bool fCommentTrimming
Definition: ofits.h:343

+ Here is the call graph for this function:

+ Here is the caller graph for this function: