41 using T = std::underlying_type<DataTypeClass>::type;
42 return static_cast<DataTypeClass>(
static_cast<T
>(lhs) |
static_cast<T
>(rhs));
46 using T = std::underlying_type<DataTypeClass>::type;
47 return static_cast<DataTypeClass>(
static_cast<T
>(lhs) &
static_cast<T
>(rhs));
76 std::string
string()
const;
92 bool empty()
const noexcept;
99 return details::get_plist<DataTypeCreateProps>(*
this, H5Tget_create_plist);
134 :
name(std::move(t_name))
148 inline CompoundType(
const std::vector<member_def>& t_members,
size_t size = 0)
149 : members(t_members) {
152 inline CompoundType(std::vector<member_def>&& t_members,
size_t size = 0)
153 : members(std::move(t_members)) {
156 inline CompoundType(
const std::initializer_list<member_def>& t_members,
size_t size = 0)
157 : members(t_members) {
167 std::ostringstream ss;
168 ss <<
"hid " <<
_hid <<
" does not refer to a compound data type";
171 int result = H5Tget_nmembers(
_hid);
175 size_t n_members =
static_cast<size_t>(result);
176 members.reserve(n_members);
177 for (
unsigned i = 0; i < n_members; i++) {
178 const char* name = H5Tget_member_name(
_hid, i);
179 size_t offset = H5Tget_member_offset(
_hid, i);
180 hid_t member_hid = H5Tget_member_type(
_hid, i);
182 members.emplace_back(name, member_type, offset);
189 inline void commit(
const Object&
object,
const std::string& name)
const;
192 inline const std::vector<member_def>&
getMembers() const noexcept {
198 std::vector<member_def> members;
203 void create(
size_t size = 0);
235 ,
value(std::move(t_value)) {}
243 : members(t_members) {
244 static_assert(std::is_enum<T>::value,
"EnumType<T>::create takes only enum");
245 if (members.empty()) {
247 "Could not create an enum without members");
252 EnumType(std::initializer_list<member_def> t_members)
258 void commit(
const Object&
object,
const std::string& name)
const;
261 std::vector<member_def> members;
283template <std::
size_t N>
309 void push_back(
const std::array<char, N>&);
314 std::string
getString(std::size_t index)
const;
317 inline const char*
operator[](std::size_t i)
const noexcept {
318 return datavec[i].data();
320 inline const char*
at(std::size_t i)
const {
321 return datavec.at(i).data();
323 inline bool empty() const noexcept {
324 return datavec.empty();
326 inline std::size_t
size() const noexcept {
327 return datavec.size();
333 return datavec.front().data();
335 inline const char*
back()
const {
336 return datavec.back().data();
339 return datavec[0].data();
341 inline const char*
data() const noexcept {
342 return datavec[0].data();
346 using vector_t =
typename std::vector<std::array<char, N>>;
357 return datavec.begin();
360 return datavec.end();
363 return datavec.begin();
366 return datavec.cbegin();
369 return datavec.end();
372 return datavec.cend();
375 return datavec.rbegin();
378 return datavec.rend();
381 return datavec.rbegin();
384 return datavec.rend();
406#define HIGHFIVE_REGISTER_TYPE(type, function) \
408 inline HighFive::DataType HighFive::create_datatype<type>() { \
create an HDF5 DataType from a C++ type
Definition H5DataType.hpp:117
AtomicType()
Definition H5DataType_misc.hpp:215
T basic_type
Definition H5DataType.hpp:121
Class representing an attribute of a dataset or group.
Definition H5Attribute.hpp:46
Create a compound HDF5 datatype.
Definition H5DataType.hpp:128
void commit(const Object &object, const std::string &name) const
Commit datatype into the given Object.
Definition H5DataType_misc.hpp:368
const std::vector< member_def > & getMembers() const noexcept
Get read access to the CompoundType members.
Definition H5DataType.hpp:192
CompoundType(const CompoundType &other)=default
CompoundType(const std::initializer_list< member_def > &t_members, size_t size=0)
Definition H5DataType.hpp:156
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:148
CompoundType(DataType &&type)
Initializes a compound type from a DataType.
Definition H5DataType.hpp:164
CompoundType(std::vector< member_def > &&t_members, size_t size=0)
Definition H5DataType.hpp:152
Class representing a dataset.
Definition H5DataSet.hpp:30
Exception specific to HighFive DataType interface.
Definition H5Exception.hpp:94
HDF5 Data Type.
Definition H5DataType.hpp:54
bool operator==(const DataType &other) const
Definition H5DataType_misc.hpp:47
bool isFixedLenStr() const
Returns whether the type is a fixed-length string.
Definition H5DataType_misc.hpp:63
DataTypeCreateProps getCreatePropertyList() const
Get the list of properties for creation of this DataType.
Definition H5DataType.hpp:98
size_t getSize() const
Returns the length (in bytes) of this type elements.
Definition H5DataType_misc.hpp:43
bool isVariableStr() const
Returns whether the type is a variable-length string.
Definition H5DataType_misc.hpp:55
bool empty() const noexcept
Check the DataType was default constructed. Such value might represent auto-detection of the datatype...
Definition H5DataType_misc.hpp:35
Object()
Definition H5Object_misc.hpp:24
std::string string() const
Returns a friendly description of the type (e.g. Float32)
Definition H5DataType_misc.hpp:71
DataTypeClass getClass() const
Return the fundamental type.
Definition H5DataType_misc.hpp:39
bool isReference() const
Returns whether the type is a Reference.
Definition H5DataType_misc.hpp:67
bool operator!=(const DataType &other) const
Definition H5DataType_misc.hpp:51
Create a enum HDF5 datatype.
Definition H5DataType.hpp:228
EnumType(std::initializer_list< member_def > t_members)
Definition H5DataType.hpp:252
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:389
EnumType(const std::vector< member_def > &t_members)
Definition H5DataType.hpp:242
File class.
Definition H5File.hpp:24
A structure representing a set of fixed-length strings.
Definition H5DataType.hpp:284
const char * front() const
Definition H5DataType.hpp:332
const_iterator cend() const noexcept
Definition H5DataType.hpp:371
const_reverse_iterator rend() const noexcept
Definition H5DataType.hpp:383
const_iterator begin() const noexcept
Definition H5DataType.hpp:362
const char * data() const noexcept
Definition H5DataType.hpp:341
typename vector_t::const_iterator const_iterator
Definition H5DataType.hpp:351
const_reverse_iterator rbegin() const noexcept
Definition H5DataType.hpp:380
const_iterator end() const noexcept
Definition H5DataType.hpp:368
const char * at(std::size_t i) const
Definition H5DataType.hpp:320
const char * back() const
Definition H5DataType.hpp:335
reverse_iterator rend() noexcept
Definition H5DataType.hpp:377
char * data() noexcept
Definition H5DataType.hpp:338
void resize(std::size_t n)
Definition H5DataType.hpp:329
reverse_iterator rbegin() noexcept
Definition H5DataType.hpp:374
std::string getString(std::size_t index) const
Retrieve a string from the structure as std::string.
Definition H5DataType_misc.hpp:266
const char * operator[](std::size_t i) const noexcept
Definition H5DataType.hpp:317
typename vector_t::value_type value_type
Definition H5DataType.hpp:354
FixedLenStringArray()=default
std::size_t size() const noexcept
Definition H5DataType.hpp:326
iterator begin() noexcept
Definition H5DataType.hpp:356
void push_back(const std::string &)
Append an std::string to the buffer structure.
Definition H5DataType_misc.hpp:252
const_iterator cbegin() const noexcept
Definition H5DataType.hpp:365
iterator end() noexcept
Definition H5DataType.hpp:359
bool empty() const noexcept
Definition H5DataType.hpp:323
typename vector_t::reverse_iterator reverse_iterator
Definition H5DataType.hpp:352
typename vector_t::const_reverse_iterator const_reverse_iterator
Definition H5DataType.hpp:353
typename vector_t::iterator iterator
Definition H5DataType.hpp:350
Definition H5Object.hpp:54
Object()
Definition H5Object_misc.hpp:24
hid_t _hid
Definition H5Object.hpp:105
HDF5 property Lists.
Definition H5PropertyList.hpp:79
An HDF5 (object) reference type.
Definition H5Reference.hpp:33
Definition H5_definitions.hpp:15
DataType create_and_check_datatype()
Create a DataType instance representing type T and perform a sanity check on its size.
Definition H5DataType_misc.hpp:479
DataType create_datatype()
Create a DataType instance representing type T.
Definition H5DataType_misc.hpp:472
DataTypeClass operator|(DataTypeClass lhs, DataTypeClass rhs)
Definition H5DataType.hpp:40
DataTypeClass operator&(DataTypeClass lhs, DataTypeClass rhs)
Definition H5DataType.hpp:45
DataTypeClass
Enum of Fundamental data classes.
Definition H5DataType.hpp:25
Use for defining a sub-type of compound type.
Definition H5DataType.hpp:132
size_t offset
Definition H5DataType.hpp:139
member_def(std::string t_name, DataType t_base_type, size_t t_offset=0)
Definition H5DataType.hpp:133
DataType base_type
Definition H5DataType.hpp:138
std::string name
Definition H5DataType.hpp:137
Use for defining a member of enum type.
Definition H5DataType.hpp:232
T value
Definition H5DataType.hpp:237
std::string name
Definition H5DataType.hpp:236
member_def(const std::string &t_name, T t_value)
Definition H5DataType.hpp:233
static void ToException(const std::string &prefix_msg)
Definition H5Exception_misc.hpp:42