EleFits
4.0.0
A modern C++ API on top of CFitsIO
|
◆ parseStructOr() [2/2]
template<typename TOut , typename TSeq >
Parse a sequence of records if they exist, return fallbacks for those which don't. Parse a sequence of records.
Several methods are provided to return records or record values as a user-defined structure, instead of a struct TOut {
T0 p0;
T1 p1;
T2 p2;
};
or a class with such a constructor: TOut::TOut(T0 p0, T1 p1, T2 p2)
where The output structure can be used to mimic a named tuple, which is generally more convenient than a Example usage: struct Body {
int age;
float height;
float mass;
float bmi() const { return mass / (height * height); }
};
// Body can be constructed from a brace-enclosed list:
// Body body { name, age, height, mass };
auto body = hdu.parseStruct<Body>(
Named<std::string>("NAME"),
Named<int>("AGE"),
Named<float>("HEIGHT"),
Named<float>("MASS"));
|