HDF5 C++ API  1.8.12
 All Classes Namespaces Files Functions Variables Typedefs Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
H5::DataType Class Reference

Class DataType provides generic operations on HDF5 datatypes. More...

#include <H5DataType.h>

Inheritance diagram for H5::DataType:
H5::H5Object H5::H5Location H5::IdComponent H5::ArrayType H5::AtomType H5::CompType H5::EnumType H5::VarLenType H5::FloatType H5::IntType H5::PredType H5::StrType

Public Member Functions

 DataType (const H5T_class_t type_class, size_t size)
 Creates a object given its class and size. More...
 
 DataType (const DataType &original)
 Copy constructor: makes a copy of the original DataType object. More...
 
 DataType (const H5Location &loc, const void *ref, H5R_type_t ref_type=H5R_OBJECT)
 Given a reference, ref, to an hdf5 group, creates a DataType object. More...
 
 DataType (const Attribute &attr, const void *ref, H5R_type_t ref_type=H5R_OBJECT)
 Given a reference, ref, to an hdf5 group, creates a DataType object. More...
 
virtual void close ()
 Closes the datatype if it is not a predefined type. More...
 
void copy (const DataType &like_type)
 Copies an existing datatype to this datatype object. More...
 
void copy (const DataSet &dset)
 Copies the datatype of the given dataset to this datatype object. More...
 
H5T_class_t getClass () const
 Returns the datatype class identifier. More...
 
void commit (H5Location &loc, const char *name)
 Commits a transient datatype to a file, creating a new named datatype. More...
 
void commit (H5Location &loc, const H5std_string &name)
 This is an overloaded member function, provided for convenience. It differs from the above function only in the type of the argument name. More...
 
bool committed () const
 Determines whether a datatype is a named type or a transient type. More...
 
H5T_conv_t find (const DataType &dest, H5T_cdata_t **pcdata) const
 Finds a conversion function that can handle a conversion from this datatype to the specified datatype, dest. More...
 
void convert (const DataType &dest, size_t nelmts, void *buf, void *background, const PropList &plist=PropList::DEFAULT) const
 Converts data from this datatype to the specified datatypes. More...
 
DataTypeoperator= (const DataType &rhs)
 Assignment operator. More...
 
bool operator== (const DataType &compared_type) const
 Compares this DataType against the given one to determines whether the two objects refer to the same actual datatype. More...
 
void lock () const
 Locks a datatype, making it read-only and non-destructible. More...
 
size_t getSize () const
 Returns the size of a datatype. More...
 
DataType getSuper () const
 Returns the base datatype from which a datatype is derived. More...
 
void registerFunc (H5T_pers_t pers, const char *name, const DataType &dest, H5T_conv_t func) const
 Registers the specified conversion function. More...
 
void registerFunc (H5T_pers_t pers, const H5std_string &name, const DataType &dest, H5T_conv_t func) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in the type of the argument name. More...
 
void unregister (H5T_pers_t pers, const char *name, const DataType &dest, H5T_conv_t func) const
 Removes a conversion function from all conversion paths. More...
 
void unregister (H5T_pers_t pers, const H5std_string &name, const DataType &dest, H5T_conv_t func) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in the type of the argument name. More...
 
void setTag (const char *tag) const
 Tags an opaque datatype. More...
 
void setTag (const H5std_string &tag) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in the type of the argument name. More...
 
H5std_string getTag () const
 Gets the tag associated with an opaque datatype. More...
 
bool detectClass (H5T_class_t cls) const
 Checks whether a datatype contains (or is) a certain type of datatype. More...
 
bool isVariableStr () const
 Check whether this datatype is a variable-length string. More...
 
virtual H5std_string fromClass () const
 Returns this class name. More...
 
 DataType (const hid_t type_id)
 Creates a datatype using an existing datatype's id. More...
 
 DataType ()
 Default constructor: Creates a stub datatype. More...
 
