diff options
-rw-r--r-- | c++/src/H5Object.cpp | 2 | ||||
-rw-r--r-- | examples/h5_attribute.c | 2 | ||||
-rw-r--r-- | hl/src/H5IM.c | 2 | ||||
-rw-r--r-- | hl/src/H5LT.c | 2 | ||||
-rw-r--r-- | src/H5A.c | 88 | ||||
-rw-r--r-- | src/H5Apublic.h | 4 | ||||
-rw-r--r-- | test/cache_common.h | 4 | ||||
-rw-r--r-- | test/dtypes.c | 8 | ||||
-rw-r--r-- | test/tattr.c | 189 | ||||
-rw-r--r-- | test/titerate.c | 10 | ||||
-rw-r--r-- | tools/h5dump/h5dump.c | 42 | ||||
-rw-r--r-- | tools/h5ls/h5ls.c | 4 |
12 files changed, 300 insertions, 57 deletions
diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp index e3dafa7..b3a404c 100644 --- a/c++/src/H5Object.cpp +++ b/c++/src/H5Object.cpp @@ -209,7 +209,7 @@ int H5Object::iterateAttrs( attr_operator_t user_op, unsigned *_idx, void *op_da // call the C library routine H5Aiterate2 to iterate the attributes hsize_t idx = (hsize_t)*_idx; - int ret_value = H5Aiterate2(id, ".", H5_INDEX_NAME, H5_ITER_INC, &idx, userAttrOpWrpr, (void *) userData, H5P_DEFAULT); + int ret_value = H5Aiterate2(id, H5_INDEX_NAME, H5_ITER_INC, &idx, userAttrOpWrpr, (void *) userData); // release memory delete userData; diff --git a/examples/h5_attribute.c b/examples/h5_attribute.c index 665e2c0..27d144a 100644 --- a/examples/h5_attribute.c +++ b/examples/h5_attribute.c @@ -210,7 +210,7 @@ main (void) /* * Get attribute info using iteration function. */ - ret = H5Aiterate2(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, attr_info, NULL, H5P_DEFAULT); + ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_info, NULL); /* * Close the dataset and the file. diff --git a/hl/src/H5IM.c b/hl/src/H5IM.c index 0cc79e4..fa5f87d 100644 --- a/hl/src/H5IM.c +++ b/hl/src/H5IM.c @@ -207,7 +207,7 @@ find_palette(hid_t loc_id, const char *name, const H5A_info_t *ainfo, herr_t H5IM_find_palette( hid_t loc_id ) { - return H5Aiterate2(loc_id, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, find_palette, NULL, H5P_DEFAULT); + return H5Aiterate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, find_palette, NULL); } diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 84b0cea..d794912 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -1423,7 +1423,7 @@ herr_t H5LTfind_attribute( hid_t loc_id, const char* attr_name ) herr_t H5LT_find_attribute( hid_t loc_id, const char* attr_name ) { - return H5Aiterate2(loc_id, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, find_attr, (void *)attr_name, H5P_DEFAULT); + return H5Aiterate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, find_attr, (void *)attr_name); } @@ -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() */ /*-------------------------------------------------------------------------- diff --git a/src/H5Apublic.h b/src/H5Apublic.h index 8637b2e..97c067e 100644 --- a/src/H5Apublic.h +++ b/src/H5Apublic.h @@ -71,7 +71,9 @@ H5_DLL herr_t H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_DLL herr_t H5Arename(hid_t loc_id, const char *old_name, const char *new_name); H5_DLL herr_t H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, const char *new_attr_name, hid_t lapl_id); -H5_DLL herr_t H5Aiterate2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, +H5_DLL 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); +H5_DLL herr_t 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 lapd_id); H5_DLL herr_t H5Adelete2(hid_t loc_id, const char *obj_name, diff --git a/test/cache_common.h b/test/cache_common.h index ed3b857..23832dc 100644 --- a/test/cache_common.h +++ b/test/cache_common.h @@ -486,8 +486,8 @@ extern const char * entry_type_names[NUMBER_OF_ENTRY_TYPES]; /* call back function declarations: */ -herr_t check_write_permitted(const H5F_t UNUSED * f, - hid_t UNUSED dxpl_id, +herr_t check_write_permitted(const H5F_t * f, + hid_t dxpl_id, hbool_t * write_permitted_ptr); herr_t pico_clear(H5F_t * f, void * thing, hbool_t dest); diff --git a/test/dtypes.c b/test/dtypes.c index ea56056..15f2b92 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -94,11 +94,11 @@ typedef enum dtype_t { static int num_opaque_conversions_g = 0; static int opaque_check(int tag_it); -static herr_t convert_opaque(hid_t UNUSED st, hid_t UNUSED dt, +static herr_t convert_opaque(hid_t st, hid_t dt, H5T_cdata_t *cdata, - size_t UNUSED nelmts, size_t UNUSED buf_stride, - size_t UNUSED bkg_stride, void UNUSED *_buf, - void UNUSED *bkg, hid_t UNUSED dset_xfer_plid); + size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *_buf, + void *bkg, hid_t dset_xfer_plid); static int opaque_long(void); static int opaque_funcs(void); diff --git a/test/tattr.c b/test/tattr.c index 5bf24f4..201989a 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -1448,7 +1448,7 @@ test_attr_iterate(hid_t fapl) /* Iterate over attributes on dataset */ count = 0; - ret = H5Aiterate2(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, attr_op1, &count, H5P_DEFAULT); + ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_op1, &count); VERIFY(ret, 0, "H5Aiterate2"); /* Close dataset */ @@ -1466,7 +1466,7 @@ test_attr_iterate(hid_t fapl) /* Iterate over attributes on dataset */ count = 0; - ret = H5Aiterate2(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, attr_op1, &count, H5P_DEFAULT); + ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_op1, &count); VERIFY(ret, 0, "H5Aiterate2"); /* Close dataset */ @@ -5694,8 +5694,9 @@ attr_iterate2_fail_cb(hid_t UNUSED group_id, const char UNUSED *attr_name, *------------------------------------------------------------------------- */ static int -attr_iterate_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, - unsigned max_attrs, attr_iter_info_t *iter_info) +attr_iterate_check(hid_t fid, const char *dsetname, hid_t obj_id, + H5_index_t idx_type, H5_iter_order_t order, unsigned max_attrs, + attr_iter_info_t *iter_info) { unsigned v; /* Local index variable */ hsize_t skip; /* # of attributes to skip on object */ @@ -5715,7 +5716,7 @@ attr_iterate_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, iter_info->ncalled = 0; iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - ret = H5Aiterate2(obj_id, ".", idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT); + ret = H5Aiterate2(obj_id, idx_type, order, &skip, attr_iterate2_cb, iter_info); CHECK(ret, FAIL, "H5Aiterate2"); /* Verify that we visited all the attributes */ @@ -5724,6 +5725,38 @@ attr_iterate_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, VERIFY(iter_info->visited[v], TRUE, "H5Aiterate2"); + /* Iterate over attributes on object */ + iter_info->nskipped = (unsigned)(skip = 0); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); + HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); + ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Aiterate_by_name"); + + /* Verify that we visited all the attributes */ + VERIFY(skip, max_attrs, "H5Aiterate_by_name"); + for(v = 0; v < max_attrs; v++) + VERIFY(iter_info->visited[v], TRUE, "H5Aiterate_by_name"); + + + /* Iterate over attributes on object */ + iter_info->nskipped = (unsigned)(skip = 0); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); + HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); + ret = H5Aiterate_by_name(obj_id, ".", idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Aiterate_by_name"); + + /* Verify that we visited all the attributes */ + VERIFY(skip, max_attrs, "H5Aiterate_by_name"); + for(v = 0; v < max_attrs; v++) + VERIFY(iter_info->visited[v], TRUE, "H5Aiterate_by_name"); + + #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over attributes on object, with H5Aiterate1 */ iter_info->nskipped = oskip = 0; @@ -5749,7 +5782,7 @@ attr_iterate_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, iter_info->ncalled = 0; iter_info->curr = order != H5_ITER_DEC ? skip : ((max_attrs - 1) - skip); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - ret = H5Aiterate2(obj_id, ".", idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT); + ret = H5Aiterate2(obj_id, idx_type, order, &skip, attr_iterate2_cb, iter_info); CHECK(ret, FAIL, "H5Aiterate2"); /* Verify that we visited all the attributes */ @@ -5774,6 +5807,70 @@ attr_iterate_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, } /* end else */ + /* Skip over some attributes on object */ + iter_info->nskipped = (unsigned)(skip = max_attrs / 2); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? skip : ((max_attrs - 1) - skip); + HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); + ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Aiterate_by_name"); + + /* Verify that we visited all the attributes */ + VERIFY(skip, max_attrs, "H5Aiterate_by_name"); + if(order == H5_ITER_INC) { + for(v = 0; v < (max_attrs / 2); v++) + VERIFY(iter_info->visited[v + (max_attrs / 2)], TRUE, "H5Aiterate_by_name"); + } /* end if */ + else if(order == H5_ITER_DEC) { + for(v = 0; v < (max_attrs / 2); v++) + VERIFY(iter_info->visited[v], TRUE, "H5Aiterate_by_name"); + } /* end if */ + else { + unsigned nvisit = 0; /* # of links visited */ + + HDassert(order == H5_ITER_NATIVE); + for(v = 0; v < max_attrs; v++) + if(iter_info->visited[v] == TRUE) + nvisit++; + + VERIFY(skip, (max_attrs / 2), "H5Aiterate_by_name"); + } /* end else */ + + + /* Skip over some attributes on object */ + iter_info->nskipped = (unsigned)(skip = max_attrs / 2); + iter_info->order = order; + iter_info->stop = -1; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? skip : ((max_attrs - 1) - skip); + HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); + ret = H5Aiterate_by_name(obj_id, ".", idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Aiterate_by_name"); + + /* Verify that we visited all the attributes */ + VERIFY(skip, max_attrs, "H5Aiterate_by_name"); + if(order == H5_ITER_INC) { + for(v = 0; v < (max_attrs / 2); v++) + VERIFY(iter_info->visited[v + (max_attrs / 2)], TRUE, "H5Aiterate_by_name"); + } /* end if */ + else if(order == H5_ITER_DEC) { + for(v = 0; v < (max_attrs / 2); v++) + VERIFY(iter_info->visited[v], TRUE, "H5Aiterate_by_name"); + } /* end if */ + else { + unsigned nvisit = 0; /* # of links visited */ + + HDassert(order == H5_ITER_NATIVE); + for(v = 0; v < max_attrs; v++) + if(iter_info->visited[v] == TRUE) + nvisit++; + + VERIFY(skip, (max_attrs / 2), "H5Aiterate_by_name"); + } /* end else */ + + #ifndef H5_NO_DEPRECATED_SYMBOLS /* Skip over some attributes on object, with H5Aiterate1 */ iter_info->nskipped = oskip = max_attrs / 2; @@ -5815,12 +5912,38 @@ attr_iterate_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, iter_info->ncalled = 0; iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); - ret = H5Aiterate2(obj_id, ".", idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT); + ret = H5Aiterate2(obj_id, idx_type, order, &skip, attr_iterate2_cb, iter_info); CHECK(ret, FAIL, "H5Aiterate2"); VERIFY(ret, CORDER_ITER_STOP, "H5Aiterate2"); VERIFY(iter_info->ncalled, 3, "H5Aiterate2"); + /* Iterate over attributes on object, stopping in the middle */ + iter_info->nskipped = (unsigned)(skip = 0); + iter_info->order = order; + iter_info->stop = 3; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); + HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); + ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Aiterate_by_name"); + VERIFY(ret, CORDER_ITER_STOP, "H5Aiterate_by_name"); + VERIFY(iter_info->ncalled, 3, "H5Aiterate_by_name"); + + + /* Iterate over attributes on object, stopping in the middle */ + iter_info->nskipped = (unsigned)(skip = 0); + iter_info->order = order; + iter_info->stop = 3; + iter_info->ncalled = 0; + iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1); + HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); + ret = H5Aiterate_by_name(obj_id, ".", idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Aiterate_by_name"); + VERIFY(ret, CORDER_ITER_STOP, "H5Aiterate_by_name"); + VERIFY(iter_info->ncalled, 3, "H5Aiterate_by_name"); + + #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over attributes on object, stopping in the middle, with H5Aiterate1() */ iter_info->nskipped = oskip = 0; @@ -5838,9 +5961,17 @@ attr_iterate_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, /* Check for iteration routine indicating failure */ skip = 0; - ret = H5Aiterate2(obj_id, ".", idx_type, order, &skip, attr_iterate2_fail_cb, NULL, H5P_DEFAULT); + ret = H5Aiterate2(obj_id, idx_type, order, &skip, attr_iterate2_fail_cb, NULL); VERIFY(ret, FAIL, "H5Aiterate2"); + skip = 0; + ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &skip, attr_iterate2_fail_cb, NULL, H5P_DEFAULT); + VERIFY(ret, FAIL, "H5Aiterate_by_name"); + + skip = 0; + ret = H5Aiterate_by_name(obj_id, ".", idx_type, order, &skip, attr_iterate2_fail_cb, NULL, H5P_DEFAULT); + VERIFY(ret, FAIL, "H5Aiterate_by_name"); + /* Retrieve current # of errors */ if(old_nerrs == GetTestNumErrs()) return(0); @@ -5877,6 +6008,7 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) hbool_t *visited = NULL; /* Array of flags for visiting links */ hsize_t idx; /* Start index for iteration */ hbool_t use_index; /* Use index on creation order values */ + const char *dsetname; /* Name of dataset for attributes */ char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned curr_dset; /* Current dataset to work on */ unsigned u; /* Local index variable */ @@ -5959,14 +6091,17 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) switch(curr_dset) { case 0: my_dataset = dset1; + dsetname = DSET1_NAME; break; case 1: my_dataset = dset2; + dsetname = DSET2_NAME; break; case 2: my_dataset = dset3; + dsetname = DSET3_NAME; break; default: @@ -5980,9 +6115,15 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test"); /* Check for iterating over object with no attributes (should be OK) */ - ret = H5Aiterate2(my_dataset, ".", idx_type, order, NULL, attr_iterate2_cb, NULL, H5P_DEFAULT); + ret = H5Aiterate2(my_dataset, idx_type, order, NULL, attr_iterate2_cb, NULL); CHECK(ret, FAIL, "H5Aiterate2"); + ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, NULL, attr_iterate2_cb, NULL, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Aiterate_by_name"); + + ret = H5Aiterate_by_name(my_dataset, ".", idx_type, order, NULL, attr_iterate2_cb, NULL, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Aiterate_by_name"); + /* Create attributes, up to limit of compact form */ for(u = 0; u < max_compact; u++) { /* Create attribute */ @@ -6014,11 +6155,19 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) /* Check for out of bound iteration */ idx = u; - ret = H5Aiterate2(my_dataset, ".", idx_type, order, &idx, attr_iterate2_cb, NULL, H5P_DEFAULT); + ret = H5Aiterate2(my_dataset, idx_type, order, &idx, attr_iterate2_cb, NULL); VERIFY(ret, FAIL, "H5Aiterate2"); + idx = u; + ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &idx, attr_iterate2_cb, NULL, H5P_DEFAULT); + VERIFY(ret, FAIL, "H5Aiterate_by_name"); + + idx = u; + ret = H5Aiterate_by_name(my_dataset, ".", idx_type, order, &idx, attr_iterate2_cb, NULL, H5P_DEFAULT); + VERIFY(ret, FAIL, "H5Aiterate_by_name"); + /* Test iteration over attributes stored compactly */ - ret = attr_iterate_check(my_dataset, idx_type, order, u, &iter_info); + ret = attr_iterate_check(fid, dsetname, my_dataset, idx_type, order, u, &iter_info); CHECK(ret, FAIL, "attr_iterate_check"); } /* end for */ @@ -6028,14 +6177,17 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) switch(curr_dset) { case 0: my_dataset = dset1; + dsetname = DSET1_NAME; break; case 1: my_dataset = dset2; + dsetname = DSET2_NAME; break; case 2: my_dataset = dset3; + dsetname = DSET3_NAME; break; default: @@ -6088,11 +6240,19 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) /* Check for out of bound iteration */ idx = u; - ret = H5Aiterate2(my_dataset, ".", idx_type, order, &idx, attr_iterate2_cb, NULL, H5P_DEFAULT); + ret = H5Aiterate2(my_dataset, idx_type, order, &idx, attr_iterate2_cb, NULL); VERIFY(ret, FAIL, "H5Aiterate2"); + idx = u; + ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &idx, attr_iterate2_cb, NULL, H5P_DEFAULT); + VERIFY(ret, FAIL, "H5Aiterate_by_name"); + + idx = u; + ret = H5Aiterate_by_name(my_dataset, ".", idx_type, order, &idx, attr_iterate2_cb, NULL, H5P_DEFAULT); + VERIFY(ret, FAIL, "H5Aiterate_by_name"); + /* Test iteration over attributes stored densely */ - ret = attr_iterate_check(my_dataset, idx_type, order, u, &iter_info); + ret = attr_iterate_check(fid, dsetname, my_dataset, idx_type, order, u, &iter_info); CHECK(ret, FAIL, "attr_iterate_check"); } /* end for */ @@ -6459,7 +6619,8 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) *------------------------------------------------------------------------- */ static int -attr_open_check(hid_t fid, const char *dsetname, hid_t obj_id, unsigned max_attrs) +attr_open_check(hid_t fid, const char *dsetname, hid_t obj_id, + unsigned max_attrs) { hid_t attr_id; /* ID of attribute to test */ H5A_info_t ainfo; /* Attribute info */ diff --git a/test/titerate.c b/test/titerate.c index 0579123..5b354ce 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -443,28 +443,28 @@ static void test_iter_attr(hid_t fapl, hbool_t new_format) /* Test skipping exactly as many attributes as there are */ idx = NATTR; H5E_BEGIN_TRY { - ret = H5Aiterate2(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info, H5P_DEFAULT); + ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info); } H5E_END_TRY; VERIFY(ret, FAIL, "H5Aiterate2"); /* Test skipping more attributes than there are */ idx = NATTR + 1; H5E_BEGIN_TRY { - ret = H5Aiterate2(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info, H5P_DEFAULT); + ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info); } H5E_END_TRY; VERIFY(ret, FAIL, "H5Aiterate2"); /* Test all attributes on dataset, when callback always returns 0 */ info.command = RET_ZERO; idx = 0; - if((ret = H5Aiterate2(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info, H5P_DEFAULT)) > 0) + if((ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info)) > 0) TestErrPrintf("Attribute iteration function didn't return zero correctly!\n"); /* Test all attributes on dataset, when callback always returns 1 */ /* This also tests the "restarting" ability, because the index changes */ info.command = RET_TWO; idx = i = 0; - while((ret = H5Aiterate2(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info, H5P_DEFAULT)) > 0) { + while((ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info)) > 0) { /* Verify return value from iterator gets propagated correctly */ VERIFY(ret, 2, "H5Aiterate2"); @@ -490,7 +490,7 @@ static void test_iter_attr(hid_t fapl, hbool_t new_format) /* This also tests the "restarting" ability, because the index changes */ info.command = new_format ? RET_CHANGE2 : RET_CHANGE; idx = i = 0; - while((ret = H5Aiterate2(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info, H5P_DEFAULT)) > 0) { + while((ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info)) > 0) { /* Verify return value from iterator gets propagated correctly */ VERIFY(ret, 1, "H5Aiterate2"); diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 759afdf..be1d80a 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -1816,9 +1816,9 @@ dump_named_datatype(hid_t tid, const char *name) in the datatype's create property list for attributes, then, sort by creation order, otherwise by name */ if( (sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) - H5Aiterate2(tid, ".", sort_by, sort_order, NULL, dump_attr_cb, NULL, H5P_DEFAULT); + H5Aiterate2(tid, sort_by, sort_order, NULL, dump_attr_cb, NULL); else - H5Aiterate2(tid, ".", H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL, H5P_DEFAULT); + H5Aiterate2(tid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL); indent -= COL; end_obj(dump_header_format->datatypeend, @@ -1928,15 +1928,15 @@ dump_group(hid_t gid, const char *name) /* attribute iteration: if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set in the group for attributes, then, sort by creation order, otherwise by name */ - if( (sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) - H5Aiterate2(gid, ".", sort_by, sort_order, NULL, dump_attr_cb, NULL, H5P_DEFAULT); + if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) + H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL); else - H5Aiterate2(gid, ".", H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL, H5P_DEFAULT); + H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL); /* if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set in the group, then, sort by creation order, otherwise by name */ - if( (sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED)) + if((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED)) H5Literate(gid, ".", sort_by, sort_order, NULL, dump_all_cb, NULL, H5P_DEFAULT); else H5Literate(gid, ".", H5_INDEX_NAME, sort_order, NULL, dump_all_cb, NULL, H5P_DEFAULT); @@ -1951,15 +1951,15 @@ dump_group(hid_t gid, const char *name) /* attribute iteration: if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set in the group for attributes, then, sort by creation order, otherwise by name */ - if( (sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) - H5Aiterate2(gid, ".", sort_by, sort_order, NULL, dump_attr_cb, NULL, H5P_DEFAULT); + if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) + H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL); else - H5Aiterate2(gid, ".", H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL, H5P_DEFAULT); + H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL); /* if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set in the group, then, sort by creation order, otherwise by name */ - if( (sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED)) + if((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED)) H5Literate(gid, ".", sort_by, sort_order, NULL, dump_all_cb, NULL, H5P_DEFAULT); else H5Literate(gid, ".", H5_INDEX_NAME, sort_order, NULL, dump_all_cb, NULL, H5P_DEFAULT); @@ -2057,9 +2057,9 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) in the group for attributes, then, sort by creation order, otherwise by name */ if( (sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) - H5Aiterate2(did, ".", sort_by, sort_order, NULL, dump_attr_cb, NULL, H5P_DEFAULT); + H5Aiterate2(did, sort_by, sort_order, NULL, dump_attr_cb, NULL); else - H5Aiterate2(did, ".", H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL, H5P_DEFAULT); + H5Aiterate2(did, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL); indent -= COL; @@ -5431,10 +5431,10 @@ xml_dump_group(hid_t gid, const char *name) /* 1. do all the attributes of the group */ - if( (sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) - H5Aiterate2(gid, ".", sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL, H5P_DEFAULT); + if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) + H5Aiterate2(gid, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL); else - H5Aiterate2(gid, ".", H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL, H5P_DEFAULT); + H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL); if(isRoot && unamedtype) { unsigned u; @@ -5495,10 +5495,10 @@ xml_dump_group(hid_t gid, const char *name) /* 1. do all the attributes of the group */ - if( (sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) - H5Aiterate2(gid, ".", sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL, H5P_DEFAULT); + if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) + H5Aiterate2(gid, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL); else - H5Aiterate2(gid, ".", H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL, H5P_DEFAULT); + H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL); if(isRoot && unamedtype) { @@ -6153,10 +6153,10 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) indent += COL; - if( (sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) - H5Aiterate2(did, ".", sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL, H5P_DEFAULT); + if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) + H5Aiterate2(did, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL); else - H5Aiterate2(did, ".", H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL, H5P_DEFAULT); + H5Aiterate2(did, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL); indent -= COL; tempi = H5Dget_storage_size(did); diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index b53abc4..db77b84 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -1787,7 +1787,7 @@ list(hid_t group, const char *name, const H5L_info_t *linfo, void *_iter) /* Display attributes */ if(oi.type >= 0) - H5Aiterate2(obj, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, list_attr, NULL, H5P_DEFAULT); + H5Aiterate2(obj, H5_INDEX_NAME, H5_ITER_INC, NULL, list_attr, NULL); /* Object location & reference count */ printf(" %-10s %lu:"H5_PRINTF_HADDR_FMT"\n", "Location:", oi.fileno, oi.addr); @@ -2315,7 +2315,7 @@ main(int argc, const char *argv[]) if(verbose_g > 0) { if((root = H5Gopen2(file, "/", H5P_DEFAULT)) < 0) leave(1); - H5Aiterate2(root, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, list_attr, NULL, H5P_DEFAULT); + H5Aiterate2(root, H5_INDEX_NAME, H5_ITER_INC, NULL, list_attr, NULL); if(H5Gclose(root) < 0) leave(1); } /* end if */ |