EleFits
4.0.1
A modern C++ API on top of CFitsIO
|
◆ parseOr() [1/2]Parse a record if it exists, return a fallback record otherwise.
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 |