◆ parse_struct_or() [1/2]
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 {
std::string name;
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.parse_struct<Body>(
as<std::string>("NAME"),
as<int>("AGE"),
as<float>("HEIGHT"),
as<float>("MASS"));
T endl(T... args) |