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

◆ parseSeqOr() [2/2]

std::tuple< Record< Ts >... > parseSeqOr ( const Record< Ts > &...  fallbacks) const

Parse a heterogeneous sequence of records if they exist, return fallbacks for those which don't.

Template Parameters
TThe record value type for homogeneous sequences (automatically deduced with fallbacks)
Ts...The record value types for heterogeneous sequences (automatically deduced with fallbacks)
TSeqThe record sequence type (automatically deduced)
Parameters
keywordsThe keywords
fallbacksThe fallback records, keywords of which are looked for

Like for single record reading, there are two ways to parse a sequence of records: with or without fallbacks. For each record to be parsed, if the specified keyword is not found in the header, the fallback is returned.

When working with fallbacks, the return type is the same as the type of fallbacks.

Example usages without fallbacks:

// Homogeneous records
auto vector = h.parseSeq<int>({"A", "B", "C"});
// Heterogeneous records
auto tuple = h.parseSeq(as<int>("INT"), as<float>("FLOAT"));

Example usages with fallbacks:

// std::vector to std::vector
std::vector<Records<VariantValue>> fallbacks {{"ONE", 1}, {"TWO", 2.0}};
auto vector = h.parseSeqOr(fallbacks);
// RecordVec to RecordVec
RecordSeq fallbacks {{{"ONE", 1}, {"TWO", 2.0}}};
auto recVec = h.parseSeqOr(fallbacks);
// std::tuple to std::tuple
auto fallbacks = std::make_tuple(Record<int>("ONE", 1), Record<double>("TWO", 2.0));
auto tuple = h.parseSeqOr(fallbacks);
// Variadic to std::tuple
auto tuple = h.parseSeqOr(Record<int>("INT", 0), Record<float>("FLOAT", 3.14));
RecordVec< VariantValue > RecordSeq
A sequence of records of any type.
Definition: RecordVec.h:126
T make_tuple(T... args)