From 3c6be60da7927d3f5dd2486dc193cabe98f08276 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sat, 5 Jan 2002 11:33:50 -0500 Subject: [svn-r4782] Purpose: Feature Add Description: Added support for dumping Group Comments. This involved a modification of the DDL as well. Solution: Steal code from h5ls and put it in the h5dump. The ddl.html file was updated as normal. And a test was created... Platforms tested: Dangermouse, Modi4, Kelgia --- MANIFEST | 2 ++ doc/html/ddl.html | 15 +++++++--- tools/h5dump/h5dump.c | 12 ++++++-- tools/h5dump/h5dumptst.c | 60 ++++++++++++++++++++++++++++++++++++++ tools/testfiles/tgrp_comments.ddl | 46 +++++++++++++++++++++++++++++ tools/testfiles/tgrp_comments.h5 | Bin 0 -> 14336 bytes 6 files changed, 129 insertions(+), 6 deletions(-) create mode 100644 tools/testfiles/tgrp_comments.ddl create mode 100644 tools/testfiles/tgrp_comments.h5 diff --git a/MANIFEST b/MANIFEST index 6266df5..96dac4e 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1086,6 +1086,8 @@ ./tools/testfiles/tgroup-1.ddl ./tools/testfiles/tgroup-2.ddl ./tools/testfiles/tgroup.h5 +./tools/testfiles/tgrp_comments.ddl +./tools/testfiles/tgrp_comments.h5 ./tools/testfiles/thlink-1.ddl ./tools/testfiles/thlink-2.ddl ./tools/testfiles/thlink-3.ddl diff --git a/doc/html/ddl.html b/doc/html/ddl.html index cf235de..9584ff5 100644 --- a/doc/html/ddl.html +++ b/doc/html/ddl.html @@ -6,7 +6,6 @@ -
@@ -84,8 +83,13 @@ This section contains a brief explanation of the symbols used in the DDL. <super_block_content> ::= TBD -<root_group> ::= GROUP "/" { <unamed_datatype>* <object_id>opt - <group_attribute>* <group_member>* } +<root_group> ::= GROUP "/" { + <unamed_datatype>* + <object_id>opt + <group_comment>opt + <group_attribute>* + <group_member>* + } <datatype> ::= <atomic_type> | <compound_type> | <variable_length_type> | <array_type> @@ -294,10 +298,12 @@ This section contains a brief explanation of the symbols used in the DDL. <hardlink> ::= HARDLINK <path_name> <group> ::= GROUP <group_name> { <hardlink> | <group_info> } + +<group_comment> ::= COMMENT <string_data> <group_name> ::= <identifier> -<group_info> ::= <group_attribute>* <group_member>* +<group_info> ::= <object_id>opt <group_comment>opt <group_attribute>* <group_member>* <group_attribute> ::= <attribute> @@ -430,6 +436,7 @@ GROUP "/" { } } GROUP "group1" { + COMMENT "This is a comment for group1"; DATASET "dset3" { DATATYPE "/type1" DATASPACE SIMPLE { ( 5 ) / ( 5 ) } diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index efb0e42..767a604 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1998, 1999, 2000, 2001 + * Copyright (C) 1998, 1999, 2000, 2001, 2002 * National Center for Supercomputing Applications * All rights reserved. * @@ -1541,7 +1541,7 @@ dump_group(hid_t gid, const char *name) { H5G_stat_t statbuf; hid_t dset, type; - char type_name[1024], *tmp; + char type_name[1024], *tmp, comment[50]; int i, xtype = H5G_UNKNOWN; /* dump all */ tmp = malloc(strlen(prefix) + strlen(name) + 2); @@ -1554,6 +1554,14 @@ dump_group(hid_t gid, const char *name) if (display_oid) dump_oid(gid); + comment[0] = '\0'; + H5Gget_comment(gid, ".", sizeof(comment), comment); + + if (comment[0]) { + indentation(indent); + printf("COMMENT \"%s\"\n", comment); + } + if (!strcmp(name, "/") && unamedtype) /* dump unamed type in root group */ for (i = 0; i < type_table->nobjs; i++) diff --git a/tools/h5dump/h5dumptst.c b/tools/h5dump/h5dumptst.c index 3654ba0..ac08c2f 100644 --- a/tools/h5dump/h5dumptst.c +++ b/tools/h5dump/h5dumptst.c @@ -44,6 +44,7 @@ #define FILE30 "tarray6.h5" #define FILE31 "tarray7.h5" #define FILE32 "tempty.h5" +#define FILE33 "tgrp_comments.h5" #define LENSTR 50 #define LENSTR2 11 @@ -2614,6 +2615,64 @@ static void test_empty(void) assert(ret>=0); } +static void test_group_comments(void) +{ + hid_t fid, group; + + fid = H5Fcreate(FILE33, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + /* / */ + group = H5Gcreate (fid, "/g1", 0); + H5Gset_comment(group, "/g1", "Comment for group /g1"); + H5Gclose(group); + group = H5Gcreate (fid, "/g2", 0); + H5Gset_comment(group, "/g2", "Comment for group /g2"); + H5Gclose(group); + group = H5Gcreate (fid, "/g3", 0); + H5Gset_comment(group, "/g3", "Comment for group /g3"); + H5Gclose(group); + + /* /g1 */ + group = H5Gcreate (fid, "/g1/g1.1", 0); + H5Gset_comment(group, "/g1/g1.1", "Comment for group /g1/g1.1"); + H5Gclose(group); + group = H5Gcreate (fid, "/g1/g1.2", 0); + H5Gset_comment(group, "/g1/g1.2", "Comment for group /g1/g1.2"); + H5Gclose(group); + + /* /g2 */ + group = H5Gcreate (fid, "/g2/g2.1", 0); + H5Gset_comment(group, "/g2/g2.1", "Comment for group /g2/g2.1"); + H5Gclose(group); + + /* /g3 */ + group = H5Gcreate (fid, "/g3/g3.1", 0); + H5Gset_comment(group, "/g3/g3.1", "Comment for group /g3/g3.1"); + H5Gclose(group); + group = H5Gcreate (fid, "/g3/g3.2", 0); + H5Gset_comment(group, "/g3/g3.2", "Comment for group /g3/g3.2"); + H5Gclose(group); + group = H5Gcreate (fid, "/g3/g3.3", 0); + H5Gset_comment(group, "/g3/g3.3", "Comment for group /g3/g3.3"); + H5Gclose(group); + group = H5Gcreate (fid, "/g3/g3.4", 0); + H5Gset_comment(group, "/g3/g3.4", "Comment for group /g3/g3.4"); + H5Gclose(group); + + /* /g2/g2.1 */ + group = H5Gcreate (fid, "/g2/g2.1/g2.1.1", 0); + H5Gset_comment(group, "/g2/g2.1/g2.1.1", "Comment for group /g2/g2.1/g2.1.1"); + H5Gclose(group); + group = H5Gcreate (fid, "/g2/g2.1/g2.1.2", 0); + H5Gset_comment(group, "/g2/g2.1/g2.1.2", "Comment for group /g2/g2.1/g2.1.2"); + H5Gclose(group); + group = H5Gcreate (fid, "/g2/g2.1/g2.1.3", 0); + H5Gset_comment(group, "/g2/g2.1/g2.1.3", "Comment for group /g2/g2.1/g2.1.3"); + H5Gclose(group); + + H5Fclose(fid); +} + int main(void) { test_group(); @@ -2658,6 +2717,7 @@ int main(void) test_array7(); test_empty(); + test_group_comments(); return 0; } diff --git a/tools/testfiles/tgrp_comments.ddl b/tools/testfiles/tgrp_comments.ddl new file mode 100644 index 0000000..aead73d --- /dev/null +++ b/tools/testfiles/tgrp_comments.ddl @@ -0,0 +1,46 @@ +############################# +Expected output for 'h5dump tgrp_comments.h5' +############################# +HDF5 "tgrp_comments.h5" { +GROUP "/" { + GROUP "g1" { + COMMENT "Comment for group /g1" + GROUP "g1.1" { + COMMENT "Comment for group /g1/g1.1" + } + GROUP "g1.2" { + COMMENT "Comment for group /g1/g1.2" + } + } + GROUP "g2" { + COMMENT "Comment for group /g2" + GROUP "g2.1" { + COMMENT "Comment for group /g2/g2.1" + GROUP "g2.1.1" { + COMMENT "Comment for group /g2/g2.1/g2.1.1" + } + GROUP "g2.1.2" { + COMMENT "Comment for group /g2/g2.1/g2.1.2" + } + GROUP "g2.1.3" { + COMMENT "Comment for group /g2/g2.1/g2.1.3" + } + } + } + GROUP "g3" { + COMMENT "Comment for group /g3" + GROUP "g3.1" { + COMMENT "Comment for group /g3/g3.1" + } + GROUP "g3.2" { + COMMENT "Comment for group /g3/g3.2" + } + GROUP "g3.3" { + COMMENT "Comment for group /g3/g3.3" + } + GROUP "g3.4" { + COMMENT "Comment for group /g3/g3.4" + } + } +} +} diff --git a/tools/testfiles/tgrp_comments.h5 b/tools/testfiles/tgrp_comments.h5 new file mode 100644 index 0000000..b72edcc Binary files /dev/null and b/tools/testfiles/tgrp_comments.h5 differ -- cgit v0.12