Namespace hdf5::datatype
¶
Classes¶
Datatype
¶
-
class hdf5::datatype::Datatype¶
base class for all data types
Subclassed by hdf5::datatype::Array, hdf5::datatype::Compound, hdf5::datatype::Enum, hdf5::datatype::Float, hdf5::datatype::Integer, hdf5::datatype::String, hdf5::datatype::VLengthArray
Public Functions
-
virtual ~Datatype()¶
destructor
Must be virtual for inheritance.
-
Datatype() = default¶
default constructor
Use default compiler implementation here. This will leave datatype as an invalid HDF5 object. For a default constructed datatype the class is NONE.
See also
-
Datatype(ObjectHandle &&handle)¶
constructor
Construct a datatype from an HDF5 object handle.
- Throws
std::runtime_error – in case of a failure
- Parameters
handle – rvalue reference to the original handle
-
Datatype &operator=(const Datatype &type)¶
copy assignment
Use default compiler implementation here.
-
Datatype &operator=(Datatype &&type) = default¶
move assignment
Use default compiler implementation here.
-
Class get_class() const¶
returns the datatypes class
- Throws
std::runtime_error – in case of a failure
-
Datatype super() const¶
get the base type
For an array type this will return the base type of the elements of the array. For an enumeration type it will return the underlying integer type.
- Throws
std::runtime_error – in case of a failure
-
Datatype native_type(Direction dir = Direction::Ascend) const¶
get native type
Returns the native type associated with a particular data type.
- Throws
std::runtime_error – in case of a failure
-
bool has_class(Class type_class) const¶
search for a type class
Checks if a type contains a particular type class.
-
virtual size_t size() const¶
get size of type in bytes
- Throws
std::runtime_error – in case of a failure
-
virtual void size(size_t size) const¶
set the size of a type in bytes
- Throws
std::runtime_error – in case of a failure
-
bool is_valid() const¶
check status of the object
Returns true if the instance is a valid HDF5 object, otherwise it returns false. This can be used to check whether or not an instance has been default constructed (in which case flase will be returned).
-
virtual ~Datatype()¶
-
bool hdf5::datatype::operator==(const Datatype &lhs, const Datatype &rhs)¶
equality check for datatypes
Returns if two datatypes are equal. Datatypes are considered equal if they represent the same type.
Array
¶
-
class hdf5::datatype::Array : public hdf5::datatype::Datatype¶
array datatype
This datatype allows storing multidimensional data as a single element in an dataspace layout. Typical applications would be to use this for tensors and vectors. This is a fixed size data type. All instances (elements) of this type stored in an attribute or dataset are of equal size.
Public Functions
-
Array(ObjectHandle &&handle)¶
construct from handle
-
Dimensions dimensions() const¶
get dimensions
Returns an instance of Dimensions with the number of elements along each dimension.
- Throws
std::runtime_error – in case of a failure
-
size_t rank() const¶
get rank
Returns the number of dimensions for an array data type
- Throws
std::runtime_error – in case of a failure
-
Array(ObjectHandle &&handle)¶
VLengthArray
¶
-
class hdf5::datatype::VLengthArray : public hdf5::datatype::Datatype¶
variable length array type
Array datatype allowing each element stored in a dataspace having a different size. This type is restricted to a single dimensions. This limitation makes sense as it does not make to much sense to think about multidimensional objects of different size stored in an attribute or dataset.
Public Functions
-
VLengthArray() = default¶
default constructor
This constructor is required for compatibility purposes with STL containers.
-
VLengthArray(ObjectHandle &&handle)¶
construct from handle
Public Static Functions
-
static VLengthArray create(const Datatype &base_type)¶
constructor
- Parameters
base_type – the base type for the variable length type
-
VLengthArray() = default¶
Compound
¶
-
class hdf5::datatype::Compound : public hdf5::datatype::Datatype¶
compound data type
A compound data type which can be used for data elements of heterogeneous type like C-structures or a C++ class.
Public Functions
-
Compound() = default¶
default constructor
-
Compound(ObjectHandle &&handle)¶
construct from handle
-
size_t field_index(const std::string &name) const¶
return the index of a type element
-
size_t number_of_fields() const¶
return the total number of elements of the type
-
Compound() = default¶
String
¶
-
class hdf5::datatype::String : public hdf5::datatype::Datatype¶
string datatype
This type can be used to represent fixed length or variable length strings.
Public Functions
-
String() = default¶
default constructor
We need this for STL containers but can rely on the default compiler implementation for now.
-
String(ObjectHandle &&handle)¶
construct from handle
-
String(const Datatype &type)¶
construct from generic datatype instance
- Throws
std::runtime_error – if the datatype is not a string type
-
bool is_variable_length() const¶
return true if type is a variable length string
- Throws
std::runtime_error – in case of a failure
-
CharacterEncoding encoding() const¶
get current character encoding for the string
- Throws
std::runtime_error – in case of a failure
-
void encoding(CharacterEncoding cset)¶
set current character encoding
- Throws
std::runtime_error – in case of a failure
-
StringPad padding() const¶
get the current string padding
- Throws
std::runtime_error – in case of a failure
-
void padding(StringPad strpad)¶
set the string padding for the type
- Throws
std::runtime_error – in case of a failure
-
virtual size_t size() const override¶
get current size of the string type
- Throws
std::runtime_error – in case of a failure
-
virtual void size(size_t size) const override¶
set the string size (number of characters)
There are two conditions which must be met in order for this function to succeed:
the String instance must not be a variable length type
the size must not be 0
- Throws
std::runtime_error – in case of a failure
- Parameters
size – the new size for the fixed length string type
Public Static Functions
-
static String fixed(size_t size)¶
construct fixed-length string
Return an instance of String for a fixed length string. The size of the string must not be 0 as this would not make any sense at all.
- Throws
std::runtime_error – in the case of a failure
- Parameters
size – the size of the new string type
-
String() = default¶
Enum
¶
-
class hdf5::datatype::Enum : public hdf5::datatype::Datatype¶
compound data type
An enum data type which can be used to save enum values along with metadata describing their meaning.
Public Functions
-
Enum() = default¶
default constructor
-
explicit Enum(ObjectHandle &&handle)¶
construct from handle
-
template<typename T>
void insert(const std::string &name, const T &data) const¶ insert enum value definition (with underlying type deduction)
-
size_t number_of_values() const¶
return the total number of enum values
-
std::string name(size_t index) const¶
get value name
-
template<typename T>
T value(size_t index) const¶ get value at index (with underlying type deduction)
-
template<typename T>
T value(const std::string &name) const¶ get value by name (with underlying type deduction)
-
Enum() = default¶
Integer
¶
-
class hdf5::datatype::Integer : public hdf5::datatype::Datatype¶
HDF5 integer datatype.
Public Functions
-
Integer() = default¶
Default constructor.
We need this for compatability with STL containers. However, we can use the compiler provided default version.
-
Integer(ObjectHandle &&handle)¶
Construct from object handle.
Construct a type from an object handle. The datatype takes full ownership of the handle whose lifetime is thus bound to the lifetime of the type.
- Parameters
handle – rvalue reference to a new object handle.
-
Integer(const Datatype &datatype)¶
Copy construction from a Datatype instance.
This copy constructor creates an integer type from an instance of Datatype. The datatype has to satisfy two conditions
it must be a valid object (is_valid() shoudld return true)
it must reference an integer datatype.
- Throws
std::runtime_error – in case of any failure
- Parameters
datatype – reference to a Datatype instance
-
virtual bool is_signed() const¶
Retrieves the sign type for an integer type.
- Throws
std::runtime_error – in case of a failure
-
virtual void make_signed(bool sign) const¶
Sets the sign property for an integer type.
- Throws
std::runtime_error – in case of a failure
-
virtual size_t precision() const¶
get the precision of type, i.e. the number of significant bits
- Throws
std::runtime_error – in case of a failure
-
virtual void precision(size_t precision) const¶
set the precision of a type, i.e. the number of significant bits
- Throws
std::runtime_error – in case of a failure
-
virtual size_t offset() const¶
get the bit offset of the first significant bit
- Throws
std::runtime_error – in case of a failure
-
virtual void offset(size_t offset) const¶
set the bit offset of the first significant bit
- Throws
std::runtime_error – in case of a failure
-
virtual Order order() const¶
get the order of datatype
- Throws
std::runtime_error – in case of a failure
-
virtual void order(Order offset) const¶
set the order of datatype
- Throws
std::runtime_error – in case of a failure
-
Integer() = default¶
Float
¶
-
class hdf5::datatype::Float : public hdf5::datatype::Datatype¶
Public Functions
-
Float() = default¶
default constructor
Need this for compliance with STL containers but we can use the default implementation of the compiler.
-
Float(ObjectHandle &&handle)¶
constructor
- Parameters
handle – rvalue reference to an HDF5 object handle
-
explicit Float(const Datatype &datatype)¶
constructor
Conversion constructor which allows creation of a Float type from a generic Datatype instance. If datatype does not reference a float datatype an exception is thrown.
- Throws
std::runtime_error – in case of a failure
- Parameters
datatype – reference to a generic datatype instance
-
virtual size_t precision() const¶
get the precision of type, i.e. the number of significant bits
- Throws
std::runtime_error – in case of a failure
-
virtual void precision(size_t precision) const¶
set the precision of a type, i.e. the number of significant bits
- Throws
std::runtime_error – in case of a failure
-
virtual size_t offset() const¶
get the bit offset of the first significant bit
- Throws
std::runtime_error – in case of a failure
-
virtual void offset(size_t offset) const¶
set the bit offset of the first significant bit
- Throws
std::runtime_error – in case of a failure
-
virtual Order order() const¶
get the order of datatype
- Throws
std::runtime_error – in case of a failure
-
virtual void order(Order order) const¶
set the order of datatype
- Throws
std::runtime_error – in case of a failure
-
virtual const std::vector<Pad> pad() const¶
get the pads of datatype
- Throws
std::runtime_error – in case of a failure
- Returns
least and most significant bits
-
virtual void pad(Pad lsb, Pad msb) const¶
set the pads of datatype
- Parameters
lsb – padding type for least-significant bits
msb – padding type for most-significant bits
- Throws
std::runtime_error – in case of a failure
-
virtual const std::vector<size_t> fields() const¶
get the floating point datatype bit field information
- Throws
std::runtime_error – in case of a failure
- Returns
floating point datatype bit field information, i.e. floating-point sign bit, exponent bit-position, size of exponent in bits mantissa bit-position, size of mantissa in bits
-
virtual void fields(size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize) const¶
set the floating point datatype bit field information
- Parameters
spos – floating-point sign bit
epos – exponent bit-position
esize – size of exponent in bits
mpos – mantissa bit-position
msize – size of mantissa in bits
- Throws
std::runtime_error – in case of a failure
-
virtual size_t ebias() const¶
get the exponent bias of a floating-point type
- Throws
std::runtime_error – in case of a failure
-
virtual void ebias(size_t ebias) const¶
set the exponent bias of a floating-point type
- Throws
std::runtime_error – in case of a failure
-
virtual Norm norm() const¶
get the mantissa normalization of a floating-point datatype
- Throws
std::runtime_error – in case of a failure
-
virtual void norm(Norm norm) const¶
set the mantissa normalization of a floating-point datatype
- Throws
std::runtime_error – in case of a failure
-
Float() = default¶
float16_t
¶
-
class hdf5::datatype::float16_t¶
DatatypeHolder
¶
-
class hdf5::datatype::DatatypeHolder¶
data type object holder
Public Functions
-
template<typename T>
const Datatype &get(const T &v = T())¶ factory holder method for getting reference of data types
Returns data type reference for static data type object if available. Otherwise it creates a new data type object and returns its reference.
- Parameters
v – provided datatype data
- Returns
data type reference for data type object
-
template<typename T>
Type traits¶
TypeTrait
¶
-
template<typename T>
class hdf5::datatype::TypeTrait¶ trait to create HDF5 datatypes
This trait provides a static function which creates a new HDF5 data type for a particular C++ type.
Specializations for this template exist for the following native types
char
,unsigned
char,singed
chardouble
- Template Parameters
T – type for which to create a new HDF5 data type
Enumerations¶
EBool
¶
Order
¶
Sign
¶
Norm
¶
Pad
¶
StringPad
¶
Direction
¶
CharacterEncoding
¶
-
enum class hdf5::datatype::CharacterEncoding : std::underlying_type<H5T_cset_t>::type¶
character set encoding
Enumeration type determining the character encoding used by string types and links.
Values:
-
enumerator ASCII¶
ASCII.
-
enumerator UTF8¶
UTF8.
-
enumerator ASCII¶
-
std::ostream &hdf5::datatype::operator<<(std::ostream &stream, const CharacterEncoding &enc)¶
stream output operator for CharacterEncoding enumerations
- Parameters
stream – reference to an output stream
enc – reference to a CharacterEncoding enumeration instance
- Returns
modified output stream
Class
¶
-
enum class hdf5::datatype::Class : std::underlying_type<H5T_class_t>::type¶
data type class
Enumeration type describing the class a particular data type belongs to.
Values:
-
enumerator None¶
indicates a non-type
-
enumerator Integer¶
indicates an integer type
-
enumerator Float¶
indicates a float type
-
enumerator Time¶
indicates a time type
-
enumerator String¶
indicates a string type
-
enumerator BitField¶
indicates a bitfield type
-
enumerator Opaque¶
indicates an opaque type
-
enumerator Compound¶
indicates a compound type
-
enumerator Reference¶
indicates a reference type
-
enumerator Enum¶
indicates an enumeration type
-
enumerator VarLength¶
indicates a variable length type
-
enumerator Array¶
indicates an array type
-
enumerator None¶