libpniio
Modules | Data Structures | Typedefs | Enumerations | Functions
HDF5 implementation classes
Collaboration diagram for HDF5 implementation classes:

Modules

 HDF5 implementation error classes
 

Data Structures

class  pni::io::nx::h5::attribute_imp
 attribute implementation More...
 
class  pni::io::nx::h5::field_factory
 factory for field construction More...
 
class  pni::io::nx::h5::field_imp
 dataset object More...
 
class  pni::io::nx::h5::file_imp
 HDF5 file implementation. More...
 
class  pni::io::nx::h5::group_imp
 HDF5 group object. More...
 
class  pni::io::nx::h5::h5dataspace
 dataspace object More...
 
class  pni::io::nx::h5::h5datatype
 HDF5 type wrapper. More...
 
class  pni::io::nx::h5::h5deflate_filter
 HDF5 deflate filter. More...
 
class  pni::io::nx::h5::h5filter
 base class for filter implementations More...
 
class  pni::io::nx::h5::h5link
 
class  pni::io::nx::h5::object_imp
 basic HDF5 ID wrapper More...
 
class  pni::io::nx::h5::selection
 describe a selection in an HDF5 file More...
 
class  pni::io::nx::h5::selection_guard< STYPE >
 selection guard More...
 
struct  pni::io::nx::h5::type_imp
 provide implementation specific types More...
 

Typedefs

typedef std::vector< char * > pni::io::nx::h5::char_ptr_vector_type
 vector tyep for char pointers More...
 
typedef std::vector< const char * > pni::io::nx::h5::char_const_ptr_vector_type
 vector type for const char pointers More...
 

Enumerations

enum  pni::io::nx::h5::h5object_type {
  pni::io::nx::h5::h5object_type::FILE, pni::io::nx::h5::h5object_type::GROUP, pni::io::nx::h5::h5object_type::DATATYPE, pni::io::nx::h5::h5object_type::DATASPACE,
  pni::io::nx::h5::h5object_type::DATASET, pni::io::nx::h5::h5object_type::ATTRIBUTE, pni::io::nx::h5::h5object_type::PLIST, pni::io::nx::h5::h5object_type::BADID
}
 HDF5 object type enumerations. More...
 

Functions

bool pni::io::nx::h5::has_attribute (const object_imp &parent, const pni::core::string &name)
 checks for an attributes existence More...
 
void pni::io::nx::h5::delete_attribute (const object_imp &parent, const pni::core::string &name)
 Deletes an attribute. More...
 
object_imp pni::io::nx::h5::create_attribute (const object_imp &parent, const pni::core::string &name, const h5datatype &type, const h5dataspace &space, bool overwrite)
 create a new attribute at parent More...
 
object_imp pni::io::nx::h5::get_attribute_by_name (const object_imp &parent, const pni::core::string &n)
 open attribute by name More...
 
size_t pni::io::nx::h5::get_number_of_attributes (const object_imp &parent)
 get number of attributes More...
 
object_imp pni::io::nx::h5::get_attribute_by_index (const object_imp &parent, size_t i)
 open attribute by index More...
 
std::ostream & pni::io::nx::h5::operator<< (std::ostream &o, const h5dataspace &s)
 output operator More...
 
bool pni::io::nx::h5::operator== (const h5datatype &a, const h5datatype &b)
 equality comparison More...
 
bool pni::io::nx::h5::operator!= (const h5datatype &a, const h5datatype &b)
 inequality More...
 
pni::core::type_id_t pni::io::nx::h5::type_id (const h5datatype &o)
 get type code More...
 
const h5datatype & pni::io::nx::h5::get_type (pni::core::type_id_t id)
 get reference to type More...
 
h5datatype pni::io::nx::h5::make_type (pni::core::type_id_t id)
 create new type More...
 
h5object_type pni::io::nx::h5::get_hdf5_type (const object_imp &o)
 return HDF5 type More...
 
pni::io::nx::nxobject_type pni::io::nx::h5::get_nexus_type (const object_imp &o)
 return Nexus type More...
 
pni::core::string pni::io::nx::h5::get_filename (const object_imp &object)
 get object filename More...
 
pni::core::string pni::io::nx::h5::get_path (const object_imp &object)
 get object path More...
 
pni::core::string pni::io::nx::h5::get_name (const object_imp &obj)
 return object name More...
 
pni::core::string pni::io::nx::h5::get_parent_path (const object_imp &object)
 get parent path More...
 