virtual hid_t getId () const
 Get the id of this datatype. More...
 
virtual ~DataType ()
 Properly terminates access to this datatype. More...
 
- Public Member Functions inherited from H5::H5Object
 H5Object (const H5Object &original)
 Copy constructor: makes a copy of the original H5Object instance. More...
 
virtual ~H5Object ()
 Noop destructor. More...
 
- Public Member Functions inherited from H5::H5Location
Attribute createAttribute (const char *name, const DataType &type, const DataSpace &space, const PropList &create_plist=PropList::DEFAULT) const
 Creates an attribute for a group, dataset, or named datatype. More...
 
Attribute createAttribute (const H5std_string &name, const DataType &type, const DataSpace &space, const PropList &create_plist=PropList::DEFAULT) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes a reference to an H5std_string for name. More...
 
Attribute openAttribute (const char *name) const
 Opens an attribute given its name. More...
 
Attribute openAttribute (const H5std_string &name) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes a reference to an H5std_string for name. More...
 
Attribute openAttribute (const unsigned int idx) const
 Opens an attribute given its index. More...
 
void flush (H5F_scope_t scope) const
 Flushes all buffers associated with a location to disk. More...
 
H5std_string getFileName () const
 Gets the name of the file, in which this HDF5 object belongs. More...
 
int getNumAttrs () const
 Returns the number of attributes attached to this HDF5 object. More...
 
H5G_obj_t getObjType (void *ref, H5R_type_t ref_type=H5R_OBJECT) const
 Retrieves the type of object that an object reference points to. More...
 
H5O_type_t getRefObjType (void *ref, H5R_type_t ref_type=H5R_OBJECT) const
 Retrieves the type of object that an object reference points to. More...
 
int iterateAttrs (attr_operator_t user_op, unsigned *idx=NULL, void *op_data=NULL)
 Iterates a user's function over all the attributes of an H5 object, which may be a group, dataset or named datatype. More...
 
bool attrExists (const char *name) const
 Checks whether the named attribute exists at this location. More...
 
bool attrExists (const H5std_string &name) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes a reference to an H5std_string for name. More...
 
void renameAttr (const char *oldname, const char *newname) const
 Renames the named attribute from this object. More...
 
void renameAttr (const H5std_string &oldname, const H5std_string &newname) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes a reference to an H5std_string for the names. More...
 
void removeAttr (const char *name) const
 Removes the named attribute from this object. More...
 
void removeAttr (const H5std_string &name) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes a reference to an H5std_string for name. More...
 
void setComment (const char *name, const char *comment) const
 Sets or resets the comment for an object specified by its name. More...
 
void setComment (const H5std_string &name, const H5std_string &comment) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name and comment. More...
 
void setComment (const char *comment) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it doesn't take an object name. More...
 
void setComment (const H5std_string &comment) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for comment. More...
 
H5std_string getComment (const char *name, size_t bufsize=256) const
 Retrieves comment for the specified object and its comment's length. More...
 
H5std_string getComment (const H5std_string &name, size_t bufsize=256) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name. More...
 
void removeComment (const char *name) const
 Removes the comment from an object specified by its name. More...
 
void removeComment (const H5std_string &name) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name. More...
 
void reference (void *ref, const char *name, H5R_type_t ref_type=H5R_OBJECT) const
 This is an overloaded function, provided for your convenience. It differs from the above function in that it does not take a DataSpace object and the reference type must be specified. More...
 
void reference (void *ref, const H5std_string &name, H5R_type_t ref_type=H5R_OBJECT) const
 This is an overloaded function, provided for your convenience. It differs from the above function in that it takes an H5std_string for the object's name. More...
 
void reference (void *ref, const char *name, const DataSpace &dataspace, H5R_type_t ref_type=H5R_DATASET_REGION) const
 Creates a reference to an HDF5 object or a dataset region. More...
 
void reference (void *ref, const H5std_string &name, const DataSpace &dataspace, H5R_type_t ref_type=H5R_DATASET_REGION) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name. More...
 
