diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2007-10-04 20:44:07 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2007-10-04 20:44:07 (GMT) |
commit | 041de441c5d7468812be8af1346b30db6ea94e3a (patch) | |
tree | f5d9463f663e2de4ce6060b1a6585f52f26b2547 /tools | |
parent | bb3afd50c2e94cf2db558218c6704dcc285c72e9 (diff) | |
download | hdf5-041de441c5d7468812be8af1346b30db6ea94e3a.zip hdf5-041de441c5d7468812be8af1346b30db6ea94e3a.tar.gz hdf5-041de441c5d7468812be8af1346b30db6ea94e3a.tar.bz2 |
[svn-r14186] Added support for displaying several iteration orders on group and named datatype attributes
tested: windows, linux
Diffstat (limited to 'tools')
-rw-r--r-- | tools/h5dump/h5dump.c | 94 | ||||
-rw-r--r-- | tools/h5dump/h5dumpgentest.c | 36 | ||||
-rw-r--r-- | tools/testfiles/torderattr.h5 | bin | 1456 -> 1652 bytes | |||
-rw-r--r-- | tools/testfiles/torderattr1.ddl | 14 | ||||
-rw-r--r-- | tools/testfiles/torderattr2.ddl | 14 | ||||
-rw-r--r-- | tools/testfiles/torderattr3.ddl | 14 | ||||
-rw-r--r-- | tools/testfiles/torderattr4.ddl | 14 |
7 files changed, 144 insertions, 42 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 01a624c..62ebc22 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -100,10 +100,11 @@ static int indent; /*how far in to indent the line static hid_t h5_fileaccess(void); static void dump_oid(hid_t oid); static void print_enum(hid_t type); -static herr_t dump_all(hid_t group, const char *name, const H5L_info_t *linfo, void *op_data); static int xml_name_to_XID(const char *, char *, int , int ); static void init_prefix(char **prfx, size_t prfx_len); static void add_prefix(char **prfx, size_t *prfx_len, const char *name); +/* callback function used by H5Literate() */ +static herr_t dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void *op_data); static h5tool_format_t dataformat = { @@ -501,12 +502,14 @@ static void dump_named_datatype(hid_t, const char *); static void dump_dataset(hid_t, const char *, struct subset_t *); static void dump_dataspace(hid_t space); static void dump_datatype(hid_t type); -static herr_t dump_attr_cb(hid_t loc_id, const char *attr_name, const H5A_info_t *info, void *_op_data); static void dump_data(hid_t, int, struct subset_t *, int); static void dump_dcpl(hid_t dcpl, hid_t type_id, hid_t obj_id); static void dump_comment(hid_t obj_id); static void dump_fcpl(hid_t fid); static void dump_fcontents(hid_t fid); +/* callback function used by H5Aiterate2() */ +static herr_t dump_attr_cb(hid_t loc_id, const char *attr_name, const H5A_info_t *info, void *_op_data); + /* XML format: same interface, alternative output */ @@ -1211,7 +1214,7 @@ dump_dataspace(hid_t space) /*------------------------------------------------------------------------- * Function: dump_attr_cb * - * Purpose: dump the attribute + * Purpose: attribute function callback called by H5Aiterate2, displays the attribute * * Return: Success: SUCCEED * @@ -1355,9 +1358,10 @@ dump_selected_attr(hid_t loc_id, const char *name) } /*------------------------------------------------------------------------- - * Function: dump_all + * Function: dump_all_cb * - * Purpose: Dump everything in the specified object + * Purpose: function callback called by H5Literate, + * displays everything in the specified object * * Return: Success: SUCCEED * @@ -1375,7 +1379,7 @@ dump_selected_attr(hid_t loc_id, const char *name) *------------------------------------------------------------------------- */ static herr_t -dump_all(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED *op_data) +dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED *op_data) { hid_t obj; char *obj_path = NULL; /* Full path of object */ @@ -1796,8 +1800,11 @@ done: * * Programmer: Ruey-Hsia Li * - * Modifications: pvn March 27, 2006 - * add printing of attributes + * Modifications: + * Pedro Vicente, March 27, 2006 + * added display of attributes + * Pedro Vicente, October 4, 2007, added parameters to H5Aiterate2() to allow for + * other iteration orders * *------------------------------------------------------------------------- */ @@ -1818,7 +1825,7 @@ dump_named_datatype(hid_t type, const char *name) /* print attributes */ indent += COL; - H5Aiterate2(type, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_attr_cb, NULL, H5P_DEFAULT); + H5Aiterate2(type, ".", sort_by, sort_order, NULL, dump_attr_cb, NULL, H5P_DEFAULT); indent -= COL; end_obj(dump_header_format->datatypeend, @@ -1836,11 +1843,12 @@ dump_named_datatype(hid_t type, const char *name) * * Modifications: * - * Call to dump_all -- add parameter to select everything. + * Call to dump_all_cb -- add parameter to select everything. * * Pedro Vicente, October 1, 2007 * extra parameters H5_index_t and H5_iter_order_t to handle H5Literate * iteration order + * added parameters to H5Aiterate2() to allow for other iteration orders * *------------------------------------------------------------------------- */ @@ -1863,46 +1871,56 @@ dump_group(hid_t gid, const char *name, H5_index_t idx_type, H5_iter_order_t ite dump_comment(gid); - if (!HDstrcmp(name, "/") && unamedtype) { + if (!HDstrcmp(name, "/") && unamedtype) + { unsigned u; /* Local index variable */ - - /* dump unamed type in root group */ - for (u = 0; u < type_table->nobjs; u++) - if (!type_table->objs[u].recorded) { - dset = H5Dopen(gid, type_table->objs[u].objname); - type = H5Dget_type(dset); - sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno); - dump_function_table->dump_named_datatype_function(type, type_name); - H5Tclose(type); - H5Dclose(dset); - } + + /* dump unamed type in root group */ + for (u = 0; u < type_table->nobjs; u++) + if (!type_table->objs[u].recorded) + { + dset = H5Dopen(gid, type_table->objs[u].objname); + type = H5Dget_type(dset); + sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno); + dump_function_table->dump_named_datatype_function(type, type_name); + H5Tclose(type); + H5Dclose(dset); + } } /* end if */ H5Oget_info(gid, ".", &oinfo, H5P_DEFAULT); - if(oinfo.rc > 1) { + if(oinfo.rc > 1) + { obj_t *found_obj; /* Found object */ - + found_obj = search_obj(group_table, oinfo.addr); - - if (found_obj == NULL) { + + if (found_obj == NULL) + { indentation(indent); - error_msg(progname, "internal error (file %s:line %d)\n", - __FILE__, __LINE__); + error_msg(progname, "internal error (file %s:line %d)\n", + __FILE__, __LINE__); d_status = EXIT_FAILURE; - } else if (found_obj->displayed) { + } + else if (found_obj->displayed) + { indentation(indent); printf("%s \"%s\"\n", HARDLINK, found_obj->objname); - } else { + } + else + { found_obj->displayed = TRUE; - H5Aiterate2(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_attr_cb, NULL, H5P_DEFAULT); - H5Literate(gid, ".", idx_type, iter_order, NULL, dump_all, NULL, H5P_DEFAULT); + H5Aiterate2(gid, ".", idx_type, iter_order, NULL, dump_attr_cb, NULL, H5P_DEFAULT); + H5Literate(gid, ".", idx_type, iter_order, NULL, dump_all_cb, NULL, H5P_DEFAULT); } - } else { - H5Aiterate2(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_attr_cb, NULL, H5P_DEFAULT); - H5Literate(gid, ".", idx_type, iter_order, NULL, dump_all, NULL, H5P_DEFAULT); + } + else + { + H5Aiterate2(gid, ".", idx_type, iter_order, NULL, dump_attr_cb, NULL, H5P_DEFAULT); + H5Literate(gid, ".", idx_type, iter_order, NULL, dump_all_cb, NULL, H5P_DEFAULT); } - + indent -= COL; indentation(indent); end_obj(dump_header_format->groupend, dump_header_format->groupblockend); @@ -5410,7 +5428,7 @@ xml_dump_group(hid_t gid, const char *name, H5_index_t UNUSED idx_type, H5_iter_ } /* iterate through all the links */ - H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all, NULL, H5P_DEFAULT); + H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all_cb, NULL, H5P_DEFAULT); } free(t_name); free(grpxid); @@ -5464,7 +5482,7 @@ xml_dump_group(hid_t gid, const char *name, H5_index_t UNUSED idx_type, H5_iter_ } /* iterate through all the links */ - H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all, NULL, H5P_DEFAULT); + H5Literate(gid, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, dump_all_cb, NULL, H5P_DEFAULT); } indent -= COL; diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index 4bf7061..862ae60 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -5925,11 +5925,14 @@ gent_attr_creation_order() if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; -#if 0 /* enable creation order tracking on attributes */ if(H5Pset_attr_creation_order(dcpl_id, H5P_CRT_ORDER_TRACKED) < 0) goto out; -#endif + + /* enable creation order tracking on groups */ + if(H5Pset_link_creation_order(gcpl_id, H5P_CRT_ORDER_TRACKED) < 0) + goto out; + /*------------------------------------------------------------------------- * create a dataset and atributes in it *------------------------------------------------------------------------- @@ -5954,13 +5957,38 @@ gent_attr_creation_order() goto out; } /* end for */ + + if (H5Dclose(did) < 0) + goto out; + +/*------------------------------------------------------------------------- + * create a group and atributes in it + *------------------------------------------------------------------------- + */ + + if ((gid = H5Gcreate2(fid, "g", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + goto out; + + /* add attributes */ + for(i = 0; i < 3; i++) + { + if ((aid = H5Acreate(gid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT)) < 0) + goto out; + + /* close attribute */ + if (H5Aclose(aid) < 0) + goto out; + + } /* end for */ + + if (H5Gclose(gid) < 0) + goto out; + /* close */ if (H5Sclose(sid) < 0) goto out; - if (H5Dclose(did) < 0) - goto out; if (H5Pclose(dcpl_id) < 0) goto out; if (H5Pclose(gcpl_id) < 0) diff --git a/tools/testfiles/torderattr.h5 b/tools/testfiles/torderattr.h5 Binary files differindex 48217aa..87d9c06 100644 --- a/tools/testfiles/torderattr.h5 +++ b/tools/testfiles/torderattr.h5 diff --git a/tools/testfiles/torderattr1.ddl b/tools/testfiles/torderattr1.ddl index 8521898..a5a7b4d 100644 --- a/tools/testfiles/torderattr1.ddl +++ b/tools/testfiles/torderattr1.ddl @@ -19,5 +19,19 @@ GROUP "/" { DATASPACE SCALAR } } + GROUP "g" { + ATTRIBUTE "a" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + ATTRIBUTE "b" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + ATTRIBUTE "c" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + } } } diff --git a/tools/testfiles/torderattr2.ddl b/tools/testfiles/torderattr2.ddl index 968b630..9b66d89 100644 --- a/tools/testfiles/torderattr2.ddl +++ b/tools/testfiles/torderattr2.ddl @@ -3,6 +3,20 @@ Expected output for 'h5dump -H --sort_by=name --sort_order=descending torderattr ############################# HDF5 "torderattr.h5" { GROUP "/" { + GROUP "g" { + ATTRIBUTE "c" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + ATTRIBUTE "b" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + ATTRIBUTE "a" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + } DATASET "dset" { DATATYPE H5T_STD_U8LE DATASPACE SCALAR diff --git a/tools/testfiles/torderattr3.ddl b/tools/testfiles/torderattr3.ddl index 15e370a..19fbade 100644 --- a/tools/testfiles/torderattr3.ddl +++ b/tools/testfiles/torderattr3.ddl @@ -19,5 +19,19 @@ GROUP "/" { DATASPACE SCALAR } } + GROUP "g" { + ATTRIBUTE "c" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + ATTRIBUTE "b" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + ATTRIBUTE "a" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + } } } diff --git a/tools/testfiles/torderattr4.ddl b/tools/testfiles/torderattr4.ddl index 3e94ebd..95fdfea 100644 --- a/tools/testfiles/torderattr4.ddl +++ b/tools/testfiles/torderattr4.ddl @@ -3,6 +3,20 @@ Expected output for 'h5dump -H --sort_by=creation_order --sort_order=descending ############################# HDF5 "torderattr.h5" { GROUP "/" { + GROUP "g" { + ATTRIBUTE "a" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + ATTRIBUTE "b" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + ATTRIBUTE "c" { + DATATYPE H5T_STD_U8LE + DATASPACE SCALAR + } + } DATASET "dset" { DATATYPE H5T_STD_U8LE DATASPACE SCALAR |