Namespace hdf5::datatype

Enumerations

Class

enum hdf5::datatype::Class

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

Warning

doxygenfunction: Unable to resolve function “hdf5::datatype::operator<<” with arguments (std::ostream&, const Class&) in doxygen xml output for project “h5cpp” from directory: /home/jenkins/build/doc/source/../doxygen_xml. Potential matches:

- DLL_EXPORT std::ostream &operator<<(std::ostream &stream, const CharacterEncoding &enc)
- DLL_EXPORT std::ostream &operator<<(std::ostream &stream, const Direction &d)
- DLL_EXPORT std::ostream &operator<<(std::ostream &stream, const Norm &n)
- DLL_EXPORT std::ostream &operator<<(std::ostream &stream, const Order &o)
- DLL_EXPORT std::ostream &operator<<(std::ostream &stream, const Pad &p)
- DLL_EXPORT std::ostream &operator<<(std::ostream &stream, const Sign &s)
- DLL_EXPORT std::ostream &operator<<(std::ostream &stream, const StringPad &pad)

Order

enum hdf5::datatype::Order

enumeration type for byte order

Values:

enumerator LE

littlen endian type

enumerator BE

big endian type

DLL_EXPORT std::ostream &hdf5::datatype::operator<<(std::ostream &stream, const Order &o)

output stream operator for the Order enumeration

Parameters
  • stream – reference to the output stream

  • o – reference to an Order enumeration instance

Returns

modified output stream

Sign

enum hdf5::datatype::Sign

enumeration for sign

Values:

enumerator TWOS_COMPLEMENT

indicates a signed type

enumerator UNSIGNED

indicates an unsigned type

DLL_EXPORT std::ostream &hdf5::datatype::operator<<(std::ostream &stream, const Sign &s)

output stream for Sign enumeration

Parameters
  • stream – reference to the output stream

  • s – reference to the Sign enumeration

Returns

modified output stream

Norm

enum hdf5::datatype::Norm

enumeration describes mantissa norm

Values:

enumerator IMPLIED
enumerator MSBSET
enumerator NONE
DLL_EXPORT std::ostream &hdf5::datatype::operator<<(std::ostream &stream, const Norm &n)

stream output operator for the Norm enumeration

Parameters
  • stream – reference to the output stream

  • n – refernece to a Norm enumeration instance

Returns

modified ouput stream

Pad

enum hdf5::datatype::Pad

enumeration for floating point padding

Values:

enumerator ZERO
enumerator ONE
enumerator BACKGROUND
DLL_EXPORT std::ostream &hdf5::datatype::operator<<(std::ostream &stream, const Pad &p)

stream output operator for Pad enumerations

Parameters
  • stream – reference to the output stream

  • p – reference to a Pad enumeratino instance

Returns

modified output stream

StringPad

enum hdf5::datatype::StringPad

enumeration determining string padding

Values:

enumerator NULLTERM

indicates a null terminated string type

enumerator NULLPAD

indicates a null padded string type

enumerator SPACEPAD

indicates a space padded string type

DLL_EXPORT std::ostream &hdf5::datatype::operator<<(std::ostream &stream, const StringPad &pad)

stream output operator for StringPad enumerations

Parameters
  • stream – reference to an output stream

  • pad – reference to a StringPad enumeration instance

Returns

modified output stream

Direction

enum hdf5::datatype::Direction

Values:

enumerator ASCEND
enumerator DESCEND
DLL_EXPORT std::ostream &hdf5::datatype::operator<<(std::ostream &stream, const Direction &d)

stream output operator for Direction enumerations

Parameters
  • stream – reference to an output stream

  • d – reference to a Direction enumeration instance

Returns

modified output stream

CharacterEncoding

enum hdf5::datatype::CharacterEncoding

character set encoding

Enumeration type determining the character encoding used by string types and links.

Values:

enumerator ASCII

ASCII.

enumerator UTF8

UTF8.

DLL_EXPORT 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

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

is_valid()

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(Datatype &&type) = default

move constructor

Use default implementation here.

Datatype(const Datatype &type)

copy constructor

Use default compiler implementation.

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).

DLL_EXPORT bool 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.

Parameters
  • lhs – reference to the left handside Datatype instance

  • rhs – reference to the right handside Datatype instance

Returns

true if instances are considered equal, false otherwise

DLL_EXPORT bool operator!=(const Datatype &lhs, const Datatype &rhs)

inequality check for datatypes

Returns true if both datatypes do not represent the same types.

Parameters
  • lhs – reference to the left hand-side Datatype instance

  • rhs – reference to the right hand-side Datatype instance

Returns

true if datatypes are not equal, false otherwise

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

Array(const Datatype &type)

cosntruct from generic datatype

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

Public Static Functions

static Array create(const Datatype &base_type, const Dimensions &dims)

named constructor

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

VLengthArray(const Datatype &type)

cosntruct from generic datatype

Public Static Functions

static VLengthArray create(const Datatype &base_type)

constructor

Parameters

base_type – the base type for the variable length type

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

Compound(const Datatype &type)

construct from generic datatype

Datatype operator[](size_t index) const

return the datatype for index element

Datatype operator[](const std::string &name) const

return the datatype for element name

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

Public Static Functions

static Compound create(size_t size)

constructor

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

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.

Failure to satify one of the above conditions will cause an exception.

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

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 variable()

construct variable-length string

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

Type traits

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 char double

tparam T

type for which to create a new HDF5 data type

Public Types

using TypeClass = Datatype

subtype of Datatype which will be used

Public Static Functions

static TypeClass create(const T& = T())

create the new type instance