void dereference (const H5Location &loc, const void *ref, H5R_type_t ref_type=H5R_OBJECT)
 Dereferences a reference into an HDF5 object, given an HDF5 object. More...
 
void dereference (const Attribute &attr, const void *ref, H5R_type_t ref_type=H5R_OBJECT)
 Dereferences a reference into an HDF5 object, given an attribute. More...
 
DataSpace getRegion (void *ref, H5R_type_t ref_type=H5R_DATASET_REGION) const
 Retrieves a dataspace with the region pointed to selected. More...
 
- Public Member Functions inherited from H5::IdComponent
void incRefCount (const hid_t obj_id) const
 Increment reference counter for a given id. More...
 
void incRefCount () const
 Increment reference counter for the id of this object. More...
 
void decRefCount (const hid_t obj_id) const
 Decrement reference counter for a given id. More...
 
void decRefCount () const
 Decrement reference counter for the id of this object. More...
 
int getCounter (const hid_t obj_id) const
 Returns the reference counter for a given id. More...
 
int getCounter () const
 Returns the reference counter for the id of this object. More...
 
IdComponentoperator= (const IdComponent &rhs)
 Assignment operator. More...
 
void setId (const hid_t new_id)
 Sets the identifier of this object to a new value. More...
 
 IdComponent (const hid_t h5_id)
 Creates an IdComponent object using the id of an existing object. More...
 
 IdComponent (const IdComponent &original)
 Copy constructor: makes a copy of the original IdComponent object. More...
 
H5std_string inMemFunc (const char *func_name) const
 Makes and returns string "<class-name>::<func_name>". More...
 
virtual ~IdComponent ()
 Noop destructor. More...
 

Protected Member Functions

virtual void p_setId (const hid_t new_id)
 Sets the identifier of this object to a new value. More...
 
- Protected Member Functions inherited from H5::H5Object
 H5Object ()
 
 H5Object (const hid_t object_id)
 
- Protected Member Functions inherited from H5::H5Location
 H5Location ()
 
 H5Location (const hid_t loc_id)
 
 H5Location (const H5Location &original)
 Copy constructor: makes a copy of the original H5Location instance. More...
 
void p_reference (void *ref, const char *name, hid_t space_id, H5R_type_t ref_type) const
 
hid_t p_dereference (hid_t loc_id, const void *ref, H5R_type_t ref_type, const char *from_func)
 
H5G_obj_t p_get_obj_type (void *ref, H5R_type_t ref_type) const
 
H5O_type_t p_get_ref_obj_type (void *ref, H5R_type_t ref_type) const
 
virtual ~H5Location ()
 Noop destructor. More...
 
- Protected Member Functions inherited from H5::IdComponent
 IdComponent ()
 Default constructor. More...
 
H5std_string p_get_file_name () const
 

Protected Attributes

hid_t id
 

Additional Inherited Members

- Static Public Member Functions inherited from H5::IdComponent
static H5I_type_t getHDFObjType (const hid_t obj_id)
 Given an id, returns the type of the object. More...
 
- Static Protected Member Functions inherited from H5::IdComponent
static bool p_valid_id (const hid_t obj_id)
 

Detailed Description

Class DataType provides generic operations on HDF5 datatypes.

DataType inherits from H5Object because a named datatype is an HDF5 object and is a base class of ArrayType, AtomType, CompType, EnumType, and VarLenType.

Constructor & Destructor Documentation

H5::DataType::DataType ( const H5T_class_t  type_class,
size_t  size 
)

Creates a object given its class and size.

Parameters
type_class- IN: Class of datatype to create
size- IN: Number of bytes in the datatype to create
Exceptions
H5::DataTypeIException
H5::DataType::DataType ( const DataType original)

Copy constructor: makes a copy of the original DataType object.

H5::DataType::DataType ( const H5Location loc,
const void *  ref,
H5R_type_t  ref_type = H5R_OBJECT 
)

