h5cpp  0.6.0
A modern C++ wrapper for the HDF5 C library
hdf5::node Namespace Reference

namespace for node like objects and related functions

Classes

class  ChunkedDataset
 dataset with chunked layout More...
 
class  Dataset
 
class  Group
 
class  GroupView
 base class for group views More...
 
class  LinkTarget
 link target descriptor More...
 
class  Link
 an HDF5 link More...
 
class  LinkIterator
 
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...
 

Typedefs

using Type = NodeType
 alias type to ensure compatibility with existing code More...
 

Enumerations

enum class  NodeType : std::underlying_type< H5O_type_t >::type { Unknown = H5O_TYPE_UNKNOWN , Group = H5O_TYPE_GROUP , Dataset = H5O_TYPE_DATASET , Datatype = H5O_TYPE_NAMED_DATATYPE }
 enumeration for node type More...
 
enum class  LinkType : std::underlying_type< H5L_type_t >::type { Hard = H5L_TYPE_HARD , Soft = H5L_TYPE_SOFT , External = H5L_TYPE_EXTERNAL , Error = H5L_TYPE_ERROR }
 link type enumeration More...
 

Functions

void resize_by (const Dataset &dataset, size_t dimension_index, ssize_t delta)
 resize a dataset by a particular offset More...
 
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...
 
void copy (const Node &source, const Group &destination, const property::ObjectCopyList &ocpl=property::ObjectCopyList(), const property::LinkCreationList &lcpl=property::LinkCreationList())
 copy node object More...
 
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...
 
void move (const Node &source, const Group &destination, const property::LinkCreationList &lcpl=property::LinkCreationList(), const property::LinkAccessList &lapl=property::LinkAccessList())
 move node object More...
 
void remove (const Group &base, const Path &object_path, const property::LinkAccessList &lapl=property::LinkAccessList())
 remove node from group More...
 
void remove (const Node &object, const property::LinkAccessList &lapl=property::LinkAccessList())
 remove node from group More...
 
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...
 
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...
 
void link (const fs::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...
 
Node get_node (const Group &base, const Path &node_path, const property::LinkAccessList &lapl=property::LinkAccessList())
 get node More...
 
Group get_real_base (const Group &base, const Path &path, const property::LinkAccessList &lapl=property::LinkAccessList())
 get real base of path More...
 
Group get_group (const Group &base, const Path &path, const property::LinkAccessList &lapl=property::LinkAccessList())
 get group More...
 
Dataset get_dataset (const Group &base, const Path &path, const property::LinkAccessList &lapl=property::LinkAccessList())
 get dataset More...
 
bool is_group (const Node &node)
 predicate function returning true if node is a group More...
 
bool is_dataset (const Node &node)
 predicate function returning true if a node is a dataset More...
 
bool operator!= (const Link &lhs, const Link &rhs)
 
std::ostream & operator<< (std::ostream &stream, const Link &link)
 
bool operator== (const Node &lhs, const Node &rhs)
 
bool operator!= (const Node &lhs, const Node &rhs)
 
std::ostream & operator<< (std::ostream &stream, const NodeType &type)
 output stream operator for the NodeType enumeration More...
 
std::ostream & operator<< (std::ostream &stream, const LinkType &type)
 output stream operator for the link type enumeration More...
 

Typedef Documentation

◆ Type

using hdf5::node::Type = typedef NodeType

This alias ensures, that existing code still using the old Type enumeration type is still working. Since NodeType and Type are equivalent from a structural point of view this should be no issue.

Enumeration Type Documentation

◆ LinkType

enum hdf5::node::LinkType : std::underlying_type< H5L_type_t >::type
strong

Enumeration type to distinguish the various link types in HDF5.

Enumerator
Hard 
Soft 
External 
Error 

◆ NodeType

enum hdf5::node::NodeType : std::underlying_type< H5O_type_t >::type
strong
Enumerator
Unknown 
Group 
Dataset 
Datatype 

Function Documentation

◆ copy() [1/2]

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]

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

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();
dataspace::Dataspace dataspace() const
get dataspace of dataset
Dataset get_dataset(const Group &base, const Path &path, const property::LinkAccessList &lapl=property::LinkAccessList())
get dataset
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()

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)
{
}
Group get_group(const Group &base, const Path &path, const property::LinkAccessList &lapl=property::LinkAccessList())
get group
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()

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

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

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);
bool is_dataset(const Node &node)
predicate function returning true if a node is a 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);
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
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()

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);
bool is_group(const Node &node)
predicate function returning true if node is a 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]

void hdf5::node::link ( const fs::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

◆ link() [2/3]

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() [3/3]

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
target_paththe 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

◆ move() [1/2]

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]

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]

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

◆ operator!=() [2/2]

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

◆ operator<<() [1/3]

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

◆ operator<<() [2/3]

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

This operator writes a textual representation of the link type to the output stream.

Parameters
streamrefernce to the output stream
typereference to the link type
Returns
modified output stream

◆ operator<<() [3/3]

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

This operator writes a text representation of the node type to the output stream.

Parameters
streamreference to the output stream
typethe actual type to write to the stream
Returns
modified output stream

◆ operator==()

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

◆ remove() [1/2]

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]

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

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