42 static const std::map<std::type_index, HH_hid_t> fundamental_types
43 = {{
typeid(bool), {H5T_NATIVE_HBOOL}},
44 {
typeid(
short int), {H5T_NATIVE_SHORT}},
45 {
typeid(
unsigned short int), {H5T_NATIVE_USHORT}},
46 {
typeid(
int), {H5T_NATIVE_INT}},
47 {
typeid(
unsigned int), {H5T_NATIVE_UINT}},
48 {
typeid(
long int), {H5T_NATIVE_LONG}},
49 {
typeid(
unsigned long int), {H5T_NATIVE_ULONG}},
50 {
typeid(
long long int), {H5T_NATIVE_LLONG}},
51 {
typeid(
unsigned long long int), {H5T_NATIVE_ULLONG}},
52 {
typeid(
signed char), {H5T_NATIVE_SCHAR}},
54 {
typeid(char), {H5T_NATIVE_CHAR}},
59 {
typeid(float), {H5T_NATIVE_FLOAT}},
60 {
typeid(double), {H5T_NATIVE_DOUBLE}},
61 {
typeid(
long double), {H5T_NATIVE_LDOUBLE}}};
63 if (!fundamental_types.count(
type))
throw Exception(
"HDF5 does not implement this type as a fundamental type.",
ioda_Here());
64 return fundamental_types.at(
type);
69 return Type{std::make_shared<HH_Type>(t),
type};
74 std::type_index typeOuter, std::type_index typeInner)
const {
78 std::vector<hsize_t> hdims;
79 for (
const auto&
d : dimensions) hdims.push_back(gsl::narrow<hsize_t>(
d));
80 hid_t t = H5Tarray_create2(fundamental_type(), gsl::narrow<unsigned int>(dimensions.size()),
85 return Type{std::make_shared<HH_Type>(hnd), typeOuter};
90 hid_t t = H5Tcreate(H5T_STRING, string_length);
92 if (H5Tset_cset(t, H5T_CSET_UTF8) < 0)
96 return Type{std::make_shared<HH_Type>(hnd), typeOuter};
HDF5 engine implementation of ioda::detail::Type_Provider.
HDF5 resource handles in C++.
Interfaces for ioda::Type and related classes.
The ioda exception class.
Represents the "type" (i.e. integer, string, float) of a piece of data.
This is the implementation of Type_Provider using HDF5. Do not use outside of IODA.
static HH_hid_t getFundamentalHHType(std::type_index type)
virtual ~HH_Type_Provider()
Type makeStringType(size_t string_length, std::type_index typeOuter) const final
Make a variable-length string type.
Type makeArrayType(std::initializer_list< Dimensions_t > dimensions, std::type_index typeOuter, std::type_index typeInner) const final
Type makeFundamentalType(std::type_index type) const final
Make a basic object type, like a double, a float, or a char.
static HH_Type_Provider * instance()
size_t getSize() const final
Get the size of a single element of a type, in bytes.
A class to wrap HDF5's hid_t resource handles.
Common preprocessor definitions used throughout IODA.
constexpr size_t _Variable_Length
static void CloseP(hid_t *h)