h5cpp  0.3.3
A modern C++ wrapper for the HDF5 C library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Enumerations | Functions
hdf5::node Namespace Reference

Classes

class  ChunkedDataset
 dataset with chunked layout More...
 
class  Dataset
 
class  Group
 
class  GroupView
 base class for group views More...
 
class  Link
 a link More...
 
class  LinkIterator
 
class  LinkTarget
 link target descriptor More...
 
class  LinkView
 
class  Node
 
class  NodeIterator
 bidirectional NodeIterator More...
 
class  NodeView
 
class  RecursiveLinkIterator
 recursive Link iterator More...
 
class  RecursiveNodeIterator
 recursive node iterator More...
 
class  VirtualDataset
 virtual dataset class More...
 

Enumerations

enum  Type : std::underlying_type< H5O_type_t >::type { Type::UNKNOWN = H5O_TYPE_UNKNOWN, Type::GROUP = H5O_TYPE_GROUP, Type::DATASET = H5O_TYPE_DATASET, Type::DATATYPE = H5O_TYPE_NAMED_DATATYPE }
 enumeration for node type More...
 
enum  LinkType : std::underlying_type< H5L_type_t >::type { LinkType::HARD = H5L_TYPE_HARD, LinkType::SOFT = H5L_TYPE_SOFT, LinkType::EXTERNAL = H5L_TYPE_EXTERNAL, LinkType::ERROR = H5L_TYPE_ERROR }
 

Functions

DLL_EXPORT void resize_by (const Dataset &dataset, size_t dimension_index, ssize_t delta)
 resize a dataset by a particular offset More...
 
DLL_EXPORT void copy (const Node &source, const Group &base, const Path &relative_path, const property::ObjectCopyList &ocpl=property::ObjectCopyList(), const property::LinkCreationList &lcpl=property::LinkCreationList())
 copy node object More...
 
DLL_EXPORT void copy (const Node &source, const Group &destination, const property::ObjectCopyList &ocpl=property::ObjectCopyList(), const property::LinkCreationList &lcpl=property::LinkCreationList())
 copy node object More...
 
DLL_EXPORT void move (const Node &source, const Group &base, const Path &relative_path, const property::LinkCreationList &lcpl=property::LinkCreationList(), const property::LinkAccessList &lapl=property::LinkAccessList())
 move node object More...
 
DLL_EXPORT void move (const Node &source, const Group &destination, const property::LinkCreationList &lcpl=property::LinkCreationList(), const property::LinkAccessList &lapl=property::LinkAccessList())
 move node object More...
 
DLL_EXPORT void remove (const Group &base, const Path &object_path, const property::LinkAccessList &lapl=property::LinkAccessList())
 remove node from group More...
 
DLL_EXPORT void remove (const Node &object, const property::LinkAccessList &lapl=property::LinkAccessList())
 remove node from group More...
 
DLL_EXPORT void link (const Node &target, const Group &link_base, const Path &link_path, const property::LinkCreationList &lcpl=property::LinkCreationList(), const property::LinkAccessList &lapl=property::LinkAccessList())
 Create a soft or external link. More...
 
DLL_EXPORT void link (const Path &target_path, const Group &link_base, const Path &link_path, const property::LinkCreationList &lcpl=property::LinkCreationList(), const property::LinkAccessList &lapl=property::LinkAccessList())
 Create a soft link. More...
 
DLL_EXPORT void link (const boost::filesystem::path &target_file, const Path &target_path, const Group &link_base, const Path &link_path, const property::LinkCreationList &lcpl=property::LinkCreationList(), const property::LinkAccessList &lapl=property::LinkAccessList())
 Create an external link. More...
 
DLL_EXPORT Node get_node (const Group &base, const Path &node_path, const property::LinkAccessList &lapl=property::LinkAccessList())
 get node More...
 
DLL_EXPORT Group get_real_base (const Group &base, const Path &path, const property::LinkAccessList &lapl=property::LinkAccessList())
 get real base of path More...
 
DLL_EXPORT Group get_group (const Group &base, const Path &path, const property::LinkAccessList &lapl=property::LinkAccessList())
 get group More...
 
