EleFits  5.3.1
A modern C++ API on top of CFITSIO
Loading...
Searching...
No Matches

◆ 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.parse_or<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);
}
Keyword-value pair with optional unit and comment.
Definition: Record.h:101
std::string keyword
The keyword.
Definition: Record.h:227

where h is a Header.

Examples
EleFitsTutorial.cpp.