Please, help us to better know about our user community by answering the following short survey: https://www.hdfgroup.org/website-survey/
HDF5  1.10.9-1
C-API Reference
Link Traversal

Detailed Description

Functions

herr_t H5Literate (hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5L_iterate_t op, void *op_data)
 Iterates over links in a group, with user callback routine, according to the order within an index. More...
 
herr_t H5Literate_by_name (hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5L_iterate_t op, void *op_data, hid_t lapl_id)
 Iterates through links in a group. More...
 
herr_t H5Lvisit (hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op, void *op_data)
 Recursively visits all links starting from a specified group. More...
 
herr_t H5Lvisit_by_name (hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op, void *op_data, hid_t lapl_id)
 Recursively visits all links starting from a specified group. More...
 

Function Documentation

◆ H5Literate()

herr_t H5Literate ( hid_t  grp_id,
H5_index_t  idx_type,
H5_iter_order_t  order,
hsize_t idx,
H5L_iterate_t  op,
void *  op_data 
)

Iterates over links in a group, with user callback routine, according to the order within an index.

Parameters
[in]grp_idGroup identifier
[in]idx_typeIndex type
[in]orderIteration order
[in,out]idxPointer to an iteration index to allow continuing a previous iteration
[in]opCallback function
[in,out]op_dataUser-defined callback function context
Returns
Success: The return value of the first operator that returns non-zero, or zero if all members were processed with no operator returning non-zero.
Failure: Negative if an error occurs in the library, or the negative value returned by one of the operators.

H5Literate() iterates through the links in a file or group, group_id, in the order of the specified index, idx_type, using a user-defined callback routine op. H5Literate() does not recursively follow links into subgroups of the specified group.

Three parameters are used to manage progress of the iteration: idx_type, order, and idx_p.

idx_type specifies the index to be used. If the links have not been indexed by the index type, they will first be sorted by that index then the iteration will begin; if the links have been so indexed, the sorting step will be unnecessary, so the iteration may begin more quickly.

order specifies the order in which objects are to be inspected along the index idx_type.

idx_p tracks the iteration and allows an iteration to be resumed if it was stopped before all members were processed. It is passed in by the application with a starting point and returned by the library with the point at which the iteration stopped.

op_data is a user-defined pointer to the data required to process links in the course of the iteration. This pointer is passed back to each step of the iteration in the op callback function's op_data parameter. op is invoked for each link encounter.

op_data is passed to and from each iteration and can be used to supply or aggregate information across iterations.

Remarks
Same pattern of behavior as H5Giterate().
Note
This function is also available through the H5Literate() macro.
Warning
The behavior of H5Literate() is undefined if the link membership of group_id changes during the iteration. This does not limit the ability to change link destinations while iterating, but caution is advised.
Since
1.8.0
See also
H5Literate_by_name(), H5Lvisit(), H5Lvisit_by_name()

◆ H5Literate_by_name()

herr_t H5Literate_by_name ( hid_t  loc_id,
const char *  group_name,
H5_index_t  idx_type,
H5_iter_order_t  order,
hsize_t idx,
H5L_iterate_t  op,
void *  op_data,
hid_t  lapl_id 
)

Iterates through links in a group.

Parameters
[in]loc_idLocation identifier
[in]group_nameGroup name
[in]idx_typeIndex type
[in]orderIteration order
[in,out]idxiteration position at which to start (IN) or position at which an interrupted iteration may be restarted (OUT)
[in]opCallback function
[in,out]op_dataUser-defined callback function context
[in]lapl_idLink access property list identifier
Returns
Success: The return value of the first operator that returns non-zero, or zero if all members were processed with no operator returning non-zero.
Failure: Negative if an error occurs in the library, or the negative value returned by one of the operators.

H5Literate_by_name() iterates through the links in a group specified by loc_id and group_name, in the order of the specified index, idx_type, using a user-defined callback routine op. H5Literate_by_name() does not recursively follow links into subgroups of the specified group.

idx_type specifies the index to be used. If the links have not been indexed by the index type, they will first be sorted by that index then the iteration will begin; if the links have been so indexed, the sorting step will be unnecessary, so the iteration may begin more quickly. Valid values include the following:

H5_INDEX_NAMELexicographic order on name
H5_INDEX_CRT_ORDERIndex on creation order

order specifies the order in which objects are to be inspected along the index specified in idx_type. Valid values include the following:

H5_ITER_INCIncreasing order
H5_ITER_DECDecreasing order
H5_ITER_NATIVEFastest available order

idx allows an interrupted iteration to be resumed; it is passed in by the application with a starting point and returned by the library with the point at which the iteration stopped.

Note
H5Literate_by_name() is not recursive. In particular, if a member of group_name is found to be a group, call it subgroup_a, H5Literate_by_name() does not examine the members of subgroup_a. When recursive iteration is required, the application must handle the recursion, explicitly calling H5Literate_by_name1() on discovered subgroups.
H5Literate_by_name() assumes that the membership of the group being iterated over remains unchanged through the iteration; if any of the links in the group change during the iteration, the function’s behavior is undefined. Note, however, that objects pointed to by the links can be modified.
H5Literate_by_name() is the same as H5Giterate(), except that H5Giterate() always proceeds in lexicographic order.
Version
1.8.8 Fortran subroutine added.
Since
1.8.0

◆ H5Lvisit()

herr_t H5Lvisit ( hid_t  grp_id,
H5_index_t  idx_type,
H5_iter_order_t  order,
H5L_iterate_t  op,
void *  op_data 
)

Recursively visits all links starting from a specified group.

Parameters
[in]grp_idGroup identifier
[in]idx_typeIndex type
[in]orderIteration order
[in]opCallback function
[in,out]op_dataUser-defined callback function context
Returns
Success: The return value of the first operator that returns non-zero, or zero if all members were processed with no operator returning non-zero.
Failure: Negative if an error occurs in the library, or the negative value returned by one of the operators.

H5Lvisit() is a recursive iteration function to visit all links in and below a group in an HDF5 file, thus providing a mechanism for an application to perform a common set of operations across all of those links or a dynamically selected subset. For non-recursive iteration across the members of a group, see H5Literate().

The group serving as the root of the iteration is specified by its group or file identifier, group_id.

Two parameters are used to establish the iteration: idx_type and order.

idx_type specifies the index to be used. If the links have not been indexed by the index type, they will first be sorted by that index then the iteration will begin; if the links have been so indexed, the sorting step will be unnecessary, so the iteration may begin more quickly. Valid values include the following:

H5_INDEX_NAMELexicographic order on name
H5_INDEX_CRT_ORDERIndex on creation order

Note that the index type passed in idx_type is a best effort setting. If the application passes in a value indicating iteration in creation order and a group is encountered that was not tracked in creation order, that group will be iterated over in lexicographic order by name, or name order. (Name order is the native order used by the HDF5 library and is always available.)

order specifies the order in which objects are to be inspected along the index specified in idx_type. Valid values include the following:

H5_ITER_INCIncreasing order
H5_ITER_DECDecreasing order
H5_ITER_NATIVEFastest available order

op is a callback function of type H5L_iterate_t that is invoked for each link encountered.

typedef herr_t (*H5L_iterate_t)(hid_t group, const char *name, const H5L_info_t *info, void *op_data);
int64_t hid_t
Definition: H5Ipublic.h:62
herr_t(* H5L_iterate_t)(hid_t group, const char *name, const H5L_info_t *info, void *op_data)
Prototype for H5Literate(), H5Literate_by_name() operator.
Definition: H5Lpublic.h:186
int herr_t
Definition: H5public.h:208
Information struct for links.
Definition: H5Lpublic.h:96

The H5L_info_t struct is defined (in H5Lpublic.h) as follows:

typedef struct {
H5L_type_t type;
hbool_t corder_valid;
int64_t corder;
H5T_cset_t cset;
union {
haddr_t address;
size_t val_size;
} u;
H5L_type_t
Link class types.
Definition: H5Lpublic.h:76
H5T_cset_t
Definition: H5Tpublic.h:95
unsigned long haddr_t
Definition: H5public.h:357
bool hbool_t
Definition: H5public.h:239

The possible return values from the callback function, and the effect of each, are as follows:

  • Zero causes the visit iterator to continue, returning zero when all group members have been processed.
  • A positive value causes the visit iterator to immediately return that positive value, indicating short-circuit success.
  • A negative value causes the visit iterator to immediately return that value, indicating failure.

The H5Lvisit() op_data parameter is a user-defined pointer to the data required to process links in the course of the iteration. This pointer is passed back to each step of the iteration in the op callback function's op_data parameter.

H5Lvisit() and H5Ovisit() are companion functions: one for examining and operating on links; the other for examining and operating on the objects that those links point to. Both functions ensure that by the time the function completes successfully, every link or object below the specified point in the file has been presented to the application for whatever processing the application requires.

Since
1.8.0
See also
H5Literate()

◆ H5Lvisit_by_name()

herr_t H5Lvisit_by_name ( hid_t  loc_id,
const char *  group_name,
H5_index_t  idx_type,
H5_iter_order_t  order,
H5L_iterate_t  op,
void *  op_data,
hid_t  lapl_id 
)

Recursively visits all links starting from a specified group.

Parameters
[in]loc_idLocation identifier
[in]group_nameGroup name
[in]idx_typeIndex type
[in]orderIteration order
[in]opCallback function
[in,out]op_dataUser-defined callback function context
[in]lapl_idLink access property list identifier
Returns
Returns a non-negative value if successful; otherwise returns a negative value.

H5Lvisit_by_name() is a recursive iteration function to visit all links in and below a group in an HDF5 file, thus providing a mechanism for an application to perform a common set of operations across all of those links or a dynamically selected subset. For non-recursive iteration across the members of a group, see H5Literate().

The group serving as the root of the iteration is specified by the loc_id / group_name parameter pair. loc_id specifies a file or group; group_name specifies either a group in the file (with an absolute name based in the file’s root group) or a group relative to loc_id. If loc_id fully specifies the group that is to serve as the root of the iteration, group_name should be '.' (a dot). (Note that when loc_id fully specifies the the group that is to serve as the root of the iteration, the user may wish to consider using H5Lvisit() instead of H5Lvisit_by_name().)

Two parameters are used to establish the iteration: idx_type and order.

idx_type specifies the index to be used. If the links have not been indexed by the index type, they will first be sorted by that index then the iteration will begin; if the links have been so indexed, the sorting step will be unnecesary, so the iteration may begin more quickly. Valid values include the following:

H5_INDEX_NAMELexicographic order on name
H5_INDEX_CRT_ORDERIndex on creation order

Note that the index type passed in idx_type is a best effort setting. If the application passes in a value indicating iteration in creation order and a group is encountered that was not tracked in creation order, that group will be iterated over in lexicographic order by name, or name order. (Name order is the native order used by the HDF5 library and is always available.)

order specifies the order in which objects are to be inspected along the index specified in idx_type. Valid values include the following:

H5_ITER_INCIncreasing order
H5_ITER_DECDecreasing order
H5_ITER_NATIVEFastest available order

The op callback function, the related H5L_info_t struct, and the effect that the callback function's return value has on the application are described in H5Lvisit().

The H5Lvisit_by_name() op_data parameter is a user-defined pointer to the data required to process links in the course of the iteration. This pointer is passed back to each step of the iteration in the callback function's op_data parameter.

lapl_id is a link access property list. In the general case, when default link access properties are acceptable, this can be passed in as H5P_DEFAULT. An example of a situation that requires a non-default link access property list is when the link is an external link; an external link may require that a link prefix be set in a link access property list (see H5Pset_elink_prefix()).

H5Lvisit_by_name() and H5Ovisit_by_name() are companion functions: one for examining and operating on links; the other for examining and operating on the objects that those links point to. Both functions ensure that by the time the function completes successfully, every link or object below the specified point in the file has been presented to the application for whatever processing the application requires.

Since
1.8.0