libpniio
Static Public Member Functions | Static Private Member Functions
pni::io::nx::h5::h5link Class Reference

#include <h5link.hpp>

Static Public Member Functions

static auto link_name (const group_imp &loc, size_t index) -> pni::core::string
 get link name More...
 
static auto link_target (const group_imp &loc, size_t index) -> pni::io::nx::nxpath
 get link target More...
 
static auto link_target (const group_imp &loc, const pni::core::string &name) -> pni::io::nx::nxpath
 get link target More...
 
static void create_external_link (const nxpath &target, const group_imp &loc, const pni::core::string &name)
 create an external link More...
 
static void create_internal_link (const nxpath &target, const group_imp &loc, const pni::core::string &name)
 create an internal link More...
 
static auto link_type (const group_imp &loc, const pni::core::string &name) -> pni::io::nx::nxlink_type
 get link type More...
 

Static Private Member Functions

static pni::core::string _nx2hdf5path (const nxpath &p)
 convert a Nexus path to an HDF5 path More...
 
static void check_if_valid (const group_imp &loc, const pni::core::exception_record &record, const pni::core::string &message)
 check if parent is valid More...
 
static void check_if_exists (const group_imp &loc, const pni::core::string &lname, const pni::core::exception_record &record, const pni::core::string &message="")
 check if link exists More...
 
static void check_if_exists (const group_imp &loc, size_t index, const pni::core::exception_record &record, const pni::core::string &message="")
 check if link exists More...
 
static H5L_info_t get_link_info (const group_imp &loc, const pni::core::string &name)
 get link info by name More...
 
static H5L_info_t get_link_info (const group_imp &loc, size_t index)
 get link info by index More...
 
static auto get_link_value (const group_imp &loc, const pni::core::string &lname) -> pni::core::string
 return the link value More...
 
static auto get_external_link_target (const group_imp &loc, const pni::core::string &lname) -> pni::io::nx::nxpath
 return external target More...
 
static auto get_soft_link_target (const group_imp &loc, const pni::core::string &lname) -> pni::io::nx::nxpath
 return internal target More...
 

Detailed Description

This class holds only static methods which can be used to create internal and external links.

Member Function Documentation

string pni::io::nx::h5::h5link::_nx2hdf5path ( const nxpath p)
staticprivate

This static method converts a Nexus path to an HDF5 path. HDF5 requires that all group and field names are given. Thus, one cannot use just the groups class to identify a group. If the name of a group or field is not given a pni::core::value_error is thrown.

Exceptions
pni::core::value_errorif element name is missing
Parameters
pNexus path object
Returns
HDF5 path as a string
static void pni::io::nx::h5::h5link::check_if_exists ( const group_imp loc,
const pni::core::string &  lname,
const pni::core::exception_record &  record,
const pni::core::string &  message = "" 
)
staticprivate

Checks if a link of name lname exists below group loc. This function assumes that loc is a valid HDF5 group. In case of doubts check_if_valid should be called before.

Exceptions
key_errorif link does not exist
Parameters
locthe parent group for the link
lnamethe name of the link
recordthe exception record at the position of the check
messagea custom error message that will be added to the default message
static void pni::io::nx::h5::h5link::check_if_exists ( const group_imp loc,
size_t  index,
const pni::core::exception_record &  record,
const pni::core::string &  message = "" 
)
staticprivate

Checks if a link with a particular index exists. This function does nothing else than checking if index does not exceed the total number of links below the parent group. The function asssumes that loc is a valid HDF5 group. In case of doubts call check_if_valid before.

Exceptions
index_errorif index exceeds the total number of links
Parameters
locparent HDF5 group
indexthe index of the link
recordexception record of the check
messageoptional message which will be added to the default error message
void pni::io::nx::h5::h5link::check_if_valid ( const group_imp loc,
const pni::core::exception_record &  record,
const pni::core::string &  message 
)
staticprivate

Static member function checking if the parent object is valid. Otherwise pni::io::invalid_object_error will be thrown.

Exceptions
invalid_object_errorif loc is not valid
Parameters
locreference to the parent object
recordexception record at the location where the test should be performed
messageerror message
void pni::io::nx::h5::h5link::create_external_link ( const nxpath target,
const group_imp loc,
const pni::core::string &  name 
)
static

The target path for an external link must be a full Nexus path including a filename. If it does not contain a filename nxlink_error will be thrown. name determines the name of the link as a child of loc. The target path must not contain element without a name (HDF5 cannot handle such situations) otherwise a value_error exception will be thrown.