object_imp pni::io::nx::h5::get_parent (const object_imp &obj)
 return the parent object More...
 
bool pni::io::nx::h5::operator== (const object_imp &a, const object_imp &b)
 equality operator More...
 
bool pni::io::nx::h5::operator!= (const object_imp &a, const object_imp &b)
 inequality operator More...
 
size_t pni::io::nx::h5::effective_rank (const selection &s) noexcept
 get effective rank More...
 
type_imp::index_vector_type pni::io::nx::h5::effective_shape (const selection &s)
 get effective shape More...
 
size_t pni::io::nx::h5::size (const selection &s) noexcept
 get selection size More...
 
selection pni::io::nx::h5::create_selection (const type_imp::selection_vector_type &s)
 
type_imp::selection_vector_type pni::io::nx::h5::create_slice_vector (const selection &s)
 
bool pni::io::nx::h5::is_vl_string (const h5datatype &type)
 check variable length string More...
 
bool pni::io::nx::h5::is_static_string (const h5datatype &type)
 check if static length string More...
 
size_t pni::io::nx::h5::static_string_size (const h5datatype &type)
 get static string size More...
 
void pni::io::nx::h5::copy_from_vector (const char_vector_type &vector, size_t nstrs, size_t strsize, pni::core::string *strings, const formatter_ptr &formatter)
 copy char vector to strings More...
 
void pni::io::nx::h5::copy_from_vector (const char_ptr_vector_type &vector, size_t nstrs, pni::core::string *strings, const formatter_ptr &formatter)
 copy strings from vector to a pointer of strings More...
 

Detailed Description

HDF5 implementation of the Nexus file format. This module describes the implementation classes which are used to instantiate the low level class templates.

Typedef Documentation

typedef std::vector<const char*> pni::io::nx::h5::char_const_ptr_vector_type

This type is mainly used for writing strings of variable length to a field or attribute

typedef std::vector<char*> pni::io::nx::h5::char_ptr_vector_type

Mainly used for reading strings of variable length from a field or attribute.

Enumeration Type Documentation

This enumeration class defines type-codes for different kinds of HDF5 objects. As all HDF5 objects are derived from H5Object an thus can be convereted into such an object we need this codes to identify the particular object type of an instance of H5Object.

Enumerator
FILE 

HDF5 file code.

GROUP 

HDF5 group code.

DATATYPE 

HDF5 datatype code.

DATASPACE 

HDF5 dataspace code.

DATASET 

HDF5 dataset code.

ATTRIBUTE 

HDF5 attribute.

PLIST 

HDF5 property list.

BADID 

unknown object

Function Documentation

void pni::io::nx::h5::copy_from_vector ( const char_vector_type &  vector,
size_t  nstrs,
size_t  strsize,
pni::core::string *  strings,
const formatter_ptr &  formatter 
)

Copies the content of char vector to a set of strings. An exception is throws if the total number of required characters does not match the size of the vector.

Exceptions
size_mismatch_errorif nstrs*strsize!=vector.size()
Parameters
vectorthe vector with characters
nstrsnumber of strings
strsizesize of the strings
stringspointer to the first string instance
void pni::io::nx::h5::copy_from_vector ( const char_ptr_vector_type &  vector,
size_t  nstrs,
pni::core::string *  strings,
const formatter_ptr &  formatter 
)

Copies the content of a pointer of stringsa

Exceptions
size_mismatch_errorif number of strings and vector size do not match
Parameters
vectorthe vector with char poitners
nstrsnumber of strings
stringspointer to the first string
object_imp pni::io::nx::h5::create_attribute ( const object_imp &  parent,
const pni::core::string &  name,
const h5datatype &  type,
const h5dataspace &  space,
bool  overwrite 
)

Create a new attribute attached to a parent.

Exceptions
invalid_objet_errorif the parent object is not valid
object_errorin case of any errors
Parameters
parentthe parent object for the attribute
namethe name for the attribute
typean HDF5 data type
spacethe dataspace for the attribute
overwriteif true overwrite an existing attribute
Returns
the attribute as h5object
selection pni::io::nx::h5::create_selection ( const type_imp::selection_vector_type &  s)

Create a selection from a slice vector.

Parameters
sreference to the slice vector
Returns
selection instance
type_imp::selection_vector_type pni::io::nx::h5::create_slice_vector ( const selection &  s)

Create a slice vector from a selection. Such a slice vector might be used to create an array selection from an mdarray instance.