Given a reference, ref, to an hdf5 group, creates a DataType object.

Parameters
loc- IN: Location referenced object is in
ref- IN: Reference pointer
ref_type- IN: Reference type - default to H5R_OBJECT
Exceptions
H5::ReferenceException
H5::DataType::DataType ( const Attribute attr,
const void *  ref,
H5R_type_t  ref_type = H5R_OBJECT 
)

Given a reference, ref, to an hdf5 group, creates a DataType object.

Parameters
attr- IN: Specifying location where the referenced object is in
ref- IN: Reference pointer
ref_type- IN: Reference type - default to H5R_OBJECT
Exceptions
H5::ReferenceException
H5::DataType::DataType ( const hid_t  existing_id)

Creates a datatype using an existing datatype's id.

Parameters
existing_id- IN: Id of the existing datatype
H5::DataType::DataType ( )

Default constructor: Creates a stub datatype.

H5::DataType::~DataType ( )
virtual

Properly terminates access to this datatype.

Member Function Documentation

void H5::DataType::close ( )
virtual

Closes the datatype if it is not a predefined type.

Exceptions
H5::DataTypeIException

Implements H5::IdComponent.

void H5::DataType::commit ( H5Location loc,
const char *  name 
)

Commits a transient datatype to a file, creating a new named datatype.

