47 using T = std::underlying_type<DataTypeClass>::type;
48 return static_cast<DataTypeClass>(
static_cast<T
>(lhs) |
static_cast<T
>(rhs));
52 using T = std::underlying_type<DataTypeClass>::type;
53 return static_cast<DataTypeClass>(
static_cast<T
>(lhs) &
static_cast<T
>(rhs));
83 std::string
string()
const;
103 bool empty()
const noexcept;
110 return details::get_plist<DataTypeCreateProps>(*
this, H5Tget_create_plist);
120 template <
typename Derivate>
126 Ascii = H5T_CSET_ASCII,
127 Utf8 = H5T_CSET_UTF8,
143 using DataType::DataType;
204 :
name(std::move(t_name))
218 inline CompoundType(
const std::vector<member_def>& t_members,
size_t size = 0)
219 : members(t_members) {
222 inline CompoundType(std::vector<member_def>&& t_members,
size_t size = 0)
223 : members(std::move(t_members)) {
226 inline CompoundType(
const std::initializer_list<member_def>& t_members,
size_t size = 0)
227 : members(t_members) {
237 std::ostringstream ss;
238 ss <<
"hid " <<
_hid <<
" does not refer to a compound data type";
241 size_t n_members =
static_cast<size_t>(detail::h5t_get_nmembers(
_hid));
242 members.reserve(n_members);
243 for (
unsigned i = 0; i < n_members; i++) {
244 char* name = detail::h5t_get_member_name(
_hid, i);
245 size_t offset = detail::h5t_get_member_offset(
_hid, i);
246 hid_t member_hid = detail::h5t_get_member_type(
_hid, i);
248 members.emplace_back(std::string(name), member_type, offset);
250 detail::h5_free_memory(name);
257 inline void commit(
const Object&
object,
const std::string& name)
const;
260 inline const std::vector<member_def>&
getMembers() const noexcept {
266 std::vector<member_def> members;
271 void create(
size_t size = 0);
303 ,
value(std::move(t_value)) {}
311 : members(t_members) {
312 static_assert(std::is_enum<T>::value,
"EnumType<T>::create takes only enum");
313 if (members.empty()) {
315 "Could not create an enum without members");
320 EnumType(std::initializer_list<member_def> t_members)
326 void commit(
const Object&
object,
const std::string& name)
const;
329 std::vector<member_def> members;
345namespace deprecated {
355template <std::
size_t N>
383 void push_back(
const std::array<char, N>&);
388 std::string
getString(std::size_t index)
const;
391 inline const char*
operator[](std::size_t i)
const noexcept {
392 return datavec[i].data();
394 inline const char*
at(std::size_t i)
const {
395 return datavec.at(i).data();
397 inline bool empty() const noexcept {
398 return datavec.empty();
400 inline std::size_t
size() const noexcept {
401 return datavec.size();
407 return datavec.front().data();
409 inline const char*
back()
const {
410 return datavec.back().data();
413 return datavec[0].data();
415 inline const char*
data() const noexcept {
416 return datavec[0].data();
420 using vector_t =
typename std::vector<std::array<char, N>>;
431 return datavec.begin();
434 return datavec.end();
437 return datavec.begin();
440 return datavec.cbegin();
443 return datavec.end();
446 return datavec.cend();
449 return datavec.rbegin();
452 return datavec.rend();
455 return datavec.rbegin();
458 return datavec.rend();
468 deprecated::FixedLenStringArray<N>;
488#define HIGHFIVE_REGISTER_TYPE(type, function) \
490 inline HighFive::DataType HighFive::create_datatype<type>() { \
#define H5_DEPRECATED_USING(msg)
Definition H5_definitions.hpp:16
create an HDF5 DataType from a C++ type
Definition H5DataType.hpp:187
AtomicType()
Definition H5DataType_misc.hpp:235
T basic_type
Definition H5DataType.hpp:191
Class representing an Attribute of a DataSet or Group.
Definition H5Attribute.hpp:46
Create a compound HDF5 datatype.
Definition H5DataType.hpp:198
void commit(const Object &object, const std::string &name) const
Commit datatype into the given Object.
Definition H5DataType_misc.hpp:381
const std::vector< member_def > & getMembers() const noexcept
Get read access to the CompoundType members.
Definition H5DataType.hpp:260
CompoundType(const CompoundType &other)=default
CompoundType(const std::initializer_list< member_def > &t_members, size_t size=0)
Definition H5DataType.hpp:226
CompoundType(const std::vector< member_def > &t_members, size_t size=0)
Initializes a compound type from a vector of member definitions.
Definition H5DataType.hpp:218
CompoundType(DataType &&type)
Initializes a compound type from a DataType.
Definition H5DataType.hpp:234
CompoundType(std::vector< member_def > &&t_members, size_t size=0)
Definition H5DataType.hpp:222
Class representing a dataset.
Definition H5DataSet.hpp:30
Exception specific to HighFive DataType interface.
Definition H5Exception.hpp:94
HDF5 Data Type.
Definition H5DataType.hpp:61
bool operator==(const DataType &other) const
Definition H5DataType_misc.hpp:44
bool isFixedLenStr() const
Returns whether the type is a fixed-length string.
Definition H5DataType_misc.hpp:56
DataTypeCreateProps getCreatePropertyList() const
Get the list of properties for creation of this DataType.
Definition H5DataType.hpp:109
size_t getSize() const
Returns the length (in bytes) of this type elements.
Definition H5DataType_misc.hpp:40
bool isVariableStr() const
Returns whether the type is a variable-length string.
Definition H5DataType_misc.hpp:52
bool empty() const noexcept
Check the DataType was default constructed.
Definition H5DataType_misc.hpp:32
std::string string() const
Returns a friendly description of the type (e.g. Float32)
Definition H5DataType_misc.hpp:76
DataTypeClass getClass() const
Return the fundamental type.
Definition H5DataType_misc.hpp:36
bool isReference() const
Returns whether the type is a Reference.
Definition H5DataType_misc.hpp:60
StringType asStringType() const
Returns this datatype as a StringType.
Definition H5DataType_misc.hpp:64
bool operator!=(const DataType &other) const
Definition H5DataType_misc.hpp:48
Create a enum HDF5 datatype.
Definition H5DataType.hpp:296
EnumType(std::initializer_list< member_def > t_members)
Definition H5DataType.hpp:320
EnumType(const EnumType &other)=default
void commit(const Object &object, const std::string &name) const
Commit datatype into the given Object.
Definition H5DataType_misc.hpp:398
EnumType(const std::vector< member_def > &t_members)
Definition H5DataType.hpp:310
File class.
Definition H5File.hpp:24
Definition H5DataType.hpp:147
FixedLengthStringType(size_t size, StringPadding padding, CharacterSet character_set=CharacterSet::Ascii)
Create a fixed length string datatype.
Definition H5DataType_misc.hpp:88
NodeTraits: Base class for Group and File.
Definition H5Node_traits.hpp:28
Definition H5Object.hpp:54
Object()
Definition H5Object_misc.hpp:25
hid_t _hid
Definition H5Object.hpp:105
HDF5 property Lists.
Definition H5PropertyList.hpp:160
An HDF5 (object) reference type.
Definition H5Reference.hpp:33
Definition H5DataType.hpp:130
StringPadding getPadding() const
For fixed length stings return the padding.
Definition H5DataType_misc.hpp:80
CharacterSet getCharacterSet() const
For stings return the character set.
Definition H5DataType_misc.hpp:84
Definition H5DataType.hpp:172
VariableLengthStringType(CharacterSet character_set=CharacterSet::Ascii)
Create a variable length string HDF5 datatype.
Definition H5DataType_misc.hpp:103
A structure representing a set of fixed-length strings.
Definition H5DataType.hpp:356
typename vector_t::const_iterator const_iterator
Definition H5DataType.hpp:425
const_iterator end() const noexcept
Definition H5DataType.hpp:442
const_iterator cend() const noexcept
Definition H5DataType.hpp:445
void resize(std::size_t n)
Definition H5DataType.hpp:403
bool empty() const noexcept
Definition H5DataType.hpp:397
const char * front() const
Definition H5DataType.hpp:406
const_iterator cbegin() const noexcept
Definition H5DataType.hpp:439
void push_back(const std::string &)
Append an std::string to the buffer structure.
Definition H5DataType_misc.hpp:268
const char * back() const
Definition H5DataType.hpp:409
typename vector_t::reverse_iterator reverse_iterator
Definition H5DataType.hpp:426
const char * at(std::size_t i) const
Definition H5DataType.hpp:394
const char * operator[](std::size_t i) const noexcept
Definition H5DataType.hpp:391
std::string getString(std::size_t index) const
Retrieve a string from the structure as std::string.
Definition H5DataType_misc.hpp:282
reverse_iterator rend() noexcept
Definition H5DataType.hpp:451
typename vector_t::const_reverse_iterator const_reverse_iterator
Definition H5DataType.hpp:427
const_iterator begin() const noexcept
Definition H5DataType.hpp:436
FixedLenStringArray()=default
const_reverse_iterator rbegin() const noexcept
Definition H5DataType.hpp:454
iterator begin() noexcept
Definition H5DataType.hpp:430
char * data() noexcept
Definition H5DataType.hpp:412
typename vector_t::value_type value_type
Definition H5DataType.hpp:428
reverse_iterator rbegin() noexcept
Definition H5DataType.hpp:448
iterator end() noexcept
Definition H5DataType.hpp:433
const_reverse_iterator rend() const noexcept
Definition H5DataType.hpp:457
typename vector_t::iterator iterator
Definition H5DataType.hpp:424
std::size_t size() const noexcept
Definition H5DataType.hpp:400
const char * data() const noexcept
Definition H5DataType.hpp:415
Definition H5_definitions.hpp:22
DataType create_and_check_datatype()
Create a DataType instance representing type T and perform a sanity check on its size.
Definition H5DataType_misc.hpp:486
DataType create_datatype()
Create a DataType instance representing type T.
Definition H5DataType_misc.hpp:479
CharacterSet
Definition H5DataType.hpp:125
DataTypeClass operator|(DataTypeClass lhs, DataTypeClass rhs)
Definition H5DataType.hpp:46
DataTypeClass operator&(DataTypeClass lhs, DataTypeClass rhs)
Definition H5DataType.hpp:51
DataTypeClass
Enum of Fundamental data classes.
Definition H5DataType.hpp:31
StringPadding
Definition string_padding.hpp:7
Use for defining a sub-type of compound type.
Definition H5DataType.hpp:202
size_t offset
Definition H5DataType.hpp:209
member_def(std::string t_name, DataType t_base_type, size_t t_offset=0)
Definition H5DataType.hpp:203
DataType base_type
Definition H5DataType.hpp:208
std::string name
Definition H5DataType.hpp:207
Use for defining a member of enum type.
Definition H5DataType.hpp:300
T value
Definition H5DataType.hpp:305
std::string name
Definition H5DataType.hpp:304
member_def(const std::string &t_name, T t_value)
Definition H5DataType.hpp:301
static void ToException(const std::string &prefix_msg)
Definition H5Exception_misc.hpp:43