Exceptions
invalid_object_errorif loc is not valid
link_errorif link creation fails
value_errorfor malformed paths
object_errorin case of any other error
Parameters
targetpath of the links target
loclocation where the link should be created
namelinkname below loc
void pni::io::nx::h5::h5link::create_internal_link ( const nxpath target,
const group_imp loc,
const pni::core::string &  name 
)
static

Unlike for external links in the target path can be either absolute in the file or relative to loc. name determines the name of the link below loc. target_path must not have elements without a name. In such a case a value_error will be thrown. In addition the target_path Nexus path must not contain a file name.

Exceptions
invalid_object_errorif loc is not valid
value_errorin case of a malformed path
link_errorif link creation fails
object_errorin case of any other error
Parameters
targetpath to the links target
loclocation for the new link
namename of the object below loc
auto pni::io::nx::h5::h5link::get_external_link_target ( const group_imp loc,
const pni::core::string &  lname 
) -> pni::io::nx::nxpath
staticprivate

Return the target of an external link as an instance of nxpath.

Exceptions
invalid_object_errorif loc is not a valid group
key_errorif a linke lname does not exist
link_errorin case that the value cannot be retrieved
object_errorin case of any other error
Parameters
locparent group
lnamename of the link
Returns
link target as nxpath
static H5L_info_t pni::io::nx::h5::h5link::get_link_info ( const group_imp loc,
const pni::core::string &  name 
)
staticprivate

Returns the info structure for a link of anme name.

Exceptions
invalid_object_errorif loc is not a valid group
key_errorif a link fo name name does not exist
object_errorin case of any other error
Parameters
locparent group of the link
namethe name of the link
Returns
HDF5 link info structure
H5L_info_t pni::io::nx::h5::h5link::get_link_info ( const group_imp loc,
size_t  index 
)
staticprivate

Returns the info structure for the link determined by index.

Exceptions
invalid_object_errorif loc is not a valid group
index_errorif index exceeds the total number of links below the parent group
object_errorin case of any other error
Parameters
locparent group of the link
indexlink index
Returns
HDF5 link info structure
auto pni::io::nx::h5::h5link::get_link_value ( const group_imp loc,
const pni::core::string &  lname 
) -> pni::core::string
staticprivate

Return the link value. In HDF5 the link value is the target to which a link referes to.

Exceptions
invalid_object_errorif loc is not a valid group
key_errorif a linke lname does not exist
link_errorin case that the value cannot be retrieved
object_errorin case of any other error
Returns
link value as string
auto pni::io::nx::h5::h5link::get_soft_link_target ( const group_imp loc,
const pni::core::string &  lname 
) -> pni::io::nx::nxpath
staticprivate

Return the target of an internal link as an instance of nxpath.

Exceptions
invalid_object_errorif loc is not a valid group
key_errorif a linke lname does not exist
link_errorin case that the value cannot be retrieved
object_errorin case of any other error
Parameters
locparent group
lnamename of the link
Returns
link target as nxpath
auto pni::io::nx::h5::h5link::link_name ( const group_imp loc,
size_t  index 
) -> pni::core::string
static

Return the name of the link with index index.

Exceptions
invalid_object_errorif loc is not a valid group
index_errorif index exceeds the total number of links below loc
object_errorin case of any other error
Parameters
locthe parent group object
indexthe index of the link
Returns
the name of link index
auto pni::io::nx::h5::h5link::link_target ( const group_imp loc,
size_t  index 
) -> pni::io::nx::nxpath
static

Return the target for the link with index index in group loc.

Exceptions
invalid_object_errorif loc is not a valid group
index_errorif index exceeds the total number of links
link_errorin case that the value cannot be retrieved
object_errorin case of any other error
Parameters
locparent group of the link
indexlink index
Returns
link target as nxpath instance
auto pni::io::nx::h5::h5link::link_target ( const group_imp loc,
const pni::core::string &  name 
) -> pni::io::nx::nxpath
static

Return the target for the link lname in group loc.

Exceptions
invalid_object_errorif loc is not a valid group
key_errorif a linke lname does not exist
link_errorin case that the value cannot be retrieved
object_errorin case of any other error
Parameters
locparent group of the link
lnamethe name of the link
Returns
link target as nxpath instance
auto pni::io::nx::h5::h5link::link_type ( const group_imp loc,
const pni::core::string &  name 
) -> pni::io::nx::nxlink_type
static

Returns the link type of a child of loc identified by its name.

Exceptions
invalid_object_errorif loc is not valid
key_errorif the child could not be found
link_errorif the link type could not be retrieved
type_errorif the link type is unkown
object_errorin case of any other error
Parameters
locparent group
namethe name of the child
Returns
link type

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