Parameters
loc- IN: A location (file, dataset, datatype, or group)
name- IN: Name of the datatype
Exceptions
H5::DataTypeIException
void H5::DataType::commit ( H5Location loc,
const H5std_string name 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in the type of the argument name.

bool H5::DataType::committed ( ) const

Determines whether a datatype is a named type or a transient type.

Returns
true if the datatype is a named type, and false, otherwise.
Exceptions
H5::DataTypeIException
void H5::DataType::convert ( const DataType dest,
size_t  nelmts,
void *  buf,
void *  background,
const PropList plist = PropList::DEFAULT 
) const

Converts data from this datatype to the specified datatypes.

Parameters
dest- IN: Destination datatype
nelmts- IN: Size of array buf
buf- IN/OUT: Array containing pre- and post-conversion values
background- IN: Optional backgroud buffer
plist- IN: Dataset transfer property list
Returns
Pointer to a suitable conversion function
Exceptions
H5::DataTypeIException
void H5::DataType::copy ( const DataType like_type)

Copies an existing datatype to this datatype object.

Parameters
like_type- IN: Datatype to be copied
Exceptions
H5::DataTypeIException
void H5::DataType::copy ( const DataSet dset)

Copies the datatype of the given dataset to this datatype object.

Parameters
dset- IN: Dataset
Exceptions
H5::DataTypeIException
Description
The resulted dataset will be transient and modifiable.
bool H5::DataType::detectClass ( H5T_class_t  cls) const

Checks whether a datatype contains (or is) a certain type of datatype.

Returns
true if this datatype contains or is the specified type, and false, otherwise.
Exceptions
H5::DataTypeIException
H5T_conv_t H5::DataType::find ( const DataType dest,
H5T_cdata_t **  pcdata 
) const

Finds a conversion function that can handle a conversion from this datatype to the specified datatype, dest.

Parameters
dest- IN: Destination datatype
pcdata- IN: Pointer to type conversion data
Returns
Pointer to a suitable conversion function
Exceptions
H5::DataTypeIException
virtual H5std_string H5::DataType::fromClass ( ) const
inlinevirtual

Returns this class name.

Reimplemented from H5::IdComponent.

Reimplemented in H5::CompType, H5::AtomType, H5::EnumType, H5::FloatType, H5::StrType, H5::PredType, H5::ArrayType, H5::IntType, and H5::VarLenType.

H5T_class_t H5::DataType::getClass ( ) const

Returns the datatype class identifier.

Returns
Datatype class identifier
Exceptions
H5::DataTypeIException
hid_t H5::DataType::getId ( ) const
virtual

Get the id of this datatype.

Returns
Datatype identifier

Implements H5::H5Location.

size_t H5::DataType::getSize ( ) const

Returns the size of a datatype.

Returns
Datatype size in bytes
Exceptions
H5::DataTypeIException
Examples:
readdata.cpp.
DataType H5::DataType::getSuper ( ) const

Returns the base datatype from which a datatype is derived.

Returns
DataType object
Exceptions
H5::DataTypeIException
H5std_string H5::DataType::getTag ( ) const

Gets the tag associated with an opaque datatype.

Returns
Tag associated with the opaque datatype
Exceptions
H5::DataTypeIException
bool H5::DataType::isVariableStr ( ) const

Check whether this datatype is a variable-length string.

Returns
true if this datatype is a variable-length string, and false, otherwise.
Exceptions
H5::DataTypeIException
void H5::DataType::lock ( ) const

Locks a datatype, making it read-only and non-destructible.

Exceptions
H5::DataTypeIException
Descrition
This is normally done by the library for predefined data types so the application doesn't inadvertently change or delete a predefined type.

Once a data type is locked it can never be unlocked unless the entire library is closed.

DataType & H5::DataType::operator= ( const DataType rhs)

Assignment operator.

Parameters
rhs- IN: Reference to the existing datatype
Returns
Reference to DataType instance
Exceptions
H5::DataTypeIException
bool H5::DataType::operator== ( const DataType compared_type) const

Compares this DataType against the given one to determines whether the two objects refer to the same actual datatype.

Parameters
compared_type- IN: Reference to the datatype to compare
Returns
true if the datatypes are equal, and false, otherwise.
Exceptions
H5::DataTypeIException
void H5::DataType::p_setId ( const hid_t  new_id)
protectedvirtual

Sets the identifier of this object to a new value.

Exceptions
H5::IdComponentExceptionwhen the attempt to close the HDF5 object fails

Implements H5::IdComponent.

void H5::DataType::registerFunc ( H5T_pers_t  pers,
const char *  name,
const DataType dest,
H5T_conv_t  func 
) const

Registers the specified conversion function.

Parameters
pers- IN: Conversion option
  • H5T_PERS_HARD for hard conversion functions
  • H5T_PERS_SOFT for soft conversion functions.
name- IN: Name displayed in diagnostic output.
dest- IN: Destination datatype.
func- IN: Function to convert between source and destination datatypes.
Exceptions
H5::DataTypeIException
Description
For more information, please see: http://www.hdfgroup.org/HDF5/doc/RM/RM_H5T.html#Datatype-Register
void H5::DataType::registerFunc ( H5T_pers_t  pers,
const H5std_string name,
const DataType dest,
H5T_conv_t  func 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in the type of the argument name.

void H5::DataType::setTag ( const char *  tag) const

Tags an opaque datatype.

Parameters
tag- IN: Descriptive ASCII string with which the opaque datatype is to be tagged.
Exceptions
H5::DataTypeIException
void H5::DataType::setTag ( const H5std_string tag) const

This is an overloaded member function, provided for convenience. It differs from the above function only in the type of the argument name.

void H5::DataType::unregister ( H5T_pers_t  pers,
const char *  name,
const DataType dest,
H5T_conv_t  func 
) const

Removes a conversion function from all conversion paths.

Parameters
pers- IN: Conversion option
  • H5T_PERS_HARD for hard conversion functions
  • H5T_PERS_SOFT for soft conversion functions.
name- IN: Name displayed in diagnostic output.
dest- IN: Destination datatype.
func- IN: Function to convert between source and destination datatypes.
Exceptions
H5::DataTypeIException
void H5::DataType::unregister ( H5T_pers_t  pers,
const H5std_string name,
const DataType dest,
H5T_conv_t  func 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in the type of the argument name.

Member Data Documentation

hid_t H5::DataType::id
protected

The documentation for this class was generated from the following files: