diff options
author | Vailin Choi <vchoi@hdfgroup.org> | 2011-03-07 16:37:49 (GMT) |
---|---|---|
committer | Vailin Choi <vchoi@hdfgroup.org> | 2011-03-07 16:37:49 (GMT) |
commit | 79757db4c2ba2181ab88ba23f392790782802645 (patch) | |
tree | 93075de94c95b19ee2ccc2fda9814273dd2a7791 /tools/lib/h5tools_str.c | |
parent | 727b687ae6c80c9854cb53814fa1c12f27c2994c (diff) | |
download | hdf5-79757db4c2ba2181ab88ba23f392790782802645.zip hdf5-79757db4c2ba2181ab88ba23f392790782802645.tar.gz hdf5-79757db4c2ba2181ab88ba23f392790782802645.tar.bz2 |
[svn-r20196] This checkin consists of the following:
A) - Changes to add the new tool "h5watch" to High Level
- Changes to add three new High Level public routines for retrieving elements appended to a dataset
B) A patch from Mike M. to fix the H5Dflush/refresh problem:
src/H5Dpkg.h
src/H5Dint.c
src/H5D.c
C) Fix for an assertion failure in H5FS_sect_link_size() in H5FSsection.c
src/H5Dbtree2.c
h5committested; tested also on linew, duty, fred.
Diffstat (limited to 'tools/lib/h5tools_str.c')
-rw-r--r-- | tools/lib/h5tools_str.c | 168 |
1 files changed, 119 insertions, 49 deletions
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 8c9960f..ae0646a 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -29,6 +29,15 @@ #include "h5tools_ref.h" #include "h5tools_str.h" /*function prototypes */ +/* Copied from hl/src/H5LDprivate.h */ +/* Info about the list of comma-separated compound fields */ +typedef struct H5LD_memb_t { + size_t tot_offset; + size_t last_tsize; + hid_t last_tid; + char **names; +} H5LD_memb_t; + /* * If REPEAT_VERBOSE is defined then character strings will be printed so * that repeated character sequences like "AAAAAAAAAA" are displayed as @@ -628,6 +637,10 @@ h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, char ch) * * PVN, 28 March 2006 * added H5T_NATIVE_LDOUBLE case + * + * Vailin Choi; August 2010 + * Modified to handle printing of selected compound fields for h5watch. + * *------------------------------------------------------------------------- */ char * @@ -851,64 +864,121 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } } else if (H5Tget_class(type) == H5T_COMPOUND) { - unsigned j; - - nmembs = H5Tget_nmembers(type); - h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{")); + if(ctx->cmpd_listv) { /* there is <list_of_fields> */ + int save_indent_level; /* The indentation level */ + int i = 0, n = 0, x = 0; /* Local index variable */ + H5LD_memb_t **listv; /* Vector of information for <list_of_fields> */ + + listv = ctx->cmpd_listv; + ctx->cmpd_listv = NULL; + h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{")); + + /* + * Go through the vector containing info about the comma-separated list of + * compound fields and then members in each field: + * put in "{", "}", ",", member name and value accordingly. + */ + save_indent_level = ctx->indent_level; + for(n = 0; listv[n] != NULL; n++) { + if(n) + h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", " OPTIONAL_LINE_BREAK)); + + /* See notes for RPM 2000-10-31 below (copied) */ + if (ctx->indent_level >= 0 && str->len && str->s[str->len - 1] == '\n') { + + h5tools_str_append(str, OPT(info->line_pre, ""), ""); + + for (x = 0; x < ctx->indent_level + 1; x++) + h5tools_str_append(str, "%s", OPT(info->line_indent, "")); + } - for (j = 0; j < nmembs; j++) { - if (j) - h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", " OPTIONAL_LINE_BREAK)); + /* Process members of each field */ + for(i = 0; listv[n]->names[i] != NULL; i++) { + h5tools_str_append(str, OPT(info->cmpd_name, ""), listv[n]->names[i]); + if(i) { + ctx->indent_level++; + h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{")); + } + } + h5tools_str_sprint(str, info, container, listv[n]->last_tid, cp_vp + listv[n]->tot_offset, ctx); + if(ctx->indent_level >= 0) + for(x = ctx->indent_level; x >= 0; x--) + h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}")); + ctx->indent_level = save_indent_level; + } + + /* See notes for RPM 2000-10-31 below (copied) */ + h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); - /* RPM 2000-10-31 - * If the previous character is a line-feed (which is true when - * h5dump is running) then insert some white space for - * indentation. Be warned that column number calculations will be - * incorrect and that object indices at the beginning of the line - * will be missing (h5dump doesn't display them anyway). */ if (ctx->indent_level >= 0 && str->len && str->s[str->len - 1] == '\n') { - int x; h5tools_str_append(str, OPT(info->line_pre, ""), ""); - for (x = 0; x < ctx->indent_level + 1; x++) + for (x = 0; x < ctx->indent_level; x++) h5tools_str_append(str, "%s", OPT(info->line_indent, "")); } - /* The name */ - name = H5Tget_member_name(type, j); - h5tools_str_append(str, OPT(info->cmpd_name, ""), name); - free(name); - - /* The value */ - offset = H5Tget_member_offset(type, j); - memb = H5Tget_member_type(type, j); - - ctx->indent_level++; - h5tools_str_sprint(str, info, container, memb, cp_vp + offset, ctx); - ctx->indent_level--; - - H5Tclose(memb); - } - - /* RPM 2000-10-31 - * If the previous character is a line feed (which is true when - * h5dump is running) then insert some white space for indentation. - * Be warned that column number calculations will be incorrect and - * that object indices at the beginning of the line will be missing - * (h5dump doesn't display them anyway). */ - h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); - - if (ctx->indent_level >= 0 && str->len && str->s[str->len - 1] == '\n') { - int x; - - h5tools_str_append(str, OPT(info->line_pre, ""), ""); - - for (x = 0; x < ctx->indent_level; x++) - h5tools_str_append(str, "%s", OPT(info->line_indent, "")); - } - - h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}")); + h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}")); + ctx->cmpd_listv = info->cmpd_listv; + } else { + unsigned j = 0; + + nmembs = H5Tget_nmembers(type); + h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{")); + + for (j = 0; j < nmembs; j++) { + if (j) + h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", " OPTIONAL_LINE_BREAK)); + + /* RPM 2000-10-31 + * If the previous character is a line-feed (which is true when + * h5dump is running) then insert some white space for + * indentation. Be warned that column number calculations will be + * incorrect and that object indices at the beginning of the line + * will be missing (h5dump doesn't display them anyway). */ + if (ctx->indent_level >= 0 && str->len && str->s[str->len - 1] == '\n') { + int x; + + h5tools_str_append(str, OPT(info->line_pre, ""), ""); + + for (x = 0; x < ctx->indent_level + 1; x++) + h5tools_str_append(str, "%s", OPT(info->line_indent, "")); + } + + /* The name */ + name = H5Tget_member_name(type, j); + h5tools_str_append(str, OPT(info->cmpd_name, ""), name); + free(name); + + /* The value */ + offset = H5Tget_member_offset(type, j); + memb = H5Tget_member_type(type, j); + + ctx->indent_level++; + h5tools_str_sprint(str, info, container, memb, cp_vp + offset, ctx); + ctx->indent_level--; + + H5Tclose(memb); + } + + /* RPM 2000-10-31 + * If the previous character is a line feed (which is true when + * h5dump is running) then insert some white space for indentation. + * Be warned that column number calculations will be incorrect and + * that object indices at the beginning of the line will be missing + * (h5dump doesn't display them anyway). */ + h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); + + if (ctx->indent_level >= 0 && str->len && str->s[str->len - 1] == '\n') { + int x; + + h5tools_str_append(str, OPT(info->line_pre, ""), ""); + + for (x = 0; x < ctx->indent_level; x++) + h5tools_str_append(str, "%s", OPT(info->line_indent, "")); + } + h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}")); + } } else if (H5Tget_class(type) == H5T_ENUM) { char enum_name[1024]; |