Add more support for strings

This commit is contained in:
Guilhem Lavaux 2019-08-21 11:19:03 +03:00
parent 2c48088476
commit 1bd685e9c5

View File

@ -263,6 +263,35 @@ namespace CosmoTool {
} }
}; };
struct CosmoString {
char const * s;
operator char const *() { return s; }
char const *operator=(char const *s0) {
s = s0;
return s0;
}
};
class hdf5_CosmoStringType {
public:
H5::StrType type;
hdf5_CosmoStringType() : type(H5::PredType::C_S1, H5T_VARIABLE) {
}
static const hdf5_CosmoStringType *ctype()
{
static hdf5_CosmoStringType singleton;
return &singleton;
}
};
template<> struct get_hdf5_data_type<CosmoString> {
static H5::DataType type() {
return hdf5_CosmoStringType::ctype()->type;
}
};
template<typename ArrayType> template<typename ArrayType>
void hdf5_write_array(H5_CommonFileGroup& fg, const std::string& data_set_name, const ArrayType& data ) void hdf5_write_array(H5_CommonFileGroup& fg, const std::string& data_set_name, const ArrayType& data )
{ {