19 using type_no_const =
typename std::remove_const<T>::type;
20 using elem_type =
typename details::type_of_array<type_no_const>::type;
21 using char_array_t =
typename details::type_char_array<type_no_const>::type;
22 static constexpr
bool is_char_array = ! std::is_same<char_array_t, void>::value;
24 BufferInfo(
const DataType& dtype);
27 const bool is_fixed_len_string;
28 const size_t n_dimensions;
29 const DataType data_type;
33 template <
typename SrcStrT>
34 struct string_type_checker {
35 static DataType getDataType(
const DataType&,
bool);
39 struct string_type_checker<void> {
40 inline static DataType getDataType(
const DataType& element_type,
bool) {
44 template <std::
size_t FixedLen>
45 struct string_type_checker<char[FixedLen]> {
46 inline static DataType getDataType(
const DataType& element_type,
bool ds_fixed_str) {
47 return ds_fixed_str ? AtomicType<char[FixedLen]>() : element_type;
51 struct string_type_checker<char*> {
52 inline static DataType getDataType(
const DataType&,
bool ds_fixed_str) {
54 throw DataSetException(
"Can't output variable-length to fixed-length strings");
55 return AtomicType<std::string>();
59 BufferInfo<T>::BufferInfo(
const DataType& dtype)
60 : is_fixed_len_string(dtype.isFixedLenStr())
62 , n_dimensions(details::array_dims<type_no_const>::value -
63 ((is_fixed_len_string && is_char_array) ? 1 : 0))
64 , data_type(string_type_checker<char_array_t>::getDataType(
66 if (is_fixed_len_string && std::is_same<elem_type, std::string>::value) {
67 throw DataSetException(
"Can't output std::string as fixed-length. "
68 "Use raw arrays or FixedLenStringArray");
71 if (dtype.getClass() != data_type.getClass()) {
72 std::cerr <<
"HighFive WARNING: data and hdf5 dataset have different types: "
73 << data_type.string() <<
" -> " << dtype.string() << std::endl;
Definition: H5_definitions.hpp:15
DataType create_datatype()
Create a DataType instance representing type T.
Definition: H5DataType_misc.hpp:399