summaryrefslogtreecommitdiffstats
path: root/src/H5A.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-10-30 19:52:05 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-10-30 19:52:05 (GMT)
commitb8bb79064999b5c0e1b695a7baebde63e3e27bf6 (patch)
tree17a101d8fc0c90c8c74a404af0d4100d65ac679d /src/H5A.c
parent8d71b4cbcdc7e184b7fdb110744cd9c7d0c4b508 (diff)
downloadhdf5-b8bb79064999b5c0e1b695a7baebde63e3e27bf6.zip
hdf5-b8bb79064999b5c0e1b695a7baebde63e3e27bf6.tar.gz
hdf5-b8bb79064999b5c0e1b695a7baebde63e3e27bf6.tar.bz2
[svn-r14220] Description:
Change H5Aiterate2 -> H5Aiterate_by_name to be more consistent with other new API routine names Re-add H5Aiterate2, to operate on a particular object Tested on: FreeBSD/32 6.2 (duty) in debug mode FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Mac OS X/32 10.4.10 (amazon) in debug mode
Diffstat (limited to 'src/H5A.c')
-rw-r--r--src/H5A.c88
1 files changed, 84 insertions, 4 deletions
diff --git a/src/H5A.c b/src/H5A.c
index d4a02a6..e97b96b 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -1824,6 +1824,86 @@ done:
PURPOSE
Calls a user's function for each attribute on an object
USAGE
+ herr_t H5Aiterate2(loc_id, idx_type, order, idx, op, op_data)
+ hid_t loc_id; IN: Base location for object
+ H5_index_t idx_type; IN: Type of index to use
+ H5_iter_order_t order; IN: Order to iterate over index
+ hsize_t *idx; IN/OUT: Starting (IN) & Ending (OUT) attribute
+ in index & order
+ H5A_operator2_t op; IN: User's function to pass each attribute to
+ void *op_data; IN/OUT: User's data to pass through to iterator
+ operator function
+ RETURNS
+ Returns a negative value if an error occurs, the return value of the
+ last operator if it was non-zero (which can be a negative value), or zero
+ if all attributes were processed.
+
+ DESCRIPTION
+ This function interates over the attributes of dataset or group
+ specified with 'loc_id' & 'obj_name'. For each attribute of the object,
+ the 'op_data' and some additional information (specified below) are passed
+ to the 'op' function. The iteration begins with the '*idx'
+ object in the group and the next attribute to be processed by the operator
+ is returned in '*idx'.
+ The operation receives the ID for the group or dataset being iterated
+ over ('loc_id'), the name of the current attribute about the object
+ ('attr_name'), the attribute's "info" struct ('ainfo') and the pointer to
+ the operator data passed in to H5Aiterate2 ('op_data'). The return values
+ from an operator are:
+ A. Zero causes the iterator to continue, returning zero when all
+ attributes have been processed.
+ B. Positive causes the iterator to immediately return that positive
+ value, indicating short-circuit success. The iterator can be
+ restarted at the next attribute.
+ C. Negative causes the iterator to immediately return that value,
+ indicating failure. The iterator can be restarted at the next
+ attribute.
+--------------------------------------------------------------------------*/
+herr_t
+H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order,
+ hsize_t *idx, H5A_operator2_t op, void *op_data)
+{
+ H5A_attr_iter_op_t attr_op; /* Attribute operator */
+ hsize_t start_idx; /* Index of attribute to start iterating at */
+ hsize_t last_attr; /* Index of last attribute examined */
+ herr_t ret_value; /* Return value */
+
+ FUNC_ENTER_API(H5Aiterate2, FAIL)
+ H5TRACE6("e", "iIiIo*hx*x", loc_id, idx_type, order, idx, op,
+ op_data);
+
+ /* check arguments */
+ if(H5I_ATTR == H5I_get_type(loc_id))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute")
+ if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified")
+ if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
+
+ /* Build attribute operator info */
+ attr_op.op_type = H5A_ATTR_OP_APP2;
+ attr_op.u.app_op2 = op;
+
+ /* Call attribute iteration routine */
+ last_attr = start_idx = (idx ? *idx : 0);
+ if((ret_value = H5O_attr_iterate(loc_id, H5AC_ind_dxpl_id, idx_type, order, start_idx, &last_attr, &attr_op, op_data)) < 0)
+ HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes");
+
+ /* Set the last attribute information */
+ if(idx)
+ *idx = last_attr;
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5Aiterate2() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Aiterate_by_name
+ PURPOSE
+ Calls a user's function for each attribute on an object
+ USAGE
herr_t H5Aiterate2(loc_id, obj_name, idx_type, order, idx, op, op_data, lapl_id)
hid_t loc_id; IN: Base location for object
const char *obj_name; IN: Name of object relative to location
@@ -1850,7 +1930,7 @@ done:
The operation receives the ID for the group or dataset being iterated
over ('loc_id'), the name of the current attribute about the object
('attr_name'), the attribute's "info" struct ('ainfo') and the pointer to
- the operator data passed in to H5Aiterate2 ('op_data'). The return values
+ the operator data passed in to H5Aiterate_by_name ('op_data'). The return values
from an operator are:
A. Zero causes the iterator to continue, returning zero when all
attributes have been processed.
@@ -1862,7 +1942,7 @@ done:
attribute.
--------------------------------------------------------------------------*/
herr_t
-H5Aiterate2(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
+H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data,
hid_t lapl_id)
{
@@ -1877,7 +1957,7 @@ H5Aiterate2(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
hsize_t last_attr; /* Index of last attribute examined */
herr_t ret_value; /* Return value */
- FUNC_ENTER_API(H5Aiterate2, FAIL)
+ FUNC_ENTER_API(H5Aiterate_by_name, FAIL)
H5TRACE8("e", "i*sIiIo*hx*xi", loc_id, obj_name, idx_type, order, idx, op,
op_data, lapl_id);
@@ -1935,7 +2015,7 @@ done:
HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location")
FUNC_LEAVE_API(ret_value)
-} /* H5Aiterate2() */
+} /* H5Aiterate_by_name() */
/*--------------------------------------------------------------------------