diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-02-20 19:58:09 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-02-20 19:58:09 (GMT) |
commit | d08fabd66d4625bf387bb2edc9c19432332aed16 (patch) | |
tree | 421b336267de887763aa82c820a6fe05c3d9611b /src/H5Adeprec.c | |
parent | 8eecc944d7f741afcfd445a6c0f9906df759cdad (diff) | |
download | hdf5-d08fabd66d4625bf387bb2edc9c19432332aed16.zip hdf5-d08fabd66d4625bf387bb2edc9c19432332aed16.tar.gz hdf5-d08fabd66d4625bf387bb2edc9c19432332aed16.tar.bz2 |
[svn-r13353] Description:
Checkpoint progress on H5Aiterate2().
Mark H5Aiterate() as deprecated.
Various code cleanups.
Tested on:
Linux/32 2.6 (chicago)
Linux/64 2.6 (chicago2)
Diffstat (limited to 'src/H5Adeprec.c')
-rw-r--r-- | src/H5Adeprec.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index 0e1d264..3baca88 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -168,6 +168,74 @@ done: /*-------------------------------------------------------------------------- NAME + H5Aiterate + PURPOSE + Calls a user's function for each attribute on an object + USAGE + herr_t H5Aiterate (loc_id, attr_num, op, data) + hid_t loc_id; IN: Object (dataset or group) to be iterated over + unsigned *attr_num; IN/OUT: Starting (IN) & Ending (OUT) attribute number + H5A_operator_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 something is wrong, the return value of the + last operator if it was non-zero, or zero if all attributes were processed. + + DESCRIPTION + This function interates over the attributes of dataset or group + specified with 'loc_id'. 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 '*attr_number' + object in the group and the next attribute to be processed by the operator + is returned in '*attr_number'. + 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') and the pointer to the operator data passed in to H5Aiterate + ('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 +H5Aiterate(hid_t loc_id, unsigned *attr_num, H5A_operator_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(H5Aiterate, FAIL) + H5TRACE4("e", "i*Iuxx", loc_id, attr_num, 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") + + /* Build attribute operator info */ + attr_op.op_type = H5A_ATTR_OP_APP; + attr_op.u.app_op = op; + + /* Call attribute iteration routine */ + last_attr = start_idx = (hsize_t)(attr_num ? *attr_num : 0); + if((ret_value = H5O_attr_iterate(loc_id, H5AC_ind_dxpl_id, H5_INDEX_CRT_ORDER, H5_ITER_INC, start_idx, &last_attr, &attr_op, op_data)) < 0) + HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); + + /* Set the last attribute information */ + if(attr_num) + *attr_num = (unsigned)last_attr; + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Aiterate() */ + + +/*-------------------------------------------------------------------------- + NAME H5Adelete PURPOSE Deletes an attribute from a location |