Parameters
sreference to the selection object
Returns
slice vector
void pni::io::nx::h5::delete_attribute ( const object_imp &  parent,
const pni::core::string &  name 
)

Deletes an attribute from the object.

Exceptions
invalid_object_errorif the object is not a valid HDF5 object
object_errorin case of all other errors
key_errorif attribute does not exist
Parameters
parentreference to the parent object
namethe name of the attribute to delete
size_t pni::io::nx::h5::effective_rank ( const selection &  s)
noexcept

The effective rank for a selection is the number of dimension for whome the count value is >1.

Parameters
sselection instance
Returns
effective rank
type_imp::index_vector_type pni::io::nx::h5::effective_shape ( const selection &  s)

The effective shape of a selection is basically the count buffer with those entries removed where its value is 1.

Parameters
sselection instance
Returns
vector with effective shape
object_imp pni::io::nx::h5::get_attribute_by_index ( const object_imp &  parent,
size_t  i 
)

Opens an attribute reference by index i. If i exceeds the number of attributes attached to this object an exception will be thrown.

Exceptions
invalid_object_errorif parent object is not valid
index_errorif i exceeds the total number of attributes attached to the parent object
object_errorin case of any other error
Parameters
parentthe parent object from which to retrieve the attribute
iindex of the attribute
Returns
instance of H5Attribute
object_imp pni::io::nx::h5::get_attribute_by_name ( const object_imp &  parent,
const pni::core::string &  n 
)

Open an existing attribute and returns it to the callee. If the object does not exist key_error is thrown. In case of any other error oject_error;

Exceptions
invalid_object_errorif the parent object is not valid
key_errorif attribute does not exist
object_errorin case of other errors
Parameters
parentreference to the parent object of the attribute
nname of the attribute
Returns
attribute object
string pni::io::nx::h5::get_filename ( const object_imp &  object)

Returns the name of the file an HDF5 object belongs too. This function works with the following objects

  • an HDF5 dataset
  • an HDF5 group
  • or an HDF5 attribute
Exceptions
invalid_object_errorif the object is not valid
io_errorif object data cannot be retrieveda
object_errorif validity check fails for some other reason
type_errorif the passed object is of inappropriate type
Parameters
objectHDF5 object
Returns
string with the file name
h5object_type pni::io::nx::h5::get_hdf5_type ( const object_imp &  o)

Returns the HDF5 type of an instance of h5object. Currently this can be

  • an HDF5 file
  • an HDF5 group
  • an HDF5 dataspace
  • an HDF5 dataset
  • an HDF5 attribute
  • an HDF5 property list

An exception is thrown in case of an unknown type.

Exceptions
type_errorin case of an unkown object type
invalid_object_errorif the object is not valid
object_errorin case of any other error
Parameters
oreference to h5object
Returns
HDF5 object type
string pni::io::nx::h5::get_name ( const object_imp &  obj)

Returns the name of an object. This function works for the following HDF5 types

  • groups
  • datasets
  • attributes
Exceptions
object_errorif validity check fails
invalid_object_errorif obj is not valid
io_errorin case of data retrieval issues
type_errorif object type cannot be determined
Parameters
objreference to the object from which to retrieve the name
Returns
name of the object
pni::nx::nexus_type pni::io::nx::h5::get_nexus_type ( const object_imp &  o)

Return the Nexus type of an instance of h5object. This can be either a

  • Nexus group
  • Nexus field
  • Nexus attribute
  • Nexus file

An exception is thrown if the type is unkown.

Exceptions
type_errorin the case of an unkown object type
invalid_object_errorif the object is not valid
object_errorin case of any other error
Parameters
oreference to h5object instance
Returns
Nexus type
size_t pni::io::nx::h5::get_number_of_attributes ( const object_imp &  parent)

Method returns the number of attributes attached to this object.

Exceptions
invalid_object_errorif the parent is not valid
object_errorin case of any other error
Parameters
parentthe parent object with attributes
Returns
number of attributes
object_imp pni::io::nx::h5::get_parent ( const object_imp &  obj)

Returns the parent object. If the current object is group or a field the returned object is always a group. In the case of an attribute the parent can be either a group or a field.

Exceptions
invalid_object_errorif object not valid
object_errorin case of any other error
type_errorif the type of the object is unkown or could not be determined
io_errorin case of any IO related errors
Parameters
objreference to the object from which to retrieve the parent
Returns
object instance of the parent
string pni::io::nx::h5::get_parent_path ( const object_imp &  object)

Return the path to the parent of a particular object. Supported HDf5 types are

  • groups
  • datasets