DLL_EXPORT Dataset get_dataset (const Group &base, const Path &path, const property::LinkAccessList &lapl=property::LinkAccessList())
 get dataset More...
 
DLL_EXPORT bool is_group (const Node &node)
 predicate function returning true if node is a group More...
 
DLL_EXPORT bool is_dataset (const Node &node)
 predicate function returning true if a node is a dataset More...
 
DLL_EXPORT bool operator!= (const Link &lhs, const Link &rhs)
 
DLL_EXPORT std::ostream & operator<< (std::ostream &stream, const Link &link)
 
DLL_EXPORT bool operator== (const Node &lhs, const Node &rhs)
 
DLL_EXPORT bool operator!= (const Node &lhs, const Node &rhs)
 
DLL_EXPORT std::ostream & operator<< (std::ostream &stream, const Type &type)
 
DLL_EXPORT std::ostream & operator<< (std::ostream &stream, const LinkType &type)
 

Enumeration Type Documentation

◆ LinkType

enum hdf5::node::LinkType : std::underlying_type< H5L_type_t >::type
strong
Enumerator
HARD 
SOFT 
EXTERNAL 
ERROR 

◆ Type

enum hdf5::node::Type : std::underlying_type< H5O_type_t >::type
strong
Enumerator
UNKNOWN 
GROUP 
DATASET 
DATATYPE 

Function Documentation

◆ copy() [1/2]

DLL_EXPORT void hdf5::node::copy ( const Node source,
const Group base,
const Path relative_path,
const property::ObjectCopyList ocpl = property::ObjectCopyList(),
const property::LinkCreationList lcpl = property::LinkCreationList() 
)

Copy source object to a new relative_path under base Group. If an object of same name already exists an exception will be thrown.

The copy operation should also work across file boundaries. In all cases the source object as well as the destination group must exist.

Parameters
sourceobject to be copied
basethe destination base group where the new copy will be stored
relative_paththe destination relative path under the base group
ocploptional object copy property list
lcploptional link creation property list
Exceptions
std::runtime_errorin case of a failure

◆ copy() [2/2]

DLL_EXPORT void hdf5::node::copy ( const Node source,
const Group destination,
const property::ObjectCopyList ocpl = property::ObjectCopyList(),
const property::LinkCreationList lcpl = property::LinkCreationList() 
)

Copy source object to a new location under destination Group using the original object's name. For instance, if we have

  • source path /detector/data
  • destination path /recorded/detectors

then the copy will appear as /recorded/detectors/data. If an object of same name already exists an exception will be thrown.

The copy operation should also work across file boundaries. In all cases the source object as well as the destination group must exist.

Parameters
sourceobject to be copied
destinationthe destination group where the new copy will be stored
ocploptional object copy property list
lcploptional link creation property list
Exceptions
std::runtime_errorin case of a failure

◆ get_dataset()

DLL_EXPORT Dataset hdf5::node::get_dataset ( const Group base,
const Path path,
const property::LinkAccessList lapl = property::LinkAccessList() 
)

A convenience function for get_node. Returns a Dataset instance if the node referenced by path is a dataset, otherwise throws an exception. Use this function whenever you want to work with a Dataset temporarily.

For instance

Group root = file.root();
Dataspace space = get_dataset(root,"run_01/sensors/temperature").dataspace();
Exceptions
std::runtime_errorin case of a failure
Parameters
basebase group
pathpath to dataset
laploptional link access property list
Returns
new Group instance
See also
get_node
get_dataset

◆ get_group()

DLL_EXPORT Group hdf5::node::get_group ( const Group base,
const Path path,
const property::LinkAccessList lapl = property::LinkAccessList() 
)

A convenience function for get_node. Returns a Group instance if the node referenced by path is a group, otherwise throws an exception. Use this function whenever you want to work with a Group temporarily.

For instance

Group root = file.root();
if(get_group(root,"run_01/sensors").nodes.size()!=0)
{
}
Exceptions
std::runtime_errorin case of a failure
Parameters
basebase group
pathpath to group
laploptional link access property list
Returns
new Group instance
See also
get_node
get_dataset

◆ get_node()

DLL_EXPORT Node hdf5::node::get_node ( const Group base,
const Path node_path,
const property::LinkAccessList lapl = property::LinkAccessList() 
)

