47 #pragma clang diagnostic push
48 #pragma clang diagnostic ignored "-Wweak-vtables"
78 void insert(
const std::string& name,
const T& data)
const;
88 std::string
name(
size_t index)
const;
94 T value(
size_t index)
const;
100 T value(
const std::string& name)
const;
108 void insert_underlying(
const std::string& name,
const T& data)
const;
119 void underlying_value(
size_t index, T& data)
const;
125 void underlying_value(
const std::string& name, T& data)
const;
129 void check_type(
const T& data)
const;
133 #pragma clang diagnostic pop
137 void Enum::check_type(
const T& data)
const
141 if (mem_type_holder.
get<T>() !=
super())
143 std::stringstream ss;
144 ss <<
"Attempt to insert enum value of mismatching type";
145 throw (std::runtime_error(ss.str()));
161 if (0 > H5Tenum_insert(
static_cast<hid_t
>(*
this),
name.c_str(), &data))
163 std::stringstream ss;
164 ss <<
"Could not insert Enum value " <<
name <<
"=" << data;
172 auto data2 =
static_cast<typename std::underlying_type<T>::type
>(data);
181 if (0 > H5Tget_member_value(
static_cast<hid_t
>(*
this),
static_cast<uint32_t
>(index), &data))
183 std::stringstream ss;
184 ss <<
"Could not retrieve Enum value at idx=" << index;
194 if (0 > H5Tenum_valueof(
static_cast<hid_t
>(*
this),
name.c_str(), &data))
196 std::stringstream ss;
197 ss <<
"Could not retrieve Enum value with name=" <<
name;
205 typename std::underlying_type<T>::type t;
207 return static_cast<T
>(t);
213 typename std::underlying_type<T>::type t;
215 return static_cast<T
>(t);
Wrapper for hid_t object identifiers.
Definition: object_handle.hpp:67
data type object holder
Definition: factory.hpp:54
const Datatype & get(const T &v=T{})
factory holder method for getting reference of data types
Definition: factory.hpp:74
base class for all data types
Definition: datatype.hpp:42
Datatype super() const
get the base type
compound data type
Definition: enum.hpp:51
Enum(const Datatype &type)
construct from generic datatype
std::string name(size_t index) const
get value name
T value(size_t index) const
get value at index (with underlying type deduction)
Definition: enum.hpp:203
Enum()=default
default constructor
static Enum create_underlying(const Datatype &base_type)
named constructor from underlying datatype
static Enum create(const T &)
named constructor (with underlying type deduction)
Definition: enum.hpp:150
size_t number_of_values() const
return the total number of enum values
void insert(const std::string &name, const T &data) const
insert enum value definition (with underlying type deduction)
Definition: enum.hpp:170
void underlying_value(size_t index, T &data) const
get value at index
Definition: enum.hpp:177
Enum(ObjectHandle &&handle)
construct from handle
void insert_underlying(const std::string &name, const T &data) const
insert enum value definition
Definition: enum.hpp:157
static Singleton & instance()
reference to singleton
Definition: error.hpp:59
void throw_with_stack(const std::string &message)
throws an exception, potentially nested with error stack
TypeTrait< typename std::remove_const< T >::type >::TypeClass create(const T &v=T{})
factory function for creating data types
Definition: factory.hpp:39
top-level namespace of the entire library
Definition: attribute.hpp:45
#define DLL_EXPORT
Definition: windows.hpp:29