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

◆ parse_n() [2/2]

std::tuple< Record< Ts >... > parse_n ( const TypedKey< Ts, std::string > &...  keywords) const

Parse a sequence of heterogeneous records.

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.parse_n<int>({"A", "B", "C"});
// Heterogeneous records
auto tuple = h.parse_n(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.parse_n_or(fallbacks);
// RecordVec to RecordVec
RecordSeq fallbacks {{{"ONE", 1}, {"TWO", 2.0}}};
auto rec_vec = h.parse_n_or(fallbacks);
// std::tuple to std::tuple
auto fallbacks = std::make_tuple(Record<int>("ONE", 1), Record<double>("TWO", 2.0));
auto tuple = h.parse_n_or(fallbacks);
// Variadic to std::tuple
auto tuple = h.parse_n_or(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)