Get a node from a base group.

Exceptions
std::runtime_errorin case of a failure
Parameters
basereference to the base group
node_pathreference to the path of the node
laploptional link access property list
Returns
new node instance

◆ get_real_base()

DLL_EXPORT Group hdf5::node::get_real_base ( const Group base,
const Path path,
const property::LinkAccessList lapl = property::LinkAccessList() 
)

Helper function to facilitate a number of convenience functions in the wrapper. Gets the most proximate parent Group of path. If path is absolute, base will only be used to obtain the root node of the file. If the parent node does not exist or is not a Group, an exception will be thrown.

Exceptions
std::runtime_errorin case of a failure
Parameters
basebase group for link
pathpath of desired node
laploptional link access property list
Returns
most recent parent Group of path

◆ is_dataset()

DLL_EXPORT bool hdf5::node::is_dataset ( const Node node)

This predicate function is used to filter dataset nodes. A typical application would be for instance

std::vector<Dataset> datasets;
std::copy_if(root.nodes.begin(),root.nodes.end(),std::back_inserter(datasets),is_dataset);

or whenever you want to partition a vector

std::vector<Nodes> nodes;
std::copy(root.nodes.begin(),root.nodes.end(),std::back_inserter(nodes));
auto first_group = std::partition_by(nodes.begin(),nodes.end(),is_dataset);
Exceptions
std::runtime_errorin case of a failure
Parameters
nodereference to the node
Returns
true if the node is a dataset, false otherwise

◆ is_group()

DLL_EXPORT bool hdf5::node::is_group ( const Node node)

This predicate function is used to filter group nodes. A typical application would be for instance

std::vector<Group> groups;
std::copy_if(root.nodes.begin(),root.nodes.end(),std::back_inserter(groups),is_group);

or whenever you want to partition a vector

std::vector<Node> nodes;
std::copy(root.nodes.begin(),root.nodes.end(),std::back_inserter(nodes));
auto first_dset = std::partition_by(nodes.begin(),nodes.end(),is_group);
Exceptions
std::runtime_errorin case of a failure
Parameters
nodereference to the node
Returns
true if the node is a group, false otherwise

◆ link() [1/3]

DLL_EXPORT void hdf5::node::link ( const Node target,
const Group link_base,
const Path link_path,
const property::LinkCreationList lcpl = property::LinkCreationList(),
const property::LinkAccessList lapl = property::LinkAccessList() 
)

Create a link from link_path under link_base to object at target_path under target_base. A soft link will be created if link_base and target_base reside in the same file. Otherwise an external link is created.

The target for the link is determined by target_base and target_path. If the latter one is a relative path the target location is assumed relative to target_base. If it is an absolute path, target_base is used to retrieve the root group of the specific file.

Parameters
targetthe target node (could also be path here?)
link_basethe base group for the link location
link_pathpath to the new link (either relative or absolute)
lcploptional link creation property list
laploptional link access property list

◆ link() [2/3]

DLL_EXPORT void hdf5::node::link ( const Path target_path,
const Group link_base,
const Path link_path,
const property::LinkCreationList lcpl = property::LinkCreationList(),
const property::LinkAccessList lapl = property::LinkAccessList() 
)

Create a link from link_path under link_base to object at target_path. The object at target_path need not already exist at this time.

If the target_path is a relative path the target location is assumed relative to link_base. If absolute, the path is assumed to be on the same file as link_base.

Parameters
targetthe target node (could also be path here?)
link_basethe base group for the link location
link_pathpath to the new link (either relative or absolute)
lcploptional link creation property list
laploptional link access property list

◆ link() [3/3]

DLL_EXPORT void hdf5::node::link ( const boost::filesystem::path &  target_file,
const Path target_path,
const Group link_base,
const Path link_path,
const property::LinkCreationList lcpl = property::LinkCreationList(),
const property::LinkAccessList lapl = property::LinkAccessList() 
)

Create an external link to an object stored in a different file. The target object is determined by the target file and an absolute path within this file. The location of the link is given by a base group and a relative or absolute path. If link_path is a relative path the new link will be relative to link_base. Otherwise link_base is only used to determine the root group (and thus the file within which the link is placed).

