summaryrefslogtreecommitdiffstats
path: root/c++
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2013-10-21 16:12:33 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2013-10-21 16:12:33 (GMT)
commit2b18e934c6812fd1b487ebfebf9240b009c3e4ae (patch)
tree4c5f328cf76071650907986d781191af05a3374a /c++
parent0a9249a4016f327a3382a103d1b3d10cc6451a5a (diff)
downloadhdf5-2b18e934c6812fd1b487ebfebf9240b009c3e4ae.zip
hdf5-2b18e934c6812fd1b487ebfebf9240b009c3e4ae.tar.gz
hdf5-2b18e934c6812fd1b487ebfebf9240b009c3e4ae.tar.bz2
[svn-r24336] Bring revisions #24118 - #24200 from trunk.
Diffstat (limited to 'c++')
-rw-r--r--c++/Makefile.in1
-rw-r--r--c++/examples/Makefile.am20
-rw-r--r--c++/examples/Makefile.in22
-rw-r--r--c++/examples/h5tutr_cmprss.cpp162
-rw-r--r--c++/examples/h5tutr_crtatt.cpp95
-rw-r--r--c++/examples/h5tutr_crtdat.cpp82
-rw-r--r--c++/examples/h5tutr_crtgrp.cpp69
-rw-r--r--c++/examples/h5tutr_crtgrpar.cpp92
-rw-r--r--c++/examples/h5tutr_crtgrpd.cpp141
-rw-r--r--c++/examples/h5tutr_extend.cpp176
-rw-r--r--c++/examples/h5tutr_rdwt.cpp79
-rw-r--r--c++/examples/h5tutr_subset.cpp183
-rw-r--r--c++/examples/run-c++-ex.sh.in31
-rw-r--r--c++/src/H5AbstractDs.h13
-rw-r--r--c++/src/H5ArrayType.h6
-rw-r--r--c++/src/H5AtomType.cpp4
-rw-r--r--c++/src/H5AtomType.h8
-rw-r--r--c++/src/H5Attribute.cpp4
-rw-r--r--c++/src/H5Attribute.h6
-rw-r--r--c++/src/H5Classes.h6
-rw-r--r--c++/src/H5CommonFG.cpp133
-rw-r--r--c++/src/H5CommonFG.h20
-rw-r--r--c++/src/H5CompType.h6
-rw-r--r--c++/src/H5Cpp.h6
-rw-r--r--c++/src/H5CppDoc.h6
-rw-r--r--c++/src/H5DataSet.cpp59
-rw-r--r--c++/src/H5DataSet.h16
-rw-r--r--c++/src/H5DataSpace.cpp7
-rw-r--r--c++/src/H5DataSpace.h9
-rw-r--r--c++/src/H5DataType.cpp64
-rw-r--r--c++/src/H5DataType.h16
-rw-r--r--c++/src/H5DcreatProp.h6
-rw-r--r--c++/src/H5DxferProp.h6
-rw-r--r--c++/src/H5EnumType.h6
-rw-r--r--c++/src/H5Exception.h6
-rw-r--r--c++/src/H5FaccProp.h6
-rw-r--r--c++/src/H5FcreatProp.h6
-rw-r--r--c++/src/H5File.cpp13
-rw-r--r--c++/src/H5File.h12
-rw-r--r--c++/src/H5FloatType.h6
-rw-r--r--c++/src/H5Group.cpp42
-rw-r--r--c++/src/H5Group.h18
-rw-r--r--c++/src/H5IdComponent.cpp15
-rw-r--r--c++/src/H5IdComponent.h8
-rw-r--r--c++/src/H5IntType.h6
-rw-r--r--c++/src/H5Library.h6
-rw-r--r--c++/src/H5Location.cpp491
-rw-r--r--c++/src/H5Location.h59
-rw-r--r--c++/src/H5Object.cpp3
-rw-r--r--c++/src/H5Object.h8
-rw-r--r--c++/src/H5PredType.cpp2
-rw-r--r--c++/src/H5PredType.h8
-rw-r--r--c++/src/H5PropList.cpp10
-rw-r--r--c++/src/H5PropList.h8
-rw-r--r--c++/src/H5StrType.h6
-rw-r--r--c++/src/H5VarLenType.h6
-rw-r--r--c++/src/Makefile.am5
-rw-r--r--c++/src/Makefile.in11
-rw-r--r--c++/test/Makefile.in1
-rw-r--r--c++/test/dsets.cpp11
-rw-r--r--c++/test/h5cpputil.cpp24
-rw-r--r--c++/test/h5cpputil.h2
-rw-r--r--c++/test/th5s.cpp5
-rw-r--r--c++/test/trefer.cpp676
64 files changed, 2346 insertions, 694 deletions
diff --git a/c++/Makefile.in b/c++/Makefile.in
index 232299d..492970b 100644
--- a/c++/Makefile.in
+++ b/c++/Makefile.in
@@ -255,6 +255,7 @@ LIPO = @LIPO@
LL_PATH = @LL_PATH@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
+LT_ADD_LIBHDF5_DEPENDENCY = @LT_ADD_LIBHDF5_DEPENDENCY@
LT_STATIC_EXEC = @LT_STATIC_EXEC@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
diff --git a/c++/examples/Makefile.am b/c++/examples/Makefile.am
index cd9a9f6..f479776 100644
--- a/c++/examples/Makefile.am
+++ b/c++/examples/Makefile.am
@@ -23,12 +23,18 @@ include $(top_srcdir)/config/commence.am
# These are the programs that 'make all' or 'make prog' will build and
# which 'make check' will run. List them in the order they should be run.
-EXAMPLE_PROG=create readdata writedata compound extend_ds chunks h5group
+EXAMPLE_PROG=create readdata writedata compound extend_ds chunks h5group \
+ h5tutr_cmprss h5tutr_crtatt h5tutr_crtdat h5tutr_crtgrpar \
+ h5tutr_crtgrp h5tutr_crtgrpd h5tutr_extend h5tutr_rdwt \
+ h5tutr_subset
TEST_SCRIPT=testh5c++.sh
# These are the example files to be installed
INSTALL_FILES=create.cpp readdata.cpp writedata.cpp compound.cpp \
- extend_ds.cpp chunks.cpp h5group.cpp
+ extend_ds.cpp chunks.cpp h5group.cpp \
+ h5tutr_cmprss.cpp h5tutr_crtatt.cpp h5tutr_crtdat.cpp \
+ h5tutr_crtgrpar.cpp h5tutr_crtgrp.cpp h5tutr_crtgrpd.cpp \
+ h5tutr_extend.cpp h5tutr_rdwt.cpp h5tutr_subset.cpp
INSTALL_SCRIPT_FILES = run-c++-ex.sh
# Some of the examples depend on files created by running other examples
@@ -58,5 +64,15 @@ extend_ds: $(srcdir)/extend_ds.cpp
chunks: $(srcdir)/chunks.cpp
h5group: $(srcdir)/h5group.cpp
+h5tutr_cmprss: $(srcdir)/h5tutr_cmprss.cpp
+h5tutr_crtatt: $(srcdir)/h5tutr_crtatt.cpp
+h5tutr_crtdat: $(srcdir)/h5tutr_crtdat.cpp
+h5tutr_crtgrpar: $(srcdir)/h5tutr_crtgrpar.cpp
+h5tutr_crtgrp: $(srcdir)/h5tutr_crtgrp.cpp
+h5tutr_crtgrpd: $(srcdir)/h5tutr_crtgrpd.cpp
+h5tutr_extend: $(srcdir)/h5tutr_extend.cpp
+h5tutr_rdwt: $(srcdir)/h5tutr_rdwt.cpp
+h5tutr_subset: $(srcdir)/h5tutr_subset.cpp
+
include $(top_srcdir)/config/examples.am
include $(top_srcdir)/config/conclude.am
diff --git a/c++/examples/Makefile.in b/c++/examples/Makefile.in
index e8aa093..f392787 100644
--- a/c++/examples/Makefile.in
+++ b/c++/examples/Makefile.in
@@ -222,6 +222,7 @@ LIPO = @LIPO@
LL_PATH = @LL_PATH@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
+LT_ADD_LIBHDF5_DEPENDENCY = @LT_ADD_LIBHDF5_DEPENDENCY@
LT_STATIC_EXEC = @LT_STATIC_EXEC@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
@@ -391,12 +392,19 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.h5
# These are the programs that 'make all' or 'make prog' will build and
# which 'make check' will run. List them in the order they should be run.
-EXAMPLE_PROG = create readdata writedata compound extend_ds chunks h5group
+EXAMPLE_PROG = create readdata writedata compound extend_ds chunks h5group \
+ h5tutr_cmprss h5tutr_crtatt h5tutr_crtdat h5tutr_crtgrpar \
+ h5tutr_crtgrp h5tutr_crtgrpd h5tutr_extend h5tutr_rdwt \
+ h5tutr_subset
+
TEST_SCRIPT = testh5c++.sh
# These are the example files to be installed
INSTALL_FILES = create.cpp readdata.cpp writedata.cpp compound.cpp \
- extend_ds.cpp chunks.cpp h5group.cpp
+ extend_ds.cpp chunks.cpp h5group.cpp \
+ h5tutr_cmprss.cpp h5tutr_crtatt.cpp h5tutr_crtdat.cpp \
+ h5tutr_crtgrpar.cpp h5tutr_crtgrp.cpp h5tutr_crtgrpd.cpp \
+ h5tutr_extend.cpp h5tutr_rdwt.cpp h5tutr_subset.cpp
INSTALL_SCRIPT_FILES = run-c++-ex.sh
@@ -668,6 +676,16 @@ extend_ds: $(srcdir)/extend_ds.cpp
chunks: $(srcdir)/chunks.cpp
h5group: $(srcdir)/h5group.cpp
+h5tutr_cmprss: $(srcdir)/h5tutr_cmprss.cpp
+h5tutr_crtatt: $(srcdir)/h5tutr_crtatt.cpp
+h5tutr_crtdat: $(srcdir)/h5tutr_crtdat.cpp
+h5tutr_crtgrpar: $(srcdir)/h5tutr_crtgrpar.cpp
+h5tutr_crtgrp: $(srcdir)/h5tutr_crtgrp.cpp
+h5tutr_crtgrpd: $(srcdir)/h5tutr_crtgrpd.cpp
+h5tutr_extend: $(srcdir)/h5tutr_extend.cpp
+h5tutr_rdwt: $(srcdir)/h5tutr_rdwt.cpp
+h5tutr_subset: $(srcdir)/h5tutr_subset.cpp
+
# How to create EXAMPLEDIR if it doesn't already exist
$(EXAMPLEDIR):
-$(top_srcdir)/bin/mkdirs $@
diff --git a/c++/examples/h5tutr_cmprss.cpp b/c++/examples/h5tutr_cmprss.cpp
new file mode 100644
index 0000000..7db73c4
--- /dev/null
+++ b/c++/examples/h5tutr_cmprss.cpp
@@ -0,0 +1,162 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * This example illustrates how to create a compressed dataset.
+ * It is used in the HDF5 Tutorial.
+ */
+
+#include <iostream>
+#include <string>
+
+#include "H5Cpp.h"
+
+#ifndef H5_NO_NAMESPACE
+ using namespace H5;
+#ifndef H5_NO_STD
+ using std::cout;
+ using std::endl;
+#endif // H5_NO_STD
+#endif
+
+const H5std_string FILE_NAME("cmprss.h5");
+const H5std_string DATASET_NAME("Compressed_Data");
+const int DIM0 = 100;
+const int DIM1 = 20;
+
+int main (void)
+{
+ hsize_t dims[2] = { DIM0, DIM1 }; // dataset dimensions
+ hsize_t chunk_dims[2] = { 20, 20 }; // chunk dimensions
+ int i,j, buf[DIM0][DIM1];
+
+ // Try block to detect exceptions raised by any of the calls inside it
+ try
+ {
+ // Turn off the auto-printing when failure occurs so that we can
+ // handle the errors appropriately
+ Exception::dontPrint();
+
+ // Create a new file using the default property lists.
+ H5File file(FILE_NAME, H5F_ACC_TRUNC);
+
+ // Create the data space for the dataset.
+ DataSpace *dataspace = new DataSpace(2, dims);
+
+ // Modify dataset creation property to enable chunking
+ DSetCreatPropList *plist = new DSetCreatPropList;
+ plist->setChunk(2, chunk_dims);
+
+ // Set ZLIB (DEFLATE) Compression using level 6.
+ // To use SZIP compression comment out this line.
+ plist->setDeflate(6);
+
+ // Uncomment these lines to set SZIP Compression
+ // unsigned szip_options_mask = H5_SZIP_NN_OPTION_MASK;
+ // unsigned szip_pixels_per_block = 16;
+ // plist->setSzip(szip_options_mask, szip_pixels_per_block);
+
+ // Create the dataset.
+ DataSet *dataset = new DataSet(file.createDataSet( DATASET_NAME,
+ PredType::STD_I32BE, *dataspace, *plist) );
+
+ for (i = 0; i< DIM0; i++)
+ for (j=0; j<DIM1; j++)
+ buf[i][j] = i+j;
+
+ // Write data to dataset.
+ dataset->write(buf, PredType::NATIVE_INT);
+
+ // Close objects and file. Either approach will close the HDF5 item.
+ delete dataspace;
+ delete dataset;
+ delete plist;
+ file.close();
+
+ // -----------------------------------------------
+ // Re-open the file and dataset, retrieve filter
+ // information for dataset and read the data back.
+ // -----------------------------------------------
+
+ int rbuf[DIM0][DIM1];
+ int numfilt;
+ size_t nelmts={1}, namelen={1};
+ unsigned flags, filter_info, cd_values[1], idx;
+ char name[1];
+ H5Z_filter_t filter_type;
+
+ // Open the file and the dataset in the file.
+ file.openFile(FILE_NAME, H5F_ACC_RDONLY);
+ dataset = new DataSet(file.openDataSet( DATASET_NAME));
+
+ // Get the create property list of the dataset.
+ plist = new DSetCreatPropList(dataset->getCreatePlist ());
+
+ // Get the number of filters associated with the dataset.
+ numfilt = plist->getNfilters();
+ cout << "Number of filters associated with dataset: " << numfilt << endl;
+
+ for (idx=0; idx < numfilt; idx++) {
+ nelmts = 0;
+
+ filter_type = plist->getFilter(idx, flags, nelmts, cd_values, namelen, name , filter_info);
+
+ cout << "Filter Type: ";
+
+ switch (filter_type) {
+ case H5Z_FILTER_DEFLATE:
+ cout << "H5Z_FILTER_DEFLATE" << endl;
+ break;
+ case H5Z_FILTER_SZIP:
+ cout << "H5Z_FILTER_SZIP" << endl;
+ break;
+ default:
+ cout << "Other filter type included." << endl;
+ }
+ }
+
+ // Read data.
+ dataset->read(rbuf, PredType::NATIVE_INT);
+
+ delete plist;
+ delete dataset;
+ file.close(); // can be skipped
+
+ } // end of try block
+
+ // catch failure caused by the H5File operations
+ catch(FileIException error)
+ {
+ error.printError();
+ return -1;
+ }
+
+ // catch failure caused by the DataSet operations
+ catch(DataSetIException error)
+ {
+ error.printError();
+ return -1;
+ }
+
+ // catch failure caused by the DataSpace operations
+ catch(DataSpaceIException error)
+ {
+ error.printError();
+ return -1;
+ }
+
+ return 0; // successfully terminated
+}
+
diff --git a/c++/examples/h5tutr_crtatt.cpp b/c++/examples/h5tutr_crtatt.cpp
new file mode 100644
index 0000000..651dc69
--- /dev/null
+++ b/c++/examples/h5tutr_crtatt.cpp
@@ -0,0 +1,95 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * This example illustrates how to create an attribute attached to a
+ * dataset. It is used in the HDF5 Tutorial.
+ */
+
+#include <iostream>
+#include <string>
+
+#include "H5Cpp.h"
+
+#ifndef H5_NO_NAMESPACE
+ using namespace H5;
+#endif
+
+const H5std_string FILE_NAME( "dset.h5" );
+const H5std_string DATASET_NAME( "dset" );
+const H5std_string ATTR_NAME( "Units" );
+
+const int DIM1 = 2;
+
+int main (void)
+{
+ int attr_data[2] = { 100, 200};
+ hsize_t dims[1] = { DIM1 };
+
+
+ // Try block to detect exceptions raised by any of the calls inside it
+ try
+ {
+ // Turn off the auto-printing when failure occurs so that we can
+ // handle the errors appropriately
+ Exception::dontPrint();
+
+ // Open an existing file and dataset.
+ H5File file( FILE_NAME, H5F_ACC_RDWR );
+ DataSet dataset = file.openDataSet( DATASET_NAME );
+
+ // Create the data space for the attribute.
+ DataSpace attr_dataspace = DataSpace (1, dims );
+
+ // Create a dataset attribute.
+ Attribute attribute = dataset.createAttribute( ATTR_NAME, PredType::STD_I32BE,
+ attr_dataspace);
+
+ // Write the attribute data.
+ attribute.write( PredType::NATIVE_INT, attr_data);
+
+ } // end of try block
+
+ // catch failure caused by the H5File operations
+ catch( DataSpaceIException error )
+ {
+ error.printError();
+ return -1;
+ }
+
+ // catch failure caused by the H5File operations
+ catch( AttributeIException error )
+ {
+ error.printError();
+ return -1;
+ }
+
+ // catch failure caused by the H5File operations
+ catch( FileIException error )
+ {
+ error.printError();
+ return -1;
+ }
+
+ // catch failure caused by the DataSet operations
+ catch( DataSetIException error )
+ {
+ error.printError();
+ return -1;
+ }
+
+ return 0; // successfully terminated
+}
+
diff --git a/c++/examples/h5tutr_crtdat.cpp b/c++/examples/h5tutr_crtdat.cpp
new file mode 100644
index 0000000..d7f887e
--- /dev/null
+++ b/c++/examples/h5tutr_crtdat.cpp
@@ -0,0 +1,82 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * This example illustrates how to create a dataset that is a 4 x 6
+ * array. It is used in the HDF5 Tutorial.
+ */
+
+#include <iostream>
+#include <string>
+
+#include "H5Cpp.h"
+
+#ifndef H5_NO_NAMESPACE
+ using namespace H5;
+#endif
+
+const H5std_string FILE_NAME("dset.h5");
+const H5std_string DATASET_NAME("dset");
+const int NX = 4; // dataset dimensions
+const int NY = 6;
+const int RANK = 2;
+
+int main (void)
+{
+ // Try block to detect exceptions raised by any of the calls inside it
+ try
+ {
+ // Turn off the auto-printing when failure occurs so that we can
+ // handle the errors appropriately
+ Exception::dontPrint();
+
+ // Create a new file using the default property lists.
+ H5File file(FILE_NAME, H5F_ACC_TRUNC);
+
+ // Create the data space for the dataset.
+ hsize_t dims[2]; // dataset dimensions
+ dims[0] = NX;
+ dims[1] = NY;
+ DataSpace dataspace(RANK, dims);
+
+ // Create the dataset.
+ DataSet dataset = file.createDataSet(DATASET_NAME, PredType::STD_I32BE, dataspace);
+
+ } // end of try block
+
+ // catch failure caused by the H5File operations
+ catch(FileIException error)
+ {
+ error.printError();
+ return -1;
+ }
+
+ // catch failure caused by the DataSet operations
+ catch(DataSetIException error)
+ {
+ error.printError();
+ return -1;
+ }
+
+ // catch failure caused by the DataSpace operations
+ catch(DataSpaceIException error)
+ {
+ error.printError();
+ return -1;
+ }
+
+ return 0; // successfully terminated
+}
+
diff --git a/c++/examples/h5tutr_crtgrp.cpp b/c++/examples/h5tutr_crtgrp.cpp
new file mode 100644
index 0000000..bbafd10
--- /dev/null
+++ b/c++/examples/h5tutr_crtgrp.cpp
@@ -0,0 +1,69 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * This example illustrates how to create and close a group.
+ * It is used in the HDF5 Tutorial.
+ */
+
+#include <iostream>
+#include <string>
+
+#include "H5Cpp.h"
+
+#ifndef H5_NO_NAMESPACE
+ using namespace H5;
+#ifndef H5_NO_STD
+ using std::cout;
+ using std::endl;
+#endif // H5_NO_STD
+#endif
+
+const H5std_string FILE_NAME("group.h5");
+
+int main(void)
+{
+ // Try block to detect exceptions raised by any of the calls inside it
+ try
+ {
+ // Turn off the auto-printing when failure occurs so that we can
+ // handle the errors appropriately
+ Exception::dontPrint();
+
+ // Create a new file using default property lists.
+ H5File file(FILE_NAME, H5F_ACC_TRUNC);
+
+ // Create a group named "/MygGroup" in the file
+ Group group(file.createGroup("/MyGroup"));
+
+ // File and group will be closed as their instances go out of scope.
+
+ } // end of try block
+
+ // catch failure caused by the H5File operations
+ catch(FileIException error)
+ {
+ error.printError();
+ return -1;
+ }
+ // catch failure caused by the Group operations
+ catch(GroupIException error)
+ {
+ error.printError();
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/c++/examples/h5tutr_crtgrpar.cpp b/c++/examples/h5tutr_crtgrpar.cpp
new file mode 100644
index 0000000..d58dff6
--- /dev/null
+++ b/c++/examples/h5tutr_crtgrpar.cpp
@@ -0,0 +1,92 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * This example illustrates the creation of groups using absolute and
+ * relative names. It is used in the HDF5 Tutorial.
+ */
+
+#include <iostream>
+#include <string>
+
+#include "H5Cpp.h"
+
+#ifndef H5_NO_NAMESPACE
+ using namespace H5;
+#ifndef H5_NO_STD
+ using std::cout;
+ using std::endl;
+#endif // H5_NO_STD
+#endif
+
+const H5std_string FILE_NAME("groups.h5");
+
+int main(void)
+{
+
+ // Try block to detect exceptions raised by any of the calls inside it
+ try
+ {
+
+ // Turn off the auto-printing when failure occurs so that we can
+ // handle the errors appropriately.
+
+ Exception::dontPrint();
+
+ // Create a new file using default properties.
+
+ H5File file(FILE_NAME, H5F_ACC_TRUNC);
+
+ // Create group "MyGroup" in the root group using an absolute name.
+
+ Group group1(file.createGroup( "/MyGroup"));
+
+ // Create group "Group_A" in group "MyGroup" using an
+ // absolute name.
+
+ Group group2(file.createGroup("/MyGroup/Group_A"));
+
+ // Create group "Group_B" in group "MyGroup" using a
+ // relative name.
+
+ Group group3(group1.createGroup ("Group_B"));
+
+ // Close the groups and file.
+
+ group1.close();
+ group2.close();
+ group3.close();
+ file.close();
+
+ } // end of try block
+
+ // catch failure caused by the File operations
+ catch(FileIException error)
+ {
+ error.printError();
+ return -1;
+ }
+
+ // catch failure caused by the Group operations
+ catch(GroupIException error)
+ {
+ error.printError();
+ return -1;
+ }
+
+ return 0;
+}
+
+
diff --git a/c++/examples/h5tutr_crtgrpd.cpp b/c++/examples/h5tutr_crtgrpd.cpp
new file mode 100644
index 0000000..fdb9108
--- /dev/null
+++ b/c++/examples/h5tutr_crtgrpd.cpp
@@ -0,0 +1,141 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * This example illustrates how to create a dataset in a group.
+ * It is used in the HDF5 Tutorial.
+ */
+
+#include <iostream>
+#include <string>
+
+#include "H5Cpp.h"
+
+#ifndef H5_NO_NAMESPACE
+ using namespace H5;
+#ifndef H5_NO_STD
+ using std::cout;
+ using std::endl;
+#endif // H5_NO_STD
+#endif
+
+const H5std_string FILE_NAME("groups.h5");
+const H5std_string DATASET_NAME1("/MyGroup/dset1");
+const H5std_string DATASET_NAME2("dset2");
+const int RANK = 2;
+const int D1DIM1 = 3;
+const int D1DIM2 = 3;
+const int D2DIM1 = 2;
+const int D2DIM2 = 10;
+
+int main(void)
+{
+ int dset1_data[D1DIM1][D1DIM2], dset2_data[D2DIM1][D2DIM2]; // data buffers
+ int i, j;
+
+ // Try block to catch exceptions raised by any of the calls inside it
+ try
+ {
+ // Turn off the auto-printing when failure occurs so that we can
+ // handle the errors appropriately
+ Exception::dontPrint();
+
+ // Initialize the first dataset.
+ for (i = 0; i < D1DIM1; i++)
+ for (j = 0; j < D1DIM2; j++)
+ dset1_data[i][j] = j + 1;
+
+ // Initialize the second dataset.
+ for (i = 0; i < D2DIM1; i++)
+ for (j = 0; j < D2DIM2; j++)
+ dset2_data[i][j] = j + 1;
+
+ // Open an existing file and dataset.
+ H5File file(FILE_NAME, H5F_ACC_RDWR);
+
+ // Create the data space for the first dataset. Note the use of
+ // pointer for the instance 'dataspace'. It can be deleted and
+ // used again later for another data space. An HDF5 identifier is
+ // closed by the destructor or the method 'close()'.
+ hsize_t dims[RANK]; // dataset dimensions
+ dims[0] = D1DIM1;
+ dims[1] = D1DIM2;
+ DataSpace *dataspace = new DataSpace (RANK, dims);
+
+ // Create the dataset in group "MyGroup". Same note as for the
+ // dataspace above.
+ DataSet *dataset = new DataSet (file.createDataSet(DATASET_NAME1,
+ PredType::STD_I32BE, *dataspace));
+
+ // Write the data to the dataset using default memory space, file
+ // space, and transfer properties.
+ dataset->write(dset1_data, PredType::NATIVE_INT);
+
+ // Close the current dataset and data space.
+ delete dataset;
+ delete dataspace;
+
+ // Create the data space for the second dataset.
+ dims[0] = D2DIM1;
+ dims[1] = D2DIM2;
+ dataspace = new DataSpace (RANK, dims);
+
+ // Create group "Group_A" in group "MyGroup".
+ Group group(file.openGroup("/MyGroup/Group_A"));
+
+ // Create the second dataset in group "Group_A".
+ dataset = new DataSet (group.createDataSet(DATASET_NAME2,
+ PredType::STD_I32BE, *dataspace));
+
+ // Write the data to the dataset using default memory space, file
+ // space, and transfer properties.
+ dataset->write(dset2_data, PredType::NATIVE_INT);
+
+ // Close all objects.
+ delete dataspace;
+ delete dataset;
+ group.close();
+
+ } // end of try block
+
+ // catch failure caused by the H5File operations
+ catch(FileIException error)
+ {
+ error.printError();
+ return -1;
+ }
+ // catch failure caused by the DataSet operations
+ catch(DataSetIException error)
+ {
+ error.printError();
+ return -1;
+ }
+
+ // catch failure caused by the DataSpace operations
+ catch(DataSpaceIException error)
+ {
+ error.printError();
+ return -1;
+ }
+
+ // catch failure caused by the Group operations
+ catch(GroupIException error)
+ {
+ error.printError();
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/c++/examples/h5tutr_extend.cpp b/c++/examples/h5tutr_extend.cpp
new file mode 100644
index 0000000..c3a18d7
--- /dev/null
+++ b/c++/examples/h5tutr_extend.cpp
@@ -0,0 +1,176 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * This example illustrates how to create a dataset that is a 4 x 6
+ * array. It is used in the HDF5 Tutorial.
+ */
+
+#include <iostream>
+#include <string>
+
+#include "H5Cpp.h"
+
+#ifndef H5_NO_NAMESPACE
+ using namespace H5;
+#ifndef H5_NO_STD
+ using std::cout;
+ using std::endl;
+#endif // H5_NO_STD
+#endif
+
+const H5std_string FILE_NAME("extend.h5");
+const H5std_string DATASETNAME("ExtendibleArray");
+
+int main (void)
+{
+ hsize_t dims[2] = {3,3}; // dataset dimensions at creation
+ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
+ hsize_t chunk_dims[2] ={2, 5};
+ int data[3][3] = { {1, 1, 1}, // data to write
+ {1, 1, 1},
+ {1, 1, 1} };
+
+ // Variables used in extending and writing to the extended portion of dataset
+
+ hsize_t size[2];
+ hsize_t offset[2];
+ hsize_t dimsext[2] = {7, 3}; // extend dimensions
+ int dataext[7][3] = { {2, 3, 4},
+ {2, 3, 4},
+ {2, 3, 4},
+ {2, 3, 4},
+ {2, 3, 4},
+ {2, 3, 4},
+ {2, 3, 4} };
+
+ // Try block to detect exceptions raised by any of the calls inside it
+ try
+ {
+ // Turn off the auto-printing when failure occurs so that we can
+ // handle the errors appropriately
+ Exception::dontPrint();
+
+ // Create a new file using the default property lists.
+ H5File file(FILE_NAME, H5F_ACC_TRUNC);
+
+ // Create the data space for the dataset. Note the use of pointer
+ // for the instance 'dataspace'. It can be deleted and used again
+ // later for another dataspace. An HDF5 identifier can be closed
+ // by the destructor or the method 'close()'.
+ DataSpace *dataspace = new DataSpace (2, dims, maxdims);
+
+ // Modify dataset creation property to enable chunking
+ DSetCreatPropList prop;
+ prop.setChunk(2, chunk_dims);
+
+ // Create the chunked dataset. Note the use of pointer.
+ DataSet *dataset = new DataSet(file.createDataSet( DATASETNAME,
+ PredType::STD_I32BE, *dataspace, prop) );
+
+ // Write data to dataset.
+ dataset->write(data, PredType::NATIVE_INT);
+
+ // Extend the dataset. Dataset becomes 10 x 3.
+ size[0] = dims[0] + dimsext[0];
+ size[1] = dims[1];
+ dataset->extend(size);
+
+ // Select a hyperslab in extended portion of the dataset.
+ DataSpace *filespace = new DataSpace(dataset->getSpace ());
+ offset[0] = 3;
+ offset[1] = 0;
+ filespace->selectHyperslab(H5S_SELECT_SET, dimsext, offset);
+
+ // Define memory space.
+ DataSpace *memspace = new DataSpace(2, dimsext, NULL);
+
+ // Write data to the extended portion of the dataset.
+ dataset->write(dataext, PredType::NATIVE_INT, *memspace, *filespace);
+
+ // Close all objects and file.
+ prop.close();
+ delete filespace;
+ delete memspace;
+ delete dataspace;
+ delete dataset;
+ file.close();
+
+ // ---------------------------------------
+ // Re-open the file and read the data back
+ // ---------------------------------------
+
+ int rdata[10][3];
+ int i,j, rank, rank_chunk;
+ hsize_t chunk_dimsr[2], dimsr[2];
+
+ // Open the file and dataset.
+ file.openFile(FILE_NAME, H5F_ACC_RDONLY);
+ dataset = new DataSet(file.openDataSet( DATASETNAME));
+
+ // Get the dataset's dataspace and creation property list.
+ filespace = new DataSpace(dataset->getSpace());
+ prop = dataset->getCreatePlist();
+
+ // Get information to obtain memory dataspace.
+ rank = filespace->getSimpleExtentNdims();
+ herr_t status_n = filespace->getSimpleExtentDims(dimsr);
+
+ if (H5D_CHUNKED == prop.getLayout())
+ rank_chunk = prop.getChunk(rank, chunk_dimsr);
+
+ memspace = new DataSpace(rank, dimsr, NULL);
+ dataset->read(rdata, PredType::NATIVE_INT, *memspace, *filespace);
+
+ cout << endl;
+ for (j = 0; j < dimsr[0]; j++) {
+ for (i = 0; i < dimsr[1]; i++)
+ cout << " " << rdata[j][i];
+ cout << endl;
+ }
+
+ // Close all objects and file.
+ prop.close();
+ delete filespace;
+ delete memspace;
+ delete dataset;
+ file.close();
+
+ } // end of try block
+
+ // catch failure caused by the H5File operations
+ catch(FileIException error)
+ {
+ error.printError();
+ return -1;
+ }
+
+ // catch failure caused by the DataSet operations
+ catch(DataSetIException error)
+ {
+ error.printError();
+ return -1;
+ }
+
+ // catch failure caused by the DataSpace operations
+ catch(DataSpaceIException error)
+ {
+ error.printError();
+ return -1;
+ }
+
+ return 0; // successfully terminated
+}
+
diff --git a/c++/examples/h5tutr_rdwt.cpp b/c++/examples/h5tutr_rdwt.cpp
new file mode 100644
index 0000000..e6e45b7
--- /dev/null
+++ b/c++/examples/h5tutr_rdwt.cpp
@@ -0,0 +1,79 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * This example illustrates how to write to and read from an existing
+ * dataset. It is used in the HDF5 Tutorial.
+ */
+
+#include <iostream>
+#include <string>
+
+#include "H5Cpp.h"
+
+#ifndef H5_NO_NAMESPACE
+ using namespace H5;
+#endif
+
+const H5std_string FILE_NAME( "dset.h5" );
+const H5std_string DATASET_NAME( "dset" );
+const int DIM0 = 4; // dataset dimensions
+const int DIM1 = 6;
+
+int main (void)
+{
+
+ // Data initialization.
+
+ int i, j;
+ int data[DIM0][DIM1]; // buffer for data to write
+
+ for (j = 0; j < DIM0; j++)
+ for (i = 0; i < DIM1; i++)
+ data[j][i] = i * 6 + j + 1;
+
+ // Try block to detect exceptions raised by any of the calls inside it
+ try
+ {
+ // Turn off the auto-printing when failure occurs so that we can
+ // handle the errors appropriately
+ Exception::dontPrint();
+
+ // Open an existing file and dataset.
+ H5File file( FILE_NAME, H5F_ACC_RDWR );
+ DataSet dataset = file.openDataSet( DATASET_NAME );
+
+ // Write the data to the dataset using default memory space, file
+ // space, and transfer properties.
+ dataset.write( data, PredType::NATIVE_INT );
+
+ } // end of try block
+
+ // catch failure caused by the H5File operations
+ catch( FileIException error )
+ {
+ error.printError();
+ return -1;
+ }
+
+ // catch failure caused by the DataSet operations
+ catch( DataSetIException error )
+ {
+ error.printError();
+ return -1;
+ }
+
+ return 0; // successfully terminated
+}
diff --git a/c++/examples/h5tutr_subset.cpp b/c++/examples/h5tutr_subset.cpp
new file mode 100644
index 0000000..77174ab
--- /dev/null
+++ b/c++/examples/h5tutr_subset.cpp
@@ -0,0 +1,183 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * This example illustrates how to read/write a subset of data (a slab)
+ * from/to a dataset in an HDF5 file. It is used in the HDF5 Tutorial.
+ */
+
+#include <iostream>
+#include <string>
+
+#include "H5Cpp.h"
+
+#ifndef H5_NO_NAMESPACE
+ using namespace H5;
+#ifndef H5_NO_STD
+ using std::cout;
+ using std::endl;
+#endif // H5_NO_STD
+#endif
+
+const H5std_string FILE_NAME("subset.h5");
+const H5std_string DATASET_NAME("IntArray");
+
+const int RANK = 2;
+const int DIM0_SUB = 3; // subset dimensions
+const int DIM1_SUB = 4;
+const int DIM0 = 8; // size of dataset
+const int DIM1 = 10;
+
+int main (void)
+{
+ int i,j;
+ int data[DIM0][DIM1], sdata[DIM0_SUB][DIM1_SUB], rdata[DIM0][DIM1];
+
+ // Try block to detect exceptions raised by any of the calls inside it
+ try
+ {
+ // Turn off the auto-printing when failure occurs so that we can
+ // handle the errors appropriately
+ Exception::dontPrint();
+
+ // ---------------------------------------------------
+ // Create a new file using the default property lists.
+ // Then create a dataset and write data to it.
+ // Close the file and dataset.
+ // ---------------------------------------------------
+
+ H5File file(FILE_NAME, H5F_ACC_TRUNC);
+
+ hsize_t dims[2];
+ dims[0] = DIM0;
+ dims[1] = DIM1;
+ DataSpace dataspace = DataSpace (RANK, dims);
+
+ DataSet dataset(file.createDataSet( DATASET_NAME,
+ PredType::STD_I32BE, dataspace) );
+
+
+ for (j = 0; j < DIM0; j++) {
+ for (i = 0; i < DIM1; i++)
+ if (i< (DIM1/2))
+ data[j][i] = 1;
+ else
+ data[j][i] = 2;
+ }
+
+ dataset.write(data, PredType::NATIVE_INT);
+
+ cout << endl << "Data Written to File:" << endl;
+ for (j = 0; j < DIM0; j++) {
+ for (i = 0; i < DIM1; i++)
+ cout << " " << data[j][i];
+ cout << endl;
+ }
+
+ dataspace.close();
+ dataset.close();
+ file.close();
+
+ // ---------------------------------------------------
+ // Reopen the file and dataset and write a subset of
+ // values to the dataset.
+ // ---------------------------------------------------
+
+ hsize_t offset[2], count[2], stride[2], block[2];
+ hsize_t dimsm[2];
+
+ file.openFile(FILE_NAME, H5F_ACC_RDWR);
+ dataset = file.openDataSet(DATASET_NAME);
+
+ // Specify size and shape of subset to write.
+
+ offset[0] = 1;
+ offset[1] = 2;
+
+ count[0] = DIM0_SUB;
+ count[1] = DIM1_SUB;
+
+ stride[0] = 1;
+ stride[1] = 1;
+
+ block[0] = 1;
+ block[1] = 1;
+
+ // Define Memory Dataspace. Get file dataspace and select
+ // a subset from the file dataspace.
+
+ dimsm[0] = DIM0_SUB;
+ dimsm[1] = DIM1_SUB;
+
+ DataSpace memspace(RANK, dimsm, NULL);
+
+ dataspace = dataset.getSpace();
+ dataspace.selectHyperslab(H5S_SELECT_SET, count, offset, stride, block);
+
+ // Write a subset of data to the dataset, then read the
+ // entire dataset back from the file.
+
+ cout << endl << "Write subset to file specifying: " << endl;
+ cout << " offset=1x2 stride=1x1 count=3x4 block=1x1" << endl;
+ for (j = 0; j < DIM0_SUB; j++) {
+ for (i = 0; i < DIM1_SUB; i++)
+ sdata[j][i] = 5;
+ }
+
+ dataset.write(sdata, PredType::NATIVE_INT, memspace, dataspace);
+ dataset.read(rdata, PredType::NATIVE_INT);
+
+
+ cout << endl << "Data in File after Subset is Written:" << endl;
+ for (i = 0; i < DIM0; i++) {
+ for (j = 0; j < DIM1; j++)
+ cout << " " << rdata[i][j];
+ cout << endl;
+ }
+ cout << endl;
+
+ // It is not necessary to close these objects because close() will
+ // be called when the object instances are going out of scope.
+ dataspace.close();
+ memspace.close();
+ dataset.close();
+ file.close();
+
+ } // end of try block
+
+ // catch failure caused by the H5File operations
+ catch(FileIException error)
+ {
+ error.printError();
+ return -1;
+ }
+
+ // catch failure caused by the DataSet operations
+ catch(DataSetIException error)
+ {
+ error.printError();
+ return -1;
+ }
+
+ // catch failure caused by the DataSpace operations
+ catch(DataSpaceIException error)
+ {
+ error.printError();
+ return -1;
+ }
+
+ return 0; // successfully terminated
+}
+
diff --git a/c++/examples/run-c++-ex.sh.in b/c++/examples/run-c++-ex.sh.in
index 6b33577..77ac36a 100644
--- a/c++/examples/run-c++-ex.sh.in
+++ b/c++/examples/run-c++-ex.sh.in
@@ -64,6 +64,10 @@ RunTest()
# Run tests
if [ $? -eq 0 ]
then
+ echo "*************************************************"
+ echo "** Run C++ API Examples **"
+ echo "** **"
+ echo "*************************************************"
if (RunTest create &&\
rm create &&\
RunTest readdata &&\
@@ -82,6 +86,33 @@ then
else
EXIT_VALUE=${EXIT_FAILURE}
fi
+ echo
+ echo "***************************************************"
+ echo "** Run Tutorial Examples **"
+ echo "** **"
+ echo "***************************************************"
+ if (RunTest h5tutr_crtdat &&\
+ rm h5tutr_crtdat &&\
+ RunTest h5tutr_rdwt &&\
+ rm h5tutr_rdwt &&\
+ RunTest h5tutr_crtatt &&\
+ rm h5tutr_crtatt &&\
+ RunTest h5tutr_crtgrp &&\
+ rm h5tutr_crtgrp &&\
+ RunTest h5tutr_crtgrpar &&\
+ rm h5tutr_crtgrpar &&\
+ RunTest h5tutr_crtgrpd &&\
+ rm h5tutr_crtgrpd &&\
+ RunTest h5tutr_extend &&\
+ rm h5tutr_extend &&\
+ RunTest h5tutr_subset &&\
+ rm h5tutr_subset &&\
+ RunTest h5tutr_cmprss &&\
+ rm h5tutr_cmprss ); then
+ EXIT_VALUE=${EXIT_SUCCESS}
+ else
+ EXIT_VALUE=${EXIT_FAILURE}
+ fi
fi
# Cleanup
diff --git a/c++/src/H5AbstractDs.h b/c++/src/H5AbstractDs.h
index 354b47b..6635f78 100644
--- a/c++/src/H5AbstractDs.h
+++ b/c++/src/H5AbstractDs.h
@@ -19,8 +19,8 @@
// Attribute and DataSet. It also inherits from H5Object and passes down
// the services that H5Object provides.
-#ifndef _AbstractDs_H
-#define _AbstractDs_H
+#ifndef __AbstractDs_H
+#define __AbstractDs_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -51,18 +51,17 @@ class H5_DLLCPP AbstractDs {
StrType getStrType() const;
VarLenType getVarLenType() const;
- // Gets the size in memory of this abstract dataset.
+ ///\brief Gets the size in memory of this abstract dataset.
virtual size_t getInMemDataSize() const = 0;
- // Gets the dataspace of this abstract dataset - pure virtual.
+ ///\brief Gets the dataspace of this abstract dataset - pure virtual.
virtual DataSpace getSpace() const = 0;
// Gets the class of the datatype that is used by this abstract
// dataset.
H5T_class_t getTypeClass() const;
- // Returns the amount of storage size required for this abstract
- // dataset - pure virtual.
+ ///\brief Returns the amount of storage size required - pure virtual.
virtual hsize_t getStorageSize() const = 0;
///\brief Returns this class name.
@@ -88,4 +87,4 @@ class H5_DLLCPP AbstractDs {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif // _AbstractDs_H
+#endif // __AbstractDs_H
diff --git a/c++/src/H5ArrayType.h b/c++/src/H5ArrayType.h
index 7daafed..d2e3c29 100644
--- a/c++/src/H5ArrayType.h
+++ b/c++/src/H5ArrayType.h
@@ -17,8 +17,8 @@
// Class ArrayType inherits from DataType and provides wrappers for the
// HDF5 C's Array Datatypes.
-#ifndef _H5ArrayType_H
-#define _H5ArrayType_H
+#ifndef __H5ArrayType_H
+#define __H5ArrayType_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -59,4 +59,4 @@ class H5_DLLCPP ArrayType : public DataType {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5ArrayType_H
diff --git a/c++/src/H5AtomType.cpp b/c++/src/H5AtomType.cpp
index 975cad6..09f762f 100644
--- a/c++/src/H5AtomType.cpp
+++ b/c++/src/H5AtomType.cpp
@@ -45,7 +45,6 @@ AtomType::AtomType() : DataType() {}
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
AtomType::AtomType( const hid_t existing_id ) : DataType( existing_id ) {}
-#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: AtomType copy constructor
@@ -53,6 +52,7 @@ AtomType::AtomType( const hid_t existing_id ) : DataType( existing_id ) {}
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
AtomType::AtomType( const AtomType& original ) : DataType( original ) {}
+#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: AtomType::setSize
@@ -285,12 +285,14 @@ void AtomType::setPad( H5T_pad_t lsb, H5T_pad_t msb ) const
}
}
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: AtomType destructor
///\brief Noop destructor.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
AtomType::~AtomType() {}
+#endif // DOXYGEN_SHOULD_SKIP_THIS
#ifndef H5_NO_NAMESPACE
} // end namespace
diff --git a/c++/src/H5AtomType.h b/c++/src/H5AtomType.h
index 25770f5..e8d6513 100644
--- a/c++/src/H5AtomType.h
+++ b/c++/src/H5AtomType.h
@@ -19,8 +19,8 @@
// subclasses. It also inherits from DataType and passes down the
// services that are common to all the datatypes.
-#ifndef _H5AtomType_H
-#define _H5AtomType_H
+#ifndef __H5AtomType_H
+#define __H5AtomType_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -60,11 +60,13 @@ class H5_DLLCPP AtomType : public DataType {
///\brief Returns this class name.
virtual H5std_string fromClass () const { return("AtomType"); }
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Copy constructor - makes copy of the original object
AtomType( const AtomType& original );
// Noop destructor
virtual ~AtomType();
+#endif // DOXYGEN_SHOULD_SKIP_THIS
protected:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
@@ -78,4 +80,4 @@ class H5_DLLCPP AtomType : public DataType {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5AtomType_H
diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp
index 120ed39..a98a970 100644
--- a/c++/src/H5Attribute.cpp
+++ b/c++/src/H5Attribute.cpp
@@ -44,6 +44,7 @@ namespace H5 {
#endif // H5_NO_STD
#endif
+class H5_DLLCPP H5Object; // forward declaration for UserData4Aiterate
//--------------------------------------------------------------------------
// Function: Attribute default constructor
///\brief Default constructor: Creates a stub attribute
@@ -411,7 +412,8 @@ void Attribute::flush(H5F_scope_t scope) const
//--------------------------------------------------------------------------
// Function: Attribute::getId
-// Purpose: Get the id of this attribute
+///\brief Get the id of this attribute
+///\return Attribute identifier
// Description:
// Class hierarchy is revised to address bugzilla 1068. Class
// AbstractDS and Attribute are moved out of H5Object. In
diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h
index dd37a99..2d01205 100644
--- a/c++/src/H5Attribute.h
+++ b/c++/src/H5Attribute.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5Attribute_H
-#define _H5Attribute_H
+#ifndef __H5Attribute_H
+#define __H5Attribute_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -99,4 +99,4 @@ class H5_DLLCPP Attribute : public AbstractDs, public IdComponent {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5Attribute_H
diff --git a/c++/src/H5Classes.h b/c++/src/H5Classes.h
index c3b61ca..de7cf4a 100644
--- a/c++/src/H5Classes.h
+++ b/c++/src/H5Classes.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5Classes_H
-#define _H5Classes_H
+#ifndef __H5Classes_H
+#define __H5Classes_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -49,4 +49,4 @@ namespace H5 {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5Classes_H
diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp
index 0651c29..3bf4b4f 100644
--- a/c++/src/H5CommonFG.cpp
+++ b/c++/src/H5CommonFG.cpp
@@ -460,137 +460,6 @@ H5std_string CommonFG::getLinkval( const H5std_string& name, size_t size ) const
}
//--------------------------------------------------------------------------
-// Function: CommonFG::setComment
-///\brief Sets or resets the comment for an object specified by its name.
-///\param name - IN: Name of the object
-///\param comment - IN: New comment
-///\exception H5::FileIException or H5::GroupIException
-///\par Description
-/// If \a comment is an empty string or a null pointer, the comment
-/// message is removed from the object.
-/// Comments should be relatively short, null-terminated, ASCII
-/// strings. They can be attached to any object that has an
-/// object header, e.g., data sets, groups, named data types,
-/// and data spaces, but not symbolic links.
-// Programmer Binh-Minh Ribler - 2000
-// Modification
-// 2007: QAK modified to use H5O APIs; however the first parameter is
-// no longer just file or group, this function should be moved
-// to another class to accommodate attribute, dataset, and named
-// datatype. - BMR
-//--------------------------------------------------------------------------
-void CommonFG::setComment( const char* name, const char* comment ) const
-{
- herr_t ret_value = H5Oset_comment_by_name( getLocId(), name, comment, H5P_DEFAULT );
- if( ret_value < 0 )
- throwException("setComment", "H5Oset_comment_by_name failed");
-}
-
-//--------------------------------------------------------------------------
-// Function: CommonFG::setComment
-///\brief This is an overloaded member function, provided for convenience.
-/// It differs from the above function in that it takes an
-/// \c H5std_string for \a name and \a comment.
-// Programmer Binh-Minh Ribler - 2000
-//--------------------------------------------------------------------------
-void CommonFG::setComment( const H5std_string& name, const H5std_string& comment ) const
-{
- setComment( name.c_str(), comment.c_str() );
-}
-
-//--------------------------------------------------------------------------
-// Function: CommonFG::removeComment
-///\brief Removes the comment from an object specified by its name.
-///\param name - IN: Name of the object
-///\exception H5::FileIException or H5::GroupIException
-// Programmer Binh-Minh Ribler - May 2005
-// 2007: QAK modified to use H5O APIs; however the first parameter is
-// no longer just file or group, this function should be moved
-// to another class to accommodate attribute, dataset, and named
-// datatype. - BMR
-//--------------------------------------------------------------------------
-void CommonFG::removeComment(const char* name) const
-{
- herr_t ret_value = H5Oset_comment_by_name(getLocId(), name, NULL, H5P_DEFAULT);
- if( ret_value < 0 )
- throwException("removeComment", "H5Oset_comment_by_name failed");
-}
-
-//--------------------------------------------------------------------------
-// Function: CommonFG::removeComment
-///\brief This is an overloaded member function, provided for convenience.
-/// It differs from the above function in that it takes an
-/// \c H5std_string for \a name.
-// Programmer Binh-Minh Ribler - May 2005
-//--------------------------------------------------------------------------
-void CommonFG::removeComment(const H5std_string& name) const
-{
- removeComment (name.c_str());
-}
-
-//--------------------------------------------------------------------------
-// Function: CommonFG::getComment
-///\brief Retrieves comment for the specified object and its comment's
-/// length.
-///\param name - IN: Name of the object
-///\param bufsize - IN: Length of the comment to retrieve
-///\return Comment string
-///\exception H5::FileIException or H5::GroupIException
-// Programmer Binh-Minh Ribler - 2000
-// 2007: QAK modified to use H5O APIs; however the first parameter is
-// no longer just file or group, this function should be moved
-// to another class to accommodate attribute, dataset, and named
-// datatype. - BMR
-//--------------------------------------------------------------------------
-H5std_string CommonFG::getComment( const char* name, size_t bufsize ) const
-{
- // bufsize is default to 256
- // temporary variable
- hid_t loc_id = getLocId(); // temporary variable
-
- // temporary C-string for the object's comment; bufsize already including
- // null character
- char* comment_C = new char[bufsize];
- ssize_t ret_value = H5Oget_comment_by_name(loc_id, name, comment_C, bufsize, H5P_DEFAULT);
-
- // if the actual length of the comment is longer than bufsize and bufsize
- // was the default value, i.e., not given by the user, then call
- // H5Oget_comment_by_name again with the correct value.
- // If the call to H5Oget_comment_by_name returned an error, skip this block
- // and throw an exception below.
- if (ret_value >= 0 && (size_t)ret_value > bufsize && bufsize == 256)
- {
- size_t new_size = ret_value;
- delete []comment_C;
- comment_C = new char[new_size]; // new_size including null terminator
- ret_value = H5Oget_comment_by_name(loc_id, name, comment_C, new_size, H5P_DEFAULT);
- }
-
- // if H5Oget_comment_by_name returns SUCCEED, return the string comment,
- // otherwise, throw an exception
- if( ret_value < 0 ) {
- delete []comment_C;
- throwException("getComment", "H5Oget_comment_by_name failed");
- }
-
- H5std_string comment = H5std_string(comment_C);
- delete []comment_C;
- return (comment);
-}
-
-//--------------------------------------------------------------------------
-// Function: CommonFG::getComment
-///\brief This is an overloaded member function, provided for convenience.
-/// It differs from the above function in that it takes an
-/// \c H5std_string for \a name.
-// Programmer Binh-Minh Ribler - 2000
-//--------------------------------------------------------------------------
-H5std_string CommonFG::getComment( const H5std_string& name, size_t bufsize ) const
-{
- return( getComment( name.c_str(), bufsize ));
-}
-
-//--------------------------------------------------------------------------
// Function: CommonFG::mount
///\brief Mounts the file \a child onto this group.
///\param name - IN: Name of the group
@@ -1138,6 +1007,7 @@ H5G_obj_t CommonFG::getObjTypeByIdx(hsize_t idx, H5std_string& type_name) const
}
#endif /* H5_NO_DEPRECATED_SYMBOLS */
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: CommonFG default constructor
///\brief Default constructor.
@@ -1151,6 +1021,7 @@ CommonFG::CommonFG() {}
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
CommonFG::~CommonFG() {}
+#endif // DOXYGEN_SHOULD_SKIP_THIS
#ifndef H5_NO_NAMESPACE
}
diff --git a/c++/src/H5CommonFG.h b/c++/src/H5CommonFG.h
index 4f32d21..1748d1d 100644
--- a/c++/src/H5CommonFG.h
+++ b/c++/src/H5CommonFG.h
@@ -18,8 +18,8 @@
// common services that are provided by H5File and Group. The file or
// group in the context of this class is referred to as 'location'.
-#ifndef _CommonFG_H
-#define _CommonFG_H
+#ifndef __CommonFG_H
+#define __CommonFG_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -49,18 +49,6 @@ class H5_DLLCPP CommonFG {
DataSet openDataSet(const char* name) const;
DataSet openDataSet(const H5std_string& name) const;
- // Retrieves comment for the HDF5 object specified by its name.
- H5std_string getComment(const char* name, size_t bufsize=256) const;
- H5std_string getComment(const H5std_string& name, size_t bufsize=256) const;
-
- // Removes the comment for the HDF5 object specified by its name.
- void removeComment(const char* name) const;
- void removeComment(const H5std_string& name) const;
-
- // Sets the comment for an HDF5 object specified by its name.
- void setComment(const char* name, const char* comment) const;
- void setComment(const H5std_string& name, const H5std_string& comment) const;
-
// Returns the value of a symbolic link.
H5std_string getLinkval(const char* link_name, size_t size=0) const;
H5std_string getLinkval(const H5std_string& link_name, size_t size=0) const;
@@ -152,7 +140,6 @@ class H5_DLLCPP CommonFG {
/// object id, i.e. file or group id.
virtual hid_t getLocId() const = 0;
-#endif // DOXYGEN_SHOULD_SKIP_THIS
/// For subclasses, H5File and Group, to throw appropriate exception.
virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const = 0;
@@ -162,11 +149,12 @@ class H5_DLLCPP CommonFG {
// Noop destructor.
virtual ~CommonFG();
+#endif // DOXYGEN_SHOULD_SKIP_THIS
}; // end of CommonFG declaration
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __CommonFG_H
diff --git a/c++/src/H5CompType.h b/c++/src/H5CompType.h
index 9b2b572..16ae839 100644
--- a/c++/src/H5CompType.h
+++ b/c++/src/H5CompType.h
@@ -17,8 +17,8 @@
// Class CompType inherits from DataType and provides accesses to a compound
// datatype.
-#ifndef _H5CompType_H
-#define _H5CompType_H
+#ifndef __H5CompType_H
+#define __H5CompType_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -111,4 +111,4 @@ class H5_DLLCPP CompType : public DataType {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5CompType_H
diff --git a/c++/src/H5Cpp.h b/c++/src/H5Cpp.h
index ddf4f19..044108b 100644
--- a/c++/src/H5Cpp.h
+++ b/c++/src/H5Cpp.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5CPP_H
-#define _H5CPP_H
+#ifndef __H5Cpp_H
+#define __H5Cpp_H
#include "H5Include.h"
#include "H5Exception.h"
@@ -56,4 +56,4 @@
#define HOFFSET(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
-#endif
+#endif // __H5Cpp_H
diff --git a/c++/src/H5CppDoc.h b/c++/src/H5CppDoc.h
index ab3fa79..baeca64 100644
--- a/c++/src/H5CppDoc.h
+++ b/c++/src/H5CppDoc.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5CPPDOC_H
-#define _H5CPPDOC_H
+#ifndef __H5CppDoc_H
+#define __H5CppDoc_H
//-------------------------------------------------------------------------
// The following section will be used to generate the 'Mainpage'
@@ -88,4 +88,4 @@
/// This example shows how to work with groups.
///\example h5group.cpp
-#endif
+#endif // __H5CppDoc_H
diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp
index 6a1524d..0722ef9 100644
--- a/c++/src/H5DataSet.cpp
+++ b/c++/src/H5DataSet.cpp
@@ -79,57 +79,29 @@ DataSet::DataSet(const DataSet& original) : AbstractDs(original), H5Object(origi
//--------------------------------------------------------------------------
// Function: DataSet overload constructor - dereference
-///\brief Given a reference, ref, to an hdf5 dataset, creates a
+///\brief Given a reference, ref, to an hdf5 location, creates a
/// DataSet object
-///\param obj - IN: Dataset reference object is in or location of
+///\param loc - IN: Dataset reference object is in or location of
/// object that the dataset is located within.
///\param ref - IN: Reference pointer
///\param ref_type - IN: Reference type - default to H5R_OBJECT
///\exception H5::DataSetIException
///\par Description
-/// \c obj can be DataSet, Group, H5File, or named DataType, that
+/// \c loc can be DataSet, Group, H5File, or named DataType, that
/// is a datatype that has been named by DataType::commit.
// Programmer Binh-Minh Ribler - Oct, 2006
// Modification
// Jul, 2008
// Added for application convenience.
//--------------------------------------------------------------------------
-DataSet::DataSet(H5Object& obj, const void* ref, H5R_type_t ref_type) : AbstractDs(), H5Object()
+DataSet::DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : AbstractDs(), H5Object(), id(0)
{
- try {
- id = p_dereference(obj.getId(), ref, ref_type);
- } catch (ReferenceException deref_error) {
- throw ReferenceException("DataSet constructor - located by object",
- deref_error.getDetailMsg());
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: DataSet overload constructor - dereference
-///\brief Given a reference, ref, to an hdf5 dataset, creates a
-/// DataSet object
-///\param h5file - IN: Location referenced object is in
-///\param ref - IN: Reference pointer
-///\param ref_type - IN: Reference type - default to H5R_OBJECT
-///\exception H5::DataSetIException
-// Programmer Binh-Minh Ribler - Oct, 2006
-// Modification
-// Jul, 2008
-// Added for application convenience.
-//--------------------------------------------------------------------------
-DataSet::DataSet(H5File& h5file, const void* ref, H5R_type_t ref_type) : AbstractDs(), H5Object()
-{
- try {
- id = p_dereference(h5file.getId(), ref, ref_type);
- } catch (ReferenceException deref_error) {
- throw ReferenceException("DataSet constructor - located by HDF5 file",
- deref_error.getDetailMsg());
- }
+ id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereferenced");
}
//--------------------------------------------------------------------------
// Function: DataSet overload constructor - dereference
-///\brief Given a reference, ref, to an hdf5 dataset, creates a
+///\brief Given a reference, ref, to an hdf5 attribute, creates a
/// DataSet object
///\param attr - IN: Specifying location where the referenced object is in
///\param ref - IN: Reference pointer
@@ -140,14 +112,9 @@ DataSet::DataSet(H5File& h5file, const void* ref, H5R_type_t ref_type) : Abstrac
// Jul, 2008
// Added for application convenience.
//--------------------------------------------------------------------------
-DataSet::DataSet(Attribute& attr, const void* ref, H5R_type_t ref_type) : AbstractDs(), H5Object()
+DataSet::DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : AbstractDs(), H5Object(), id(0)
{
- try {
- id = p_dereference(attr.getId(), ref, ref_type);
- } catch (ReferenceException deref_error) {
- throw ReferenceException("DataSet constructor - located by attribute",
- deref_error.getDetailMsg());
- }
+ id = H5Location::p_dereference(attr.getId(), ref, ref_type, plist, "constructor - by dereference");
}
//--------------------------------------------------------------------------
@@ -430,7 +397,7 @@ void DataSet::read( void* buf, const DataType& mem_type, const DataSpace& mem_sp
// Function: DataSet::read
///\brief This is an overloaded member function, provided for convenience.
/// It takes a reference to a \c H5std_string for the buffer.
-///\param buf - IN: Buffer for read data
+///\param strg - IN: Buffer for read data string
///\param mem_type - IN: Memory datatype
///\param mem_space - IN: Memory dataspace
///\param file_space - IN: Dataset's dataspace in the file
@@ -647,6 +614,7 @@ void DataSet::fillMemBuf(void *buf, DataType& buf_type, DataSpace& space)
//--------------------------------------------------------------------------
// Function: DataSet::getId
///\brief Get the id of this dataset.
+///\return DataSet identifier
// Description:
// Class hierarchy is revised to address bugzilla 1068. Class
// AbstractDs and Attribute are moved out of H5Object. In
@@ -726,8 +694,9 @@ void DataSet::p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space
HDfree(strg_C);
}
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
-// Function: DataSet::p_setId (private)
+// Function: DataSet::p_setId (protected)
///\brief Sets the identifier of this dataset to a new value.
///
///\exception H5::IdComponentException when the attempt to close the HDF5
@@ -749,10 +718,8 @@ void DataSet::p_setId(const hid_t new_id)
}
// reset object's id to the given id
id = new_id;
-
- // increment the reference counter of the new id
- //incRefCount();
}
+#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: DataSet::close
diff --git a/c++/src/H5DataSet.h b/c++/src/H5DataSet.h
index 54e9d6f..a3a6a76 100644
--- a/c++/src/H5DataSet.h
+++ b/c++/src/H5DataSet.h
@@ -16,8 +16,8 @@
// Class DataSet inherits from AbstractDs and provides accesses to a dataset.
-#ifndef _H5DataSet_H
-#define _H5DataSet_H
+#ifndef __H5DataSet_H
+#define __H5DataSet_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -76,16 +76,12 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs {
// Iterates the selected elements in the specified dataspace - not implemented in C++ style yet
int iterateElems( void* buf, const DataType& type, const DataSpace& space, H5D_operator_t op, void* op_data = NULL );
- // Retrieves a dataspace with the region pointed to selected.
- DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
-
///\brief Returns this class name.
virtual H5std_string fromClass () const { return("DataSet"); }
// Creates a dataset by way of dereference.
- DataSet(H5Object& obj, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
- DataSet(H5File& h5file, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
- DataSet(Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
+ DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT);
+ DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT);
// Default constructor.
DataSet();
@@ -105,7 +101,6 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs {
private:
hid_t id; // HDF5 dataset id
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
// This function contains the common code that is used by
// getTypeClass and various API functions getXxxType
// defined in AbstractDs for generic datatype and specific
@@ -117,6 +112,7 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs {
void p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, const hid_t xfer_plist_id, H5std_string& strg) const;
protected:
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Sets the dataset id.
virtual void p_setId(const hid_t new_id);
#endif // DOXYGEN_SHOULD_SKIP_THIS
@@ -124,4 +120,4 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5DataSet_H
diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp
index 755ca5b..059c812 100644
--- a/c++/src/H5DataSpace.cpp
+++ b/c++/src/H5DataSpace.cpp
@@ -446,7 +446,7 @@ void DataSpace::getSelectBounds ( hsize_t* start, hsize_t* end ) const
}
//--------------------------------------------------------------------------
-// Function: DataSpace::H5Sselect_elements
+// Function: DataSpace::selectElements
///\brief Selects array elements to be included in the selection for
/// this dataspace.
///\param op - IN: Operator specifying how the new selection is to be
@@ -556,7 +556,8 @@ void DataSpace::selectHyperslab( H5S_seloper_t op, const hsize_t *count, const h
//--------------------------------------------------------------------------
// Function: DataSpace::getId
-// Purpose: Get the id of this attribute
+///\brief Get the id of this dataspace
+///\return Dataspace identifier
// Modification:
// May 2008 - BMR
// Class hierarchy is revised to address bugzilla 1068. Class
@@ -570,6 +571,7 @@ hid_t DataSpace::getId() const
return(id);
}
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: DataSpace::p_setId
///\brief Sets the identifier of this object to a new value.
@@ -594,6 +596,7 @@ void DataSpace::p_setId(const hid_t new_id)
// reset object's id to the given id
id = new_id;
}
+#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: DataSpace::close
diff --git a/c++/src/H5DataSpace.h b/c++/src/H5DataSpace.h
index 9afb8ab..1ea7188 100644
--- a/c++/src/H5DataSpace.h
+++ b/c++/src/H5DataSpace.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5DataSpace_H
-#define _H5DataSpace_H
+#ifndef __H5DataSpace_H
+#define __H5DataSpace_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -122,10 +122,13 @@ class H5_DLLCPP DataSpace : public IdComponent {
hid_t id; // HDF5 dataspace id
protected:
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Sets the dataspace id.
virtual void p_setId(const hid_t new_id);
+#endif // DOXYGEN_SHOULD_SKIP_THIS
+
};
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5DataSpace_H
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index 99525bc..be05623 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -49,6 +49,13 @@ namespace H5 {
#endif
//--------------------------------------------------------------------------
+// Function: DataType default constructor
+///\brief Default constructor: Creates a stub datatype
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
+DataType::DataType() : H5Object(), id(0) {}
+
+//--------------------------------------------------------------------------
// Function: DataType overloaded constructor
///\brief Creates a datatype using an existing datatype's id
///\param existing_id - IN: Id of the existing datatype
@@ -88,32 +95,6 @@ DataType::DataType( const H5T_class_t type_class, size_t size ) : H5Object()
// Function: DataType overload constructor - dereference
///\brief Given a reference, ref, to an hdf5 group, creates a
/// DataType object
-///\param obj - IN: Specifying location referenced object is in
-///\param ref - IN: Reference pointer
-///\param ref_type - IN: Reference type - default to H5R_OBJECT
-///\exception H5::ReferenceException
-///\par Description
-/// \c obj can be DataSet, Group, or named DataType, that
-/// is a datatype that has been named by DataType::commit.
-// Programmer Binh-Minh Ribler - Oct, 2006
-// Modification
-// Jul, 2008
-// Added for application convenience.
-//--------------------------------------------------------------------------
-DataType::DataType(H5Object& obj, const void* ref, H5R_type_t ref_type) : H5Object()
-{
- try {
- id = p_dereference(obj.getId(), ref, ref_type);
- } catch (ReferenceException deref_error) {
- throw ReferenceException("DataType constructor - located by an H5Object",
- deref_error.getDetailMsg());
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: DataType overload constructor - dereference
-///\brief Given a reference, ref, to an hdf5 group, creates a
-/// DataType object
///\param h5file - IN: Location referenced object is in
///\param ref - IN: Reference pointer
///\param ref_type - IN: Reference type - default to H5R_OBJECT
@@ -123,14 +104,11 @@ DataType::DataType(H5Object& obj, const void* ref, H5R_type_t ref_type) : H5Obje
// Jul, 2008
// Added for application convenience.
//--------------------------------------------------------------------------
-DataType::DataType(H5File& h5file, const void* ref, H5R_type_t ref_type) : H5Object()
+DataType::DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), id(0)
{
- try {
- id = p_dereference(h5file.getId(), ref, ref_type);
- } catch (ReferenceException deref_error) {
- throw ReferenceException("DataType constructor - located by an H5File",
- deref_error.getDetailMsg());
- }
+ /* H5Location::dereference(loc, ref, ref_type, plist);
+ */
+ id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereference");
}
//--------------------------------------------------------------------------
@@ -146,24 +124,19 @@ DataType::DataType(H5File& h5file, const void* ref, H5R_type_t ref_type) : H5Obj
// Jul, 2008
// Added for application convenience.
//--------------------------------------------------------------------------
-DataType::DataType(Attribute& attr, const void* ref, H5R_type_t ref_type) : H5Object()
+DataType::DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), id(0)
{
- try {
- id = p_dereference(attr.getId(), ref, ref_type);
+ id = H5Location::p_dereference(attr.getId(), ref, ref_type, plist, "constructor - by dereference");
+ /* try {
+ id = p_dereference(attr.getId(), ref, ref_type, plist);
} catch (ReferenceException deref_error) {
throw ReferenceException("DataType constructor - located by an Attribute",
deref_error.getDetailMsg());
}
+ */
}
//--------------------------------------------------------------------------
-// Function: DataType default constructor
-///\brief Default constructor: Creates a stub datatype
-// Programmer Binh-Minh Ribler - 2000
-//--------------------------------------------------------------------------
-DataType::DataType() : H5Object(), id(0) {}
-
-//--------------------------------------------------------------------------
// Function: DataType copy constructor
///\brief Copy constructor: makes a copy of the original DataType object.
// Programmer Binh-Minh Ribler - 2000
@@ -681,7 +654,8 @@ bool DataType::isVariableStr() const
//--------------------------------------------------------------------------
// Function: DataType::getId
-// Purpose: Get the id of this attribute
+///\brief Get the id of this datatype
+///\return Datatype identifier
// Modification:
// May 2008 - BMR
// Class hierarchy is revised to address bugzilla 1068. Class
@@ -695,6 +669,7 @@ hid_t DataType::getId() const
return(id);
}
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: DataType::p_setId
///\brief Sets the identifier of this object to a new value.
@@ -719,6 +694,7 @@ void DataType::p_setId(const hid_t new_id)
// reset object's id to the given id
id = new_id;
}
+#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: DataType::close
diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h
index 98514bb..104eed4 100644
--- a/c++/src/H5DataType.h
+++ b/c++/src/H5DataType.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5DataType_H
-#define _H5DataType_H
+#ifndef __H5DataType_H
+#define __H5DataType_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -30,9 +30,8 @@ class H5_DLLCPP DataType : public H5Object {
DataType( const DataType& original );
// Creates a datatype by way of dereference.
- DataType(H5Object& obj, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
- DataType(H5File& h5file, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
- DataType(Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
+ DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT);
+ DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT);
// Closes this datatype.
virtual void close();
@@ -101,9 +100,6 @@ class H5_DLLCPP DataType : public H5Object {
// Checks whether this datatype is a variable-length string.
bool isVariableStr() const;
- // Retrieves a dataspace with the region pointed to selected.
- DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
-
///\brief Returns this class name.
virtual H5std_string fromClass () const { return("DataType"); }
@@ -120,10 +116,12 @@ class H5_DLLCPP DataType : public H5Object {
virtual ~DataType();
protected:
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
hid_t id; // HDF5 datatype id
// Sets the datatype id.
virtual void p_setId(const hid_t new_id);
+#endif // DOXYGEN_SHOULD_SKIP_THIS
private:
void p_commit(hid_t loc_id, const char* name);
@@ -131,4 +129,4 @@ class H5_DLLCPP DataType : public H5Object {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5DataType_H
diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h
index ac7664e..385bc61 100644
--- a/c++/src/H5DcreatProp.h
+++ b/c++/src/H5DcreatProp.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5DSCreatPropList_H
-#define _H5DSCreatPropList_H
+#ifndef __H5DSCreatPropList_H
+#define __H5DSCreatPropList_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -123,4 +123,4 @@ class H5_DLLCPP DSetCreatPropList : public PropList {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5DSCreatPropList_H
diff --git a/c++/src/H5DxferProp.h b/c++/src/H5DxferProp.h
index bf481c3..b136ba4 100644
--- a/c++/src/H5DxferProp.h
+++ b/c++/src/H5DxferProp.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5DSetMemXferPropList_H
-#define _H5DSetMemXferPropList_H
+#ifndef __H5DSetMemXferPropList_H
+#define __H5DSetMemXferPropList_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -102,5 +102,5 @@ class H5_DLLCPP DSetMemXferPropList : public PropList {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5DSetMemXferPropList_H
diff --git a/c++/src/H5EnumType.h b/c++/src/H5EnumType.h
index 914eb66..71e36c3 100644
--- a/c++/src/H5EnumType.h
+++ b/c++/src/H5EnumType.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5EnumType_H
-#define _H5EnumType_H
+#ifndef __H5EnumType_H
+#define __H5EnumType_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -74,4 +74,4 @@ class H5_DLLCPP EnumType : public DataType {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5EnumType_H
diff --git a/c++/src/H5Exception.h b/c++/src/H5Exception.h
index b4af2ba..8b12abc 100644
--- a/c++/src/H5Exception.h
+++ b/c++/src/H5Exception.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5Exception_H
-#define _H5Exception_H
+#ifndef __H5Exception_H
+#define __H5Exception_H
#include <string>
@@ -161,4 +161,4 @@ class H5_DLLCPP IdComponentException : public Exception {
}
#endif
-#endif // _H5Exception_H
+#endif // __H5Exception_H
diff --git a/c++/src/H5FaccProp.h b/c++/src/H5FaccProp.h
index 0c2cc21..040b3e9 100644
--- a/c++/src/H5FaccProp.h
+++ b/c++/src/H5FaccProp.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5FileAccPropList_H
-#define _H5FileAccPropList_H
+#ifndef __H5FileAccPropList_H
+#define __H5FileAccPropList_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -139,4 +139,4 @@ class H5_DLLCPP FileAccPropList : public PropList {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5FileAccPropList_H
diff --git a/c++/src/H5FcreatProp.h b/c++/src/H5FcreatProp.h
index 61074ea..b11be62 100644
--- a/c++/src/H5FcreatProp.h
+++ b/c++/src/H5FcreatProp.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5FileCreatPropList_H
-#define _H5FileCreatPropList_H
+#ifndef __H5FileCreatPropList_H
+#define __H5FileCreatPropList_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -78,4 +78,4 @@ class H5_DLLCPP FileCreatPropList : public PropList {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5FileCreatPropList_H
diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp
index ede7469..77dd7be 100644
--- a/c++/src/H5File.cpp
+++ b/c++/src/H5File.cpp
@@ -82,7 +82,7 @@ H5File::H5File() : H5Location(), id(0) {}
// to catch then re-throw it. -BMR 2013/03/21
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : H5Location(0)
+H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : H5Location(), id(0)
{
try {
p_get_file(name, flags, create_plist, access_plist);
@@ -107,7 +107,7 @@ H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& c
// to catch then re-throw it. -BMR 2013/03/21
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-H5File::H5File( const H5std_string& name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : H5Location(0)
+H5File::H5File( const H5std_string& name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : H5Location(), id(0)
{
try {
p_get_file(name.c_str(), flags, create_plist, access_plist);
@@ -116,6 +116,7 @@ H5File::H5File( const H5std_string& name, unsigned int flags, const FileCreatPro
}
}
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// This function is private and contains common code between the
// constructors taking a string or a char*
@@ -146,6 +147,7 @@ void H5File::p_get_file(const char* name, unsigned int flags, const FileCreatPro
}
}
}
+#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: H5File copy constructor
@@ -518,7 +520,8 @@ hid_t H5File::getLocId() const
//--------------------------------------------------------------------------
// Function: H5File::getId
-// Purpose: Get the id of this attribute
+///\brief Get the id of this file
+///\return File identifier
// Modification:
// May 2008 - BMR
// Class hierarchy is revised to address bugzilla 1068. Class
@@ -532,8 +535,9 @@ hid_t H5File::getId() const
return(id);
}
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
-// Function: H5File::p_setId
+// Function: H5File::p_setId (protected)
///\brief Sets the identifier of this object to a new value.
///
///\exception H5::IdComponentException when the attempt to close the HDF5
@@ -556,6 +560,7 @@ void H5File::p_setId(const hid_t new_id)
// reset object's id to the given id
id = new_id;
}
+#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: H5File::close
diff --git a/c++/src/H5File.h b/c++/src/H5File.h
index cfb6bdf..830dda0 100644
--- a/c++/src/H5File.h
+++ b/c++/src/H5File.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5File_H
-#define _H5File_H
+#ifndef __H5File_H
+#define __H5File_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -61,9 +61,6 @@ class H5_DLLCPP H5File : public H5Location, public CommonFG {
// and datatypes) in the same file.
void getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const;
- // Retrieves a dataspace with the region pointed to selected.
- DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
-
// Returns the pointer to the file handle of the low-level file driver.
void getVFDHandle(FileAccPropList& fapl, void **file_handle) const;
void getVFDHandle(void **file_handle) const;
@@ -100,13 +97,12 @@ class H5_DLLCPP H5File : public H5Location, public CommonFG {
private:
hid_t id; // HDF5 file id
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-
// This function is private and contains common code between the
// constructors taking a string or a char*
void p_get_file( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist );
protected:
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Sets the HDF5 file id.
virtual void p_setId(const hid_t new_id);
@@ -116,4 +112,4 @@ class H5_DLLCPP H5File : public H5Location, public CommonFG {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5File_H
diff --git a/c++/src/H5FloatType.h b/c++/src/H5FloatType.h
index cbb9541..06148d6 100644
--- a/c++/src/H5FloatType.h
+++ b/c++/src/H5FloatType.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5FloatType_H
-#define _H5FloatType_H
+#ifndef __H5FloatType_H
+#define __H5FloatType_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -71,4 +71,4 @@ class H5_DLLCPP FloatType : public AtomType {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5FloatType_H
diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp
index e83b635..6299ea3 100644
--- a/c++/src/H5Group.cpp
+++ b/c++/src/H5Group.cpp
@@ -99,33 +99,11 @@ Group::Group(const hid_t existing_id) : H5Object()
/// is a datatype that has been named by DataType::commit.
// Programmer Binh-Minh Ribler - Oct, 2006
//--------------------------------------------------------------------------
-Group::Group(H5Object& obj, const void* ref, H5R_type_t ref_type) : H5Object()
+Group::Group(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), id(0)
{
- try {
- id = p_dereference(obj.getId(), ref, ref_type);
- } catch (ReferenceException deref_error) {
- throw ReferenceException("Group constructor - located by an H5Object",
- deref_error.getDetailMsg());
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: Group overload constructor - dereference
-///\brief Given a reference, ref, to an hdf5 group, creates a Group object
-///\param h5file - IN: Location referenced object is in
-///\param ref - IN: Reference pointer
-///\param ref_type - IN: Reference type - default to H5R_OBJECT
-///\exception H5::ReferenceException
-// Programmer Binh-Minh Ribler - Oct, 2006
-//--------------------------------------------------------------------------
-Group::Group(H5File& h5file, const void* ref, H5R_type_t ref_type) : H5Object()
-{
- try {
- id = p_dereference(h5file.getId(), ref, ref_type);
- } catch (ReferenceException deref_error) {
- throw ReferenceException("Group constructor - located by an H5File",
- deref_error.getDetailMsg());
- }
+ /* H5Location::dereference(loc, ref, ref_type, plist);
+ */
+ id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereference");
}
//--------------------------------------------------------------------------
@@ -137,19 +115,23 @@ Group::Group(H5File& h5file, const void* ref, H5R_type_t ref_type) : H5Object()
///\exception H5::ReferenceException
// Programmer Binh-Minh Ribler - Oct, 2006
//--------------------------------------------------------------------------
-Group::Group(Attribute& attr, const void* ref, H5R_type_t ref_type) : H5Object()
+Group::Group(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), id(0)
{
+ id = H5Location::p_dereference(attr.getId(), ref, ref_type, plist, "constructor - by dereference");
+/*
try {
- id = p_dereference(attr.getId(), ref, ref_type);
+ id = p_dereference(attr.getId(), ref, ref_type, plist);
} catch (ReferenceException deref_error) {
throw ReferenceException("Group constructor - located by an Attribute",
deref_error.getDetailMsg());
}
+*/
}
//--------------------------------------------------------------------------
// Function: Group::getId
-// Purpose: Get the id of this attribute
+///\brief Get the id of this group
+///\return Group identifier
// Modification:
// May 2008 - BMR
// Class hierarchy is revised to address bugzilla 1068. Class
@@ -163,6 +145,7 @@ hid_t Group::getId() const
return(id);
}
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: Group::p_setId
///\brief Sets the identifier of this object to a new value.
@@ -187,6 +170,7 @@ void Group::p_setId(const hid_t new_id)
// reset object's id to the given id
id = new_id;
}
+#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: Group::close
diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h
index e4c2415..a5e324c 100644
--- a/c++/src/H5Group.h
+++ b/c++/src/H5Group.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5Group_H
-#define _H5Group_H
+#ifndef __H5Group_H
+#define __H5Group_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -26,9 +26,6 @@ class H5_DLLCPP Group : public H5Object, public CommonFG {
// Close this group.
virtual void close();
- // Retrieves a dataspace with the region pointed to selected.
- DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
-
///\brief Returns this class name.
virtual H5std_string fromClass () const { return("Group"); }
@@ -39,9 +36,10 @@ class H5_DLLCPP Group : public H5Object, public CommonFG {
virtual hid_t getLocId() const;
// Creates a group by way of dereference.
- Group(H5Object& obj, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
- Group(H5File& h5file, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
- Group(Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
+ Group(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT);
+ /* Group(H5File& h5file, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
+ */
+ Group(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT);
// default constructor
Group();
@@ -62,10 +60,12 @@ class H5_DLLCPP Group : public H5Object, public CommonFG {
hid_t id; // HDF5 group id
protected:
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Sets the group id.
virtual void p_setId(const hid_t new_id);
+#endif // DOXYGEN_SHOULD_SKIP_THIS
};
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5Group_H
diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp
index 9f96277..c60d05c 100644
--- a/c++/src/H5IdComponent.cpp
+++ b/c++/src/H5IdComponent.cpp
@@ -144,6 +144,8 @@ int IdComponent::getCounter() const
//--------------------------------------------------------------------------
H5I_type_t IdComponent::getHDFObjType(const hid_t obj_id)
{
+ if (obj_id == 0)
+ return H5I_BADID; // invalid
H5I_type_t id_type = H5Iget_type(obj_id);
if (id_type <= H5I_BADID || id_type >= H5I_NTYPES)
return H5I_BADID; // invalid
@@ -269,7 +271,7 @@ IdComponent::IdComponent() {}
// Description:
// This function is protected so that the user applications can
// only have access to its code via allowable classes, namely,
-// H5File and H5Object subclasses.
+// Attribute and H5Location subclasses.
// Programmer Binh-Minh Ribler - Jul, 2004
//--------------------------------------------------------------------------
H5std_string IdComponent::p_get_file_name() const
@@ -314,6 +316,9 @@ H5std_string IdComponent::p_get_file_name() const
//--------------------------------------------------------------------------
bool IdComponent::p_valid_id(const hid_t obj_id)
{
+ if (obj_id == 0)
+ return false;
+
H5I_type_t id_type = H5Iget_type(obj_id);
if (id_type <= H5I_BADID || id_type >= H5I_NTYPES)
return false;
@@ -321,6 +326,14 @@ bool IdComponent::p_valid_id(const hid_t obj_id)
return true;
}
+// Notes about IdComponent::id
+// May 2008 - BMR
+// Class hierarchy is revised to address bugzilla 1068...
+// ...member IdComponent::id is moved into subclasses, and
+// IdComponent::getId now becomes pure virtual function.
+// (reasons: 1. encountered problems when adding H5Location;
+// 2. Scott Meyers, item 33)
+
#endif // DOXYGEN_SHOULD_SKIP_THIS
#ifndef H5_NO_NAMESPACE
diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h
index 7dc1da3..5a61947 100644
--- a/c++/src/H5IdComponent.h
+++ b/c++/src/H5IdComponent.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _IdComponent_H
-#define _IdComponent_H
+#ifndef __IdComponent_H
+#define __IdComponent_H
// IdComponent represents an HDF5 object that has an identifier.
@@ -44,8 +44,10 @@ class H5_DLLCPP IdComponent {
// Assignment operator.
IdComponent& operator=( const IdComponent& rhs );
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Gets the identifier of this object.
virtual hid_t getId () const = 0;
+#endif // DOXYGEN_SHOULD_SKIP_THIS
// Sets the identifier of this object to a new value.
void setId(const hid_t new_id);
@@ -96,4 +98,4 @@ class H5_DLLCPP IdComponent {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __IdComponent_H
diff --git a/c++/src/H5IntType.h b/c++/src/H5IntType.h
index 53864ee..02efb64 100644
--- a/c++/src/H5IntType.h
+++ b/c++/src/H5IntType.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5IntType_H
-#define _H5IntType_H
+#ifndef __H5IntType_H
+#define __H5IntType_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -53,4 +53,4 @@ class H5_DLLCPP IntType : public AtomType {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5IntType_H
diff --git a/c++/src/H5Library.h b/c++/src/H5Library.h
index a3e1c99..c92a943 100644
--- a/c++/src/H5Library.h
+++ b/c++/src/H5Library.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5Library_H
-#define _H5Library_H
+#ifndef __H5Library_H
+#define __H5Library_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -67,4 +67,4 @@ class H5_DLLCPP H5Library {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5Library_H
diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp
index 98878d7..22db85c 100644
--- a/c++/src/H5Location.cpp
+++ b/c++/src/H5Location.cpp
@@ -55,22 +55,20 @@ extern "C" herr_t userAttrOpWrpr(hid_t loc_id, const char *attr_name,
}
//--------------------------------------------------------------------------
-// Function: H5Location default constructor (protected)
-// Programmer Binh-Minh Ribler - 2000
+// Function: H5Location default constructor (protected)
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-H5Location::H5Location() : IdComponent(0) {}
+H5Location::H5Location() : IdComponent() {}
//--------------------------------------------------------------------------
-// Function: H5Location overloaded constructor (protected)
-// Purpose Creates an H5Location object using the id of an existing HDF5
-// object.
-// Parameters object_id - IN: Id of an existing HDF5 object
-// Programmer Binh-Minh Ribler - 2000
+// Function: H5Location overloaded constructor (protected)
+// Purpose Creates an H5Location object using the id of an existing HDF5
+// object.
+// Parameters object_id - IN: Id of an existing HDF5 object
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
H5Location::H5Location(const hid_t object_id) : IdComponent(object_id) {}
-#endif // DOXYGEN_SHOULD_SKIP_THIS
-
//--------------------------------------------------------------------------
// Function: H5Location copy constructor
///\brief Copy constructor: makes a copy of the original H5Location
@@ -80,6 +78,8 @@ H5Location::H5Location(const hid_t object_id) : IdComponent(object_id) {}
//--------------------------------------------------------------------------
H5Location::H5Location( const H5Location& original ) : IdComponent( original ) {}
+#endif // DOXYGEN_SHOULD_SKIP_THIS
+
//--------------------------------------------------------------------------
// Function: H5Location::createAttribute
///\brief Creates an attribute for a group, dataset, or named datatype.
@@ -342,7 +342,7 @@ void H5Location::renameAttr(const H5std_string& oldname, const H5std_string& new
/// which can be either of these values:
/// \li \c H5F_SCOPE_GLOBAL - Flushes the entire virtual file
/// \li \c H5F_SCOPE_LOCAL - Flushes only the specified file
-///\exception H5::FileIException
+///\exception H5::Exception
///\par Description
/// This location is used to identify the file to be flushed.
// Programmer Binh-Minh Ribler - 2012
@@ -355,7 +355,7 @@ void H5Location::flush(H5F_scope_t scope) const
herr_t ret_value = H5Fflush(getId(), scope);
if( ret_value < 0 )
{
- throw FileIException(inMemFunc("flush"), "H5Fflush failed");
+ throw Exception(inMemFunc("flush"), "H5Fflush failed");
}
}
@@ -377,36 +377,198 @@ H5std_string H5Location::getFileName() const
}
//--------------------------------------------------------------------------
-// Function: H5Location::p_reference (protected)
-// Purpose Creates a reference to an HDF5 object or a dataset region.
+// Function: H5Location::setComment
+///\brief Sets or resets the comment for an object specified by its name.
+///\param name - IN: Name of the object
+///\param comment - IN: New comment
+///\exception H5::Exception
+///\par Description
+/// If \a comment is an empty string or a null pointer, the comment
+/// message is removed from the object.
+/// Comments should be relatively short, null-terminated, ASCII
+/// strings. They can be attached to any object that has an
+/// object header, e.g., data sets, groups, named data types,
+/// and data spaces, but not symbolic links.
+// Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013)
+// Modification
+// 2007: QAK modified to use H5O APIs; however the first parameter is
+// no longer just file or group, this function should be moved
+// to another class to accommodate attribute, dataset, and named
+// datatype. - BMR
+//--------------------------------------------------------------------------
+void H5Location::setComment(const char* name, const char* comment) const
+{
+ herr_t ret_value = H5Oset_comment_by_name(getId(), name, comment, H5P_DEFAULT);
+ if( ret_value < 0 )
+ throw Exception(inMemFunc("setComment"), "H5Oset_comment_by_name failed");
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::setComment
+///\brief This is an overloaded member function, provided for convenience.
+/// It differs from the above function in that it takes an
+/// \c H5std_string for \a name and \a comment.
+// Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013)
+//--------------------------------------------------------------------------
+void H5Location::setComment(const H5std_string& name, const H5std_string& comment) const
+{
+ setComment(name.c_str(), comment.c_str());
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::setComment
+///\brief This is an overloaded member function, provided for convenience.
+/// It differs from the above function in that it doesn't take
+/// an object name.
+// Programmer Binh-Minh Ribler - Sep 2013
+// Modification
+//--------------------------------------------------------------------------
+void H5Location::setComment(const char* comment) const
+{
+ herr_t ret_value = H5Oset_comment_by_name(getId(), ".", comment, H5P_DEFAULT);
+ if( ret_value < 0 )
+ throw Exception(inMemFunc("setComment"), "H5Oset_comment_by_name failed");
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::setComment
+///\brief This is an overloaded member function, provided for convenience.
+/// It differs from the above function in that it takes an
+/// \c H5std_string for \a comment.
+// Programmer Binh-Minh Ribler - Sep 2013
+//--------------------------------------------------------------------------
+void H5Location::setComment(const H5std_string& comment) const
+{
+ setComment(comment.c_str());
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::removeComment
+///\brief Removes the comment from an object specified by its name.
+///\param name - IN: Name of the object
+///\exception H5::Exception
+// Programmer Binh-Minh Ribler - May 2005 (moved from CommonFG, Sep 2013)
+// 2007: QAK modified to use H5O APIs; however the first parameter is
+// no longer just file or group, this function should be moved
+// to another class to accommodate attribute, dataset, and named
+// datatype. - BMR
+//--------------------------------------------------------------------------
+void H5Location::removeComment(const char* name) const
+{
+ herr_t ret_value = H5Oset_comment_by_name(getId(), name, NULL, H5P_DEFAULT);
+ if( ret_value < 0 )
+ throw Exception(inMemFunc("removeComment"), "H5Oset_comment_by_name failed");
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::removeComment
+///\brief This is an overloaded member function, provided for convenience.
+/// It differs from the above function in that it takes an
+/// \c H5std_string for \a name.
+// Programmer Binh-Minh Ribler - May 2005 (moved from CommonFG, Sep 2013)
+//--------------------------------------------------------------------------
+void H5Location::removeComment(const H5std_string& name) const
+{
+ removeComment (name.c_str());
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::getComment
+///\brief Retrieves comment for the specified object and its comment's
+/// length.
+///\param name - IN: Name of the object
+///\param bufsize - IN: Length of the comment to retrieve
+///\return Comment string
+///\exception H5::Exception
+// Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013)
+// 2007: QAK modified to use H5O APIs; however the first parameter is
+// no longer just file or group, this function should be moved
+// to another class to accommodate attribute, dataset, and named
+// datatype. - BMR
+//--------------------------------------------------------------------------
+H5std_string H5Location::getComment(const char* name, size_t bufsize) const
+{
+ // bufsize is default to 256
+ // temporary variable
+ hid_t loc_id = getId(); // temporary variable
+
+ // temporary C-string for the object's comment; bufsize already including
+ // null character
+ char* comment_C = new char[bufsize];
+ ssize_t ret_value = H5Oget_comment_by_name(loc_id, name, comment_C, bufsize, H5P_DEFAULT);
+
+ // if the actual length of the comment is longer than bufsize and bufsize
+ // was the default value, i.e., not given by the user, then call
+ // H5Oget_comment_by_name again with the correct value.
+ // If the call to H5Oget_comment_by_name returned an error, skip this block
+ // and throw an exception below.
+ if (ret_value >= 0 && (size_t)ret_value > bufsize && bufsize == 256)
+ {
+ size_t new_size = ret_value;
+ delete []comment_C;
+ comment_C = new char[new_size]; // new_size including null terminator
+ ret_value = H5Oget_comment_by_name(loc_id, name, comment_C, new_size, H5P_DEFAULT);
+ }
+
+ // if H5Oget_comment_by_name returns SUCCEED, return the string comment,
+ // otherwise, throw an exception
+ if (ret_value < 0) {
+ delete []comment_C;
+ throw Exception(inMemFunc("getComment"), "H5Oget_comment_by_name failed");
+ }
+
+ H5std_string comment = H5std_string(comment_C);
+ delete []comment_C;
+ return (comment);
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::getComment
+///\brief This is an overloaded member function, provided for convenience.
+/// It differs from the above function in that it takes an
+/// \c H5std_string for \a name.
+// Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013)
+//--------------------------------------------------------------------------
+H5std_string H5Location::getComment(const H5std_string& name, size_t bufsize) const
+{
+ return(getComment(name.c_str(), bufsize));
+}
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+//--------------------------------------------------------------------------
+// Function: H5Location::p_reference (protected)
+// Purpose Creates a reference to an HDF5 object or a dataset region.
// Parameters
-// name - IN: Name of the object to be referenced
-// dataspace - IN: Dataspace with selection
-// ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION
-// Exception H5::IdComponentException
-// Programmer Binh-Minh Ribler - May, 2004
+// name - IN: Name of the object to be referenced
+// dataspace - IN: Dataspace with selection
+// ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION
+// Exception H5::IdComponentException
+// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
void H5Location::p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const
{
herr_t ret_value = H5Rcreate(ref, getId(), name, ref_type, space_id);
if (ret_value < 0)
{
- throw ReferenceException("", "H5Rcreate failed");
+ throw ReferenceException(inMemFunc("reference"), "H5Rcreate failed");
}
}
+#endif // DOXYGEN_SHOULD_SKIP_THIS
+
//--------------------------------------------------------------------------
-// Function: H5Location::reference
-///\brief Creates a reference to an HDF5 object or a dataset region.
-///\param ref - IN: Reference pointer
-///\param name - IN: Name of the object to be referenced
-///\param dataspace - IN: Dataspace with selection
-///\param ref_type - IN: Type of reference to query, valid values are:
+// Function: H5Location::reference
+///\brief Creates a reference to an HDF5 object or a dataset region.
+///\param ref - IN: Reference pointer
+///\param name - IN: Name of the object to be referenced
+///\param dataspace - IN: Dataspace with selection
+///\param ref_type - IN: Type of reference to query, valid values are:
/// \li \c H5R_OBJECT - Reference is an object reference.
/// \li \c H5R_DATASET_REGION - Reference is a dataset region
/// reference. - this is the default
-///\exception H5::ReferenceException
-// Programmer Binh-Minh Ribler - May, 2004
+///\exception H5::ReferenceException
+///\notes This method is more suitable for a dataset region reference.
+// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
void H5Location::reference(void* ref, const char* name, const DataSpace& dataspace, H5R_type_t ref_type) const
{
@@ -414,48 +576,79 @@ void H5Location::reference(void* ref, const char* name, const DataSpace& dataspa
p_reference(ref, name, dataspace.getId(), ref_type);
}
catch (ReferenceException E) {
- throw ReferenceException("H5Location::reference", E.getDetailMsg());
+ throw ReferenceException(inMemFunc("reference"), E.getDetailMsg());
}
}
//--------------------------------------------------------------------------
-// Function: H5Location::reference
-///\brief This is an overloaded function, provided for your convenience.
-/// It differs from the above function in that it only creates
-/// a reference to an HDF5 object, not to a dataset region.
-///\param ref - IN: Reference pointer
-///\param name - IN: Name of the object to be referenced - \c char pointer
-///\exception H5::ReferenceException
-///\par Description
-// This function passes H5R_OBJECT and -1 to the protected
-// function for it to pass to the C API H5Rcreate
-// to create a reference to the named object.
-// Programmer Binh-Minh Ribler - May, 2004
+// Function: H5Location::reference
+///\brief This is an overloaded member function, provided for convenience.
+/// It differs from the above function in that it takes an
+/// \c H5std_string for \a name.
+///\param ref - IN: Reference pointer
+///\param name - IN: Name of the object to be referenced
+///\param dataspace - IN: Dataspace with selection
+///\param ref_type - IN: Type of reference to query, valid values are:
+/// \li \c H5R_OBJECT - Reference is an object reference.
+/// \li \c H5R_DATASET_REGION - Reference is a dataset region
+/// reference. - this is the default
+///\exception H5::ReferenceException
+///\notes This method is more suitable for a dataset region reference.
+// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
-void H5Location::reference(void* ref, const char* name) const
+void H5Location::reference(void* ref, const H5std_string& name, const DataSpace& dataspace, H5R_type_t ref_type) const
{
try {
- p_reference(ref, name, -1, H5R_OBJECT);
+ p_reference(ref, name.c_str(), dataspace.getId(), ref_type);
}
catch (ReferenceException E) {
- throw ReferenceException("H5Location::reference", E.getDetailMsg());
+ throw ReferenceException(inMemFunc("reference"), E.getDetailMsg());
}
}
//--------------------------------------------------------------------------
-// Function: H5Location::reference
-///\brief This is an overloaded function, provided for your convenience.
-/// It differs from the above function in that it takes an
-/// \c H5std_string for the object's name.
-///\param ref - IN: Reference pointer
-///\param name - IN: Name of the object to be referenced - \c H5std_string
-// Programmer Binh-Minh Ribler - May, 2004
+// Function: H5Location::reference
+///\brief This is an overloaded function, provided for your convenience.
+/// It differs from the above function in that it does not take
+/// a DataSpace object and the reference type must be specified.
+///\param ref - IN: Reference pointer
+///\param name - IN: Name of the object to be referenced
+///\param ref_type - IN: Type of reference to query, valid values are:
+/// \li \c H5R_OBJECT - Reference is an object reference.
+/// \li \c H5R_DATASET_REGION - Reference is a dataset region
+///\exception H5::ReferenceException
+///\notes This method is more suitable for an object reference.
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+void H5Location::reference(void* ref, const char* name, H5R_type_t ref_type) const
+{
+ try {
+ p_reference(ref, name, -1, ref_type);
+ }
+ catch (ReferenceException E) {
+ throw ReferenceException(inMemFunc("reference"), E.getDetailMsg());
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::reference
+///\brief This is an overloaded function, provided for your convenience.
+/// It differs from the above function in that it takes an
+/// \c H5std_string for the object's name.
+///\param ref - IN: Reference pointer
+///\param name - IN: Name of the object to be referenced - \c H5std_string
+///\param ref_type - IN: Type of reference to query, valid values are:
+/// \li \c H5R_OBJECT - Reference is an object reference.
+/// \li \c H5R_DATASET_REGION - Reference is a dataset region
+///\notes This method is more suitable for an object reference.
+// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
-void H5Location::reference(void* ref, const H5std_string& name) const
+void H5Location::reference(void* ref, const H5std_string& name, H5R_type_t ref_type) const
{
- reference(ref, name.c_str());
+ reference(ref, name.c_str(), ref_type);
}
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: H5Location::p_dereference (protected)
// Purpose Dereference a ref into an hdf5 object.
@@ -470,18 +663,23 @@ void H5Location::reference(void* ref, const H5std_string& name) const
// May 2008 - BMR
// Moved from IdComponent.
//--------------------------------------------------------------------------
-hid_t H5Location::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type)
+hid_t H5Location::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type, const PropList& plist, const char* from_func)
{
- hid_t temp_id;
- temp_id = H5Rdereference2(loc_id, H5P_DEFAULT, ref_type, ref);
+ hid_t plist_id;
+ if (p_valid_id(plist.getId()))
+ plist_id = plist.getId();
+ else
+ plist_id = H5P_DEFAULT;
+
+ hid_t temp_id = H5Rdereference2(loc_id, plist_id, ref_type, ref);
if (temp_id < 0)
{
- throw ReferenceException("", "H5Rdereference failed");
+ throw ReferenceException(inMemFunc(from_func), "H5Rdereference failed");
}
- // No failure, set id to the object
return(temp_id);
}
+#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: H5Location::dereference
@@ -490,45 +688,14 @@ hid_t H5Location::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_ty
///\param ref - IN: Reference pointer
///\param ref_type - IN: Reference type
///\exception H5::ReferenceException
-// Programmer Binh-Minh Ribler - Oct, 2006
-// Modification
-// May, 2008
-// Corrected missing parameters. - BMR
-//--------------------------------------------------------------------------
-void H5Location::dereference(H5Object& obj, const void* ref, H5R_type_t ref_type)
-{
- hid_t temp_id;
- try {
- temp_id = p_dereference(obj.getId(), ref, ref_type);
- }
- catch (ReferenceException E) {
- throw ReferenceException("H5Location::dereference - located by object", E.getDetailMsg());
- }
- p_setId(temp_id);
-}
-
-//--------------------------------------------------------------------------
-// Function: H5Location::dereference
-///\brief Dereferences a reference into an HDF5 object, given an HDF5 file.
-///\param h5file - IN: HDF5 file specifying the location of the referenced object
-///\param ref - IN: Reference pointer
-///\param ref_type - IN: Reference type
-///\exception H5::ReferenceException
-// Programmer Binh-Minh Ribler - Oct, 2006
+// Programmer Binh-Minh Ribler - Oct, 2006
// Modification
// May, 2008
// Corrected missing parameters. - BMR
//--------------------------------------------------------------------------
-void H5Location::dereference(H5File& h5file, const void* ref, H5R_type_t ref_type)
+void H5Location::dereference(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist)
{
- hid_t temp_id;
- try {
- temp_id = p_dereference(h5file.getId(), ref, ref_type);
- }
- catch (ReferenceException E) {
- throw ReferenceException("H5Location::dereference - located by file", E.getDetailMsg());
- }
- p_setId(temp_id);
+ p_setId(p_dereference(loc.getId(), ref, ref_type, plist, "dereference"));
}
//--------------------------------------------------------------------------
@@ -538,21 +705,14 @@ void H5Location::dereference(H5File& h5file, const void* ref, H5R_type_t ref_typ
///\param ref - IN: Reference pointer
///\param ref_type - IN: Reference type
///\exception H5::ReferenceException
-// Programmer Binh-Minh Ribler - Oct, 2006
+// Programmer Binh-Minh Ribler - Oct, 2006
// Modification
// May, 2008
// Corrected missing parameters. - BMR
//--------------------------------------------------------------------------
-void H5Location::dereference(Attribute& attr, const void* ref, H5R_type_t ref_type)
+void H5Location::dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist)
{
- hid_t temp_id;
- try {
- temp_id = p_dereference(attr.getId(), ref, ref_type);
- }
- catch (ReferenceException E) {
- throw ReferenceException("H5Location::dereference - located by attribute", E.getDetailMsg());
- }
- p_setId(temp_id);
+ p_setId(p_dereference(attr.getId(), ref, ref_type, plist, "dereference"));
}
#ifndef H5_NO_DEPRECATED_SYMBOLS
@@ -560,16 +720,16 @@ void H5Location::dereference(Attribute& attr, const void* ref, H5R_type_t ref_ty
// Function: H5Location::getObjType
///\brief Retrieves the type of object that an object reference points to.
///\param ref_type - IN: Type of reference to query, valid values are:
-/// \li \c H5R_OBJECT \tReference is an object reference.
-/// \li \c H5R_DATASET_REGION \tReference is a dataset region reference.
+/// \li \c H5R_OBJECT - Reference is an object reference.
+/// \li \c H5R_DATASET_REGION - Reference is a dataset region reference.
///\param ref - IN: Reference to query
///\return An object type, which can be one of the following:
-/// \li \c H5G_UNKNOWN \tA failure occurs. (-1)
-/// \li \c H5G_GROUP \tObject is a group.
-/// \li \c H5G_DATASET \tObject is a dataset.
-/// \li \c H5G_TYPE Object \tis a named datatype
-/// \li \c H5G_LINK \tObject is a symbolic link.
-/// \li \c H5G_UDLINK \tObject is a user-defined link.
+/// \li \c H5G_UNKNOWN - A failure occurs. (-1)
+/// \li \c H5G_GROUP - Object is a group.
+/// \li \c H5G_DATASET - Object is a dataset.
+/// \li \c H5G_TYPE Object - is a named datatype
+/// \li \c H5G_LINK - Object is a symbolic link.
+/// \li \c H5G_UDLINK - Object is a user-defined link.
///\exception H5::ReferenceException
// Programmer Binh-Minh Ribler - May, 2004
// Modification
@@ -581,25 +741,26 @@ H5G_obj_t H5Location::getObjType(void *ref, H5R_type_t ref_type) const
return(p_get_obj_type(ref, ref_type));
}
catch (ReferenceException E) {
- throw ReferenceException("H5Location::getObjType", E.getDetailMsg());
+ throw ReferenceException(inMemFunc("getObjType"), E.getDetailMsg());
}
}
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
-// Function: H5Location::p_get_obj_type (protected)
-// Purpose Retrieves the type of object that an object reference points to.
+// Function: H5Location::p_get_obj_type (protected)
+// Purpose Retrieves the type of object that an object reference points to.
// Parameters
-// ref - IN: Reference to query
-// ref_type - IN: Type of reference to query
-// Return An object type, which can be one of the following:
-// H5G_UNKNOWN \tFailure occurs (-1)
-// H5G_GROUP \tObject is a group.
-// H5G_DATASET \tObject is a dataset.
-// H5G_TYPE Object \tis a named datatype.
-// H5G_LINK \tObject is a symbolic link.
-// H5G_UDLINK \tObject is a user-defined link.
-// Exception H5::ReferenceException
-// Programmer Binh-Minh Ribler - May, 2004
+// ref - IN: Reference to query
+// ref_type - IN: Type of reference to query
+// Return An object type, which can be one of the following:
+// H5G_UNKNOWN \tFailure occurs (-1)
+// H5G_GROUP \tObject is a group.
+// H5G_DATASET \tObject is a dataset.
+// H5G_TYPE Object \tis a named datatype.
+// H5G_LINK \tObject is a symbolic link.
+// H5G_UDLINK \tObject is a user-defined link.
+// Exception H5::ReferenceException
+// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
H5G_obj_t H5Location::p_get_obj_type(void *ref, H5R_type_t ref_type) const
{
@@ -607,28 +768,28 @@ H5G_obj_t H5Location::p_get_obj_type(void *ref, H5R_type_t ref_type) const
if (obj_type == H5G_UNKNOWN)
{
- throw ReferenceException("", "H5Rget_obj_type1 failed");
+ throw ReferenceException(inMemFunc("getObjType"), "H5Rget_obj_type1 failed");
}
return(obj_type);
}
+#endif // DOXYGEN_SHOULD_SKIP_THIS
#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
//--------------------------------------------------------------------------
-// Function: H5Location::getRefObjType
-///\brief Retrieves the type of object that an object reference points to.
-///\param ref - IN: Reference to query
-///\param ref_type - IN: Type of reference to query, valid values are:
-/// \li \c H5R_OBJECT - Reference is an object reference.
-/// \li \c H5R_DATASET_REGION - Reference is a dataset region reference.
-///\return An object type, which can be one of the following:
-/// \li \c H5O_TYPE_UNKNOWN - Unknown object type (-1)
-/// \li \c H5O_TYPE_GROUP - Object is a group
-/// \li \c H5O_TYPE_DATASET - Object is a dataset
-/// \li \c H5O_TYPE_NAMED_DATATYPE - Object is a named datatype
-/// \li \c H5O_TYPE_NTYPES - Number of different object types
-///\exception H5::ReferenceException
-// Programmer Binh-Minh Ribler - May, 2004
+// Function: H5Location::getRefObjType
+///\brief Retrieves the type of object that an object reference points to.
+///\param ref - IN: Reference to query
+///\param ref_type - IN: Type of reference to query, valid values are:
+/// \li \c H5R_OBJECT - Reference is an object reference.
+/// \li \c H5R_DATASET_REGION - Reference is a dataset region reference.
+///\return An object type, which can be one of the following:
+/// \li \c H5O_TYPE_UNKNOWN - Unknown object type (-1)
+/// \li \c H5O_TYPE_GROUP - Object is a group
+/// \li \c H5O_TYPE_DATASET - Object is a dataset
+/// \li \c H5O_TYPE_NAMED_DATATYPE - Object is a named datatype
+/// \li \c H5O_TYPE_NTYPES - Number of different object types
+///\exception H5::ReferenceException
+// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
H5O_type_t H5Location::getRefObjType(void *ref, H5R_type_t ref_type) const
{
@@ -636,24 +797,25 @@ H5O_type_t H5Location::getRefObjType(void *ref, H5R_type_t ref_type) const
return(p_get_ref_obj_type(ref, ref_type));
}
catch (ReferenceException E) {
- throw ReferenceException("H5Location::getRefObjType", E.getDetailMsg());
+ throw ReferenceException(inMemFunc("getRefObjType"), E.getDetailMsg());
}
}
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
-// Function: H5Location::p_get_ref_obj_type (protected)
-// Purpose Retrieves the type of object that an object reference points to.
+// Function: H5Location::p_get_ref_obj_type (protected)
+// Purpose Retrieves the type of object that an object reference points to.
// Parameters
-// ref - IN: Reference to query
-// ref_type - IN: Type of reference to query
-// Return An object type, which can be one of the following:
+// ref - IN: Reference to query
+// ref_type - IN: Type of reference to query
+// Return An object type, which can be one of the following:
// H5O_TYPE_UNKNOWN - Unknown object type (-1)
// H5O_TYPE_GROUP - Object is a group
// H5O_TYPE_DATASET - Object is a dataset
// H5O_TYPE_NAMED_DATATYPE - Object is a named datatype
// H5O_TYPE_NTYPES - Number of object types
-// Exception H5::ReferenceException
-// Programmer Binh-Minh Ribler - May, 2004
+// Exception H5::ReferenceException
+// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
H5O_type_t H5Location::p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const
{
@@ -662,31 +824,36 @@ H5O_type_t H5Location::p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const
if (obj_type == H5O_TYPE_UNKNOWN || obj_type >= H5O_TYPE_NTYPES)
{
- throw ReferenceException("", "H5Rget_obj_type2 failed");
+ throw ReferenceException(inMemFunc("getRefObjType"), "H5Rget_obj_type2 failed");
}
return(obj_type);
}
//--------------------------------------------------------------------------
-// Function: H5Location::p_get_region (protected)
-// Purpose Retrieves a dataspace with the region pointed to selected.
-// Parameters
-// ref_type - IN: Type of reference to get region of - default
-// to H5R_DATASET_REGION
-// ref - IN: Reference to get region of
-// Return Dataspace id
-// Exception H5::ReferenceException
-// Programmer Binh-Minh Ribler - May, 2004
+// Function: H5Location::getRegion
+///\brief Retrieves a dataspace with the region pointed to selected.
+///\param ref - IN: Reference to get region of
+///\param ref_type - IN: Type of reference to get region of - default
+// to H5R_DATASET_REGION
+///\return DataSpace object
+///\exception H5::ReferenceException
+// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
-hid_t H5Location::p_get_region(void *ref, H5R_type_t ref_type) const
+DataSpace H5Location::getRegion(void *ref, H5R_type_t ref_type) const
{
hid_t space_id = H5Rget_region(getId(), ref_type, ref);
if (space_id < 0)
{
- throw ReferenceException("", "H5Rget_region failed");
+ throw ReferenceException(inMemFunc("getRegion"), "H5Rget_region failed");
+ }
+ try {
+ DataSpace dataspace(space_id);
+ return(dataspace);
+ }
+ catch (DataSpaceIException E) {
+ throw ReferenceException(inMemFunc("getRegion"), E.getDetailMsg());
}
- return(space_id);
}
@@ -697,6 +864,8 @@ hid_t H5Location::p_get_region(void *ref, H5R_type_t ref_type) const
//--------------------------------------------------------------------------
H5Location::~H5Location() {}
+#endif // DOXYGEN_SHOULD_SKIP_THIS
+
#ifndef H5_NO_NAMESPACE
} // end namespace
#endif
diff --git a/c++/src/H5Location.h b/c++/src/H5Location.h
index 8eae454..4ea13cd 100644
--- a/c++/src/H5Location.h
+++ b/c++/src/H5Location.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5Location_H
-#define _H5Location_H
+#ifndef __H5Location_H
+#define __H5Location_H
#include "H5Classes.h" // constains forward class declarations
@@ -36,12 +36,12 @@ typedef void (*attr_operator_t)( H5Location& loc/*in*/,
class UserData4Aiterate { // user data for attribute iteration
public:
- attr_operator_t op;
- void* opData;
- H5Location* location;
+ attr_operator_t op;
+ void* opData;
+ H5Location* location;
};
-// An H5Location can be a file, group, dataset, named datatype, or attribute.
+// An H5Location can be a file, group, dataset, or committed datatype.
class H5_DLLCPP H5Location : public IdComponent {
public:
@@ -85,29 +85,49 @@ class H5_DLLCPP H5Location : public IdComponent {
bool attrExists(const char* name) const;
bool attrExists(const H5std_string& name) const;
+ // Renames the named attribute to a new name.
+ void renameAttr(const char* oldname, const char* newname) const;
+ void renameAttr(const H5std_string& oldname, const H5std_string& newname) const;
+
// Removes the named attribute from this location.
void removeAttr(const char* name) const;
void removeAttr(const H5std_string& name) const;
- // Renames the named attribute to a new name.
- void renameAttr(const char* oldname, const char* newname) const;
- void renameAttr(const H5std_string& oldname, const H5std_string& newname) const;
+ // Sets the comment for an HDF5 object specified by its name.
+ void setComment(const char* name, const char* comment) const;
+ void setComment(const H5std_string& name, const H5std_string& comment) const;
+ void setComment(const char* comment) const;
+ void setComment(const H5std_string& comment) const;
+
+ // Retrieves comment for the HDF5 object specified by its name.
+ H5std_string getComment(const char* name, size_t bufsize=256) const;
+ H5std_string getComment(const H5std_string& name, size_t bufsize=256) const;
+
+ // Removes the comment for the HDF5 object specified by its name.
+ void removeComment(const char* name) const;
+ void removeComment(const H5std_string& name) const;
// Creates a reference to a named object or to a dataset region
// in this object.
+ void reference(void* ref, const char* name,
+ H5R_type_t ref_type = H5R_OBJECT) const;
+ void reference(void* ref, const H5std_string& name,
+ H5R_type_t ref_type = H5R_DATASET_REGION) const;
void reference(void* ref, const char* name, const DataSpace& dataspace,
H5R_type_t ref_type = H5R_DATASET_REGION) const;
- void reference(void* ref, const char* name) const;
- void reference(void* ref, const H5std_string& name) const;
+ void reference(void* ref, const H5std_string& name, const DataSpace& dataspace,
+ H5R_type_t ref_type = H5R_DATASET_REGION) const;
// Open a referenced object whose location is specified by either
// a file, an HDF5 object, or an attribute.
- void dereference(H5File& h5file, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
- void dereference(H5Object& obj, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
- void dereference(Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
+ void dereference(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT);
+ void dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT);
+
+ // Retrieves a dataspace with the region pointed to selected.
+ DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
- // For subclasses.
- virtual hid_t getId() const = 0;
+ ///\brief Returns an identifier. (pure virtual)
+ virtual hid_t getId() const = 0;
protected:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
@@ -124,7 +144,7 @@ class H5_DLLCPP H5Location : public IdComponent {
void p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const;
// Dereferences a ref into an HDF5 id.
- hid_t p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type);
+ hid_t p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type, const PropList& plist, const char* from_func);
#ifndef H5_NO_DEPRECATED_SYMBOLS
// Retrieves the type of object that an object reference points to.
@@ -134,9 +154,6 @@ class H5_DLLCPP H5Location : public IdComponent {
// Retrieves the type of object that an object reference points to.
H5O_type_t p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const;
- // Retrieves a dataspace with the region pointed to selected.
- hid_t p_get_region(void *ref, H5R_type_t ref_type) const;
-
// Noop destructor.
virtual ~H5Location();
@@ -147,4 +164,4 @@ class H5_DLLCPP H5Location : public IdComponent {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5Location_H
diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp
index e29e80e..1d96f2e 100644
--- a/c++/src/H5Object.cpp
+++ b/c++/src/H5Object.cpp
@@ -52,8 +52,6 @@ H5Object::H5Object() : H5Location() {}
//--------------------------------------------------------------------------
H5Object::H5Object( const hid_t object_id ) : H5Location( object_id ) {}
-#endif // DOXYGEN_SHOULD_SKIP_THIS
-
//--------------------------------------------------------------------------
// Function: H5Object copy constructor
///\brief Copy constructor: makes a copy of the original H5Object
@@ -69,6 +67,7 @@ H5Object::H5Object( const H5Object& original ) : H5Location( original ) {}
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
H5Object::~H5Object() {}
+#endif // DOXYGEN_SHOULD_SKIP_THIS
#ifndef H5_NO_NAMESPACE
} // end namespace
diff --git a/c++/src/H5Object.h b/c++/src/H5Object.h
index bfd5e6f..3f9c343 100644
--- a/c++/src/H5Object.h
+++ b/c++/src/H5Object.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5Object_H
-#define _H5Object_H
+#ifndef __H5Object_H
+#define __H5Object_H
#include "H5Location.h"
#include "H5Classes.h" // constains forward class declarations
@@ -40,6 +40,7 @@ namespace H5 {
class H5_DLLCPP H5Object : public H5Location {
public:
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Copy constructor: makes copy of an H5Object object.
H5Object(const H5Object& original);
@@ -47,7 +48,6 @@ class H5_DLLCPP H5Object : public H5Location {
virtual ~H5Object();
protected:
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Default constructor
H5Object();
@@ -61,4 +61,4 @@ class H5_DLLCPP H5Object : public H5Location {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5Object_H
diff --git a/c++/src/H5PredType.cpp b/c++/src/H5PredType.cpp
index 9dfc760..27cfd3a 100644
--- a/c++/src/H5PredType.cpp
+++ b/c++/src/H5PredType.cpp
@@ -56,6 +56,7 @@ PredType::PredType( const hid_t predtype_id ) : AtomType( predtype_id )
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
PredType::PredType() : AtomType() {}
+#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: PredType copy constructor
@@ -65,6 +66,7 @@ PredType::PredType() : AtomType() {}
//--------------------------------------------------------------------------
PredType::PredType( const PredType& original ) : AtomType( original ) {}
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Flag to terminate HDF5 library in DataType::~DataType
const PredType PredType::AtExit(H5CPP_EXITED);
diff --git a/c++/src/H5PredType.h b/c++/src/H5PredType.h
index 8a04f0c..65e1c07 100644
--- a/c++/src/H5PredType.h
+++ b/c++/src/H5PredType.h
@@ -19,8 +19,8 @@
// closed by H5Tclose. They are treated as constants.
/////////////////////////////////////////////////////////////////////
-#ifndef _H5PredType_H
-#define _H5PredType_H
+#ifndef __H5PredType_H
+#define __H5PredType_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -32,7 +32,9 @@ namespace H5 {
before the other PredType objects are created. At exit, when this special
PredType object is to be destructed, no HDF5 library function will be called
and the library will be terminated. -BMR, Mar 30, 2012 */
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define H5CPP_EXITED -3 // -3 is less likely to be used elsewhere
+#endif // DOXYGEN_SHOULD_SKIP_THIS
class H5_DLLCPP PredType : public AtomType {
public:
@@ -256,4 +258,4 @@ class H5_DLLCPP PredType : public AtomType {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5PredType_H
diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp
index ceea15f..9476d46 100644
--- a/c++/src/H5PropList.cpp
+++ b/c++/src/H5PropList.cpp
@@ -39,7 +39,7 @@ namespace H5 {
//--------------------------------------------------------------------------
///\brief Constant for default property.
//--------------------------------------------------------------------------
-const PropList PropList::DEFAULT( H5P_DEFAULT );
+const PropList PropList::DEFAULT;
//--------------------------------------------------------------------------
// Function Default constructor
@@ -74,6 +74,9 @@ PropList::PropList(const PropList& original) : IdComponent(original)
//--------------------------------------------------------------------------
PropList::PropList( const hid_t plist_id ) : IdComponent()
{
+ if (plist_id == 0)
+ id = H5P_DEFAULT;
+
H5I_type_t id_type = H5Iget_type(plist_id);
switch (id_type) {
case H5I_GENPROP_CLS:
@@ -216,7 +219,8 @@ void PropList::copyProp( PropList& dest, PropList& src, const H5std_string& name
//--------------------------------------------------------------------------
// Function: PropList::getId
-// Purpose: Get the id of this attribute
+///\brief Get the id of this property list
+///\return Property list identifier
// Description:
// Class hierarchy is revised to address bugzilla 1068. Class
// AbstractDS and Attribute are moved out of H5Object. In
@@ -229,6 +233,7 @@ hid_t PropList::getId() const
return(id);
}
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: PropList::p_setId
///\brief Sets the identifier of this object to a new value.
@@ -253,6 +258,7 @@ void PropList::p_setId(const hid_t new_id)
// reset object's id to the given id
id = new_id;
}
+#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: PropList::close
diff --git a/c++/src/H5PropList.h b/c++/src/H5PropList.h
index 7e47b32..b2c50d4 100644
--- a/c++/src/H5PropList.h
+++ b/c++/src/H5PropList.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5PropList_H
-#define _H5PropList_H
+#ifndef __H5PropList_H
+#define __H5PropList_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -110,13 +110,15 @@ class H5_DLLCPP PropList : public IdComponent {
virtual ~PropList();
protected:
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
hid_t id; // HDF5 property list id
// Sets the property list id.
virtual void p_setId(const hid_t new_id);
+#endif // DOXYGEN_SHOULD_SKIP_THIS
};
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif // _H5PropList_H
+#endif // __H5PropList_H
diff --git a/c++/src/H5StrType.h b/c++/src/H5StrType.h
index be9fed8..251b0b8 100644
--- a/c++/src/H5StrType.h
+++ b/c++/src/H5StrType.h
@@ -14,8 +14,8 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef _H5StrType_H
-#define _H5StrType_H
+#ifndef __H5StrType_H
+#define __H5StrType_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -65,4 +65,4 @@ class H5_DLLCPP StrType : public AtomType {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5StrType_H
diff --git a/c++/src/H5VarLenType.h b/c++/src/H5VarLenType.h
index 0cee219..caa347a 100644
--- a/c++/src/H5VarLenType.h
+++ b/c++/src/H5VarLenType.h
@@ -17,8 +17,8 @@
// Class VarLenType inherits from DataType and provides wrappers for
// the HDF5 C's Variable-length Datatypes.
-#ifndef _H5VarLenType_H
-#define _H5VarLenType_H
+#ifndef __H5VarLenType_H
+#define __H5VarLenType_H
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -49,4 +49,4 @@ class H5_DLLCPP VarLenType : public DataType {
#ifndef H5_NO_NAMESPACE
}
#endif
-#endif
+#endif // __H5VarLenType_H
diff --git a/c++/src/Makefile.am b/c++/src/Makefile.am
index ec942fd..759b4a7 100644
--- a/c++/src/Makefile.am
+++ b/c++/src/Makefile.am
@@ -47,8 +47,11 @@ libhdf5_cpp_la_SOURCES=H5Exception.cpp H5IdComponent.cpp H5Library.cpp \
H5StrType.cpp H5ArrayType.cpp H5VarLenType.cpp H5CompType.cpp \
H5DataSet.cpp H5CommonFG.cpp H5Group.cpp H5File.cpp
-# HDF5 C++ library depends on HDF5 Library.
+# HDF5 C++ library depends on HDF5 Library. However, only add the dependency
+# if --enable-sharedlib-rpath is yes.
+if LT_ADD_LIBHDF5_DEPENDENCY
libhdf5_cpp_la_LIBADD=$(LIBHDF5)
+endif
# Public headers
include_HEADERS=H5Cpp.h H5AbstractDs.h H5AtomType.h H5Attribute.h H5Classes.h \
diff --git a/c++/src/Makefile.in b/c++/src/Makefile.in
index f601487..4cb0ac1 100644
--- a/c++/src/Makefile.in
+++ b/c++/src/Makefile.in
@@ -118,7 +118,8 @@ am__uninstall_files_from_dir = { \
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
"$(DESTDIR)$(includedir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
-libhdf5_cpp_la_DEPENDENCIES = $(LIBHDF5)
+@LT_ADD_LIBHDF5_DEPENDENCY_TRUE@libhdf5_cpp_la_DEPENDENCIES = \
+@LT_ADD_LIBHDF5_DEPENDENCY_TRUE@ $(LIBHDF5)
am_libhdf5_cpp_la_OBJECTS = H5Exception.lo H5IdComponent.lo \
H5Library.lo H5Attribute.lo H5Location.lo H5Object.lo \
H5PropList.lo H5FaccProp.lo H5FcreatProp.lo H5DcreatProp.lo \
@@ -297,6 +298,7 @@ LIPO = @LIPO@
LL_PATH = @LL_PATH@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
+LT_ADD_LIBHDF5_DEPENDENCY = @LT_ADD_LIBHDF5_DEPENDENCY@
LT_STATIC_EXEC = @LT_STATIC_EXEC@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
@@ -467,7 +469,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog
# Add libtool shared library version numbers to the HDF5 library
# See libtool versioning documentation online.
LT_VERS_INTERFACE = 6
-LT_VERS_REVISION = 154
+LT_VERS_REVISION = 155
LT_VERS_AGE = 0
# Include src directory
@@ -490,8 +492,9 @@ libhdf5_cpp_la_SOURCES = H5Exception.cpp H5IdComponent.cpp H5Library.cpp
H5DataSet.cpp H5CommonFG.cpp H5Group.cpp H5File.cpp
-# HDF5 C++ library depends on HDF5 Library.
-libhdf5_cpp_la_LIBADD = $(LIBHDF5)
+# HDF5 C++ library depends on HDF5 Library. However, only add the dependency
+# if --enable-sharedlib-rpath is yes.
+@LT_ADD_LIBHDF5_DEPENDENCY_TRUE@libhdf5_cpp_la_LIBADD = $(LIBHDF5)
# Public headers
include_HEADERS = H5Cpp.h H5AbstractDs.h H5AtomType.h H5Attribute.h H5Classes.h \
diff --git a/c++/test/Makefile.in b/c++/test/Makefile.in
index ef1455c..3c4c645 100644
--- a/c++/test/Makefile.in
+++ b/c++/test/Makefile.in
@@ -258,6 +258,7 @@ LIPO = @LIPO@
LL_PATH = @LL_PATH@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
+LT_ADD_LIBHDF5_DEPENDENCY = @LT_ADD_LIBHDF5_DEPENDENCY@
LT_STATIC_EXEC = @LT_STATIC_EXEC@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp
index 643762b..811d8c7 100644
--- a/c++/test/dsets.cpp
+++ b/c++/test/dsets.cpp
@@ -283,13 +283,13 @@ test_simple_io( H5File& file)
*-------------------------------------------------------------------------
*/
static herr_t
-test_datasize()
+test_datasize(FileAccPropList &fapl)
{
SUBTEST("DataSet::getInMemDataSize()");
try
{
// Open FILE1.
- H5File file(FILE1, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, FileAccPropList::DEFAULT);
+ H5File file(FILE1, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl);
// Open dataset DSET_SIMPLE_IO_NAME.
DataSet dset = file.openDataSet (DSET_SIMPLE_IO_NAME);
@@ -1058,7 +1058,7 @@ void test_dset()
// Cause the library to emit initial messages
Group grp = file.createGroup( "emit diagnostics", 0);
- grp.setComment( ".", "Causes diagnostic messages to be emitted");
+ grp.setComment("Causes diagnostic messages to be emitted");
nerrors += test_create(file)<0 ?1:0;
nerrors += test_simple_io(file)<0 ?1:0;
@@ -1067,9 +1067,12 @@ void test_dset()
nerrors += test_multiopen (file)<0 ?1:0;
nerrors += test_types(file)<0 ?1:0;
+ // Close group "emit diagnostics".
+ grp.close();
+
// Close the file before testing data size.
file.close();
- nerrors += test_datasize() <0 ? 1:0;
+ nerrors += test_datasize(fapl) <0 ? 1:0;
}
catch (Exception E)
{
diff --git a/c++/test/h5cpputil.cpp b/c++/test/h5cpputil.cpp
index c6a7a2a..cd85b6e 100644
--- a/c++/test/h5cpputil.cpp
+++ b/c++/test/h5cpputil.cpp
@@ -107,6 +107,30 @@ void issue_fail_msg(const char* where, int line, const char* file_name,
}
/*-------------------------------------------------------------------------
+ * Function: issue_fail_msg
+ *
+ * Purpose: Displays that a function has failed with its location.
+ *
+ * Return: None
+ *
+ * Programmer: Binh-Minh Ribler (copied and modified macro CHECK from C)
+ * Monday, December 20, 2004
+ *
+ *-------------------------------------------------------------------------
+ */
+void issue_fail_msg(const char* where, int line, const char* file_name,
+ const char* func_name, const char* message)
+{
+ //if (GetTestVerbosity()>=VERBO_HI)
+ {
+ cerr << endl;
+ cerr << ">>> FAILED in " << where << ": " << func_name << endl <<
+ " at line " << line << " in " << file_name << endl <<
+ " C library detail: " << message << endl << endl;
+ }
+}
+
+/*-------------------------------------------------------------------------
* Function: check_values
*
* Purpose: Checks a read value against the written value. If they are
diff --git a/c++/test/h5cpputil.h b/c++/test/h5cpputil.h
index 02f3d0d..e6aba79 100644
--- a/c++/test/h5cpputil.h
+++ b/c++/test/h5cpputil.h
@@ -42,6 +42,8 @@ int check_values (hsize_t i, hsize_t j, int apoint, int acheck);
int test_report (int, const H5std_string&);
void issue_fail_msg(const char* where, int line, const char* file_name,
const char* message="");
+void issue_fail_msg(const char* where, int line, const char* file_name,
+ const char* func_name, const char* message);
class InvalidActionException : public Exception {
public:
diff --git a/c++/test/th5s.cpp b/c++/test/th5s.cpp
index 7947a9b..cfdeb1f 100644
--- a/c++/test/th5s.cpp
+++ b/c++/test/th5s.cpp
@@ -188,7 +188,10 @@ static void test_h5s_basic()
* If this test fails and the H5S_MAX_RANK variable has changed, follow
* the instructions in space_overflow.c for regenating the th5s.h5 file.
*/
- const char *testfile = H5_get_srcdir_filename(TESTFILE.c_str());
+ char *tmp_str = new char[TESTFILE.length()+1];
+ strcpy(tmp_str, TESTFILE.c_str());
+ const char *testfile = H5_get_srcdir_filename(tmp_str);
+ delete []tmp_str;
// Create file
H5File fid1(testfile, H5F_ACC_RDONLY);
diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp
index ce18e58..36c2ee4 100644
--- a/c++/test/trefer.cpp
+++ b/c++/test/trefer.cpp
@@ -27,13 +27,6 @@
#endif
#include <string>
-#ifndef H5_NO_NAMESPACE
-#ifndef H5_NO_STD
- using std::cerr;
- using std::endl;
-#endif // H5_NO_STD
-#endif
-
#include "H5Cpp.h" // C++ API header file
#ifndef H5_NO_NAMESPACE
@@ -44,27 +37,25 @@
const H5std_string FILE1("trefer1.h5");
const H5std_string FILE2("trefer2.h5");
-const H5std_string FILE3("trefer3.h5");
-const H5std_string DSET_DEFAULT_NAME("default");
// Dataset 1
const H5std_string DSET1_NAME("Dataset1");
-const int DSET1_LEN = 8;
+const H5std_string DSET2_NAME("Dataset2");
const H5std_string MEMBER1( "a_name" );
const H5std_string MEMBER2( "b_name" );
const H5std_string MEMBER3( "c_name" );
// 1-D dataset with fixed dimensions
-const H5std_string SPACE1_NAME("Space1");
const int SPACE1_RANK = 1;
const int SPACE1_DIM1 = 4;
-// 2-D dataset with fixed dimensions
-const H5std_string SPACE2_NAME("Space2");
+/* Larger 1-D dataset with fixed dimensions */
+const int SPACE3_RANK = 1;
+const int SPACE3_DIM1 = 100;
-// Larger 1-D dataset with fixed dimensions
-const H5std_string SPACE3_NAME("Space3");
+/* Element selection information */
+const int POINT1_NPOINTS = 10;
// Compound datatype
typedef struct s1_t {
@@ -75,8 +66,123 @@ typedef struct s1_t {
/****************************************************************
**
-** test_reference_obj(): Test basic object reference functionality.
-** Tests references to various kinds of objects
+** test_reference_params(): Test basic H5R (reference) parameters
+** for correct processing
+**
+****************************************************************/
+static void
+test_reference_params(void)
+{
+ const char *write_comment = "Foo!"; /* Comments for group */
+
+ // Output message about test being performed
+ SUBTEST("Object Reference Parameters");
+
+ H5File* file1 = NULL;
+ try {
+ hobj_ref_t *wbuf, // buffer to write to disk
+ *rbuf, // buffer read from disk
+ *tbuf; // temp. buffer read from disk
+
+ // Allocate write & read buffers
+ int temp_size = MAX(sizeof(unsigned),sizeof(hobj_ref_t));
+ wbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1);
+ rbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1);
+ tbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1);
+
+ // Create file FILE1
+ file1 = new H5File (FILE1, H5F_ACC_TRUNC);
+
+ // Create dataspace for datasets
+ hsize_t dims1[] = {SPACE1_DIM1};
+ DataSpace sid1(SPACE1_RANK, dims1);
+
+ // Create a group
+ Group group = file1->createGroup("Group1");
+
+ // Set group's comment
+ group.setComment(".", write_comment);
+
+ // Create a dataset (inside /Group1)
+ DataSet dataset = group.createDataSet(DSET1_NAME, PredType::NATIVE_UINT, sid1);
+
+ unsigned *tu32; // Temporary pointer to uint32 data
+ int i;
+ for (tu32=(unsigned *)wbuf, i=0; i<SPACE1_DIM1; i++)
+ *tu32++=i*3; // from C test
+
+ // Write selection to disk
+ dataset.write(wbuf, PredType::NATIVE_UINT);
+
+ // Close Dataset
+ dataset.close();
+
+ // Create another dataset (inside /Group1)
+ dataset = group.createDataSet("Dataset2", PredType::NATIVE_UCHAR, sid1);
+
+ // Close Dataset
+ dataset.close();
+
+ // Create a datatype to refer to
+ CompType dtype1(sizeof(s1_t));
+
+ // Insert fields
+ dtype1.insertMember(MEMBER1, HOFFSET(s1_t, a), PredType::NATIVE_INT);
+ dtype1.insertMember(MEMBER2, HOFFSET(s1_t, b), PredType::NATIVE_INT);
+ dtype1.insertMember(MEMBER3, HOFFSET(s1_t, c), PredType::NATIVE_FLOAT);
+
+ // Save datatype for later
+ dtype1.commit(group, "Datatype1");
+
+ // Close datatype and group
+ dtype1.close();
+ group.close();
+
+ // Create a dataset
+ dataset = file1->createDataSet("Dataset3", PredType::STD_REF_OBJ, sid1);
+
+ /* Test parameters to H5Location::reference */
+ try {
+ file1->reference(NULL, "/Group1/Dataset1");
+ } catch (ReferenceException E) {} // We expect this to fail
+ try {
+ file1->reference(&wbuf[0], NULL);
+ } catch (ReferenceException E) {} // We expect this to fail
+ try {
+ file1->reference(&wbuf[0], "");
+ } catch (ReferenceException E) {} // We expect this to fail
+ try {
+ file1->reference(&wbuf[0], "/Group1/Dataset1", H5R_MAXTYPE);
+ } catch (ReferenceException E) {} // We expect this to fail
+ try {
+ file1->reference(&wbuf[0], "/Group1/Dataset1", H5R_DATASET_REGION);
+ } catch (ReferenceException E) {} // We expect this to fail
+
+ // Close resources
+ dataset.close();
+ file1->close();
+ // Let sid1 go out of scope
+
+ // Free memory buffers
+ HDfree(wbuf);
+ HDfree(rbuf);
+ HDfree(tbuf);
+
+ PASSED();
+ } // end try
+ catch (Exception E) {
+ issue_fail_msg("test_reference_param()",__LINE__,__FILE__,
+ E.getCFuncName(), E.getCDetailMsg());
+ }
+
+ if(file1)
+ delete file1;
+} /* test_reference_param() */
+
+/****************************************************************
+**
+** test_reference_obj(): Test basic object reference functions
+** to various kinds of objects
**
****************************************************************/
static void test_reference_obj(void)
@@ -106,8 +212,11 @@ static void test_reference_obj(void)
hsize_t dims1[] = {SPACE1_DIM1};
DataSpace sid1(SPACE1_RANK, dims1);
+ // Create dataset access property list
+ PropList dapl(H5P_DATASET_ACCESS);
+
// Create a group
- Group group = file1->createGroup("Group1", (size_t)-1);
+ Group group = file1->createGroup("Group1");
// Set group's comment
group.setComment(".", write_comment);
@@ -116,7 +225,7 @@ static void test_reference_obj(void)
DataSet dataset = group.createDataSet(DSET1_NAME, PredType::NATIVE_UINT, sid1);
unsigned *tu32; // Temporary pointer to uint32 data
- for (tu32=(unsigned *)wbuf, i=0; i<SPACE1_DIM1; i++)
+ for (tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++)
*tu32++=i*3; // from C test
// Write selection to disk
@@ -152,22 +261,22 @@ static void test_reference_obj(void)
// Create reference to dataset and test getRefObjType
file1->reference(&wbuf[0], "/Group1/Dataset1");
H5O_type_t refobj_type = dataset.getRefObjType(&wbuf[0], H5R_OBJECT);
- verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__);
+ verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__);
// Create reference to dataset and test getRefObjType
file1->reference(&wbuf[1], "/Group1/Dataset2");
refobj_type = dataset.getRefObjType(&wbuf[1], H5R_OBJECT);
- verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__);
+ verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__);
// Create reference to group
file1->reference(&wbuf[2], "/Group1");
refobj_type = dataset.getRefObjType(&wbuf[2], H5R_OBJECT);
- verify_val(refobj_type, H5O_TYPE_GROUP, "DataSet::getRefObjType", __LINE__, __FILE__);
+ verify_val(refobj_type, H5O_TYPE_GROUP, "DataSet::getRefObjType",__LINE__,__FILE__);
// Create reference to named datatype
file1->reference(&wbuf[3], "/Group1/Datatype1");
refobj_type = dataset.getRefObjType(&wbuf[3], H5R_OBJECT);
- verify_val(refobj_type, H5O_TYPE_NAMED_DATATYPE, "DataSet::getRefObjType", __LINE__, __FILE__);
+ verify_val(refobj_type, H5O_TYPE_NAMED_DATATYPE, "DataSet::getRefObjType",__LINE__,__FILE__);
// Write selection to disk
dataset.write(wbuf, PredType::STD_REF_OBJ);
@@ -188,18 +297,18 @@ static void test_reference_obj(void)
// Dereference dataset object by ctor, from the location where
// 'dataset' is located
- DataSet dset2(dataset, &rbuf[0]);
+ DataSet dset2(dataset, &rbuf[0], H5R_OBJECT, dapl);
// Check information in the referenced dataset
sid1 = dset2.getSpace();
hssize_t n_elements = sid1.getSimpleExtentNpoints();
- verify_val((long)n_elements, 4, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
+ verify_val((long)n_elements, 4, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__);
// Read from disk
dset2.read(tbuf, PredType::NATIVE_UINT);
- for(tu32=(unsigned *)tbuf,i=0; i<SPACE1_DIM1; i++,tu32++)
- verify_val(*tu32, (uint32_t)(i*3), "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
+ for(tu32 = (unsigned *)tbuf, i = 0; i < SPACE1_DIM1; i++, tu32++)
+ verify_val(*tu32, (uint32_t)(i*3), "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__);
// Close dereferenced dataset
dset2.close();
@@ -209,7 +318,7 @@ static void test_reference_obj(void)
// Get group's comment
H5std_string read_comment1 = group.getComment(".", 10);
- verify_val(read_comment1, write_comment, "Group::getComment", __LINE__, __FILE__);
+ verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__);
// Test that getComment handles failures gracefully
try {
@@ -217,96 +326,29 @@ static void test_reference_obj(void)
}
catch (Exception E) {} // We expect this to fail
- // Test reading the name of an item in the group
-
- // Test getObjnameByIdx(idx)
- H5std_string name;
- name = group.getObjnameByIdx(0);
- verify_val(name, DSET1_NAME, "Group::getObjnameByIdx", __LINE__, __FILE__);
- // Test getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size)
- name.clear();
- ssize_t name_size = group.getObjnameByIdx(0, name, 5);
- verify_val(name, "Data", "Group::getObjnameByIdx(index,(std::string)buf,buf_len)", __LINE__, __FILE__);
- verify_val(name_size, DSET1_LEN, "Group::getObjnameByIdx(index,(std::string)buf,buf_len)", __LINE__, __FILE__);
-
- name.clear();
- name_size = group.getObjnameByIdx(0, name, name_size+1);
- verify_val(name, DSET1_NAME, "Group::getObjnameByIdx(index,(std::string)buf,buf_len)", __LINE__, __FILE__);
- verify_val(name_size, DSET1_LEN, "Group::getObjnameByIdx(index,(std::string)buf,buf_len)", __LINE__, __FILE__);
-
- // Test getObjnameByIdx(hsize_t idx, char* name, size_t size)
- group.getObjnameByIdx(0, name, name_size+1);
- verify_val(name, DSET1_NAME, "Group::getObjnameByIdx(index,(char*)buf,buf_len)", __LINE__, __FILE__);
- verify_val(name_size, DSET1_LEN, "Group::getObjnameByIdx(index,(char*)buf,buf_len)", __LINE__, __FILE__);
-
-#ifndef H5_NO_DEPRECATED_SYMBOLS
- // Test getting the type of objects
-
- // Test getObjTypeByIdx(hsize_t idx)
- H5G_obj_t obj_type = group.getObjTypeByIdx(0);
- verify_val(obj_type, H5G_DATASET, "Group::getObjTypeByIdx(index)", __LINE__, __FILE__);
-
- // Test getObjTypeByIdx(hsize_t idx, char* type_name)
- obj_type = H5G_UNKNOWN;
- char type_name_C[256];
- obj_type = group.getObjTypeByIdx(0, type_name_C);
- verify_val(obj_type, H5G_DATASET, "Group::getObjTypeByIdx(index, (char*)name)", __LINE__, __FILE__);
- verify_val((const char*)type_name_C, (const char*)"dataset", "Group::getObjTypeByIdx(index, (char*)name)", __LINE__, __FILE__);
-
- // Test getObjTypeByIdx(hsize_t idx, H5std_string& type_name)
- obj_type = H5G_UNKNOWN;
- H5std_string type_name;
- obj_type = group.getObjTypeByIdx(0, type_name);
- verify_val(obj_type, H5G_DATASET, "Group::getObjTypeByIdx(index, (char*)name)", __LINE__, __FILE__);
- verify_val(type_name, "dataset", "Group::getObjTypeByIdx(index, (char*)name)", __LINE__, __FILE__);
-
-#endif // ifndef H5_NO_DEPRECATED_SYMBOLS
-
// Close group
group.close();
- // Dereference group object using file to specify location
- group.dereference(*file1, &rbuf[2]);
- H5std_string read_comment2 = group.getComment(".", 10);
- verify_val(read_comment2, write_comment, "Group::getComment", __LINE__, __FILE__);
- group.close();
-
- // Dereference group object by ctor and using dataset to specify
- // location
- Group new_group(dataset, &rbuf[2]);
- H5std_string read_comment3 = new_group.getComment(".", 10);
- verify_val(read_comment3, write_comment, "Group::getComment", __LINE__, __FILE__);
- new_group.close();
-
- // Dereference datatype object from the location where 'dataset'
- // is located
+ /*
+ * Verify correct referenced datatype
+ */
+ // Open datatype object
dtype1.dereference(dataset, &rbuf[3]);
// Verify correct datatype
- H5T_class_t tclass = dtype1.getClass();
- verify_val(tclass, H5T_COMPOUND, "DataType::getClass", __LINE__, __FILE__);
+ H5T_class_t tclass;
+ tclass = dtype1.getClass();
+ verify_val(tclass, H5T_COMPOUND, "DataType::getClass",__LINE__,__FILE__);
int n_members = dtype1.getNmembers();
- verify_val(n_members, 3, "DataType::getNmembers", __LINE__, __FILE__);
+ verify_val(n_members, 3, "CompType::getNmembers",__LINE__,__FILE__);
- // Close datatype
+ // Close all objects and file
dtype1.close();
-
- // Dereference datatype object by ctor, using file to specify location
- DataType dtype2(*file1, &rbuf[3]);
-
- // Verify correct datatype
- H5T_class_t tclass2 = dtype2.getClass();
- verify_val(tclass2, H5T_COMPOUND, "DataType::getClass", __LINE__, __FILE__);
-
- // Close datatype
- dtype2.close();
-
- // Close dataset and file
dataset.close();
file1->close();
- // Free memory buffers
+ // Free allocated buffers
HDfree(wbuf);
HDfree(rbuf);
HDfree(tbuf);
@@ -314,13 +356,431 @@ static void test_reference_obj(void)
PASSED();
} // end try
catch (Exception E) {
- issue_fail_msg("test_reference_obj()", __LINE__, __FILE__, E.getCDetailMsg());
+ issue_fail_msg("test_reference_obj()",__LINE__,__FILE__,
+ E.getCFuncName(), E.getCDetailMsg());
}
if(file1)
delete file1;
} // test_reference_obj()
+
+/****************************************************************
+**
+** test_reference_group(): Test object reference functionality
+** Tests for correct behavior of various routines on
+** dereferenced group
+**
+****************************************************************/
+#define GROUPNAME "/group"
+#define GROUPNAME2 "group2"
+#define GROUPNAME3 "group3"
+#define DSETNAME "/dset"
+#define DSETNAME2 "dset2"
+#define NAME_SIZE 16
+
+static void
+test_reference_group(void)
+{
+ hobj_ref_t wref; /* Reference to write */
+ hobj_ref_t rref; /* Reference to read */
+ const H5std_string write_comment="Foo!"; // Comments for group
+
+ // Output message about test being performed
+ SUBTEST("Object Reference to Group");
+
+ H5File* file1 = NULL;
+ try {
+ /*
+ * Create file with a group and a dataset containing an object
+ * reference to the group
+ */
+
+ // Create file FILE1
+ file1 = new H5File (FILE1, H5F_ACC_TRUNC);
+
+ // Create scalar dataspace
+ DataSpace sid1;
+
+ // Create a group
+ Group group = file1->createGroup(GROUPNAME);
+
+ /* Create nested groups */
+ Group group2 = group.createGroup(GROUPNAME2);
+ group2.close();
+ group2 = group.createGroup(GROUPNAME3);
+ group2.close();
+
+ // Create bottom dataset
+ DataSet dset1 = group.createDataSet(DSETNAME2, PredType::NATIVE_INT, sid1);
+ dset1.close();
+
+ // Close group 1
+ group.close();
+
+ // Create dataset
+ DataSet dset2 = file1->createDataSet(DSETNAME, PredType::STD_REF_OBJ, sid1);
+
+ file1->reference(&wref, GROUPNAME);
+
+ // Write selection to disk
+ dset2.write(&wref, PredType::STD_REF_OBJ);
+
+ // Close resources
+ dset2.close();
+ sid1.close();
+ file1->close();
+
+ /*
+ * Re-open the file and test deferencing group
+ */
+
+ // Re-open file
+ file1->openFile(FILE1, H5F_ACC_RDWR);
+
+ // Re-open dataset
+ dset1 = file1->openDataSet(DSETNAME);
+
+ // Read in the reference
+ dset1.read(&rref, PredType::STD_REF_OBJ);
+
+ // Dereference to get the group
+ Group refgroup(dset1, &rref);
+
+ // Dereference group object the other way
+ group.dereference(dset1, &rref);
+
+ /*
+ * Various queries on the group opened
+ */
+
+ // Check number of objects in the group dereferenced by constructor
+ hsize_t nobjs = refgroup.getNumObjs();
+ verify_val(nobjs, 3, "H5Group::getNumObjs",__LINE__,__FILE__);
+
+ // Check number of objects in the group dereferenced by ::reference
+ nobjs = group.getNumObjs();
+ verify_val(nobjs, 3, "H5Group::getNumObjs",__LINE__,__FILE__);
+
+ // Check getting file name given the group dereferenced via constructor
+ H5std_string fname = refgroup.getFileName();
+ verify_val(fname, FILE1, "H5Group::getFileName",__LINE__,__FILE__);
+
+ // Check getting file name given the group dereferenced by ::reference
+ fname = group.getFileName();
+ verify_val(fname, FILE1, "H5Group::getFileName",__LINE__,__FILE__);
+
+ // Unlink one of the objects in the dereferenced group, and re-check
+ refgroup.unlink(GROUPNAME2);
+ nobjs = refgroup.getNumObjs();
+ verify_val(nobjs, 2, "H5Group::getNumObjs",__LINE__,__FILE__);
+
+ // Close resources
+ group.close();
+ refgroup.close();
+ dset1.close();
+ file1->close();
+
+ PASSED();
+ } // end try
+ catch (Exception E) {
+ issue_fail_msg("test_reference_group()",__LINE__,__FILE__,
+ E.getCFuncName(), E.getCDetailMsg());
+ }
+
+ if(file1)
+ delete file1;
+} /* test_reference_group() */
+
+/****************************************************************
+**
+** test_reference_region_1D(): Test 1-D reference functionality
+** Tests 1-D references to various kinds of objects
+**
+****************************************************************/
+static void
+test_reference_region_1D(void)
+{
+ hsize_t start[SPACE3_RANK]; /* Starting location of hyperslab */
+ hsize_t stride[SPACE3_RANK]; /* Stride of hyperslab */
+ hsize_t count[SPACE3_RANK]; /* Element count of hyperslab */
+ hsize_t block[SPACE3_RANK]; /* Block size of hyperslab */
+ hsize_t coord1[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */
+ hsize_t * coords; /* Coordinate buffer */
+ hsize_t low[SPACE3_RANK]; /* Selection bounds */
+ hsize_t high[SPACE3_RANK]; /* Selection bounds */
+ int i; /* counting variables */
+
+ // Output message about test being performed
+ SUBTEST("1-D Dataset Region Reference Functions");
+
+ try {
+ hdset_reg_ref_t *wbuf, // buffer to write to disk
+ *rbuf; // buffer read from disk
+ uint8_t *dwbuf, // Buffer for writing numeric data to disk
+ *drbuf; // Buffer for reading numeric data from disk
+
+ // Allocate write & read buffers
+ wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1);
+ rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1);
+ dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE3_DIM1);
+ drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)SPACE3_DIM1);
+
+ // Create file FILE1
+ H5File file1(FILE2, H5F_ACC_TRUNC);
+
+ // Create dataspace for datasets
+ hsize_t dims3[] = {SPACE3_DIM1};
+ DataSpace sid3(SPACE3_RANK, dims3);
+
+ // Create dataset access property list
+ PropList dapl(H5P_DATASET_ACCESS);
+
+ // Create a dataset
+ DataSet dset3 = file1.createDataSet(DSET2_NAME, PredType::STD_U8LE, sid3);
+
+ uint8_t *tu8; // Temporary pointer to uint8 data
+ for (tu8 = dwbuf, i = 0; i < SPACE3_DIM1; i++)
+ *tu8++ = i * 3; // from C test
+
+ // Write selection to disk
+ dset3.write(dwbuf, PredType::STD_U8LE);
+
+ // Close Dataset
+ dset3.close();
+
+ // Create dataspace for datasets
+ hsize_t dims1[] = {SPACE1_DIM1};
+ DataSpace sid1(SPACE1_RANK, dims1);
+
+ // Create a dataset
+ DataSet dset1 = file1.createDataSet(DSET1_NAME, PredType::STD_REF_DSETREG, sid1);
+
+ /*
+ * Create references and prepare for testing
+ */
+
+ /* Select 15 2x1 hyperslabs for first reference */
+ start[0] = 2;
+ stride[0] = 5;
+ count[0] = 15;
+ block[0] = 2;
+
+ // Select a hyperslab region to add to the current selected region
+ sid3.selectHyperslab(H5S_SELECT_SET, count, start, stride, block);
+
+ // Get and verify the number of elements in a dataspace selection
+ hssize_t nelms = sid3.getSelectNpoints();
+ verify_val(nelms, 30, "DataSet::getRefObjType",__LINE__,__FILE__);
+
+ // Store first dataset region
+ file1.reference(&wbuf[0], "/Dataset2", sid3);
+
+ // Get and verify object type
+ H5O_type_t obj_type = dset1.getRefObjType(&wbuf[0], H5R_DATASET_REGION);
+ verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__);
+
+ /* Select sequence of ten points for second reference */
+ coord1[0][0] = 16;
+ coord1[1][0] = 22;
+ coord1[2][0] = 38;
+ coord1[3][0] = 41;
+ coord1[4][0] = 52;
+ coord1[5][0] = 63;
+ coord1[6][0] = 70;
+ coord1[7][0] = 89;
+ coord1[8][0] = 97;
+ coord1[9][0] = 3;
+
+ // Selects array elements to be included in the selection for sid3
+ sid3.selectElements(H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1);
+
+ // Get and verify the number of elements in a dataspace selection
+ nelms = sid3.getSelectNpoints();
+ verify_val(nelms, 10, "DataSet::getRefObjType",__LINE__,__FILE__);
+
+ // Store first dataset region
+ file1.reference(&wbuf[1], "/Dataset2", sid3);
+
+ // Write selection to disk
+ dset1.write(wbuf, PredType::STD_REF_DSETREG);
+
+ // Close disk dataspace, dataset, and file
+ sid1.close();
+ dset1.close();
+ sid3.close();
+ file1.close();
+
+ /*
+ * Testing various dereference functions
+ */
+
+ // Re-open the file
+ file1.openFile(FILE2, H5F_ACC_RDWR);
+
+ // Open the dataset
+ dset1 = file1.openDataSet("/Dataset1");
+
+ // Read selection from disk
+ dset1.read(rbuf, PredType::STD_REF_DSETREG);
+
+ { // Test DataSet::dereference
+ dset3.dereference(dset1, &rbuf[0], H5R_DATASET_REGION, dapl);
+
+ // Get and verify object type
+ obj_type = dset1.getRefObjType(&rbuf[0], H5R_DATASET_REGION);
+ verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__);
+
+ // Get dataspace of dset3 the verify number of elements
+ sid1 = dset3.getSpace();
+ nelms = sid1.getSimpleExtentNpoints();
+ verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__);
+ } // End of test DataSet::dereference
+
+ { // Test DataSet constructor -by dereference
+ // Dereference dataset object by ctor, from the location where
+ // 'dset1' is located
+ DataSet newds(dset1, &rbuf[0], H5R_DATASET_REGION, dapl);
+
+ // Get dataspace of newds then verify number of elements
+ sid1 = newds.getSpace();
+ nelms = sid1.getSimpleExtentNpoints();
+ verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__);
+
+ // Close objects for this mini test
+ newds.close();
+ sid1.close();
+ } // End of test DataSet constructor -by dereference
+
+ // Read from disk
+ dset3.read(drbuf, PredType::STD_U8LE);
+
+ for(tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++)
+ verify_val(*tu8, (uint8_t)(i * 3), "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__);
+
+ /*
+ * Test getting the referenced region
+ */
+
+ // Get region
+ DataSpace reg_sp = dset1.getRegion(&rbuf[0]);
+
+ // Get and verify number of elements in a dataspace selection
+ nelms = reg_sp.getSelectNpoints();
+ verify_val((long)nelms, 30, "DataSpace::getSelectNpoints",__LINE__,__FILE__);
+
+ // Get and verify number of hyperslab blocks
+ nelms = reg_sp.getSelectHyperNblocks();
+ verify_val((long)nelms, 15, "DataSpace::getSelectNpoints",__LINE__,__FILE__);
+
+ /* Allocate space for the hyperslab blocks */
+ coords = (hsize_t *)HDmalloc(nelms * SPACE3_RANK * sizeof(hsize_t) * 2);
+
+ // Get the list of hyperslab blocks currently selected
+ reg_sp.getSelectHyperBlocklist((hsize_t)0, (hsize_t)nelms, coords);
+
+ // Verify values in the list
+ verify_val(coords[0], 2, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[1], 3, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[2], 7, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[3], 8, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[4], 12, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[5], 13, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[6], 17, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[7], 18, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[8], 22, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[9], 23, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[10], 27, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[11], 28, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[12], 32, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[13], 33, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[14], 37, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[15], 38, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[16], 42, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[17], 43, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[18], 47, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[19], 48, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[20], 52, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[21], 53, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[22], 57, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[23], 58, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[24], 62, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[25], 63, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[26], 67, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[27], 68, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[28], 72, "Hyperslab Coordinates",__LINE__,__FILE__);
+ verify_val(coords[29], 73, "Hyperslab Coordinates",__LINE__,__FILE__);
+
+ HDfree(coords);
+
+ // Check boundaries
+ reg_sp.getSelectBounds(low, high);
+ verify_val(low[0], 2, "DataSpace::getSelectBounds",__LINE__,__FILE__);
+ verify_val(high[0], 73, "DataSpace::getSelectBounds",__LINE__,__FILE__);
+
+ /* Close region space */
+ reg_sp.close();
+
+ /*
+ * Another test on getting the referenced region
+ */
+
+ // Get region
+ DataSpace elm_sp = dset1.getRegion(&rbuf[1]);
+
+ // Get and verify number of element points in the current selection
+ hssize_t nelmspts = elm_sp.getSelectElemNpoints();
+ verify_val((long)nelmspts, 10, "DataSpace::getSelectNpoints",__LINE__,__FILE__);
+
+ /* Allocate space for the hyperslab blocks */
+ coords = (hsize_t *)HDmalloc(nelmspts * SPACE3_RANK * sizeof(hsize_t));
+
+ // Get the list of element points currently selected
+ elm_sp.getSelectElemPointlist((hsize_t)0, (hsize_t)nelmspts, coords);
+
+ // Verify points
+ verify_val(coords[0], coord1[0][0], "Element Coordinates",__LINE__,__FILE__);
+ verify_val(coords[1], coord1[1][0], "Element Coordinates",__LINE__,__FILE__);
+ verify_val(coords[2], coord1[2][0], "Element Coordinates",__LINE__,__FILE__);
+ verify_val(coords[3], coord1[3][0], "Element Coordinates",__LINE__,__FILE__);
+ verify_val(coords[4], coord1[4][0], "Element Coordinates",__LINE__,__FILE__);
+ verify_val(coords[5], coord1[5][0], "Element Coordinates",__LINE__,__FILE__);
+ verify_val(coords[6], coord1[6][0], "Element Coordinates",__LINE__,__FILE__);
+ verify_val(coords[7], coord1[7][0], "Element Coordinates",__LINE__,__FILE__);
+ verify_val(coords[8], coord1[8][0], "Element Coordinates",__LINE__,__FILE__);
+ verify_val(coords[9], coord1[9][0], "Element Coordinates",__LINE__,__FILE__);
+
+ HDfree(coords);
+
+ // Check boundaries
+ elm_sp.getSelectBounds(low, high);
+ verify_val(low[0], 3, "DataSpace::getSelectBounds",__LINE__,__FILE__);
+ verify_val(high[0], 97, "DataSpace::getSelectBounds",__LINE__,__FILE__);
+
+ // Close element space
+ elm_sp.close();
+
+ // Close resources
+ sid1.close();
+ dset3.close();
+ dset1.close();
+ file1.close();
+
+ // Free memory buffers
+ HDfree(wbuf);
+ HDfree(rbuf);
+ HDfree(dwbuf);
+ HDfree(drbuf);
+
+ PASSED();
+ } // end try
+ catch (Exception E) {
+ issue_fail_msg("test_reference_region_1D()",__LINE__,__FILE__,
+ E.getCFuncName(), E.getCDetailMsg());
+ }
+} /* test_reference_region_1D() */
+
+
/****************************************************************
**
** test_reference_compat(): Test basic object reference functionality.
@@ -346,7 +806,10 @@ void test_reference(void)
// Output message about test being performed
MESSAGE(5, ("Testing References\n"));
+ test_reference_params(); // Test basic parameters of reference functionality
test_reference_obj(); // Test basic object reference functionality
+ test_reference_group(); // Test group reference functionality
+ test_reference_region_1D(); // Test 1-D reference functionality
test_reference_compat(); // Tests deprecated reference routines (not yet)
} // test_reference()
@@ -363,5 +826,6 @@ extern "C"
void cleanup_reference(void)
{
HDremove(FILE1.c_str());
+ HDremove(FILE2.c_str());
}