14#include "H5Object.hpp"
15#include "bits/H5Utils.hpp"
23enum class DataTypeClass {
74 std::string
string()
const;
90 bool empty()
const noexcept;
99 bool operator!=(
const DataType& other)
const;
101 static DataType FromId(
const hid_t&
id,
const bool& increaseRefCount =
false){
102 Object obj =
Object(
id, ObjectType::UserDataType, increaseRefCount);
108 using Object::Object;
128 typedef T basic_type;
130 static AtomicType FromId(
const hid_t&
id,
const bool& increaseRefCount =
false){
131 DataType obj = DataType::FromId(
id, increaseRefCount);
151 : name(std::move(t_name))
152 , base_type(std::move(t_base_type))
153 , offset(t_offset) {}
165 inline CompoundType(
const std::vector<member_def>& t_members,
size_t size = 0)
166 : members(t_members) {
170 inline CompoundType(std::vector<member_def>&& t_members,
size_t size = 0)
171 : members(std::move(t_members)) {
175 inline CompoundType(
const std::initializer_list<member_def>& t_members,
177 : members(t_members) {
184 inline void commit(
const Object&
object,
const std::string& name)
const;
187 inline const std::vector<member_def>&
getMembers() const noexcept {
191 DataTypeClass getMemberClass(
const unsigned& member_no)
const;
192 int getMemberIndex(
const std::string& field_name)
const;
193 std::string getMemberName(
const unsigned& field_idx)
const;
194 size_t getMemberOffset(
const unsigned& memb_no)
const;
197 int getNMembers()
const;
200 static CompoundType FromId(
const hid_t&
id,
const bool& increaseRefCount =
false){
201 DataType obj = DataType::FromId(
id, increaseRefCount);
206 CompoundType(
const DataType& obj) : DataType(obj){};
211 std::vector<member_def> members;
216 void create(
size_t size = 0);
246 member_def(
const std::string& t_name, T t_value)
248 , value(std::move(t_value)) {}
255 EnumType(
const std::vector<member_def>& t_members)
256 : members(t_members) {
260 EnumType(std::initializer_list<member_def> t_members)
261 :
EnumType(std::vector<member_def>({t_members})) {}
266 void commit(
const Object&
object,
const std::string& name)
const;
268 int getMemberIndex(
const std::string& field_name)
const;
269 std::string getMemberName(
const unsigned& field_idx)
const;
270 void getMemberValue(
const unsigned& memb_no,
void *value)
const;
271 int getNMembers()
const;
273 static EnumType FromId(
const hid_t&
id,
const bool& increaseRefCount =
false){
274 DataType obj = DataType::FromId(
id, increaseRefCount);
275 return EnumType(obj);
279 EnumType(
const DataType& obj) : DataType(obj){};
282 std::vector<member_def> members;
290DataType create_datatype();
295DataType create_and_check_datatype();
304template <std::
size_t N>
330 void push_back(
const std::array<char, N>&);
335 std::string
getString(std::size_t index)
const;
338 inline const char* operator[](std::size_t i)
const noexcept {
339 return datavec[i].data();
341 inline const char* at(std::size_t i)
const {
342 return datavec.at(i).data();
344 inline bool empty()
const noexcept {
345 return datavec.empty();
347 inline std::size_t size()
const noexcept {
348 return datavec.size();
350 inline void resize(std::size_t n) {
353 inline const char* front()
const {
354 return datavec.front().data();
356 inline const char* back()
const {
357 return datavec.back().data();
359 inline char* data()
noexcept {
360 return datavec[0].data();
362 inline const char* data()
const noexcept {
363 return datavec[0].data();
367 using vector_t =
typename std::vector<std::array<char, N>>;
371 using iterator =
typename vector_t::iterator;
372 using const_iterator =
typename vector_t::const_iterator;
373 using reverse_iterator =
typename vector_t::reverse_iterator;
374 using const_reverse_iterator =
typename vector_t::const_reverse_iterator;
375 using value_type =
typename vector_t::value_type;
377 inline iterator begin()
noexcept {
378 return datavec.begin();
380 inline iterator end()
noexcept {
381 return datavec.end();
383 inline const_iterator begin()
const noexcept {
384 return datavec.begin();
386 inline const_iterator cbegin()
const noexcept {
387 return datavec.cbegin();
389 inline const_iterator end()
const noexcept {
390 return datavec.end();
392 inline const_iterator cend()
const noexcept {
393 return datavec.cend();
395 inline reverse_iterator rbegin()
noexcept {
396 return datavec.rbegin();
398 inline reverse_iterator rend()
noexcept {
399 return datavec.rend();
401 inline const_reverse_iterator rbegin()
const noexcept {
402 return datavec.rbegin();
404 inline const_reverse_iterator rend()
const noexcept {
405 return datavec.rend();
433#define H5GT_REGISTER_TYPE(type, function) \
435 inline h5gt::DataType h5gt::create_datatype<type>() { \
439#include "bits/H5DataType_misc.hpp"
create an HDF5 DataType from a C++ type
Definition H5DataType.hpp:124
Class representing an attribute of a dataset or group.
Definition H5Attribute.hpp:22
Create a compound HDF5 datatype.
Definition H5DataType.hpp:143
void commit(const Object &object, const std::string &name) const
Commit datatype into the given Object.
Definition H5DataType_misc.hpp:454
CompoundType(const std::initializer_list< member_def > &t_members, size_t size=0)
Definition H5DataType.hpp:175
const std::vector< member_def > & getMembers() const noexcept
Get read access to the CompoundType members.
Definition H5DataType.hpp:187
CompoundType(std::vector< member_def > &&t_members, size_t size=0)
Definition H5DataType.hpp:170
hid_t getMemberType(const unsigned &field_idx) const
return predefined type specified by hdf5 macro like: H5T_C_S1, H5T_NATIVE_INT, H5T_IEEE_F32BE etc.
Definition H5DataType_misc.hpp:474
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:165
Class representing a dataset.
Definition H5DataSet.hpp:28
HDF5 Data Type.
Definition H5DataType.hpp:48
size_t getSize() const
Returns the length (in bytes) of this type elements.
Definition H5DataType_misc.hpp:36
std::string string() const
Returns a friendly description of the type (e.g. Float32)
Definition H5DataType_misc.hpp:80
bool operator==(const DataType &other) const
operator == Check if objects reside in the same file and equal to each other
Definition H5DataType_misc.hpp:72
bool isReference() const
Returns whether the type is a Reference.
Definition H5DataType_misc.hpp:68
bool empty() const noexcept
Check the DataType was default constructed. Such value might represent auto-detection of the datatype...
Definition H5DataType_misc.hpp:28
DataTypeClass getClass() const
Return the fundamental type.
Definition H5DataType_misc.hpp:32
virtual bool isTypeEqual(const DataType &other) const
isTypeEqual Unlike == operator this only checks if the data types are equal and do not check if they ...
Definition H5DataType_misc.hpp:42
bool isVariableStr() const
Returns whether the type is a variable-length string.
Definition H5DataType_misc.hpp:55
bool isFixedLenStr() const
Returns whether the type is a fixed-length string.
Definition H5DataType_misc.hpp:64
Create a enum HDF5 datatype.
Definition H5DataType.hpp:241
void commit(const Object &object, const std::string &name) const
Commit datatype into the given Object.
Definition H5DataType_misc.hpp:503
File class.
Definition H5File.hpp:25
A structure representing a set of fixed-length strings.
Definition H5DataType.hpp:305
void push_back(const std::string &)
Append an std::string to the buffer structure.
Definition H5DataType_misc.hpp:382
std::string getString(std::size_t index) const
Retrieve a string from the structure as std::string.
Definition H5DataType_misc.hpp:396
Represents an hdf5 group.
Definition H5Group.hpp:23
NodeTraits: Base class for Group and File.
Definition H5Node_traits.hpp:23
Definition H5Object.hpp:55
Use for defining a sub-type of compound type If your dtype contains 'std::string' then you need to ex...
Definition H5DataType.hpp:149
Use for defining a member of enum type.
Definition H5DataType.hpp:245