Exceptions
std::runtime_errorin case of a failure
Parameters
target_filethe file where the link target is stored
target_pathabsolute path to the object which we want to reference in the target file
link_basebase group for the link
link_pathabsolute or relative path to the new link
lcploptional link creation property list
laploptional link access property list
Precondition
target_path must be an absolute path
link_base must be a valid HDF5 object

◆ move() [1/2]

DLL_EXPORT void hdf5::node::move ( const Node source,
const Group base,
const Path relative_path,
const property::LinkCreationList lcpl = property::LinkCreationList(),
const property::LinkAccessList lapl = property::LinkAccessList() 
)

Move source object to a new relative_path under base Group. If an object of same name already exists an exception will be thrown. In all cases the source object as well as the destination group must exist.

Parameters
sourceobject to be moved
basethe destination base group where the object will be moved
relative_paththe destination relative path under the base group
lcploptional link creation property list
laploptional link access property list
Exceptions
std::runtime_errorin case of a failure

◆ move() [2/2]

DLL_EXPORT void hdf5::node::move ( const Node source,
const Group destination,
const property::LinkCreationList lcpl = property::LinkCreationList(),
const property::LinkAccessList lapl = property::LinkAccessList() 
)

Move source object to a new location under destination Group using the original object's name. For instance, if we have

  • source path /detector/data
  • destination path /recorded/detectors

then the moved object will appear as /recorded/detectors/data. If an object of same name already exists an exception will be thrown. In all cases the source object as well as the destination group must exist.

Parameters
sourceobject to be moved
destinationthe new group where the object should be located
lcploptional link creation property list
laploptional link access property list
Exceptions
std::runtime_errorin case of a failure

◆ operator!=() [1/2]

DLL_EXPORT bool hdf5::node::operator!= ( const Node lhs,
const Node rhs 
)

◆ operator!=() [2/2]

DLL_EXPORT bool hdf5::node::operator!= ( const Link lhs,
const Link rhs 
)

◆ operator<<() [1/3]

DLL_EXPORT std::ostream& hdf5::node::operator<< ( std::ostream &  stream,
const Type type 
)

◆ operator<<() [2/3]

DLL_EXPORT std::ostream& hdf5::node::operator<< ( std::ostream &  stream,
const LinkType type 
)

◆ operator<<() [3/3]

DLL_EXPORT std::ostream& hdf5::node::operator<< ( std::ostream &  stream,
const Link link 
)

◆ operator==()

DLL_EXPORT bool hdf5::node::operator== ( const Node lhs,
const Node rhs 
)

◆ remove() [1/2]

DLL_EXPORT void hdf5::node::remove ( const Group base,
const Path object_path,
const property::LinkAccessList lapl = property::LinkAccessList() 
)

Removes link at object_path within the base Group. If there are more references (links) to this particular object, they remain active. Additionally: removing an object entirely from an HDF5 file means removing all links to this object and thus rendering it inaccessible. No storage space in the file will be cleared. In order to reduce the size of the file h5repack must be used which will simply not copy objects which cannot be referenced.

Exceptions
std::runtime_errorin case of a failure
Parameters
basegroup relative to which the link or object resides
object_pathpath relative to base determining the link or object to remove
laploptional link access property list

◆ remove() [2/2]

DLL_EXPORT void hdf5::node::remove ( const Node object,
const property::LinkAccessList lapl = property::LinkAccessList() 
)

Removes link to object from parent Group via which it was accessed.

Exceptions
std::runtime_errorin case of a failure
Parameters
objectthe object which to remove
Precondition
object must be a valid HDF5 object instance
Parameters
laploptional link access property list
See also
remove(const Node &base, const Path &object_path)

◆ resize_by()

DLL_EXPORT void hdf5::node::resize_by ( const Dataset dataset,
size_t  dimension_index,
ssize_t  delta 
)

Resizes a dataset along the dimension determined by dimension_index by delta elements. As delta is a signed integer one can either enlarge or shrink the dataset.

Parameters
datasetreference to the dataset to resize
dimension_indexthe index of the dimension to resize
deltathe number of elements about which the dataset should be resized
Exceptions
std::runtime_errorin case of any failure