EleFits  5.0.0
A modern C++ API on top of CFITSIO

◆ parse()

Record< T > parse ( const std::string keyword) const

Parse a record.

Template Parameters
TThe record value type
Parameters
keywordThe record keyword
fallbackThe fallback record, keyword of which is looked for

There are two ways to parse a record: with or without a fallback, that is, a record which is returned if the specified keyword is not found in the header. Without a fallback, the expected return value type is provided as the template parameter. When a fallback is provided, the return type is the fallback type, by default, and the template parameter can be omitted.

Example usages:

// Parse a record
Record<int> record = h.parse<int>("INT");
// Parse a record and keep the value only
int value = h.parse<int>("INT");
// Parse a record if available, or get a fallback value
auto record = h.parseOr<int>("INT", -1);
// The above line is a shortcut for
Record<int> record("INT", -1);
if (h.has(record.keyword)) {
record = h.parse<T>(record.keyword);
}

where h is a Header.