[svn-r22531] HDFFV-5942: sort options with contents option

Added static local variables in h5trav to hold the index_by and index_order values. Defaults are set.
H5dump only use of the trav_print function, added two parameters and passed in the sort_by and sort_order variables.

Tested: local linux
This commit is contained in:
Allen Byrne 2012-07-09 14:41:17 -05:00
parent 637df34074
commit 17eca872f1
8 changed files with 43 additions and 5 deletions

View File

@ -1471,6 +1471,8 @@
./tools/testfiles/tall-2A.ddl
./tools/testfiles/tall-2B.ddl
./tools/testfiles/tcontents.ddl
./tools/testfiles/tordercontents1.ddl
./tools/testfiles/tordercontents2.ddl
./tools/testfiles/tfilters.h5
./tools/testfiles/tchunked.ddl
./tools/testfiles/tcompact.ddl

View File

@ -1096,6 +1096,8 @@ IF (BUILD_TESTING)
# test for file contents
ADD_H5_TEST (tcontents 0 --enable-error-stack -n tfcontents1.h5)
ADD_H5_TEST (tordercontents1 0 --enable-error-stack -n --sort_by=name --sort_order=ascending tfcontents1.h5)
ADD_H5_TEST (tordercontents2 0 --enable-error-stack -n --sort_by=name --sort_order=descending tfcontents1.h5)
# tests for storage layout
# compact

View File

@ -1294,7 +1294,7 @@ dump_fcontents(hid_t fid)
}
/* print objects in the files */
h5trav_print(fid);
h5trav_print(fid, sort_by, sort_order);
HDfprintf(rawoutstream, " %s\n",END);
}

View File

@ -720,6 +720,8 @@ TOOLTEST3 tperror.ddl --enable-error-stack -p -d bogus tfcontents1.h5
# test for file contents
TOOLTEST tcontents.ddl --enable-error-stack -n tfcontents1.h5
TOOLTEST tordercontents1.ddl --enable-error-stack -n --sort_by=name --sort_order=ascending tfcontents1.h5
TOOLTEST tordercontents2.ddl --enable-error-stack -n --sort_by=name --sort_order=descending tfcontents1.h5
# tests for storage layout
# compact

View File

@ -60,6 +60,13 @@ static void trav_table_addlink(trav_table_t *table,
haddr_t objno,
const char *path);
/*-------------------------------------------------------------------------
* local variables
*-------------------------------------------------------------------------
*/
static H5_index_t trav_index_by = H5_INDEX_NAME;
static H5_iter_order_t trav_index_order = H5_ITER_INC;
/*-------------------------------------------------------------------------
* "h5trav info" public functions. used in h5diff
*-------------------------------------------------------------------------
@ -255,12 +262,12 @@ traverse(hid_t file_id, const char *grp_name, hbool_t visit_start,
/* Check for iteration of links vs. visiting all links recursively */
if(recurse) {
/* Visit all links in group, recursively */
if(H5Lvisit_by_name(file_id, grp_name, H5_INDEX_NAME, H5_ITER_INC, traverse_cb, &udata, H5P_DEFAULT) < 0)
if(H5Lvisit_by_name(file_id, grp_name, trav_index_by, trav_index_order, traverse_cb, &udata, H5P_DEFAULT) < 0)
return -1;
} /* end if */
else {
/* Iterate over links in group */
if(H5Literate_by_name(file_id, grp_name, H5_INDEX_NAME, H5_ITER_INC, NULL, traverse_cb, &udata, H5P_DEFAULT) < 0)
if(H5Literate_by_name(file_id, grp_name, trav_index_by, trav_index_order, NULL, traverse_cb, &udata, H5P_DEFAULT) < 0)
return -1;
} /* end else */
@ -948,8 +955,11 @@ trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata)
*/
int
h5trav_print(hid_t fid)
h5trav_print(hid_t fid, H5_index_t print_index_by, H5_iter_order_t print_index_order)
{
trav_index_by = print_index_by;
trav_index_order = print_index_order;
trav_print_udata_t print_udata; /* User data for traversal */
trav_visitor_t print_visitor; /* Visitor structure for printing objects */

View File

@ -158,7 +158,7 @@ H5TOOLS_DLL int h5trav_getindext(const char *obj, const trav_table_t *travt);
* "h5trav print" public functions
*-------------------------------------------------------------------------
*/
H5TOOLS_DLL int h5trav_print(hid_t fid);
H5TOOLS_DLL int h5trav_print(hid_t fid, H5_index_t print_index_by, H5_iter_order_t print_index_order);
#ifdef __cplusplus
}

View File

@ -0,0 +1,11 @@
HDF5 "torderattr.h5" {
FILE_CONTENTS {
group /
dataset /d
dataset /dt
group /g
group /gt
datatype /t
datatype /tt
}
}

View File

@ -0,0 +1,11 @@
HDF5 "torderattr.h5" {
FILE_CONTENTS {
group /
datatype /tt
datatype /t
group /gt
group /g
dataset /dt
dataset /d
}
}