Exceptions
invalid_object_errorif object is not valid
io_errorin case of errors
object_errorif validity check fails
type_errorif the object is of an inappropriate type
Parameters
objectthe HDF5 object from which to retrieve the parent path
Returns
path to the parent
string pni::io::nx::h5::get_path ( const object_imp &  object)

Return the path of an HDF5 object as a string. This function works for the following HDF5 object types

  • group
  • dataset
Exceptions
object_errorif object validity cannot be verified
invalid_object_errorif the object is not valid
io_errorin case of any IO related error.
type_errorobject is not a group or dataset
Parameters
objectreference to the object from which to retrieve the path
Returns
path as string
const h5datatype& pni::io::nx::h5::get_type ( pni::core::type_id_t  id)
Exceptions
type_errorif id has no corresponding HDF5 data type
Parameters
idtype id for which to requeste an HDF5 datatype
Returns
reference to a predefined data type
bool pni::io::nx::h5::has_attribute ( const object_imp &  parent,
const pni::core::string &  name 
)

Checks if an attribute exists and returns true if it does. Otherwise false will be returned.

Exceptions
invalid_object_errorif parent object not valid
object_errorin case of any other errors
Parameters
parentthe parent object where we look for the attribute
namethe name of the attribute to look for
Returns
true if exists, false otherwise
bool pni::io::nx::h5::is_static_string ( const h5datatype &  type)

Returns true if the data type represents a static length string. If type is not a string type at all false will be returned.

Exceptions
object_errorif information retrieval fails
invalid_object_errorif object not valid
type_errorif data type is not supported
Parameters
typeinstance of h5datatype
Returns
true if static string type, false otherwise
bool pni::io::nx::h5::is_vl_string ( const h5datatype &  type)

Returns true if the data type represents a variable length string type.

Exceptions
object_errorif type inquery fails
invalid_object_errorif type is not valid
type_errorif the datatype is not supported
Parameters
typea type instance
Returns
true if VL string type, false otherwise
h5datatype pni::io::nx::h5::make_type ( pni::core::type_id_t  id)
Exceptions
type_errorif the ID has no HDF5 counterpart
Parameters
idtype id
Returns
h5datatype instance
bool pni::io::nx::h5::operator!= ( const h5datatype &  a,
const h5datatype &  b 
)
Exceptions
object_errorif comparison fails
Parameters
alhs value of the operator
brhs value of the operator
Returns
true if not equal
bool pni::io::nx::h5::operator!= ( const object_imp &  a,
const object_imp &  b 
)

Simply the inverse of the equality operator.

Exceptions
object_errorin case of errors
type_errorif object type cannot be determined
Parameters
alhs value of the operator
brhs value of the operator
Returns
true if not equal, false otherwise
std::ostream & pni::io::nx::h5::operator<< ( std::ostream &  o,
const h5dataspace &  s 
)
Exceptions
invalid_object_errorif dataspace is not valid
Parameters
ooutput stream
sHDF5 dataspace
Returns
modified output stream
bool pni::io::nx::h5::operator== ( const h5datatype &  a,
const h5datatype &  b 
)
Exceptions
object_errorif comparison fails
Parameters
alhs value of the operator
brhs value of the operator
Returns
true if types are equal
bool pni::io::nx::h5::operator== ( const object_imp &  a,
const object_imp &  b 
)

Operator checks if two HDF5 object are equal. This check is done by comparing the address of the objects in the file. If they share the same address the objects should be equal. Invalid objects are considered as not equal.

Exceptions
object_errorin case of errors
type_errorif object type cannot be determined
Parameters
alhs value of the operator
brhs value of the operator
Returns
true if equal, false otherwise
size_t pni::io::nx::h5::size ( const selection &  s)
noexcept

Get the number of elements referenced by the selection.

Parameters
sselection instance
Returns
number of selected elements
size_t pni::io::nx::h5::static_string_size ( const h5datatype &  type)

Return the size of the strings for a static string size type.

Exceptions
type_errorif type is not a static string type
invalid_type_errorif the type is not valid
object_errorin any other case
Parameters
typethe datatype from which to retrieve the string size
Returns
number of characters in each string
type_id_t pni::io::nx::h5::type_id ( const h5datatype &  o)

Obtain the type code of a datatype object

Exceptions
type_errorif the passed datatype is not known
invalid_object_errorif the data type instance is not valid
object_errorin case of any other error
Parameters
oinstance of an HDF5 datat type
Returns
type_id_t value for the data type