diff options
author | Larry Knox <lrknox@hdfgroup.org> | 2021-10-29 22:10:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-29 22:10:31 (GMT) |
commit | 111c7ae9ac2efc29e8b399e6951253af9110b81a (patch) | |
tree | f69fa03253bdab97d7cf3615baff02cd936323f9 /c++ | |
parent | db30c2da68ece4a155e9e50c28ec16d6057509b2 (diff) | |
download | hdf5-111c7ae9ac2efc29e8b399e6951253af9110b81a.zip hdf5-111c7ae9ac2efc29e8b399e6951253af9110b81a.tar.gz hdf5-111c7ae9ac2efc29e8b399e6951253af9110b81a.tar.bz2 |
Merge hdf5 1 10 8 (#1154)hdf5-1_10_8
Merge HDF5 1.10.8 release files to 1.10/master
Diffstat (limited to 'c++')
121 files changed, 9625 insertions, 9133 deletions
diff --git a/c++/COPYING b/c++/COPYING deleted file mode 100644 index 6497ace..0000000 --- a/c++/COPYING +++ /dev/null @@ -1,13 +0,0 @@ - - Copyright by The HDF Group and - The Board of Trustees of the University of Illinois. - All rights reserved. - - The files and subdirectories in this directory are part of HDF5. - The full HDF5 copyright notice, including terms governing use, - modification, and redistribution, is contained in the COPYING file - which can be found at the root of the source code distribution tree - or in https://support.hdfgroup.org/ftp/HDF5/releases. If you do - not have access to either file, you may request a copy from - help@hdfgroup.org. - diff --git a/c++/Makefile.am b/c++/Makefile.am index b95afdf..a16616d 100644 --- a/c++/Makefile.am +++ b/c++/Makefile.am @@ -6,7 +6,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. ## diff --git a/c++/Makefile.in b/c++/Makefile.in index 7c3661b..b14039c 100644 --- a/c++/Makefile.in +++ b/c++/Makefile.in @@ -22,7 +22,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # @@ -113,6 +113,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/aclocal_cxx.m4 \ $(top_srcdir)/m4/ax_check_junit.m4 \ $(top_srcdir)/m4/ax_java_options.m4 \ $(top_srcdir)/m4/ax_jni_include_dir.m4 \ + $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/ax_prog_jar.m4 \ $(top_srcdir)/m4/ax_prog_java.m4 \ $(top_srcdir)/m4/ax_prog_java_works.m4 \ @@ -386,7 +387,7 @@ am__set_b = \ esac am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/bin/test-driver \ $(top_srcdir)/config/commence.am \ - $(top_srcdir)/config/conclude.am COPYING + $(top_srcdir)/config/conclude.am DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ @@ -422,9 +423,9 @@ AMTAR = @AMTAR@ # AM_CFLAGS is an automake construct which should be used by Makefiles # instead of CFLAGS, as CFLAGS is reserved solely for the user to define. # This applies to FCFLAGS, CXXFLAGS, CPPFLAGS, and LDFLAGS as well. -AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ @H5_ECFLAGS@ +AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ AM_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@ -AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ @H5_ECXXFLAGS@ +AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_FCFLAGS = @AM_FCFLAGS@ @H5_FCFLAGS@ AM_JAVACFLAGS = @AM_JAVACFLAGS@ @@ -462,11 +463,56 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DEPRECATED_SYMBOLS = @DEPRECATED_SYMBOLS@ DESIRED_FILE_LOCKING = @DESIRED_FILE_LOCKING@ -DEV_WARNINGS = @DEV_WARNINGS@ +DIAGS = @DIAGS@ DIRECT_VFD = @DIRECT_VFD@ DLLTOOL = @DLLTOOL@ +DOXYGEN_EXAMPLES_DIRECTORY = @DOXYGEN_EXAMPLES_DIRECTORY@ +DOXYGEN_EXTERNAL_SEARCH = @DOXYGEN_EXTERNAL_SEARCH@ +DOXYGEN_HTML_EXTRA_FILES = @DOXYGEN_HTML_EXTRA_FILES@ +DOXYGEN_HTML_EXTRA_STYLESHEET = @DOXYGEN_HTML_EXTRA_STYLESHEET@ +DOXYGEN_HTML_FOOTER = @DOXYGEN_HTML_FOOTER@ +DOXYGEN_HTML_HEADER = @DOXYGEN_HTML_HEADER@ +DOXYGEN_INCLUDE_ALIASES = @DOXYGEN_INCLUDE_ALIASES@ +DOXYGEN_INPUT_DIRECTORY = @DOXYGEN_INPUT_DIRECTORY@ +DOXYGEN_LAYOUT_FILE = @DOXYGEN_LAYOUT_FILE@ +DOXYGEN_MACRO_EXPANSION = @DOXYGEN_MACRO_EXPANSION@ +DOXYGEN_OPTIMIZE_OUTPUT_FOR_C = @DOXYGEN_OPTIMIZE_OUTPUT_FOR_C@ +DOXYGEN_OUTPUT_DIRECTORY = @DOXYGEN_OUTPUT_DIRECTORY@ +DOXYGEN_PACKAGE = @DOXYGEN_PACKAGE@ +DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ +DOXYGEN_PREDEFINED = @DOXYGEN_PREDEFINED@ +DOXYGEN_PROJECT_BRIEF = @DOXYGEN_PROJECT_BRIEF@ +DOXYGEN_PROJECT_LOGO = @DOXYGEN_PROJECT_LOGO@ +DOXYGEN_SEARCHENGINE_URL = @DOXYGEN_SEARCHENGINE_URL@ +DOXYGEN_SERVER_BASED_SEARCH = @DOXYGEN_SERVER_BASED_SEARCH@ +DOXYGEN_STRIP_FROM_PATH = @DOXYGEN_STRIP_FROM_PATH@ +DOXYGEN_TAG_FILE = @DOXYGEN_TAG_FILE@ +DOXYGEN_VERSION_STRING = @DOXYGEN_VERSION_STRING@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ +DX_CONFIG = @DX_CONFIG@ +DX_DOCDIR = @DX_DOCDIR@ +DX_DOT = @DX_DOT@ +DX_DOXYGEN = @DX_DOXYGEN@ +DX_DVIPS = @DX_DVIPS@ +DX_EGREP = @DX_EGREP@ +DX_ENV = @DX_ENV@ +DX_FLAG_chi = @DX_FLAG_chi@ +DX_FLAG_chm = @DX_FLAG_chm@ +DX_FLAG_doc = @DX_FLAG_doc@ +DX_FLAG_dot = @DX_FLAG_dot@ +DX_FLAG_html = @DX_FLAG_html@ +DX_FLAG_man = @DX_FLAG_man@ +DX_FLAG_pdf = @DX_FLAG_pdf@ +DX_FLAG_ps = @DX_FLAG_ps@ +DX_FLAG_rtf = @DX_FLAG_rtf@ +DX_FLAG_xml = @DX_FLAG_xml@ +DX_HHC = @DX_HHC@ +DX_LATEX = @DX_LATEX@ +DX_MAKEINDEX = @DX_MAKEINDEX@ +DX_PDFLATEX = @DX_PDFLATEX@ +DX_PERL = @DX_PERL@ +DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ @@ -498,8 +544,6 @@ H5_CFLAGS = @H5_CFLAGS@ H5_CLASSPATH = @H5_CLASSPATH@ H5_CPPFLAGS = @H5_CPPFLAGS@ H5_CXXFLAGS = @H5_CXXFLAGS@ -H5_ECFLAGS = @H5_ECFLAGS@ -H5_ECXXFLAGS = @H5_ECXXFLAGS@ H5_FCFLAGS = @H5_FCFLAGS@ H5_FORTRAN_SHARED = @H5_FORTRAN_SHARED@ H5_IS_DARWIN = @H5_IS_DARWIN@ @@ -513,7 +557,9 @@ HAVE_DMALLOC = @HAVE_DMALLOC@ HAVE_Fortran_INTEGER_SIZEOF_16 = @HAVE_Fortran_INTEGER_SIZEOF_16@ HAVE_LIBHDFS = @HAVE_LIBHDFS@ HAVE_PTHREAD = @HAVE_PTHREAD@ +HDF5_DOXYGEN = @HDF5_DOXYGEN@ HDF5_HL = @HDF5_HL@ +HDF5_HL_TOOLS = @HDF5_HL_TOOLS@ HDF5_INTERFACES = @HDF5_INTERFACES@ HDF5_TESTS = @HDF5_TESTS@ HDF5_TOOLS = @HDF5_TOOLS@ @@ -523,6 +569,7 @@ HDF_JAVA = @HDF_JAVA@ HID_T = @HID_T@ HL = @HL@ HL_FOR = @HL_FOR@ +HL_TOOLS = @HL_TOOLS@ HSIZE_T = @HSIZE_T@ HSSIZE_T = @HSSIZE_T@ IGNORE_DISABLED_FILE_LOCKS = @IGNORE_DISABLED_FILE_LOCKS@ @@ -716,7 +763,7 @@ LIBH5F_HL = $(top_builddir)/hl/fortran/src/libhdf5hl_fortran.la LIBH5CPP_HL = $(top_builddir)/hl/c++/src/libhdf5_hl_cpp.la # Note that in svn revision 19400 the '/' after DESTDIR in H5* variables below -# has been removed. According to the official description of DESTDIR by Gnu at +# has been removed. According to the official description of DESTDIR by GNU at # http://www.gnu.org/prep/standards/html_node/DESTDIR.html, DESTDIR is # prepended to the normal and complete install path that it precedes for the # purpose of installing in a temporary directory which is useful for building @@ -1238,8 +1285,9 @@ uninstall-am: # commands that should be executed even if a file with the same name already # exists. .PHONY: build-check-clean build-check-p build-check-s build-lib build-progs \ - build-tests check-clean check-install check-p check-s check-vfd \ - install-doc lib progs tests uninstall-doc _exec_check-s _test help + build-tests check-clean check-install check-p check-s check-vfd \ + install-doc lib progs tests uninstall-doc \ + _exec_check-s _test help trace doxygen help: @$(top_srcdir)/bin/makehelp diff --git a/c++/examples/CMakeLists.txt b/c++/examples/CMakeLists.txt index 890d22d..c50315f 100644 --- a/c++/examples/CMakeLists.txt +++ b/c++/examples/CMakeLists.txt @@ -34,38 +34,52 @@ set (tutr_examples foreach (example ${examples}) add_executable (cpp_ex_${example} ${HDF5_CPP_EXAMPLES_SOURCE_DIR}/${example}.cpp) - target_include_directories (cpp_ex_${example} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (cpp_ex_${example} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (cpp_ex_${example} STATIC) target_link_libraries (cpp_ex_${example} PRIVATE ${HDF5_CPP_LIB_TARGET} ${HDF5_LIB_TARGET}) else () TARGET_C_PROPERTIES (cpp_ex_${example} SHARED) target_link_libraries (cpp_ex_${example} PRIVATE ${HDF5_CPP_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) - if (MINGW) + if (MINGW AND HDF5_MINGW_STATIC_GCC_LIBS) target_link_options (${HDF5_CPP_LIBSH_TARGET} PRIVATE -static-libgcc -static-libstdc++ ) endif () endif () set_target_properties (cpp_ex_${example} PROPERTIES FOLDER examples/cpp) + + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_CPP_EXAMPLES_${example}_FORMAT cpp_ex_${example}) + endif () endforeach () foreach (example ${tutr_examples}) add_executable (cpp_ex_${example} ${HDF5_CPP_EXAMPLES_SOURCE_DIR}/${example}.cpp) - target_include_directories (cpp_ex_${example} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (cpp_ex_${example} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (cpp_ex_${example} STATIC) target_link_libraries (cpp_ex_${example} PRIVATE ${HDF5_CPP_LIB_TARGET} ${HDF5_LIB_TARGET}) else () TARGET_C_PROPERTIES (cpp_ex_${example} SHARED) target_link_libraries (cpp_ex_${example} PRIVATE ${HDF5_CPP_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) - if (MINGW) + if (MINGW AND HDF5_MINGW_STATIC_GCC_LIBS) target_link_options (${HDF5_CPP_LIBSH_TARGET} PRIVATE -static-libgcc -static-libstdc++ ) endif () endif () set_target_properties (cpp_ex_${example} PROPERTIES FOLDER examples/cpp) + + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_CPP_EXAMPLES_${example}_FORMAT cpp_ex_${example}) + endif () endforeach () if (BUILD_TESTING AND HDF5_TEST_CPP AND HDF5_TEST_EXAMPLES AND HDF5_TEST_SERIAL) diff --git a/c++/examples/CMakeTests.cmake b/c++/examples/CMakeTests.cmake index bbe3433..a7fc9b8 100644 --- a/c++/examples/CMakeTests.cmake +++ b/c++/examples/CMakeTests.cmake @@ -5,7 +5,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # diff --git a/c++/examples/Makefile.am b/c++/examples/Makefile.am index cbec8f8..a316e1b 100644 --- a/c++/examples/Makefile.am +++ b/c++/examples/Makefile.am @@ -6,7 +6,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. ## diff --git a/c++/examples/Makefile.in b/c++/examples/Makefile.in index e2eed2f..9db194b 100644 --- a/c++/examples/Makefile.in +++ b/c++/examples/Makefile.in @@ -22,7 +22,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # @@ -117,6 +117,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/aclocal_cxx.m4 \ $(top_srcdir)/m4/ax_check_junit.m4 \ $(top_srcdir)/m4/ax_java_options.m4 \ $(top_srcdir)/m4/ax_jni_include_dir.m4 \ + $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/ax_prog_jar.m4 \ $(top_srcdir)/m4/ax_prog_java.m4 \ $(top_srcdir)/m4/ax_prog_java_works.m4 \ @@ -370,9 +371,9 @@ AMTAR = @AMTAR@ # AM_CFLAGS is an automake construct which should be used by Makefiles # instead of CFLAGS, as CFLAGS is reserved solely for the user to define. # This applies to FCFLAGS, CXXFLAGS, CPPFLAGS, and LDFLAGS as well. -AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ @H5_ECFLAGS@ +AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ AM_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@ -AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ @H5_ECXXFLAGS@ +AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_FCFLAGS = @AM_FCFLAGS@ @H5_FCFLAGS@ AM_JAVACFLAGS = @AM_JAVACFLAGS@ @@ -410,11 +411,56 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DEPRECATED_SYMBOLS = @DEPRECATED_SYMBOLS@ DESIRED_FILE_LOCKING = @DESIRED_FILE_LOCKING@ -DEV_WARNINGS = @DEV_WARNINGS@ +DIAGS = @DIAGS@ DIRECT_VFD = @DIRECT_VFD@ DLLTOOL = @DLLTOOL@ +DOXYGEN_EXAMPLES_DIRECTORY = @DOXYGEN_EXAMPLES_DIRECTORY@ +DOXYGEN_EXTERNAL_SEARCH = @DOXYGEN_EXTERNAL_SEARCH@ +DOXYGEN_HTML_EXTRA_FILES = @DOXYGEN_HTML_EXTRA_FILES@ +DOXYGEN_HTML_EXTRA_STYLESHEET = @DOXYGEN_HTML_EXTRA_STYLESHEET@ +DOXYGEN_HTML_FOOTER = @DOXYGEN_HTML_FOOTER@ +DOXYGEN_HTML_HEADER = @DOXYGEN_HTML_HEADER@ +DOXYGEN_INCLUDE_ALIASES = @DOXYGEN_INCLUDE_ALIASES@ +DOXYGEN_INPUT_DIRECTORY = @DOXYGEN_INPUT_DIRECTORY@ +DOXYGEN_LAYOUT_FILE = @DOXYGEN_LAYOUT_FILE@ +DOXYGEN_MACRO_EXPANSION = @DOXYGEN_MACRO_EXPANSION@ +DOXYGEN_OPTIMIZE_OUTPUT_FOR_C = @DOXYGEN_OPTIMIZE_OUTPUT_FOR_C@ +DOXYGEN_OUTPUT_DIRECTORY = @DOXYGEN_OUTPUT_DIRECTORY@ +DOXYGEN_PACKAGE = @DOXYGEN_PACKAGE@ +DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ +DOXYGEN_PREDEFINED = @DOXYGEN_PREDEFINED@ +DOXYGEN_PROJECT_BRIEF = @DOXYGEN_PROJECT_BRIEF@ +DOXYGEN_PROJECT_LOGO = @DOXYGEN_PROJECT_LOGO@ +DOXYGEN_SEARCHENGINE_URL = @DOXYGEN_SEARCHENGINE_URL@ +DOXYGEN_SERVER_BASED_SEARCH = @DOXYGEN_SERVER_BASED_SEARCH@ +DOXYGEN_STRIP_FROM_PATH = @DOXYGEN_STRIP_FROM_PATH@ +DOXYGEN_TAG_FILE = @DOXYGEN_TAG_FILE@ +DOXYGEN_VERSION_STRING = @DOXYGEN_VERSION_STRING@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ +DX_CONFIG = @DX_CONFIG@ +DX_DOCDIR = @DX_DOCDIR@ +DX_DOT = @DX_DOT@ +DX_DOXYGEN = @DX_DOXYGEN@ +DX_DVIPS = @DX_DVIPS@ +DX_EGREP = @DX_EGREP@ +DX_ENV = @DX_ENV@ +DX_FLAG_chi = @DX_FLAG_chi@ +DX_FLAG_chm = @DX_FLAG_chm@ +DX_FLAG_doc = @DX_FLAG_doc@ +DX_FLAG_dot = @DX_FLAG_dot@ +DX_FLAG_html = @DX_FLAG_html@ +DX_FLAG_man = @DX_FLAG_man@ +DX_FLAG_pdf = @DX_FLAG_pdf@ +DX_FLAG_ps = @DX_FLAG_ps@ +DX_FLAG_rtf = @DX_FLAG_rtf@ +DX_FLAG_xml = @DX_FLAG_xml@ +DX_HHC = @DX_HHC@ +DX_LATEX = @DX_LATEX@ +DX_MAKEINDEX = @DX_MAKEINDEX@ +DX_PDFLATEX = @DX_PDFLATEX@ +DX_PERL = @DX_PERL@ +DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ @@ -446,8 +492,6 @@ H5_CFLAGS = @H5_CFLAGS@ H5_CLASSPATH = @H5_CLASSPATH@ H5_CPPFLAGS = @H5_CPPFLAGS@ H5_CXXFLAGS = @H5_CXXFLAGS@ -H5_ECFLAGS = @H5_ECFLAGS@ -H5_ECXXFLAGS = @H5_ECXXFLAGS@ H5_FCFLAGS = @H5_FCFLAGS@ H5_FORTRAN_SHARED = @H5_FORTRAN_SHARED@ H5_IS_DARWIN = @H5_IS_DARWIN@ @@ -461,7 +505,9 @@ HAVE_DMALLOC = @HAVE_DMALLOC@ HAVE_Fortran_INTEGER_SIZEOF_16 = @HAVE_Fortran_INTEGER_SIZEOF_16@ HAVE_LIBHDFS = @HAVE_LIBHDFS@ HAVE_PTHREAD = @HAVE_PTHREAD@ +HDF5_DOXYGEN = @HDF5_DOXYGEN@ HDF5_HL = @HDF5_HL@ +HDF5_HL_TOOLS = @HDF5_HL_TOOLS@ HDF5_INTERFACES = @HDF5_INTERFACES@ HDF5_TESTS = @HDF5_TESTS@ HDF5_TOOLS = @HDF5_TOOLS@ @@ -471,6 +517,7 @@ HDF_JAVA = @HDF_JAVA@ HID_T = @HID_T@ HL = @HL@ HL_FOR = @HL_FOR@ +HL_TOOLS = @HL_TOOLS@ HSIZE_T = @HSIZE_T@ HSSIZE_T = @HSSIZE_T@ IGNORE_DISABLED_FILE_LOCKS = @IGNORE_DISABLED_FILE_LOCKS@ @@ -664,7 +711,7 @@ LIBH5F_HL = $(top_builddir)/hl/fortran/src/libhdf5hl_fortran.la LIBH5CPP_HL = $(top_builddir)/hl/c++/src/libhdf5_hl_cpp.la # Note that in svn revision 19400 the '/' after DESTDIR in H5* variables below -# has been removed. According to the official description of DESTDIR by Gnu at +# has been removed. According to the official description of DESTDIR by GNU at # http://www.gnu.org/prep/standards/html_node/DESTDIR.html, DESTDIR is # prepended to the normal and complete install path that it precedes for the # purpose of installing in a temporary directory which is useful for building @@ -1104,8 +1151,9 @@ uninstall-am: uninstall-local # commands that should be executed even if a file with the same name already # exists. .PHONY: build-check-clean build-check-p build-check-s build-lib build-progs \ - build-tests check-clean check-install check-p check-s check-vfd \ - install-doc lib progs tests uninstall-doc _exec_check-s _test help + build-tests check-clean check-install check-p check-s check-vfd \ + install-doc lib progs tests uninstall-doc \ + _exec_check-s _test help trace doxygen help: @$(top_srcdir)/bin/makehelp diff --git a/c++/examples/chunks.cpp b/c++/examples/chunks.cpp index 03e2855..3717fcb 100644 --- a/c++/examples/chunks.cpp +++ b/c++/examples/chunks.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,11 +16,7 @@ * We will read from the file created by extend.cpp */ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cout; using std::endl; @@ -28,20 +24,20 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME( "SDSextendible.h5" ); -const H5std_string DATASET_NAME( "ExtendibleArray" ); -const int NX = 10; -const int NY = 5; -const int RANK = 2; -const int RANKC = 1; +const H5std_string FILE_NAME("SDSextendible.h5"); +const H5std_string DATASET_NAME("ExtendibleArray"); +const int NX = 10; +const int NY = 5; +const int RANK = 2; +const int RANKC = 1; -int main (void) +int +main(void) { - hsize_t i, j; + hsize_t i, j; // Try block to detect exceptions raised by any of the calls inside it - try - { + try { /* * Turn off the auto-printing when failure occurs so that we can * handle the errors appropriately @@ -51,8 +47,8 @@ int main (void) /* * Open the file and the dataset. */ - H5File file( FILE_NAME, H5F_ACC_RDONLY ); - DataSet dataset = file.openDataSet( DATASET_NAME ); + H5File file(FILE_NAME, H5F_ACC_RDONLY); + DataSet dataset = file.openDataSet(DATASET_NAME); /* * Get filespace for rank and dimension @@ -67,10 +63,9 @@ int main (void) /* * Get and print the dimension sizes of the file dataspace */ - hsize_t dims[2]; // dataset dimensions - rank = filespace.getSimpleExtentDims( dims ); - cout << "dataset rank = " << rank << ", dimensions " - << (unsigned long)(dims[0]) << " x " + hsize_t dims[2]; // dataset dimensions + rank = filespace.getSimpleExtentDims(dims); + cout << "dataset rank = " << rank << ", dimensions " << (unsigned long)(dims[0]) << " x " << (unsigned long)(dims[1]) << endl; /* @@ -81,13 +76,12 @@ int main (void) /* * Read dataset back and display. */ - int data_out[NX][NY]; // buffer for dataset to be read - dataset.read( data_out, PredType::NATIVE_INT, mspace1, filespace ); + int data_out[NX][NY]; // buffer for dataset to be read + dataset.read(data_out, PredType::NATIVE_INT, mspace1, filespace); cout << "\n"; cout << "Dataset: \n"; - for (j = 0; j < dims[0]; j++) - { + for (j = 0; j < dims[0]; j++) { for (i = 0; i < dims[1]; i++) cout << data_out[j][i] << " "; cout << endl; @@ -117,20 +111,20 @@ int main (void) */ hsize_t col_dims[1]; col_dims[0] = 10; - DataSpace mspace2( RANKC, col_dims ); + DataSpace mspace2(RANKC, col_dims); /* * Define the column (hyperslab) to read. */ - hsize_t offset[2] = { 0, 2 }; - hsize_t count[2] = { 10, 1 }; - int column[10]; // buffer for column to be read + hsize_t offset[2] = {0, 2}; + hsize_t count[2] = {10, 1}; + int column[10]; // buffer for column to be read /* * Define hyperslab and read. */ - filespace.selectHyperslab( H5S_SELECT_SET, count, offset ); - dataset.read( column, PredType::NATIVE_INT, mspace2, filespace ); + filespace.selectHyperslab(H5S_SELECT_SET, count, offset); + dataset.read(column, PredType::NATIVE_INT, mspace2, filespace); cout << endl; cout << "Third column: " << endl; @@ -161,20 +155,18 @@ int main (void) */ hsize_t chunk_dims[2]; int rank_chunk; - if( H5D_CHUNKED == cparms.getLayout() ) - { + if (H5D_CHUNKED == cparms.getLayout()) { /* * Get chunking information: rank and dimensions */ - rank_chunk = cparms.getChunk( 2, chunk_dims); - cout << "chunk rank " << rank_chunk << "dimensions " - << (unsigned long)(chunk_dims[0]) << " x " - << (unsigned long)(chunk_dims[1]) << endl; + rank_chunk = cparms.getChunk(2, chunk_dims); + cout << "chunk rank " << rank_chunk << "dimensions " << (unsigned long)(chunk_dims[0]) << " x " + << (unsigned long)(chunk_dims[1]) << endl; /* * Define the memory space to read a chunk. */ - DataSpace mspace3( rank_chunk, chunk_dims ); + DataSpace mspace3(rank_chunk, chunk_dims); /* * Define chunk in the file (hyperslab) to read. @@ -183,17 +175,16 @@ int main (void) offset[1] = 0; count[0] = chunk_dims[0]; count[1] = chunk_dims[1]; - filespace.selectHyperslab( H5S_SELECT_SET, count, offset ); + filespace.selectHyperslab(H5S_SELECT_SET, count, offset); /* * Read chunk back and display. */ - int chunk_out[2][5]; // buffer for chunk to be read - dataset.read( chunk_out, PredType::NATIVE_INT, mspace3, filespace ); + int chunk_out[2][5]; // buffer for chunk to be read + dataset.read(chunk_out, PredType::NATIVE_INT, mspace3, filespace); cout << endl; cout << "Chunk:" << endl; - for (j = 0; j < chunk_dims[0]; j++) - { + for (j = 0; j < chunk_dims[0]; j++) { for (i = 0; i < chunk_dims[1]; i++) cout << chunk_out[j][i] << " "; cout << endl; @@ -204,25 +195,22 @@ int main (void) * 2 0 0 0 0 */ } - } // end of try block + } // end of try block // catch failure caused by the H5File operations - catch( FileIException error ) - { + catch (FileIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSet operations - catch( DataSetIException error ) - { + catch (DataSetIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSpace operations - catch( DataSpaceIException error ) - { + catch (DataSpaceIException error) { error.printErrorStack(); return -1; } diff --git a/c++/examples/compound.cpp b/c++/examples/compound.cpp index 4b116e0..8975845 100644 --- a/c++/examples/compound.cpp +++ b/c++/examples/compound.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,11 +17,7 @@ * and read back fields' subsets. */ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cout; using std::endl; @@ -29,175 +25,170 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME( "SDScompound.h5" ); -const H5std_string DATASET_NAME( "ArrayOfStructures" ); -const H5std_string MEMBER1( "a_name" ); -const H5std_string MEMBER2( "b_name" ); -const H5std_string MEMBER3( "c_name" ); -const int LENGTH = 10; -const int RANK = 1; +const H5std_string FILE_NAME("SDScompound.h5"); +const H5std_string DATASET_NAME("ArrayOfStructures"); +const H5std_string MEMBER1("a_name"); +const H5std_string MEMBER2("b_name"); +const H5std_string MEMBER3("c_name"); +const int LENGTH = 10; +const int RANK = 1; -int main(void) +int +main(void) { - /* First structure and dataset*/ - typedef struct s1_t { + /* First structure and dataset*/ + typedef struct s1_t { int a; float b; double c; - } s1_t; + } s1_t; - /* Second structure (subset of s1_t) and dataset*/ - typedef struct s2_t { + /* Second structure (subset of s1_t) and dataset*/ + typedef struct s2_t { double c; int a; - } s2_t; - - // Try block to detect exceptions raised by any of the calls inside it - try - { - /* - * Initialize the data - */ - int i; - s1_t s1[LENGTH]; - for (i = 0; i< LENGTH; i++) - { - s1[i].a = i; - s1[i].b = i*i; - s1[i].c = 1./(i+1); - } - - /* - * Turn off the auto-printing when failure occurs so that we can - * handle the errors appropriately - */ - Exception::dontPrint(); - - /* - * Create the data space. - */ - hsize_t dim[] = {LENGTH}; /* Dataspace dimensions */ - DataSpace space( RANK, dim ); - - /* - * Create the file. - */ - H5File* file = new H5File( FILE_NAME, H5F_ACC_TRUNC ); - - /* - * Create the memory datatype. - */ - CompType mtype1( sizeof(s1_t) ); - mtype1.insertMember( MEMBER1, HOFFSET(s1_t, a), PredType::NATIVE_INT); - mtype1.insertMember( MEMBER3, HOFFSET(s1_t, c), PredType::NATIVE_DOUBLE); - mtype1.insertMember( MEMBER2, HOFFSET(s1_t, b), PredType::NATIVE_FLOAT); - - /* - * Create the dataset. - */ - DataSet* dataset; - dataset = new DataSet(file->createDataSet(DATASET_NAME, mtype1, space)); - - /* - * Write data to the dataset; - */ - dataset->write( s1, mtype1 ); - - /* - * Release resources - */ - delete dataset; - delete file; - - /* - * Open the file and the dataset. - */ - file = new H5File( FILE_NAME, H5F_ACC_RDONLY ); - dataset = new DataSet (file->openDataSet( DATASET_NAME )); - - /* - * Create a datatype for s2 - */ - CompType mtype2( sizeof(s2_t) ); - - mtype2.insertMember( MEMBER3, HOFFSET(s2_t, c), PredType::NATIVE_DOUBLE); - mtype2.insertMember( MEMBER1, HOFFSET(s2_t, a), PredType::NATIVE_INT); - - /* - * Read two fields c and a from s1 dataset. Fields in the file - * are found by their names "c_name" and "a_name". - */ - s2_t s2[LENGTH]; - dataset->read( s2, mtype2 ); - - /* - * Display the fields - */ - cout << endl << "Field c : " << endl; - for( i = 0; i < LENGTH; i++) - cout << s2[i].c << " "; - cout << endl; - - cout << endl << "Field a : " << endl; - for( i = 0; i < LENGTH; i++) - cout << s2[i].a << " "; - cout << endl; - - /* - * Create a datatype for s3. - */ - CompType mtype3( sizeof(float) ); - - mtype3.insertMember( MEMBER2, 0, PredType::NATIVE_FLOAT); - - /* - * Read field b from s1 dataset. Field in the file is found by its name. - */ - float s3[LENGTH]; // Third "structure" - used to read float field of s1 - dataset->read( s3, mtype3 ); - - /* - * Display the field - */ - cout << endl << "Field b : " << endl; - for( i = 0; i < LENGTH; i++) - cout << s3[i] << " "; - cout << endl; - - /* - * Release resources - */ - delete dataset; - delete file; - } // end of try block - - // catch failure caused by the H5File operations - catch( FileIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSet operations - catch( DataSetIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSpace operations - catch( DataSpaceIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSpace operations - catch( DataTypeIException error ) - { - error.printErrorStack(); - return -1; - } - - return 0; + } s2_t; + + // Try block to detect exceptions raised by any of the calls inside it + try { + /* + * Initialize the data + */ + int i; + s1_t s1[LENGTH]; + for (i = 0; i < LENGTH; i++) { + s1[i].a = i; + s1[i].b = i * i; + s1[i].c = 1. / (i + 1); + } + + /* + * Turn off the auto-printing when failure occurs so that we can + * handle the errors appropriately + */ + Exception::dontPrint(); + + /* + * Create the data space. + */ + hsize_t dim[] = {LENGTH}; /* Dataspace dimensions */ + DataSpace space(RANK, dim); + + /* + * Create the file. + */ + H5File *file = new H5File(FILE_NAME, H5F_ACC_TRUNC); + + /* + * Create the memory datatype. + */ + CompType mtype1(sizeof(s1_t)); + mtype1.insertMember(MEMBER1, HOFFSET(s1_t, a), PredType::NATIVE_INT); + mtype1.insertMember(MEMBER3, HOFFSET(s1_t, c), PredType::NATIVE_DOUBLE); + mtype1.insertMember(MEMBER2, HOFFSET(s1_t, b), PredType::NATIVE_FLOAT); + + /* + * Create the dataset. + */ + DataSet *dataset; + dataset = new DataSet(file->createDataSet(DATASET_NAME, mtype1, space)); + + /* + * Write data to the dataset; + */ + dataset->write(s1, mtype1); + + /* + * Release resources + */ + delete dataset; + delete file; + + /* + * Open the file and the dataset. + */ + file = new H5File(FILE_NAME, H5F_ACC_RDONLY); + dataset = new DataSet(file->openDataSet(DATASET_NAME)); + + /* + * Create a datatype for s2 + */ + CompType mtype2(sizeof(s2_t)); + + mtype2.insertMember(MEMBER3, HOFFSET(s2_t, c), PredType::NATIVE_DOUBLE); + mtype2.insertMember(MEMBER1, HOFFSET(s2_t, a), PredType::NATIVE_INT); + + /* + * Read two fields c and a from s1 dataset. Fields in the file + * are found by their names "c_name" and "a_name". + */ + s2_t s2[LENGTH]; + dataset->read(s2, mtype2); + + /* + * Display the fields + */ + cout << endl << "Field c : " << endl; + for (i = 0; i < LENGTH; i++) + cout << s2[i].c << " "; + cout << endl; + + cout << endl << "Field a : " << endl; + for (i = 0; i < LENGTH; i++) + cout << s2[i].a << " "; + cout << endl; + + /* + * Create a datatype for s3. + */ + CompType mtype3(sizeof(float)); + + mtype3.insertMember(MEMBER2, 0, PredType::NATIVE_FLOAT); + + /* + * Read field b from s1 dataset. Field in the file is found by its name. + */ + float s3[LENGTH]; // Third "structure" - used to read float field of s1 + dataset->read(s3, mtype3); + + /* + * Display the field + */ + cout << endl << "Field b : " << endl; + for (i = 0; i < LENGTH; i++) + cout << s3[i] << " "; + cout << endl; + + /* + * Release resources + */ + delete dataset; + delete file; + } // end of try block + + // catch failure caused by the H5File operations + catch (FileIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSet operations + catch (DataSetIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSpace operations + catch (DataSpaceIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSpace operations + catch (DataTypeIException error) { + error.printErrorStack(); + return -1; + } + + return 0; } diff --git a/c++/examples/create.cpp b/c++/examples/create.cpp index 06b981b..e55230f 100644 --- a/c++/examples/create.cpp +++ b/c++/examples/create.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,115 +15,105 @@ * This example writes a dataset to a new HDF5 file. */ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif #include <string> #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME( "SDS.h5" ); -const H5std_string DATASET_NAME( "IntArray" ); -const int NX = 5; // dataset dimensions -const int NY = 6; -const int RANK = 2; +const H5std_string FILE_NAME("SDS.h5"); +const H5std_string DATASET_NAME("IntArray"); +const int NX = 5; // dataset dimensions +const int NY = 6; +const int RANK = 2; -int main (void) +int +main(void) { - /* - * Data initialization. - */ - int i, j; - int data[NX][NY]; // buffer for data to write - for (j = 0; j < NX; j++) - { - for (i = 0; i < NY; i++) - data[j][i] = i + j; - } - /* - * 0 1 2 3 4 5 - * 1 2 3 4 5 6 - * 2 3 4 5 6 7 - * 3 4 5 6 7 8 - * 4 5 6 7 8 9 - */ - - // 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 H5F_ACC_TRUNC access, - * default file creation properties, and default file - * access properties. - */ - H5File file( FILE_NAME, H5F_ACC_TRUNC ); - - /* - * Define the size of the array and create the data space for fixed - * size dataset. - */ - hsize_t dimsf[2]; // dataset dimensions - dimsf[0] = NX; - dimsf[1] = NY; - DataSpace dataspace( RANK, dimsf ); - - /* - * Define datatype for the data in the file. - * We will store little endian INT numbers. - */ - IntType datatype( PredType::NATIVE_INT ); - datatype.setOrder( H5T_ORDER_LE ); - - /* - * Create a new dataset within the file using defined dataspace and - * datatype and default dataset creation properties. - */ - DataSet dataset = file.createDataSet( DATASET_NAME, datatype, dataspace ); - - /* - * 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.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSet operations - catch( DataSetIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSpace operations - catch( DataSpaceIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSpace operations - catch( DataTypeIException error ) - { - error.printErrorStack(); - return -1; - } - - return 0; // successfully terminated + /* + * Data initialization. + */ + int i, j; + int data[NX][NY]; // buffer for data to write + for (j = 0; j < NX; j++) { + for (i = 0; i < NY; i++) + data[j][i] = i + j; + } + /* + * 0 1 2 3 4 5 + * 1 2 3 4 5 6 + * 2 3 4 5 6 7 + * 3 4 5 6 7 8 + * 4 5 6 7 8 9 + */ + + // 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 H5F_ACC_TRUNC access, + * default file creation properties, and default file + * access properties. + */ + H5File file(FILE_NAME, H5F_ACC_TRUNC); + + /* + * Define the size of the array and create the data space for fixed + * size dataset. + */ + hsize_t dimsf[2]; // dataset dimensions + dimsf[0] = NX; + dimsf[1] = NY; + DataSpace dataspace(RANK, dimsf); + + /* + * Define datatype for the data in the file. + * We will store little endian INT numbers. + */ + IntType datatype(PredType::NATIVE_INT); + datatype.setOrder(H5T_ORDER_LE); + + /* + * Create a new dataset within the file using defined dataspace and + * datatype and default dataset creation properties. + */ + DataSet dataset = file.createDataSet(DATASET_NAME, datatype, dataspace); + + /* + * 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.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSet operations + catch (DataSetIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSpace operations + catch (DataSpaceIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSpace operations + catch (DataTypeIException error) { + error.printErrorStack(); + return -1; + } + + return 0; // successfully terminated } - diff --git a/c++/examples/extend_ds.cpp b/c++/examples/extend_ds.cpp index 9e005c6..24f5f3e 100644 --- a/c++/examples/extend_ds.cpp +++ b/c++/examples/extend_ds.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,11 +18,7 @@ * */ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif #include <string> using std::cout; @@ -32,201 +28,195 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME( "SDSextendible.h5" ); -const H5std_string DATASET_NAME( "ExtendibleArray" ); -const int NX = 10; -const int NY = 5; -const int RANK = 2; +const H5std_string FILE_NAME("SDSextendible.h5"); +const H5std_string DATASET_NAME("ExtendibleArray"); +const int NX = 10; +const int NY = 5; +const int RANK = 2; -int main (void) +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 the data space with unlimited dimensions. - */ - hsize_t dims[2] = { 3, 3}; // dataset dimensions at creation - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; - DataSpace mspace1( RANK, dims, maxdims); - - /* - * Create a new file. If file exists its contents will be overwritten. - */ - H5File file( FILE_NAME, H5F_ACC_TRUNC ); - - /* - * Modify dataset creation properties, i.e. enable chunking. - */ - DSetCreatPropList cparms; - - hsize_t chunk_dims[2] ={2, 5}; - cparms.setChunk( RANK, chunk_dims ); - - /* - * Set fill value for the dataset - */ - int fill_val = 0; - cparms.setFillValue( PredType::NATIVE_INT, &fill_val); - - /* - * Create a new dataset within the file using cparms - * creation properties. - */ - DataSet dataset = file.createDataSet( DATASET_NAME, PredType::NATIVE_INT, mspace1, cparms); - - /* - * Extend the dataset. This call assures that dataset is at least 3 x 3. - */ - hsize_t size[2]; - size[0] = 3; - size[1] = 3; - dataset.extend( size ); - - /* - * Select a hyperslab. - */ - DataSpace fspace1 = dataset.getSpace (); - hsize_t offset[2]; - offset[0] = 0; - offset[1] = 0; - hsize_t dims1[2] = { 3, 3}; /* data1 dimensions */ - fspace1.selectHyperslab( H5S_SELECT_SET, dims1, offset ); - - /* - * Write the data to the hyperslab. - */ - int data1[3][3] = { {1, 1, 1}, /* data to write */ - {1, 1, 1}, - {1, 1, 1} }; - dataset.write( data1, PredType::NATIVE_INT, mspace1, fspace1 ); - - /* - * Extend the dataset. Dataset becomes 10 x 3. - */ - hsize_t dims2[2] = { 7, 1}; /* data2 dimensions */ - dims[0] = dims1[0] + dims2[0]; - size[0] = dims[0]; - size[1] = dims[1]; - dataset.extend( size ); - - /* - * Select a hyperslab. - */ - DataSpace fspace2 = dataset.getSpace (); - offset[0] = 3; - offset[1] = 0; - fspace2.selectHyperslab( H5S_SELECT_SET, dims2, offset ); - - /* - * Define memory space - */ - DataSpace mspace2( RANK, dims2 ); - - /* - * Write the data to the hyperslab. - */ - int data2[7] = { 2, 2, 2, 2, 2, 2, 2}; - dataset.write( data2, PredType::NATIVE_INT, mspace2, fspace2 ); - - /* - * Extend the dataset. Dataset becomes 10 x 5. - */ - hsize_t dims3[2] = { 2, 2}; /* data3 dimensions */ - dims[1] = dims1[1] + dims3[1]; - size[0] = dims[0]; - size[1] = dims[1]; - dataset.extend( size ); - - /* - * Select a hyperslab - */ - DataSpace fspace3 = dataset.getSpace (); - offset[0] = 0; - offset[1] = 3; - fspace3.selectHyperslab( H5S_SELECT_SET, dims3, offset ); - - /* - * Define memory space. - */ - DataSpace mspace3( RANK, dims3 ); - - /* - * Write the data to the hyperslab. - */ - int data3[2][2] = { {3, 3}, {3, 3} }; - dataset.write( data3, PredType::NATIVE_INT, mspace3, fspace3 ); - - /* - * Read the data from this dataset and display it. - */ - int i, j; - int data_out[NX][NY]; - for (i = 0; i < NX; i++) - { - for (j = 0; j < NY; j++) - data_out[i][j] = 0; - } - dataset.read( data_out, PredType::NATIVE_INT ); - /* - * Resulting dataset - * - * 1 1 1 3 3 - * 1 1 1 3 3 - * 1 1 1 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - */ - /* - * Display the result. - */ - for (i=0; i < NX; i++) - { - for(j=0; j < NY; j++) - cout << data_out[i][j] << " "; - cout << endl; - } - } // end of try block - - // catch failure caused by the H5File operations - catch( FileIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSet operations - catch( DataSetIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSpace operations - catch( DataSpaceIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSpace operations - catch( DataTypeIException error ) - { - error.printErrorStack(); - return -1; - } - return 0; + /* + * 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 the data space with unlimited dimensions. + */ + hsize_t dims[2] = {3, 3}; // dataset dimensions at creation + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; + DataSpace mspace1(RANK, dims, maxdims); + + /* + * Create a new file. If file exists its contents will be overwritten. + */ + H5File file(FILE_NAME, H5F_ACC_TRUNC); + + /* + * Modify dataset creation properties, i.e. enable chunking. + */ + DSetCreatPropList cparms; + + hsize_t chunk_dims[2] = {2, 5}; + cparms.setChunk(RANK, chunk_dims); + + /* + * Set fill value for the dataset + */ + int fill_val = 0; + cparms.setFillValue(PredType::NATIVE_INT, &fill_val); + + /* + * Create a new dataset within the file using cparms + * creation properties. + */ + DataSet dataset = file.createDataSet(DATASET_NAME, PredType::NATIVE_INT, mspace1, cparms); + + /* + * Extend the dataset. This call assures that dataset is at least 3 x 3. + */ + hsize_t size[2]; + size[0] = 3; + size[1] = 3; + dataset.extend(size); + + /* + * Select a hyperslab. + */ + DataSpace fspace1 = dataset.getSpace(); + hsize_t offset[2]; + offset[0] = 0; + offset[1] = 0; + hsize_t dims1[2] = {3, 3}; /* data1 dimensions */ + fspace1.selectHyperslab(H5S_SELECT_SET, dims1, offset); + + /* + * Write the data to the hyperslab. + */ + int data1[3][3] = {{1, 1, 1}, /* data to write */ + {1, 1, 1}, + {1, 1, 1}}; + dataset.write(data1, PredType::NATIVE_INT, mspace1, fspace1); + + /* + * Extend the dataset. Dataset becomes 10 x 3. + */ + hsize_t dims2[2] = {7, 1}; /* data2 dimensions */ + dims[0] = dims1[0] + dims2[0]; + size[0] = dims[0]; + size[1] = dims[1]; + dataset.extend(size); + + /* + * Select a hyperslab. + */ + DataSpace fspace2 = dataset.getSpace(); + offset[0] = 3; + offset[1] = 0; + fspace2.selectHyperslab(H5S_SELECT_SET, dims2, offset); + + /* + * Define memory space + */ + DataSpace mspace2(RANK, dims2); + + /* + * Write the data to the hyperslab. + */ + int data2[7] = {2, 2, 2, 2, 2, 2, 2}; + dataset.write(data2, PredType::NATIVE_INT, mspace2, fspace2); + + /* + * Extend the dataset. Dataset becomes 10 x 5. + */ + hsize_t dims3[2] = {2, 2}; /* data3 dimensions */ + dims[1] = dims1[1] + dims3[1]; + size[0] = dims[0]; + size[1] = dims[1]; + dataset.extend(size); + + /* + * Select a hyperslab + */ + DataSpace fspace3 = dataset.getSpace(); + offset[0] = 0; + offset[1] = 3; + fspace3.selectHyperslab(H5S_SELECT_SET, dims3, offset); + + /* + * Define memory space. + */ + DataSpace mspace3(RANK, dims3); + + /* + * Write the data to the hyperslab. + */ + int data3[2][2] = {{3, 3}, {3, 3}}; + dataset.write(data3, PredType::NATIVE_INT, mspace3, fspace3); + + /* + * Read the data from this dataset and display it. + */ + int i, j; + int data_out[NX][NY]; + for (i = 0; i < NX; i++) { + for (j = 0; j < NY; j++) + data_out[i][j] = 0; + } + dataset.read(data_out, PredType::NATIVE_INT); + /* + * Resulting dataset + * + * 1 1 1 3 3 + * 1 1 1 3 3 + * 1 1 1 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + */ + /* + * Display the result. + */ + for (i = 0; i < NX; i++) { + for (j = 0; j < NY; j++) + cout << data_out[i][j] << " "; + cout << endl; + } + } // end of try block + + // catch failure caused by the H5File operations + catch (FileIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSet operations + catch (DataSetIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSpace operations + catch (DataSpaceIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSpace operations + catch (DataTypeIException error) { + error.printErrorStack(); + return -1; + } + return 0; } diff --git a/c++/examples/h5group.cpp b/c++/examples/h5group.cpp index fab54cd..3c7f260 100644 --- a/c++/examples/h5group.cpp +++ b/c++/examples/h5group.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,11 +20,7 @@ * the C version is used in this example. */ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cout; using std::endl; @@ -32,22 +28,21 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME( "Group.h5" ); +const H5std_string FILE_NAME("Group.h5"); const int RANK = 2; // Operator function -extern "C" herr_t file_info(hid_t loc_id, const char *name, const H5L_info_t *linfo, - void *opdata); +extern "C" herr_t file_info(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *opdata); -int main(void) +int +main(void) { - hsize_t dims[2]; - hsize_t cdims[2]; + hsize_t dims[2]; + hsize_t cdims[2]; // Try block to detect exceptions raised by any of the calls inside it - try - { + try { /* * Turn off the auto-printing when failure occurs so that we can * handle the errors appropriately @@ -58,12 +53,12 @@ int main(void) * Create the named file, truncating the existing one if any, * using default create and access property lists. */ - H5File *file = new H5File( FILE_NAME, H5F_ACC_TRUNC ); + H5File *file = new H5File(FILE_NAME, H5F_ACC_TRUNC); /* * Create a group in the file */ - Group* group = new Group( file->createGroup( "/Data" )); + Group *group = new Group(file->createGroup("/Data")); /* * Create dataset "Compressed Data" in the group using absolute @@ -71,21 +66,20 @@ int main(void) * GZIP compression with the compression effort set to 6. * Note that compression can be used only when dataset is chunked. */ - dims[0] = 1000; - dims[1] = 20; - cdims[0] = 20; - cdims[1] = 20; - DataSpace *dataspace = new DataSpace(RANK, dims); // create new dspace - DSetCreatPropList ds_creatplist; // create dataset creation prop list - ds_creatplist.setChunk( 2, cdims ); // then modify it for compression - ds_creatplist.setDeflate( 6 ); + dims[0] = 1000; + dims[1] = 20; + cdims[0] = 20; + cdims[1] = 20; + DataSpace * dataspace = new DataSpace(RANK, dims); // create new dspace + DSetCreatPropList ds_creatplist; // create dataset creation prop list + ds_creatplist.setChunk(2, cdims); // then modify it for compression + ds_creatplist.setDeflate(6); /* * Create the first dataset. */ - DataSet* dataset = new DataSet(file->createDataSet( - "/Data/Compressed_Data", PredType::NATIVE_INT, - *dataspace, ds_creatplist )); + DataSet *dataset = new DataSet( + file->createDataSet("/Data/Compressed_Data", PredType::NATIVE_INT, *dataspace, ds_creatplist)); /* * Close the first dataset. @@ -96,11 +90,10 @@ int main(void) /* * Create the second dataset. */ - dims[0] = 500; - dims[1] = 20; + dims[0] = 500; + dims[1] = 20; dataspace = new DataSpace(RANK, dims); // create second dspace - dataset = new DataSet(file->createDataSet("/Data/Float_Data", - PredType::NATIVE_FLOAT, *dataspace)); + dataset = new DataSet(file->createDataSet("/Data/Float_Data", PredType::NATIVE_FLOAT, *dataspace)); delete dataset; delete dataspace; @@ -110,16 +103,16 @@ int main(void) /* * Now reopen the file and group in the file. */ - file = new H5File(FILE_NAME, H5F_ACC_RDWR); + file = new H5File(FILE_NAME, H5F_ACC_RDWR); group = new Group(file->openGroup("Data")); /* * Access "Compressed_Data" dataset in the group. */ - try { // to determine if the dataset exists in the group - dataset = new DataSet( group->openDataSet( "Compressed_Data" )); + try { // to determine if the dataset exists in the group + dataset = new DataSet(group->openDataSet("Compressed_Data")); } - catch( GroupIException not_found_error ) { + catch (GroupIException not_found_error) { cout << " Dataset is not found." << endl; } cout << "dataset \"/Data/Compressed_Data\" is open" << endl; @@ -132,17 +125,16 @@ int main(void) /* * Create hard link to the Data group. */ - file->link( H5L_TYPE_HARD, "Data", "Data_new" ); + file->link(H5L_TYPE_HARD, "Data", "Data_new"); /* * We can access "Compressed_Data" dataset using created * hard link "Data_new". */ - try { // to determine if the dataset exists in the file - dataset = new DataSet(file->openDataSet( "/Data_new/Compressed_Data" )); + try { // to determine if the dataset exists in the file + dataset = new DataSet(file->openDataSet("/Data_new/Compressed_Data")); } - catch( FileIException not_found_error ) - { + catch (FileIException not_found_error) { cout << " Dataset is not found." << endl; } cout << "dataset \"/Data_new/Compressed_Data\" is open" << endl; @@ -165,11 +157,10 @@ int main(void) * of the objects in the file root direvtory. */ cout << "Unlinking..." << endl; - try { // attempt to unlink the dataset - file->unlink( "Data" ); + try { // attempt to unlink the dataset + file->unlink("Data"); } - catch( FileIException unlink_error ) - { + catch (FileIException unlink_error) { cout << " unlink failed." << endl; } cout << "\"Data\" is unlinked" << endl; @@ -183,32 +174,28 @@ int main(void) */ delete group; delete file; - } // end of try block + } // end of try block // catch failure caused by the H5File operations - catch( FileIException error ) - { + catch (FileIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSet operations - catch( DataSetIException error ) - { + catch (DataSetIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSpace operations - catch( DataSpaceIException error ) - { + catch (DataSpaceIException error) { error.printErrorStack(); return -1; } // catch failure caused by the Attribute operations - catch( AttributeIException error ) - { + catch (AttributeIException error) { error.printErrorStack(); return -1; } @@ -236,4 +223,3 @@ file_info(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *opdata) H5Gclose(group); return 0; } - diff --git a/c++/examples/h5tutr_cmprss.cpp b/c++/examples/h5tutr_cmprss.cpp index e3cf978..7c55709 100644 --- a/c++/examples/h5tutr_cmprss.cpp +++ b/c++/examples/h5tutr_cmprss.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,20 +24,20 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME("h5tutr_cmprss.h5"); -const H5std_string DATASET_NAME("Compressed_Data"); -const int DIM0 = 100; -const int DIM1 = 20; +const H5std_string FILE_NAME("h5tutr_cmprss.h5"); +const H5std_string DATASET_NAME("Compressed_Data"); +const int DIM0 = 100; +const int DIM1 = 20; -int main (void) +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]; + 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 - { + try { // Turn off the auto-printing when failure occurs so that we can // handle the errors appropriately Exception::dontPrint(); @@ -49,7 +49,7 @@ int main (void) DataSpace *dataspace = new DataSpace(2, dims); // Modify dataset creation property to enable chunking - DSetCreatPropList *plist = new DSetCreatPropList; + DSetCreatPropList *plist = new DSetCreatPropList; plist->setChunk(2, chunk_dims); // Set ZLIB (DEFLATE) Compression using level 6. @@ -62,12 +62,12 @@ int main (void) // 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) ); + 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; + 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); @@ -83,41 +83,41 @@ int main (void) // 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]; + 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)); + dataset = new DataSet(file.openDataSet(DATASET_NAME)); // Get the create property list of the dataset. - plist = new DSetCreatPropList(dataset->getCreatePlist ()); + 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++) { + for (idx = 0; idx < numfilt; idx++) { nelmts = 0; - filter_type = plist->getFilter(idx, flags, nelmts, cd_values, namelen, name , filter_info); + 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; - } + 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. @@ -125,31 +125,27 @@ int main (void) delete plist; delete dataset; - file.close(); // can be skipped + file.close(); // can be skipped - } // end of try block + } // end of try block // catch failure caused by the H5File operations - catch(FileIException error) - { + catch (FileIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSet operations - catch(DataSetIException error) - { + catch (DataSetIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSpace operations - catch(DataSpaceIException error) - { + catch (DataSpaceIException error) { error.printErrorStack(); return -1; } - return 0; // successfully terminated + return 0; // successfully terminated } - diff --git a/c++/examples/h5tutr_crtatt.cpp b/c++/examples/h5tutr_crtatt.cpp index 409bd62..76a4730 100644 --- a/c++/examples/h5tutr_crtatt.cpp +++ b/c++/examples/h5tutr_crtatt.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,69 +21,62 @@ #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME( "h5tutr_dset.h5" ); -const H5std_string DATASET_NAME( "dset" ); -const H5std_string ATTR_NAME( "Units" ); +const H5std_string FILE_NAME("h5tutr_dset.h5"); +const H5std_string DATASET_NAME("dset"); +const H5std_string ATTR_NAME("Units"); -const int DIM1 = 2; +const int DIM1 = 2; -int main (void) +int +main(void) { - int attr_data[2] = { 100, 200}; - hsize_t dims[1] = { DIM1 }; + 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 - { + // 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 ); + 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 ); + DataSpace attr_dataspace = DataSpace(1, dims); // Create a dataset attribute. - Attribute attribute = dataset.createAttribute( ATTR_NAME, PredType::STD_I32BE, - attr_dataspace); + Attribute attribute = dataset.createAttribute(ATTR_NAME, PredType::STD_I32BE, attr_dataspace); // Write the attribute data. - attribute.write( PredType::NATIVE_INT, attr_data); + attribute.write(PredType::NATIVE_INT, attr_data); - } // end of try block + } // end of try block - // catch failure caused by the H5File operations - catch( DataSpaceIException error ) - { + // catch failure caused by the H5File operations + catch (DataSpaceIException error) { error.printErrorStack(); return -1; - } + } - // catch failure caused by the H5File operations - catch( AttributeIException error ) - { + // catch failure caused by the H5File operations + catch (AttributeIException error) { error.printErrorStack(); return -1; - } + } - // catch failure caused by the H5File operations - catch( FileIException error ) - { + // catch failure caused by the H5File operations + catch (FileIException error) { error.printErrorStack(); return -1; - } + } - // catch failure caused by the DataSet operations - catch( DataSetIException error ) - { + // catch failure caused by the DataSet operations + catch (DataSetIException error) { error.printErrorStack(); return -1; - } + } - return 0; // successfully terminated + return 0; // successfully terminated } - diff --git a/c++/examples/h5tutr_crtdat.cpp b/c++/examples/h5tutr_crtdat.cpp index 3257223..93a245c 100644 --- a/c++/examples/h5tutr_crtdat.cpp +++ b/c++/examples/h5tutr_crtdat.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,17 +22,17 @@ #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME("h5tutr_dset.h5"); -const H5std_string DATASET_NAME("dset"); -const int NX = 4; // dataset dimensions -const int NY = 6; -const int RANK = 2; +const H5std_string FILE_NAME("h5tutr_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) +int +main(void) { // Try block to detect exceptions raised by any of the calls inside it - try - { + try { // Turn off the auto-printing when failure occurs so that we can // handle the errors appropriately Exception::dontPrint(); @@ -41,7 +41,7 @@ int main (void) H5File file(FILE_NAME, H5F_ACC_TRUNC); // Create the data space for the dataset. - hsize_t dims[2]; // dataset dimensions + hsize_t dims[2]; // dataset dimensions dims[0] = NX; dims[1] = NY; DataSpace dataspace(RANK, dims); @@ -49,29 +49,25 @@ int main (void) // Create the dataset. DataSet dataset = file.createDataSet(DATASET_NAME, PredType::STD_I32BE, dataspace); - } // end of try block + } // end of try block // catch failure caused by the H5File operations - catch(FileIException error) - { + catch (FileIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSet operations - catch(DataSetIException error) - { + catch (DataSetIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSpace operations - catch(DataSpaceIException error) - { + catch (DataSpaceIException error) { error.printErrorStack(); return -1; } - return 0; // successfully terminated + return 0; // successfully terminated } - diff --git a/c++/examples/h5tutr_crtgrp.cpp b/c++/examples/h5tutr_crtgrp.cpp index 43af08a..45d1929 100644 --- a/c++/examples/h5tutr_crtgrp.cpp +++ b/c++/examples/h5tutr_crtgrp.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,11 +26,11 @@ using namespace H5; const H5std_string FILE_NAME("h5tutr_group.h5"); -int main(void) +int +main(void) { // Try block to detect exceptions raised by any of the calls inside it - try - { + try { // Turn off the auto-printing when failure occurs so that we can // handle the errors appropriately Exception::dontPrint(); @@ -46,14 +46,12 @@ int main(void) } // end of try block // catch failure caused by the H5File operations - catch(FileIException error) - { + catch (FileIException error) { error.printErrorStack(); return -1; } // catch failure caused by the Group operations - catch(GroupIException error) - { + catch (GroupIException error) { error.printErrorStack(); return -1; } diff --git a/c++/examples/h5tutr_crtgrpar.cpp b/c++/examples/h5tutr_crtgrpar.cpp index 15cf1df..7c7bab5c 100644 --- a/c++/examples/h5tutr_crtgrpar.cpp +++ b/c++/examples/h5tutr_crtgrpar.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,12 +26,12 @@ using namespace H5; const H5std_string FILE_NAME("h5tutr_groups.h5"); -int main(void) +int +main(void) { // Try block to detect exceptions raised by any of the calls inside it - try - { + try { // Turn off the auto-printing when failure occurs so that we can // handle the errors appropriately. @@ -44,7 +44,7 @@ int main(void) // Create group "MyGroup" in the root group using an absolute name. - Group group1(file.createGroup( "/MyGroup")); + Group group1(file.createGroup("/MyGroup")); // Create group "Group_A" in group "MyGroup" using an // absolute name. @@ -54,7 +54,7 @@ int main(void) // Create group "Group_B" in group "MyGroup" using a // relative name. - Group group3(group1.createGroup ("Group_B")); + Group group3(group1.createGroup("Group_B")); // Close the groups and file. @@ -66,20 +66,16 @@ int main(void) } // end of try block // catch failure caused by the File operations - catch(FileIException error) - { + catch (FileIException error) { error.printErrorStack(); return -1; } // catch failure caused by the Group operations - catch(GroupIException error) - { + catch (GroupIException error) { error.printErrorStack(); return -1; } return 0; } - - diff --git a/c++/examples/h5tutr_crtgrpd.cpp b/c++/examples/h5tutr_crtgrpd.cpp index c28b666..14b45c0 100644 --- a/c++/examples/h5tutr_crtgrpd.cpp +++ b/c++/examples/h5tutr_crtgrpd.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,20 +27,20 @@ using namespace H5; const H5std_string FILE_NAME("h5tutr_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) +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 - { + try { // Turn off the auto-printing when failure occurs so that we can // handle the errors appropriately Exception::dontPrint(); @@ -48,12 +48,12 @@ int main(void) // Initialize the first dataset. for (i = 0; i < D1DIM1; i++) for (j = 0; j < D1DIM2; j++) - dset1_data[i][j] = j + 1; + 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; + 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); @@ -62,15 +62,14 @@ int main(void) // 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); + 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)); + 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. @@ -81,16 +80,15 @@ int main(void) delete dataspace; // Create the data space for the second dataset. - dims[0] = D2DIM1; - dims[1] = D2DIM2; - dataspace = new DataSpace (RANK, dims); + 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)); + 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. @@ -104,31 +102,27 @@ int main(void) } // end of try block // catch failure caused by the H5File operations - catch(FileIException error) - { - error.printErrorStack(); - return -1; + catch (FileIException error) { + error.printErrorStack(); + return -1; } // catch failure caused by the DataSet operations - catch(DataSetIException error) - { - error.printErrorStack(); - return -1; + catch (DataSetIException error) { + error.printErrorStack(); + return -1; } // catch failure caused by the DataSpace operations - catch(DataSpaceIException error) - { + catch (DataSpaceIException error) { error.printErrorStack(); return -1; } // catch failure caused by the Group operations - catch(GroupIException error) - { + catch (GroupIException error) { error.printErrorStack(); return -1; } - return 0; + return 0; } diff --git a/c++/examples/h5tutr_extend.cpp b/c++/examples/h5tutr_extend.cpp index 94e9acf..bd7e9a5 100644 --- a/c++/examples/h5tutr_extend.cpp +++ b/c++/examples/h5tutr_extend.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,34 +24,28 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME("h5tutr_extend.h5"); -const H5std_string DATASETNAME("ExtendibleArray"); +const H5std_string FILE_NAME("h5tutr_extend.h5"); +const H5std_string DATASETNAME("ExtendibleArray"); -int main (void) +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} }; + 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 - { + try { // Turn off the auto-printing when failure occurs so that we can // handle the errors appropriately Exception::dontPrint(); @@ -63,15 +57,15 @@ int main (void) // 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); + 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) ); + DataSet *dataset = + new DataSet(file.createDataSet(DATASETNAME, PredType::STD_I32BE, *dataspace, prop)); // Write data to dataset. dataset->write(data, PredType::NATIVE_INT); @@ -82,9 +76,9 @@ int main (void) dataset->extend(size); // Select a hyperslab in extended portion of the dataset. - DataSpace *filespace = new DataSpace(dataset->getSpace ()); - offset[0] = 3; - offset[1] = 0; + DataSpace *filespace = new DataSpace(dataset->getSpace()); + offset[0] = 3; + offset[1] = 0; filespace->selectHyperslab(H5S_SELECT_SET, dimsext, offset); // Define memory space. @@ -105,25 +99,26 @@ int main (void) // 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]; + 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)); + dataset = new DataSet(file.openDataSet(DATASETNAME)); // Get the dataset's dataspace and creation property list. filespace = new DataSpace(dataset->getSpace()); - prop = dataset->getCreatePlist(); + prop = dataset->getCreatePlist(); // Get information to obtain memory dataspace. - rank = filespace->getSimpleExtentNdims(); + rank = filespace->getSimpleExtentNdims(); herr_t status_n = filespace->getSimpleExtentDims(dimsr); if (H5D_CHUNKED == prop.getLayout()) - rank_chunk = prop.getChunk(rank, chunk_dimsr); - cout << "rank chunk = " << rank_chunk << endl;; + rank_chunk = prop.getChunk(rank, chunk_dimsr); + cout << "rank chunk = " << rank_chunk << endl; + ; memspace = new DataSpace(rank, dimsr, NULL); dataset->read(rdata, PredType::NATIVE_INT, *memspace, *filespace); @@ -131,7 +126,7 @@ int main (void) cout << endl; for (j = 0; j < dimsr[0]; j++) { for (i = 0; i < dimsr[1]; i++) - cout << " " << rdata[j][i]; + cout << " " << rdata[j][i]; cout << endl; } @@ -142,29 +137,25 @@ int main (void) delete dataset; file.close(); - } // end of try block + } // end of try block // catch failure caused by the H5File operations - catch(FileIException error) - { + catch (FileIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSet operations - catch(DataSetIException error) - { + catch (DataSetIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSpace operations - catch(DataSpaceIException error) - { + catch (DataSpaceIException error) { error.printErrorStack(); return -1; } - return 0; // successfully terminated + return 0; // successfully terminated } - diff --git a/c++/examples/h5tutr_rdwt.cpp b/c++/examples/h5tutr_rdwt.cpp index e9b76ad..3e1ee82 100644 --- a/c++/examples/h5tutr_rdwt.cpp +++ b/c++/examples/h5tutr_rdwt.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,53 +21,51 @@ #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME("h5tutr_dset.h5"); -const H5std_string DATASET_NAME("dset"); -const int DIM0 = 4; // dataset dimensions -const int DIM1 = 6; +const H5std_string FILE_NAME("h5tutr_dset.h5"); +const H5std_string DATASET_NAME("dset"); +const int DIM0 = 4; // dataset dimensions +const int DIM1 = 6; -int main (void) +int +main(void) { // Data initialization. int i, j; - int data[DIM0][DIM1]; // buffer for data to write + 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; + data[j][i] = i * 6 + j + 1; // Try block to detect exceptions raised by any of the calls inside it - try - { + 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); + 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 + } // end of try block // catch failure caused by the H5File operations - catch(FileIException error) - { + catch (FileIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSet operations - catch(DataSetIException error) - { + catch (DataSetIException error) { error.printErrorStack(); return -1; } - return 0; // successfully terminated + return 0; // successfully terminated } diff --git a/c++/examples/h5tutr_subset.cpp b/c++/examples/h5tutr_subset.cpp index f7d0513..5c62c89 100644 --- a/c++/examples/h5tutr_subset.cpp +++ b/c++/examples/h5tutr_subset.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,23 +24,23 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME("h5tutr_subset.h5"); -const H5std_string DATASET_NAME("IntArray"); +const H5std_string FILE_NAME("h5tutr_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; +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 +main(void) { - int i,j; - int data[DIM0][DIM1], sdata[DIM0_SUB][DIM1_SUB], rdata[DIM0][DIM1]; + 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 - { + try { // Turn off the auto-printing when failure occurs so that we can // handle the errors appropriately Exception::dontPrint(); @@ -54,28 +54,26 @@ int main (void) 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) ); + 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)) + for (i = 0; i < DIM1; i++) + if (i < (DIM1 / 2)) data[j][i] = 1; - else + 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 << " " << data[j][i]; cout << endl; } @@ -99,8 +97,8 @@ int main (void) offset[0] = 1; offset[1] = 2; - count[0] = DIM0_SUB; - count[1] = DIM1_SUB; + count[0] = DIM0_SUB; + count[1] = DIM1_SUB; stride[0] = 1; stride[1] = 1; @@ -126,17 +124,16 @@ int main (void) 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; + 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 << " " << rdata[i][j]; cout << endl; } cout << endl; @@ -148,29 +145,25 @@ int main (void) dataset.close(); file.close(); - } // end of try block + } // end of try block // catch failure caused by the H5File operations - catch(FileIException error) - { + catch (FileIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSet operations - catch(DataSetIException error) - { + catch (DataSetIException error) { error.printErrorStack(); return -1; } // catch failure caused by the DataSpace operations - catch(DataSpaceIException error) - { + catch (DataSpaceIException error) { error.printErrorStack(); return -1; } - return 0; // successfully terminated + return 0; // successfully terminated } - diff --git a/c++/examples/readdata.cpp b/c++/examples/readdata.cpp index 3df8191..e247a8e 100644 --- a/c++/examples/readdata.cpp +++ b/c++/examples/readdata.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,11 +17,7 @@ // information about the dataset in the SDS.h5 file is obtained. // -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cout; using std::endl; @@ -29,184 +25,174 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME( "SDS.h5" ); -const H5std_string DATASET_NAME( "IntArray" ); -const int NX_SUB = 3; // hyperslab dimensions -const int NY_SUB = 4; -const int NX = 7; // output buffer dimensions -const int NY = 7; -const int NZ = 3; -const int RANK_OUT = 3; - -int main (void) +const H5std_string FILE_NAME("SDS.h5"); +const H5std_string DATASET_NAME("IntArray"); +const int NX_SUB = 3; // hyperslab dimensions +const int NY_SUB = 4; +const int NX = 7; // output buffer dimensions +const int NY = 7; +const int NZ = 3; +const int RANK_OUT = 3; + +int +main(void) { - /* - * Output buffer initialization. - */ - int i, j, k; - int data_out[NX][NY][NZ ]; /* output buffer */ - for (j = 0; j < NX; j++) - { - for (i = 0; i < NY; i++) - { - for (k = 0; k < NZ ; k++) - data_out[j][i][k] = 0; - } - } - - /* - * 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 the specified file and the specified dataset in the file. - */ - H5File file( FILE_NAME, H5F_ACC_RDONLY ); - DataSet dataset = file.openDataSet( DATASET_NAME ); - - /* - * Get the class of the datatype that is used by the dataset. - */ - H5T_class_t type_class = dataset.getTypeClass(); - - /* - * Get class of datatype and print message if it's an integer. - */ - if( type_class == H5T_INTEGER ) - { - cout << "Data set has INTEGER type" << endl; - - /* - * Get the integer datatype - */ - IntType intype = dataset.getIntType(); - - /* - * Get order of datatype and print message if it's a little endian. - */ - H5std_string order_string; - H5T_order_t order = intype.getOrder( order_string ); - cout << order_string << endl; - - /* - * Get size of the data element stored in file and print it. - */ - size_t size = intype.getSize(); - cout << "Data size is " << size << endl; - } - - /* - * Get dataspace of the dataset. - */ - DataSpace dataspace = dataset.getSpace(); - - /* - * Get the number of dimensions in the dataspace. - */ - int rank = dataspace.getSimpleExtentNdims(); - - /* - * Get the dimension size of each dimension in the dataspace and - * display them. - */ - hsize_t dims_out[2]; - int ndims = dataspace.getSimpleExtentDims( dims_out, NULL); - cout << "rank " << rank << ", dimensions " << - (unsigned long)(dims_out[0]) << " x " << - (unsigned long)(dims_out[1]) << endl; - - /* - * Define hyperslab in the dataset; implicitly giving strike and - * block NULL. - */ - hsize_t offset[2]; // hyperslab offset in the file - hsize_t count[2]; // size of the hyperslab in the file - offset[0] = 1; - offset[1] = 2; - count[0] = NX_SUB; - count[1] = NY_SUB; - dataspace.selectHyperslab( H5S_SELECT_SET, count, offset ); - - /* - * Define the memory dataspace. - */ - hsize_t dimsm[3]; /* memory space dimensions */ - dimsm[0] = NX; - dimsm[1] = NY; - dimsm[2] = NZ ; - DataSpace memspace( RANK_OUT, dimsm ); - - /* - * Define memory hyperslab. - */ - hsize_t offset_out[3]; // hyperslab offset in memory - hsize_t count_out[3]; // size of the hyperslab in memory - offset_out[0] = 3; - offset_out[1] = 0; - offset_out[2] = 0; - count_out[0] = NX_SUB; - count_out[1] = NY_SUB; - count_out[2] = 1; - memspace.selectHyperslab( H5S_SELECT_SET, count_out, offset_out ); - - /* - * Read data from hyperslab in the file into the hyperslab in - * memory and display the data. - */ - dataset.read( data_out, PredType::NATIVE_INT, memspace, dataspace ); - - for (j = 0; j < NX; j++) - { - for (i = 0; i < NY; i++) - cout << data_out[j][i][0] << " "; - cout << endl; - } - /* - * 0 0 0 0 0 0 0 - * 0 0 0 0 0 0 0 - * 0 0 0 0 0 0 0 - * 3 4 5 6 0 0 0 - * 4 5 6 7 0 0 0 - * 5 6 7 8 0 0 0 - * 0 0 0 0 0 0 0 - */ - } // end of try block - - // catch failure caused by the H5File operations - catch( FileIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSet operations - catch( DataSetIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSpace operations - catch( DataSpaceIException error ) - { - error.printErrorStack(); - return -1; - } - - // catch failure caused by the DataSpace operations - catch( DataTypeIException error ) - { - error.printErrorStack(); - return -1; - } - - return 0; // successfully terminated + /* + * Output buffer initialization. + */ + int i, j, k; + int data_out[NX][NY][NZ]; /* output buffer */ + for (j = 0; j < NX; j++) { + for (i = 0; i < NY; i++) { + for (k = 0; k < NZ; k++) + data_out[j][i][k] = 0; + } + } + + /* + * 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 the specified file and the specified dataset in the file. + */ + H5File file(FILE_NAME, H5F_ACC_RDONLY); + DataSet dataset = file.openDataSet(DATASET_NAME); + + /* + * Get the class of the datatype that is used by the dataset. + */ + H5T_class_t type_class = dataset.getTypeClass(); + + /* + * Get class of datatype and print message if it's an integer. + */ + if (type_class == H5T_INTEGER) { + cout << "Data set has INTEGER type" << endl; + + /* + * Get the integer datatype + */ + IntType intype = dataset.getIntType(); + + /* + * Get order of datatype and print message if it's a little endian. + */ + H5std_string order_string; + H5T_order_t order = intype.getOrder(order_string); + cout << order_string << endl; + + /* + * Get size of the data element stored in file and print it. + */ + size_t size = intype.getSize(); + cout << "Data size is " << size << endl; + } + + /* + * Get dataspace of the dataset. + */ + DataSpace dataspace = dataset.getSpace(); + + /* + * Get the number of dimensions in the dataspace. + */ + int rank = dataspace.getSimpleExtentNdims(); + + /* + * Get the dimension size of each dimension in the dataspace and + * display them. + */ + hsize_t dims_out[2]; + int ndims = dataspace.getSimpleExtentDims(dims_out, NULL); + cout << "rank " << rank << ", dimensions " << (unsigned long)(dims_out[0]) << " x " + << (unsigned long)(dims_out[1]) << endl; + + /* + * Define hyperslab in the dataset; implicitly giving strike and + * block NULL. + */ + hsize_t offset[2]; // hyperslab offset in the file + hsize_t count[2]; // size of the hyperslab in the file + offset[0] = 1; + offset[1] = 2; + count[0] = NX_SUB; + count[1] = NY_SUB; + dataspace.selectHyperslab(H5S_SELECT_SET, count, offset); + + /* + * Define the memory dataspace. + */ + hsize_t dimsm[3]; /* memory space dimensions */ + dimsm[0] = NX; + dimsm[1] = NY; + dimsm[2] = NZ; + DataSpace memspace(RANK_OUT, dimsm); + + /* + * Define memory hyperslab. + */ + hsize_t offset_out[3]; // hyperslab offset in memory + hsize_t count_out[3]; // size of the hyperslab in memory + offset_out[0] = 3; + offset_out[1] = 0; + offset_out[2] = 0; + count_out[0] = NX_SUB; + count_out[1] = NY_SUB; + count_out[2] = 1; + memspace.selectHyperslab(H5S_SELECT_SET, count_out, offset_out); + + /* + * Read data from hyperslab in the file into the hyperslab in + * memory and display the data. + */ + dataset.read(data_out, PredType::NATIVE_INT, memspace, dataspace); + + for (j = 0; j < NX; j++) { + for (i = 0; i < NY; i++) + cout << data_out[j][i][0] << " "; + cout << endl; + } + /* + * 0 0 0 0 0 0 0 + * 0 0 0 0 0 0 0 + * 0 0 0 0 0 0 0 + * 3 4 5 6 0 0 0 + * 4 5 6 7 0 0 0 + * 5 6 7 8 0 0 0 + * 0 0 0 0 0 0 0 + */ + } // end of try block + + // catch failure caused by the H5File operations + catch (FileIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSet operations + catch (DataSetIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSpace operations + catch (DataSpaceIException error) { + error.printErrorStack(); + return -1; + } + + // catch failure caused by the DataSpace operations + catch (DataTypeIException error) { + error.printErrorStack(); + 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 81164fc..ff932e0 100644 --- a/c++/examples/run-c++-ex.sh.in +++ b/c++/examples/run-c++-ex.sh.in @@ -6,7 +6,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. diff --git a/c++/examples/testh5c++.sh.in b/c++/examples/testh5c++.sh.in index 907a980..44dc9e7 100644 --- a/c++/examples/testh5c++.sh.in +++ b/c++/examples/testh5c++.sh.in @@ -7,7 +7,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # @@ -67,11 +67,7 @@ temp_FILES="a.out $applib" cat > $appmain <<EOF #include <string> -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif #include "H5Cpp.h" @@ -95,19 +91,11 @@ EOF # generate prog1 cat > $prog1 <<EOF -#ifdef OLD_HEADER_FILENAME - #include <iostream.h> -#else - #include <iostream> -#endif +#include <iostream> #include <string> -#ifndef H5_NO_NAMESPACE -#ifndef H5_NO_STD - using std::cout; - using std::endl; -#endif // H5_NO_STD -#endif +using std::cout; +using std::endl; int sub1(void) { cout << "in sub1" << endl; @@ -117,19 +105,11 @@ EOF # generate prog2 cat > $prog2 <<EOF -#ifdef OLD_HEADER_FILENAME - #include <iostream.h> -#else - #include <iostream> -#endif +#include <iostream> #include <string> -#ifndef H5_NO_NAMESPACE -#ifndef H5_NO_STD - using std::cout; - using std::endl; -#endif // H5_NO_STD -#endif +using std::cout; +using std::endl; int sub2(void) { cout << "in sub2" << endl; @@ -142,11 +122,7 @@ EOF cat > $hdf5main <<EOF #include <string> -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif #include "H5Cpp.h" diff --git a/c++/examples/writedata.cpp b/c++/examples/writedata.cpp index eada2ed..f2b715a 100644 --- a/c++/examples/writedata.cpp +++ b/c++/examples/writedata.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,11 +20,7 @@ * file is closed. Program reopens the file and reads and displays the result. */ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cout; using std::endl; @@ -32,31 +28,31 @@ using std::endl; #include "H5Cpp.h" using namespace H5; -const H5std_string FILE_NAME( "Select.h5" ); -const H5std_string DATASET_NAME( "Matrix in file" ); -const int MSPACE1_RANK = 1; // Rank of the first dataset in memory -const int MSPACE1_DIM = 50; // Dataset size in memory -const int MSPACE2_RANK = 1; // Rank of the second dataset in memory -const int MSPACE2_DIM = 4; // Dataset size in memory -const int FSPACE_RANK = 2; // Dataset rank as it is stored in the file -const int FSPACE_DIM1 = 8; // Dimension sizes of the dataset as it is -const int FSPACE_DIM2 = 12; // stored in the file -const int MSPACE_RANK = 2; // Rank of the first dataset in memory -const int MSPACE_DIM1 = 8; // We will read dataset back from the file -const int MSPACE_DIM2 = 9; // to the dataset in memory with these - // dataspace parameters -const int NPOINTS = 4; // Number of points that will be selected - // and overwritten - -int main (void) +const H5std_string FILE_NAME("Select.h5"); +const H5std_string DATASET_NAME("Matrix in file"); +const int MSPACE1_RANK = 1; // Rank of the first dataset in memory +const int MSPACE1_DIM = 50; // Dataset size in memory +const int MSPACE2_RANK = 1; // Rank of the second dataset in memory +const int MSPACE2_DIM = 4; // Dataset size in memory +const int FSPACE_RANK = 2; // Dataset rank as it is stored in the file +const int FSPACE_DIM1 = 8; // Dimension sizes of the dataset as it is +const int FSPACE_DIM2 = 12; // stored in the file +const int MSPACE_RANK = 2; // Rank of the first dataset in memory +const int MSPACE_DIM1 = 8; // We will read dataset back from the file +const int MSPACE_DIM2 = 9; // to the dataset in memory with these + // dataspace parameters +const int NPOINTS = 4; // Number of points that will be selected + // and overwritten + +int +main(void) { - int i,j; // loop indices */ + int i, j; // loop indices */ /* * Try block to detect exceptions raised by any of the calls inside it */ - try - { + try { /* * Turn off the auto-printing when failure occurs so that we can * handle the errors appropriately @@ -66,47 +62,51 @@ int main (void) /* * Create a file. */ - H5File* file = new H5File( FILE_NAME, H5F_ACC_TRUNC ); + H5File *file = new H5File(FILE_NAME, H5F_ACC_TRUNC); /* - * Create property list for a dataset and set up fill values. - */ - int fillvalue = 0; /* Fill value for the dataset */ + * Create property list for a dataset and set up fill values. + */ + int fillvalue = 0; /* Fill value for the dataset */ DSetCreatPropList plist; plist.setFillValue(PredType::NATIVE_INT, &fillvalue); /* * Create dataspace for the dataset in the file. */ - hsize_t fdim[] = {FSPACE_DIM1, FSPACE_DIM2}; // dim sizes of ds (on disk) - DataSpace fspace( FSPACE_RANK, fdim ); + hsize_t fdim[] = {FSPACE_DIM1, FSPACE_DIM2}; // dim sizes of ds (on disk) + DataSpace fspace(FSPACE_RANK, fdim); /* * Create dataset and write it into the file. */ - DataSet* dataset = new DataSet(file->createDataSet( - DATASET_NAME, PredType::NATIVE_INT, fspace, plist)); + DataSet *dataset = + new DataSet(file->createDataSet(DATASET_NAME, PredType::NATIVE_INT, fspace, plist)); /* * Select hyperslab for the dataset in the file, using 3x2 blocks, * (4,3) stride and (2,4) count starting at the position (0,1). */ - hsize_t start[2]; // Start of hyperslab + hsize_t start[2]; // Start of hyperslab hsize_t stride[2]; // Stride of hyperslab hsize_t count[2]; // Block count hsize_t block[2]; // Block sizes - start[0] = 0; start[1] = 1; - stride[0] = 4; stride[1] = 3; - count[0] = 2; count[1] = 4; - block[0] = 3; block[1] = 2; - fspace.selectHyperslab( H5S_SELECT_SET, count, start, stride, block); + start[0] = 0; + start[1] = 1; + stride[0] = 4; + stride[1] = 3; + count[0] = 2; + count[1] = 4; + block[0] = 3; + block[1] = 2; + fspace.selectHyperslab(H5S_SELECT_SET, count, start, stride, block); /* * Create dataspace for the first dataset. */ - hsize_t dim1[] = {MSPACE1_DIM}; /* Dimension size of the first dataset - (in memory) */ - DataSpace mspace1( MSPACE1_RANK, dim1 ); + hsize_t dim1[] = {MSPACE1_DIM}; /* Dimension size of the first dataset + (in memory) */ + DataSpace mspace1(MSPACE1_RANK, dim1); /* * Select hyperslab. @@ -117,7 +117,7 @@ int main (void) stride[0] = 1; count[0] = 48; block[0] = 1; - mspace1.selectHyperslab( H5S_SELECT_SET, count, start, stride, block); + mspace1.selectHyperslab(H5S_SELECT_SET, count, start, stride, block); /* * Write selection from the vector buffer to the dataset in the file. @@ -132,7 +132,7 @@ int main (void) * 0 41 42 0 43 44 0 45 46 0 47 48 * 0 0 0 0 0 0 0 0 0 0 0 0 */ - int vector[MSPACE1_DIM]; // vector buffer for dset + int vector[MSPACE1_DIM]; // vector buffer for dset /* * Buffer initialization. @@ -141,7 +141,7 @@ int main (void) for (i = 1; i < MSPACE1_DIM - 1; i++) vector[i] = i; - dataset->write( vector, PredType::NATIVE_INT, mspace1, fspace ); + dataset->write(vector, PredType::NATIVE_INT, mspace1, fspace); /* * Reset the selection for the file dataspace fid. @@ -151,27 +151,31 @@ int main (void) /* * Create dataspace for the second dataset. */ - hsize_t dim2[] = {MSPACE2_DIM}; /* Dimension size of the second dataset - (in memory */ - DataSpace mspace2( MSPACE2_RANK, dim2 ); + hsize_t dim2[] = {MSPACE2_DIM}; /* Dimension size of the second dataset + (in memory */ + DataSpace mspace2(MSPACE2_RANK, dim2); /* * Select sequence of NPOINTS points in the file dataspace. */ hsize_t coord[NPOINTS][FSPACE_RANK]; /* Array to store selected points from the file dataspace */ - coord[0][0] = 0; coord[0][1] = 0; - coord[1][0] = 3; coord[1][1] = 3; - coord[2][0] = 3; coord[2][1] = 5; - coord[3][0] = 5; coord[3][1] = 6; + coord[0][0] = 0; + coord[0][1] = 0; + coord[1][0] = 3; + coord[1][1] = 3; + coord[2][0] = 3; + coord[2][1] = 5; + coord[3][0] = 5; + coord[3][1] = 6; - fspace.selectElements( H5S_SELECT_SET, NPOINTS, (const hsize_t *)coord); + fspace.selectElements(H5S_SELECT_SET, NPOINTS, (const hsize_t *)coord); /* * Write new selection of points to the dataset. */ - int values[] = {53, 59, 61, 67}; /* New values to be written */ - dataset->write( values, PredType::NATIVE_INT, mspace2, fspace ); + int values[] = {53, 59, 61, 67}; /* New values to be written */ + dataset->write(values, PredType::NATIVE_INT, mspace2, fspace); /* * File dataset should look like this: @@ -195,12 +199,12 @@ int main (void) /* * Open the file. */ - file = new H5File( FILE_NAME, H5F_ACC_RDONLY ); + file = new H5File(FILE_NAME, H5F_ACC_RDONLY); /* * Open the dataset. */ - dataset = new DataSet( file->openDataSet( DATASET_NAME )); + dataset = new DataSet(file->openDataSet(DATASET_NAME)); /* * Get dataspace of the dataset. @@ -215,10 +219,14 @@ int main (void) * 0 59 0 61 * */ - start[0] = 1; start[1] = 2; - block[0] = 1; block[1] = 1; - stride[0] = 1; stride[1] = 1; - count[0] = 3; count[1] = 4; + start[0] = 1; + start[1] = 2; + block[0] = 1; + block[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = 3; + count[1] = 4; fspace.selectHyperslab(H5S_SELECT_SET, count, start, stride, block); /* @@ -234,10 +242,14 @@ int main (void) * 19 20 * 0 61 */ - start[0] = 2; start[1] = 4; - block[0] = 1; block[1] = 1; - stride[0] = 1; stride[1] = 1; - count[0] = 6; count[1] = 5; + start[0] = 2; + start[1] = 4; + block[0] = 1; + block[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = 6; + count[1] = 5; fspace.selectHyperslab(H5S_SELECT_OR, count, start, stride, block); /* @@ -253,15 +265,23 @@ int main (void) * Select two hyperslabs in memory. Hyperslabs has the same * size and shape as the selected hyperslabs for the file dataspace. */ - start[0] = 0; start[1] = 0; - block[0] = 1; block[1] = 1; - stride[0] = 1; stride[1] = 1; - count[0] = 3; count[1] = 4; + start[0] = 0; + start[1] = 0; + block[0] = 1; + block[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = 3; + count[1] = 4; mspace.selectHyperslab(H5S_SELECT_SET, count, start, stride, block); - start[0] = 1; start[1] = 2; - block[0] = 1; block[1] = 1; - stride[0] = 1; stride[1] = 1; - count[0] = 6; count[1] = 5; + start[0] = 1; + start[1] = 2; + block[0] = 1; + block[1] = 1; + stride[0] = 1; + stride[1] = 1; + count[0] = 6; + count[1] = 5; mspace.selectHyperslab(H5S_SELECT_OR, count, start, stride, block); /* @@ -289,9 +309,8 @@ int main (void) * 0 0 0 0 0 0 0 0 0 * 0 0 0 0 0 0 0 0 0 */ - for (i=0; i < MSPACE_DIM1; i++) - { - for(j=0; j < MSPACE_DIM2; j++) + for (i = 0; i < MSPACE_DIM1; i++) { + for (j = 0; j < MSPACE_DIM2; j++) cout << matrix_out[i][j] << " "; cout << endl; } @@ -301,28 +320,25 @@ int main (void) */ delete dataset; delete file; - } // end of try block + } // end of try block - // catch failure caused by the H5File operations - catch( FileIException error ) - { + // catch failure caused by the H5File operations + catch (FileIException error) { error.printErrorStack(); return -1; - } + } - // catch failure caused by the DataSet operations - catch( DataSetIException error ) - { + // catch failure caused by the DataSet operations + catch (DataSetIException error) { error.printErrorStack(); return -1; - } + } - // catch failure caused by the DataSpace operations - catch( DataSpaceIException error ) - { + // catch failure caused by the DataSpace operations + catch (DataSpaceIException error) { error.printErrorStack(); return -1; - } + } - return 0; + return 0; } diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt index 058f457..835d422 100644 --- a/c++/src/CMakeLists.txt +++ b/c++/src/CMakeLists.txt @@ -5,7 +5,7 @@ project (HDF5_CPP_SRC CXX) # Generate configure file #----------------------------------------------------------------------------- configure_file (${HDF_RESOURCES_DIR}/H5cxx_config.h.in - ${HDF5_BINARY_DIR}/H5cxx_pubconf.h + ${HDF5_SRC_BINARY_DIR}/H5cxx_pubconf.h ) #----------------------------------------------------------------------------- @@ -87,7 +87,7 @@ set (CPP_HDRS if (NOT ONLY_SHARED_LIBS) add_library (${HDF5_CPP_LIB_TARGET} STATIC ${CPP_SOURCES} ${CPP_HDRS}) target_include_directories (${HDF5_CPP_LIB_TARGET} - PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" + PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) target_compile_options(${HDF5_CPP_LIB_TARGET} PRIVATE "${HDF5_CMAKE_CXX_FLAGS}") @@ -105,7 +105,7 @@ endif () if (BUILD_SHARED_LIBS) add_library (${HDF5_CPP_LIBSH_TARGET} SHARED ${CPP_SOURCES} ${CPP_HDRS}) target_include_directories (${HDF5_CPP_LIBSH_TARGET} - PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" + PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) target_compile_options(${HDF5_CPP_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_CXX_FLAGS}") @@ -117,7 +117,7 @@ if (BUILD_SHARED_LIBS) target_link_libraries (${HDF5_CPP_LIBSH_TARGET} PUBLIC ${HDF5_LIBSH_TARGET} ) - if (MINGW) + if (MINGW AND HDF5_MINGW_STATIC_GCC_LIBS) target_link_options (${HDF5_CPP_LIBSH_TARGET} PRIVATE -static-libgcc -static-libstdc++ ) @@ -129,6 +129,17 @@ if (BUILD_SHARED_LIBS) endif () #----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + if (NOT ONLY_SHARED_LIBS) + clang_format (HDF5_CPP_SRC_FORMAT ${HDF5_CPP_LIB_TARGET}) + else () + clang_format (HDF5_CPP_SRC_FORMAT ${HDF5_CPP_LIBSH_TARGET}) + endif () +endif () + +#----------------------------------------------------------------------------- # Add file(s) to CMake Install #----------------------------------------------------------------------------- install ( @@ -183,22 +194,26 @@ if (BUILD_SHARED_LIBS) set (_PKG_CONFIG_SH_LIBS "${_PKG_CONFIG_SH_LIBS} -l${HDF5_CPP_LIB_CORENAME}") endif () -set (_PKG_CONFIG_REQUIRES "${HDF5_LIB_CORENAME}") -set (_PKG_CONFIG_REQUIRES_PRIVATE "${HDF5_LIB_CORENAME}") +set (_PKG_CONFIG_REQUIRES "${HDF5_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}") +set (_PKG_CONFIG_REQUIRES_PRIVATE "${HDF5_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}") configure_file ( - ${HDF_RESOURCES_DIR}/libhdf5.pc.in - ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_CPP_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}.pc + ${HDF_CONFIG_DIR}/libhdf5.pc.in + ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_CPP_LIB_CORENAME}.pc @ONLY ) install ( - FILES ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_CPP_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}.pc + FILES ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_CPP_LIB_CORENAME}.pc DESTINATION ${HDF5_INSTALL_LIB_DIR}/pkgconfig COMPONENT cpplibraries ) if (NOT WIN32 AND NOT MINGW) - set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER}) + if (HDF5_ENABLE_PARALLEL AND MPI_CXX_FOUND) + set (_PKG_CONFIG_COMPILER ${MPI_CXX_COMPILER}) + else () + set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER}) + endif () configure_file ( ${HDF_RESOURCES_DIR}/libh5cc.in ${HDF5_BINARY_DIR}/CMakeFiles/h5c++ diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp index d59a3cb..eeb0155 100644 --- a/c++/src/H5AbstractDs.cpp +++ b/c++/src/H5AbstractDs.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -38,7 +38,9 @@ namespace H5 { ///\brief Default constructor // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AbstractDs::AbstractDs(){} +AbstractDs::AbstractDs() +{ +} //-------------------------------------------------------------------------- // Function: AbstractDs default constructor @@ -61,19 +63,20 @@ AbstractDs::AbstractDs(){} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_class_t AbstractDs::getTypeClass() const +H5T_class_t +AbstractDs::getTypeClass() const { // Gets the datatype used by this dataset or attribute. // p_get_type calls either H5Dget_type or H5Aget_type depending on // which object invokes getTypeClass hid_t datatype_id; try { - datatype_id = p_get_type(); // returned value is already validated + datatype_id = p_get_type(); // returned value is already validated } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getTypeClass", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getTypeClass", E.getDetailMsg()); } @@ -82,8 +85,7 @@ H5T_class_t AbstractDs::getTypeClass() const // Close temporary datatype_id herr_t ret_value = H5Tclose(datatype_id); - if (ret_value < 0) - { + if (ret_value < 0) { if (fromClass() == "DataSet") throw DataTypeIException("DataSet::getTypeClass", "H5Tclose failed"); else if (fromClass() == "Attribute") @@ -91,14 +93,13 @@ H5T_class_t AbstractDs::getTypeClass() const } // Check on the returned type_class - if (type_class == H5T_NO_CLASS) - { + if (type_class == H5T_NO_CLASS) { if (fromClass() == "DataSet") throw DataTypeIException("DataSet::getTypeClass", "H5Tget_class returns H5T_NO_CLASS"); else if (fromClass() == "Attribute") throw DataTypeIException("Attribute::getTypeClass", "H5Tget_class returns H5T_NO_CLASS"); } - return(type_class); + return (type_class); } //-------------------------------------------------------------------------- @@ -109,7 +110,8 @@ H5T_class_t AbstractDs::getTypeClass() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType AbstractDs::getDataType() const +DataType +AbstractDs::getDataType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -118,12 +120,12 @@ DataType AbstractDs::getDataType() const try { DataType datatype; f_DataType_setId(&datatype, p_get_type()); - return(datatype); + return (datatype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getDataType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getDataType", E.getDetailMsg()); } } @@ -136,7 +138,8 @@ DataType AbstractDs::getDataType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -ArrayType AbstractDs::getArrayType() const +ArrayType +AbstractDs::getArrayType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -147,12 +150,12 @@ ArrayType AbstractDs::getArrayType() const // problem described in the JIRA issue HDFFV-7947 ArrayType arraytype; f_DataType_setId(&arraytype, p_get_type()); - return(arraytype); + return (arraytype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getArrayType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getArrayType", E.getDetailMsg()); } } @@ -165,7 +168,8 @@ ArrayType AbstractDs::getArrayType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType AbstractDs::getCompType() const +CompType +AbstractDs::getCompType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -174,12 +178,12 @@ CompType AbstractDs::getCompType() const try { CompType comptype; f_DataType_setId(&comptype, p_get_type()); - return(comptype); + return (comptype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getCompType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getCompType", E.getDetailMsg()); } } @@ -192,7 +196,8 @@ CompType AbstractDs::getCompType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType AbstractDs::getEnumType() const +EnumType +AbstractDs::getEnumType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -201,12 +206,12 @@ EnumType AbstractDs::getEnumType() const try { EnumType enumtype; f_DataType_setId(&enumtype, p_get_type()); - return(enumtype); + return (enumtype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getEnumType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getEnumType", E.getDetailMsg()); } } @@ -219,7 +224,8 @@ EnumType AbstractDs::getEnumType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType AbstractDs::getIntType() const +IntType +AbstractDs::getIntType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -228,12 +234,12 @@ IntType AbstractDs::getIntType() const try { IntType inttype; f_DataType_setId(&inttype, p_get_type()); - return(inttype); + return (inttype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getIntType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getIntType", E.getDetailMsg()); } } @@ -246,7 +252,8 @@ IntType AbstractDs::getIntType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType AbstractDs::getFloatType() const +FloatType +AbstractDs::getFloatType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -255,12 +262,12 @@ FloatType AbstractDs::getFloatType() const try { FloatType floatype; f_DataType_setId(&floatype, p_get_type()); - return(floatype); + return (floatype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getFloatType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getFloatType", E.getDetailMsg()); } } @@ -273,7 +280,8 @@ FloatType AbstractDs::getFloatType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType AbstractDs::getStrType() const +StrType +AbstractDs::getStrType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -282,12 +290,12 @@ StrType AbstractDs::getStrType() const try { StrType strtype; f_DataType_setId(&strtype, p_get_type()); - return(strtype); + return (strtype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getStrType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getStrType", E.getDetailMsg()); } } @@ -300,7 +308,8 @@ StrType AbstractDs::getStrType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -VarLenType AbstractDs::getVarLenType() const +VarLenType +AbstractDs::getVarLenType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -309,12 +318,12 @@ VarLenType AbstractDs::getVarLenType() const try { VarLenType varlentype; f_DataType_setId(&varlentype, p_get_type()); - return(varlentype); + return (varlentype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getVarLenType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getVarLenType", E.getDetailMsg()); } } @@ -324,6 +333,8 @@ VarLenType AbstractDs::getVarLenType() const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AbstractDs::~AbstractDs() {} +AbstractDs::~AbstractDs() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5AbstractDs.h b/c++/src/H5AbstractDs.h index 399e033..b84867b 100644 --- a/c++/src/H5AbstractDs.h +++ b/c++/src/H5AbstractDs.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __AbstractDs_H -#define __AbstractDs_H +#ifndef H5AbstractDs_H +#define H5AbstractDs_H namespace H5 { @@ -34,51 +34,51 @@ class DataSpace; and DataSet. */ class H5_DLLCPP AbstractDs { - public: - // Gets a copy the datatype of that this abstract dataset uses. - // Note that this datatype is a generic one and can only be accessed - // via generic member functions, i.e., member functions belong - // to DataType. To get specific datatype, i.e. EnumType, FloatType, - // etc..., use the specific functions, that follow, instead. - DataType getDataType() const; - - // Gets a copy of the specific datatype of this abstract dataset. - ArrayType getArrayType() const; - CompType getCompType() const; - EnumType getEnumType() const; - IntType getIntType() const; - FloatType getFloatType() const; - StrType getStrType() const; - VarLenType getVarLenType() const; - - ///\brief Gets the size in memory of this abstract dataset. - virtual size_t getInMemDataSize() const = 0; - - ///\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; - - ///\brief Returns the amount of storage size required - pure virtual. - virtual hsize_t getStorageSize() const = 0; - - // Returns this class name - pure virtual. - virtual H5std_string fromClass() const = 0; - - // Destructor - virtual ~AbstractDs(); - - protected: - // Default constructor - AbstractDs(); - - private: - // This member function is implemented by DataSet and Attribute - pure virtual. - virtual hid_t p_get_type() const = 0; + public: + // Gets a copy the datatype of that this abstract dataset uses. + // Note that this datatype is a generic one and can only be accessed + // via generic member functions, i.e., member functions belong + // to DataType. To get specific datatype, i.e. EnumType, FloatType, + // etc..., use the specific functions, that follow, instead. + DataType getDataType() const; + + // Gets a copy of the specific datatype of this abstract dataset. + ArrayType getArrayType() const; + CompType getCompType() const; + EnumType getEnumType() const; + IntType getIntType() const; + FloatType getFloatType() const; + StrType getStrType() const; + VarLenType getVarLenType() const; + + ///\brief Gets the size in memory of this abstract dataset. + virtual size_t getInMemDataSize() const = 0; + + ///\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; + + ///\brief Returns the amount of storage size required - pure virtual. + virtual hsize_t getStorageSize() const = 0; + + // Returns this class name - pure virtual. + virtual H5std_string fromClass() const = 0; + + // Destructor + virtual ~AbstractDs(); + + protected: + // Default constructor + AbstractDs(); + + private: + // This member function is implemented by DataSet and Attribute - pure virtual. + virtual hid_t p_get_type() const = 0; }; // end of AbstractDs } // namespace H5 -#endif // __AbstractDs_H +#endif // H5AbstractDs_H diff --git a/c++/src/H5Alltypes.h b/c++/src/H5Alltypes.h index d67f3fe..7a14774 100644 --- a/c++/src/H5Alltypes.h +++ b/c++/src/H5Alltypes.h @@ -7,7 +7,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp index 0dab8ef..6999f1b 100644 --- a/c++/src/H5ArrayType.cpp +++ b/c++/src/H5ArrayType.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -34,7 +34,9 @@ namespace H5 { ///\brief Default constructor: Creates a stub ArrayType // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -ArrayType::ArrayType() : DataType() {} +ArrayType::ArrayType() : DataType() +{ +} //-------------------------------------------------------------------------- // Function: ArrayType overloaded constructor @@ -43,14 +45,18 @@ ArrayType::ArrayType() : DataType() {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -ArrayType::ArrayType(const hid_t existing_id) : DataType(existing_id) {} +ArrayType::ArrayType(const hid_t existing_id) : DataType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: ArrayType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -ArrayType::ArrayType(const ArrayType& original) : DataType(original) {} +ArrayType::ArrayType(const ArrayType &original) : DataType(original) +{ +} //-------------------------------------------------------------------------- // Function: ArrayType overloaded constructor @@ -62,7 +68,7 @@ ArrayType::ArrayType(const ArrayType& original) : DataType(original) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -ArrayType::ArrayType(const DataType& base_type, int ndims, const hsize_t* dims) : DataType() +ArrayType::ArrayType(const DataType &base_type, int ndims, const hsize_t *dims) : DataType() { // Call C API to create an array data type hid_t new_type_id = H5Tarray_create2(base_type.getId(), ndims, dims); @@ -87,7 +93,7 @@ ArrayType::ArrayType(const DataType& base_type, int ndims, const hsize_t* dims) // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -ArrayType::ArrayType(const H5Location& loc, const char *dtype_name) : DataType() +ArrayType::ArrayType(const H5Location &loc, const char *dtype_name) : DataType() { id = p_opentype(loc, dtype_name); } @@ -106,7 +112,7 @@ ArrayType::ArrayType(const H5Location& loc, const char *dtype_name) : DataType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -ArrayType::ArrayType(const H5Location& loc, const H5std_string& dtype_name) : DataType() +ArrayType::ArrayType(const H5Location &loc, const H5std_string &dtype_name) : DataType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -122,21 +128,21 @@ ArrayType::ArrayType(const H5Location& loc, const H5std_string& dtype_name) : Da // each data member from the rhs object. (Issue HDFFV-9562) // Programmer Binh-Minh Ribler - Mar 2016 //-------------------------------------------------------------------------- -ArrayType& ArrayType::operator=(const ArrayType& rhs) +ArrayType & +ArrayType::operator=(const ArrayType &rhs) { - if (this != &rhs) - { + if (this != &rhs) { // handling references to this id try { setId(rhs.id); // Note: a = b, so there are two objects with the same hdf5 id // that's why incRefCount is needed, and it is called by setId } - catch (Exception& close_error) { + catch (Exception &close_error) { throw DataTypeIException(inMemFunc("operator="), close_error.getDetailMsg()); } } - return(*this); + return (*this); } //-------------------------------------------------------------------------- @@ -147,7 +153,8 @@ ArrayType& ArrayType::operator=(const ArrayType& rhs) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* ArrayType::decode() const +DataType * +ArrayType::decode() const { hid_t encoded_arrtype_id = H5I_INVALID_HID; try { @@ -158,7 +165,7 @@ DataType* ArrayType::decode() const } ArrayType *encoded_arrtype = new ArrayType; encoded_arrtype->p_setId(encoded_arrtype_id); - return(encoded_arrtype); + return (encoded_arrtype); } //-------------------------------------------------------------------------- @@ -168,16 +175,16 @@ DataType* ArrayType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -int ArrayType::getArrayNDims() const +int +ArrayType::getArrayNDims() const { // Get the rank of the array type specified by id from the C API int ndims = H5Tget_array_ndims(id); - if (ndims < 0) - { + if (ndims < 0) { throw DataTypeIException("ArrayType::getArrayNDims", "H5Tget_array_ndims failed"); } - return(ndims); + return (ndims); } //-------------------------------------------------------------------------- @@ -188,7 +195,8 @@ int ArrayType::getArrayNDims() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -int ArrayType::getArrayDims(hsize_t* dims) const +int +ArrayType::getArrayDims(hsize_t *dims) const { // Get the dimensions int ndims = H5Tget_array_dims2(id, dims); @@ -196,7 +204,7 @@ int ArrayType::getArrayDims(hsize_t* dims) const throw DataTypeIException("ArrayType::getArrayDims", "H5Tget_array_dims2 failed"); // Return the number of dimensions - return(ndims); + return (ndims); } //-------------------------------------------------------------------------- @@ -204,6 +212,8 @@ int ArrayType::getArrayDims(hsize_t* dims) const ///\brief Properly terminates access to this array datatype. // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -ArrayType::~ArrayType() {} +ArrayType::~ArrayType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5ArrayType.h b/c++/src/H5ArrayType.h index d99b936..4302352 100644 --- a/c++/src/H5ArrayType.h +++ b/c++/src/H5ArrayType.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5ArrayType_H -#define __H5ArrayType_H +#ifndef H5ArrayType_H +#define H5ArrayType_H namespace H5 { @@ -23,46 +23,50 @@ namespace H5 { */ // Inheritance: DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP ArrayType : public DataType { - public: - // Constructor that creates a new array data type based on the - // specified base type. - ArrayType(const DataType& base_type, int ndims, const hsize_t* dims); + public: + // Constructor that creates a new array data type based on the + // specified base type. + ArrayType(const DataType &base_type, int ndims, const hsize_t *dims); - // Assignment operator - ArrayType& operator=(const ArrayType& rhs); + // Assignment operator + ArrayType &operator=(const ArrayType &rhs); - // Constructors that open an array datatype, given a location. - ArrayType(const H5Location& loc, const char* name); - ArrayType(const H5Location& loc, const H5std_string& name); + // Constructors that open an array datatype, given a location. + ArrayType(const H5Location &loc, const char *name); + ArrayType(const H5Location &loc, const H5std_string &name); - // Returns an ArrayType object via DataType* by decoding the - // binary object description of this type. - virtual DataType* decode() const; + // Returns an ArrayType object via DataType* by decoding the + // binary object description of this type. + virtual DataType *decode() const; - // Returns the number of dimensions of this array datatype. - int getArrayNDims() const; - //int getArrayNDims(); // removed 1.8.18 and 1.10.1 + // Returns the number of dimensions of this array datatype. + int getArrayNDims() const; + // int getArrayNDims(); // removed 1.8.18 and 1.10.1 - // Returns the sizes of dimensions of this array datatype. - int getArrayDims(hsize_t* dims) const; - //int getArrayDims(hsize_t* dims); // removed 1.8.18 and 1.10.1 + // Returns the sizes of dimensions of this array datatype. + int getArrayDims(hsize_t *dims) const; + // int getArrayDims(hsize_t* dims); // removed 1.8.18 and 1.10.1 - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("ArrayType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("ArrayType"); + } - // Copy constructor: same as the original ArrayType. - ArrayType(const ArrayType& original); + // Copy constructor: same as the original ArrayType. + ArrayType(const ArrayType &original); - // Constructor that takes an existing id - ArrayType(const hid_t existing_id); + // Constructor that takes an existing id + ArrayType(const hid_t existing_id); - // Noop destructor - virtual ~ArrayType(); + // Noop destructor + virtual ~ArrayType(); - // Default constructor - ArrayType(); + // Default constructor + ArrayType(); }; // end of ArrayType } // namespace H5 -#endif // __H5ArrayType_H +#endif // H5ArrayType_H diff --git a/c++/src/H5AtomType.cpp b/c++/src/H5AtomType.cpp index 9408452..0b48046 100644 --- a/c++/src/H5AtomType.cpp +++ b/c++/src/H5AtomType.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -35,7 +35,9 @@ namespace H5 { // Purpose Default constructor: creates a stub atomic datatype. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AtomType::AtomType() : DataType() {} +AtomType::AtomType() : DataType() +{ +} //-------------------------------------------------------------------------- // Function: AtomType overloaded constructor [protected] @@ -44,14 +46,18 @@ AtomType::AtomType() : DataType() {} // Exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AtomType::AtomType(const hid_t existing_id) : DataType(existing_id) {} +AtomType::AtomType(const hid_t existing_id) : DataType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: AtomType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AtomType::AtomType(const AtomType& original) : DataType(original) {} +AtomType::AtomType(const AtomType &original) : DataType(original) +{ +} #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- @@ -61,12 +67,12 @@ AtomType::AtomType(const AtomType& original) : DataType(original) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setSize(size_t size) const +void +AtomType::setSize(size_t size) const { // Call C routine H5Tset_size to set the total size herr_t ret_value = H5Tset_size(id, size); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("setSize"), "H5Tset_size failed"); } } @@ -81,18 +87,17 @@ void AtomType::setSize(size_t size) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- -H5T_order_t AtomType::getOrder() const +H5T_order_t +AtomType::getOrder() const { // Call C routine to get the byte ordering H5T_order_t type_order = H5Tget_order(id); // return a byte order constant if successful - if (type_order == H5T_ORDER_ERROR) - { - throw DataTypeIException(inMemFunc("getOrder"), - "H5Tget_order returns H5T_ORDER_ERROR"); + if (type_order == H5T_ORDER_ERROR) { + throw DataTypeIException(inMemFunc("getOrder"), "H5Tget_order returns H5T_ORDER_ERROR"); } - return(type_order); + return (type_order); } //-------------------------------------------------------------------------- @@ -112,7 +117,8 @@ H5T_order_t AtomType::getOrder() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_order_t AtomType::getOrder(H5std_string& order_string) const +H5T_order_t +AtomType::getOrder(H5std_string &order_string) const { // Call the overloaded to get the type order without text H5T_order_t type_order = getOrder(); @@ -124,7 +130,7 @@ H5T_order_t AtomType::getOrder(H5std_string& order_string) const order_string = "Big endian byte ordering (1)"; else if (type_order == H5T_ORDER_VAX) order_string = "VAX mixed byte ordering (2)"; - return(type_order); + return (type_order); } //-------------------------------------------------------------------------- @@ -137,12 +143,12 @@ H5T_order_t AtomType::getOrder(H5std_string& order_string) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setOrder(H5T_order_t order) const +void +AtomType::setOrder(H5T_order_t order) const { // Call C routine to set the byte ordering herr_t ret_value = H5Tset_order(id, order); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("setOrder"), "H5Tset_order failed"); } } @@ -158,17 +164,17 @@ void AtomType::setOrder(H5T_order_t order) const /// value returned by \c DataType::getSize(). // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -size_t AtomType::getPrecision() const +size_t +AtomType::getPrecision() const { - size_t num_signi_bits = H5Tget_precision(id); // C routine + size_t num_signi_bits = H5Tget_precision(id); // C routine // returns number of significant bits if successful - if (num_signi_bits == 0) - { + if (num_signi_bits == 0) { throw DataTypeIException(inMemFunc("getPrecision"), - "H5Tget_precision returns invalid number of significant bits"); + "H5Tget_precision returns invalid number of significant bits"); } - return(num_signi_bits); + return (num_signi_bits); } //-------------------------------------------------------------------------- @@ -181,12 +187,12 @@ size_t AtomType::getPrecision() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setPrecision(size_t precision) const +void +AtomType::setPrecision(size_t precision) const { // Call C routine to set the datatype precision herr_t ret_value = H5Tset_precision(id, precision); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("setPrecision"), "H5Tset_precision failed"); } } @@ -205,17 +211,16 @@ void AtomType::setPrecision(size_t precision) const // - return type changed from size_t to int // - offset = -1 when failure occurs vs. 0 //-------------------------------------------------------------------------- -int AtomType::getOffset() const +int +AtomType::getOffset() const { - int offset = H5Tget_offset(id); // C routine + int offset = H5Tget_offset(id); // C routine // returns a non-negative offset value if successful - if (offset == -1) - { - throw DataTypeIException(inMemFunc("getOffset"), - "H5Tget_offset returns a negative offset value"); + if (offset == -1) { + throw DataTypeIException(inMemFunc("getOffset"), "H5Tget_offset returns a negative offset value"); } - return(offset); + return (offset); } //-------------------------------------------------------------------------- @@ -228,12 +233,12 @@ int AtomType::getOffset() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setOffset(size_t offset) const +void +AtomType::setOffset(size_t offset) const { // Call C routine to set the bit offset herr_t ret_value = H5Tset_offset(id, offset); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("setOffset"), "H5Tset_offset failed"); } } @@ -252,12 +257,12 @@ void AtomType::setOffset(size_t offset) const /// \li \c H5T_PAD_BACKGROUND (2) - Leave background alone. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::getPad(H5T_pad_t& lsb, H5T_pad_t& msb) const +void +AtomType::getPad(H5T_pad_t &lsb, H5T_pad_t &msb) const { // Call C routine to get the padding type herr_t ret_value = H5Tget_pad(id, &lsb, &msb); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("getPad"), "H5Tget_pad failed"); } } @@ -275,12 +280,12 @@ void AtomType::getPad(H5T_pad_t& lsb, H5T_pad_t& msb) const /// \li \c H5T_PAD_BACKGROUND (2) - Leave background alone. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setPad(H5T_pad_t lsb, H5T_pad_t msb) const +void +AtomType::setPad(H5T_pad_t lsb, H5T_pad_t msb) const { // Call C routine to set the padding type herr_t ret_value = H5Tset_pad(id, lsb, msb); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("setPad"), "H5Tset_pad failed"); } } @@ -291,7 +296,9 @@ void AtomType::setPad(H5T_pad_t lsb, H5T_pad_t msb) const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AtomType::~AtomType() {} +AtomType::~AtomType() +{ +} #endif // DOXYGEN_SHOULD_SKIP_THIS -} // end namespace +} // namespace H5 diff --git a/c++/src/H5AtomType.h b/c++/src/H5AtomType.h index 80271ac..84da5e9 100644 --- a/c++/src/H5AtomType.h +++ b/c++/src/H5AtomType.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5AtomType_H -#define __H5AtomType_H +#ifndef H5AtomType_H +#define H5AtomType_H namespace H5 { @@ -26,57 +26,61 @@ namespace H5 { */ // Inheritance: DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP AtomType : public DataType { - public: - // Returns the byte order of an atomic datatype. - H5T_order_t getOrder() const; - H5T_order_t getOrder(H5std_string& order_string) const; + public: + // Returns the byte order of an atomic datatype. + H5T_order_t getOrder() const; + H5T_order_t getOrder(H5std_string &order_string) const; - // Sets the byte ordering of an atomic datatype. - void setOrder(H5T_order_t order) const; + // Sets the byte ordering of an atomic datatype. + void setOrder(H5T_order_t order) const; - // Retrieves the bit offset of the first significant bit. - // 12/05/00 - changed return type to int from size_t - C API - int getOffset() const; + // Retrieves the bit offset of the first significant bit. + // 12/05/00 - changed return type to int from size_t - C API + int getOffset() const; - // Sets the bit offset of the first significant bit. - void setOffset(size_t offset) const; + // Sets the bit offset of the first significant bit. + void setOffset(size_t offset) const; - // Retrieves the padding type of the least and most-significant bit padding. - void getPad(H5T_pad_t& lsb, H5T_pad_t& msb) const; + // Retrieves the padding type of the least and most-significant bit padding. + void getPad(H5T_pad_t &lsb, H5T_pad_t &msb) const; - // Sets the least and most-significant bits padding types - void setPad(H5T_pad_t lsb, H5T_pad_t msb) const; + // Sets the least and most-significant bits padding types + void setPad(H5T_pad_t lsb, H5T_pad_t msb) const; - // Returns the precision of an atomic datatype. - size_t getPrecision() const; + // Returns the precision of an atomic datatype. + size_t getPrecision() const; - // Sets the precision of an atomic datatype. - void setPrecision(size_t precision) const; + // Sets the precision of an atomic datatype. + void setPrecision(size_t precision) const; - // Sets the total size for an atomic datatype. - void setSize(size_t size) const; + // Sets the total size for an atomic datatype. + void setSize(size_t size) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("AtomType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("AtomType"); + } #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Copy constructor: same as the original AtomType. - AtomType(const AtomType& original); + // Copy constructor: same as the original AtomType. + AtomType(const AtomType &original); - // Noop destructor - virtual ~AtomType(); + // Noop destructor + virtual ~AtomType(); #endif // DOXYGEN_SHOULD_SKIP_THIS - protected: + protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Default constructor - AtomType(); + // Default constructor + AtomType(); - // Constructor that takes an existing id - AtomType(const hid_t existing_id); + // Constructor that takes an existing id + AtomType(const hid_t existing_id); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of AtomType } // namespace H5 -#endif // __H5AtomType_H +#endif // H5AtomType_H diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index 33f992a..0e37c2b 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -6,19 +6,15 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif #include <string> -#include "H5private.h" // for HDfree +#include "H5private.h" // for HDfree #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -41,14 +37,16 @@ namespace H5 { using std::cerr; using std::endl; -class H5_DLLCPP H5Object; // forward declaration for UserData4Aiterate +class H5Object; // forward declaration for UserData4Aiterate //-------------------------------------------------------------------------- // Function: Attribute default constructor ///\brief Default constructor: Creates a stub attribute // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -Attribute::Attribute() : AbstractDs(), H5Location(), id(H5I_INVALID_HID) {} +Attribute::Attribute() : AbstractDs(), H5Location(), id(H5I_INVALID_HID) +{ +} //-------------------------------------------------------------------------- // Function: Attribute copy constructor @@ -56,7 +54,7 @@ Attribute::Attribute() : AbstractDs(), H5Location(), id(H5I_INVALID_HID) {} ///\param original - IN: Original Attribute object to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute::Attribute(const Attribute& original) : AbstractDs(), H5Location(), id(original.id) +Attribute::Attribute(const Attribute &original) : AbstractDs(), H5Location(), id(original.id) { incRefCount(); // increment number of references to this id } @@ -82,11 +80,11 @@ Attribute::Attribute(const hid_t existing_id) : AbstractDs(), H5Location(), id(e ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Attribute::write(const DataType& mem_type, const void *buf) const +void +Attribute::write(const DataType &mem_type, const void *buf) const { - herr_t ret_value = H5Awrite(id, mem_type.getId(), buf); - if (ret_value < 0) - { + herr_t ret_value = H5Awrite(id, mem_type.getId(), buf); + if (ret_value < 0) { throw AttributeIException("Attribute::write", "H5Awrite failed"); } } @@ -100,32 +98,29 @@ void Attribute::write(const DataType& mem_type, const void *buf) const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - Apr, 2003 //-------------------------------------------------------------------------- -void Attribute::write(const DataType& mem_type, const H5std_string& strg) const +void +Attribute::write(const DataType &mem_type, const H5std_string &strg) const { // Check if this attribute has variable-len string or fixed-len string and // proceed appropriately. htri_t is_variable_len = H5Tis_variable_str(mem_type.getId()); - if (is_variable_len < 0) - { + if (is_variable_len < 0) { throw AttributeIException("Attribute::write", "H5Tis_variable_str failed"); } // Convert string to C-string - const char* strg_C; - strg_C = strg.c_str(); // strg_C refers to the contents of strg as a C-str + const char *strg_C; + strg_C = strg.c_str(); // strg_C refers to the contents of strg as a C-str herr_t ret_value = 0; // Pass string in differently depends on variable or fixed length - if (!is_variable_len) - { + if (!is_variable_len) { ret_value = H5Awrite(id, mem_type.getId(), strg_C); } - else - { + else { // passing third argument by address ret_value = H5Awrite(id, mem_type.getId(), &strg_C); } - if (ret_value < 0) - { + if (ret_value < 0) { throw AttributeIException("Attribute::write", "H5Awrite failed"); } } @@ -138,11 +133,11 @@ void Attribute::write(const DataType& mem_type, const H5std_string& strg) const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Attribute::read(const DataType& mem_type, void *buf) const +void +Attribute::read(const DataType &mem_type, void *buf) const { - herr_t ret_value = H5Aread(id, mem_type.getId(), buf); - if (ret_value < 0) - { + herr_t ret_value = H5Aread(id, mem_type.getId(), buf); + if (ret_value < 0) { throw AttributeIException("Attribute::read", "H5Aread failed"); } } @@ -167,22 +162,21 @@ void Attribute::read(const DataType& mem_type, void *buf) const // variable-len string data: p_read_fixed_len and // p_read_variable_len. This should improve readability. -BMR //-------------------------------------------------------------------------- -void Attribute::read(const DataType& mem_type, H5std_string& strg) const +void +Attribute::read(const DataType &mem_type, H5std_string &strg) const { // Check if this attribute has variable-len string or fixed-len string and // proceed appropriately. htri_t is_variable_len = H5Tis_variable_str(mem_type.getId()); - if (is_variable_len < 0) - { + if (is_variable_len < 0) { throw AttributeIException("Attribute::read", "H5Tis_variable_str failed"); } - if (!is_variable_len) // only allocate for fixed-len string + if (!is_variable_len) // only allocate for fixed-len string { p_read_fixed_len(mem_type, strg); } - else - { + else { p_read_variable_len(mem_type, strg); } } @@ -194,62 +188,55 @@ void Attribute::read(const DataType& mem_type, H5std_string& strg) const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - Apr 2009 //-------------------------------------------------------------------------- -size_t Attribute::getInMemDataSize() const +size_t +Attribute::getInMemDataSize() const { const char *func = "Attribute::getInMemDataSize"; // Get the data type of this attribute hid_t mem_type_id = H5Aget_type(id); - if (mem_type_id < 0) - { + if (mem_type_id < 0) { throw AttributeIException(func, "H5Aget_type failed"); } // Get the data type's size by first getting its native type then getting // the native type's size. hid_t native_type = H5Tget_native_type(mem_type_id, H5T_DIR_DEFAULT); - if (native_type < 0) - { + if (native_type < 0) { throw AttributeIException(func, "H5Tget_native_type failed"); } size_t type_size = H5Tget_size(native_type); - if (type_size == 0) - { + if (type_size == 0) { throw AttributeIException(func, "H5Tget_size failed"); } // Close the native type and the datatype of this attribute. - if (H5Tclose(native_type) < 0) - { + if (H5Tclose(native_type) < 0) { throw DataSetIException(func, "H5Tclose(native_type) failed"); } - if (H5Tclose(mem_type_id) < 0) - { + if (H5Tclose(mem_type_id) < 0) { throw DataSetIException(func, "H5Tclose(mem_type_id) failed"); } // Get number of elements of the attribute by first getting its dataspace // then getting the number of elements in the dataspace hid_t space_id = H5Aget_space(id); - if (space_id < 0) - { + if (space_id < 0) { throw AttributeIException(func, "H5Aget_space failed"); } hssize_t num_elements = H5Sget_simple_extent_npoints(space_id); - if (num_elements < 0) - { + if (num_elements < 0) { throw AttributeIException(func, "H5Sget_simple_extent_npoints failed"); } // Close the dataspace - if (H5Sclose(space_id) < 0) - { + if (H5Sclose(space_id) < 0) { throw DataSetIException(func, "H5Sclose failed"); } // Calculate and return the size of the data size_t data_size = type_size * num_elements; - return(data_size); + return (data_size); } //-------------------------------------------------------------------------- @@ -259,20 +246,19 @@ size_t Attribute::getInMemDataSize() const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace Attribute::getSpace() const +DataSpace +Attribute::getSpace() const { - // Calls C function H5Aget_space to get the id of the dataspace - hid_t dataspace_id = H5Aget_space(id); + // Calls C function H5Aget_space to get the id of the dataspace + hid_t dataspace_id = H5Aget_space(id); - // If the dataspace id is valid, create and return the DataSpace object - if (dataspace_id > 0) - { + // If the dataspace id is valid, create and return the DataSpace object + if (dataspace_id > 0) { DataSpace dataspace; f_DataSpace_setId(&dataspace, dataspace_id); - return(dataspace); + return (dataspace); } - else - { + else { throw AttributeIException("Attribute::getSpace", "H5Aget_space failed"); } } @@ -294,22 +280,21 @@ DataSpace Attribute::getSpace() const /// first argument and ignore the second argument. // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -ssize_t Attribute::getName(char* attr_name, size_t buf_size) const +ssize_t +Attribute::getName(char *attr_name, size_t buf_size) const { // H5Aget_name will get buf_size-1 chars of the name to null terminate it ssize_t name_size = H5Aget_name(id, buf_size, attr_name); // If H5Aget_name returns a negative value, raise an exception - if (name_size < 0) - { + if (name_size < 0) { throw AttributeIException("Attribute::getName", "H5Aget_name failed"); } - else if (name_size == 0) - { + else if (name_size == 0) { throw AttributeIException("Attribute::getName", "Attribute must have a name, name length is 0"); } // Return length of the name - return(name_size); + return (name_size); } //-------------------------------------------------------------------------- @@ -322,40 +307,37 @@ ssize_t Attribute::getName(char* attr_name, size_t buf_size) const // Mar 2014 - BMR // Revised to use the modified getName() above //-------------------------------------------------------------------------- -H5std_string Attribute::getName() const +H5std_string +Attribute::getName() const { - H5std_string attr_name(""); // attribute name to return + H5std_string attr_name; // attribute name to return // Preliminary call to get the size of the attribute name ssize_t name_size = H5Aget_name(id, static_cast<size_t>(0), NULL); // If H5Aget_name failed, throw exception - if (name_size < 0) - { + if (name_size < 0) { throw AttributeIException("Attribute::getName", "H5Aget_name failed"); } - else if (name_size == 0) - { + else if (name_size == 0) { throw AttributeIException("Attribute::getName", "Attribute must have a name, name length is 0"); } // Attribute's name exists, retrieve it - else if (name_size > 0) - { - char* name_C = new char[name_size+1]; // temporary C-string - HDmemset(name_C, 0, name_size+1); // clear buffer + else if (name_size > 0) { + char *name_C = new char[name_size + 1]; // temporary C-string + HDmemset(name_C, 0, name_size + 1); // clear buffer // Use overloaded function - name_size = getName(name_C, name_size+1); + name_size = getName(name_C, name_size + 1); // Convert the C attribute name to return attr_name = name_C; // Clean up resource - delete []name_C; - + delete[] name_C; } // Return attribute's name - return(attr_name); + return (attr_name); } //-------------------------------------------------------------------------- @@ -371,14 +353,15 @@ H5std_string Attribute::getName() const // Mar 2014 - BMR // Revised to use the new getName() below //-------------------------------------------------------------------------- -H5std_string Attribute::getName(size_t len) const +H5std_string +Attribute::getName(size_t len) const { H5std_string attr_name; - ssize_t name_size = getName(attr_name, len); + ssize_t name_size = getName(attr_name, len); if (name_size < 0) - return(""); + return (""); else - return(attr_name); + return (attr_name); } //-------------------------------------------------------------------------- @@ -398,35 +381,34 @@ H5std_string Attribute::getName(size_t len) const // Added to replace getName(size_t, H5std_string&) so that it'll // allow the argument "len" to be skipped. //-------------------------------------------------------------------------- -ssize_t Attribute::getName(H5std_string& attr_name, size_t len) const +ssize_t +Attribute::getName(H5std_string &attr_name, size_t len) const { ssize_t name_size = 0; // If no length is provided, get the entire attribute name - if (len == 0) - { + if (len == 0) { attr_name = getName(); name_size = attr_name.length(); } // If length is provided, get that number of characters in name - else - { - char* name_C = new char[len+1]; // temporary C-string - HDmemset(name_C, 0, len+1); // clear buffer + else { + char *name_C = new char[len + 1]; // temporary C-string + HDmemset(name_C, 0, len + 1); // clear buffer // Use overloaded function - name_size = getName(name_C, len+1); + name_size = getName(name_C, len + 1); // Convert the C attribute name to return attr_name = name_C; // Clean up resource - delete []name_C; + delete[] name_C; } // Otherwise, keep attr_name intact // Return name size - return(name_size); + return (name_size); } //-------------------------------------------------------------------------- @@ -444,7 +426,7 @@ ssize_t Attribute::getName(H5std_string& attr_name, size_t len) const // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//ssize_t Attribute::getName(size_t len, H5std_string& attr_name) const +// ssize_t Attribute::getName(size_t len, H5std_string& attr_name) const //{ // return (getName(attr_name, len)); //} @@ -458,10 +440,11 @@ ssize_t Attribute::getName(H5std_string& attr_name, size_t len) const // function should have no failure. (from SLU) // Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- -hsize_t Attribute::getStorageSize() const +hsize_t +Attribute::getStorageSize() const { - hsize_t storage_size = H5Aget_storage_size(id); - return (storage_size); + hsize_t storage_size = H5Aget_storage_size(id); + return (storage_size); } //-------------------------------------------------------------------------- @@ -480,9 +463,10 @@ hsize_t Attribute::getStorageSize() const // an attribute id can be used to specify a location in HDF5 // library. //-------------------------------------------------------------------------- -hid_t Attribute::getId() const +hid_t +Attribute::getId() const { - return(id); + return (id); } //-------------------------------------------------------------------------- @@ -494,13 +478,13 @@ hid_t Attribute::getId() const // This private function is used in AbstractDs. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hid_t Attribute::p_get_type() const +hid_t +Attribute::p_get_type() const { hid_t type_id = H5Aget_type(id); if (type_id > 0) - return(type_id); - else - { + return (type_id); + else { throw AttributeIException("", "H5Aget_type failed"); } } @@ -517,7 +501,8 @@ hid_t Attribute::p_get_type() const // Separated the fixed length case from the original // Attribute::read //-------------------------------------------------------------------------- -void Attribute::p_read_fixed_len(const DataType& mem_type, H5std_string& strg) const +void +Attribute::p_read_fixed_len(const DataType &mem_type, H5std_string &strg) const { // Only allocate for fixed-len string. @@ -525,19 +510,17 @@ void Attribute::p_read_fixed_len(const DataType& mem_type, H5std_string& strg) c size_t attr_size = getInMemDataSize(); // If there is data, allocate buffer and read it. - if (attr_size > 0) - { - char *strg_C = new char[attr_size+1]; + if (attr_size > 0) { + char * strg_C = new char[attr_size + 1]; herr_t ret_value = H5Aread(id, mem_type.getId(), strg_C); - if (ret_value < 0) - { - delete []strg_C; // de-allocate for fixed-len string + if (ret_value < 0) { + delete[] strg_C; // de-allocate for fixed-len string throw AttributeIException("Attribute::read", "H5Aread failed"); } // Get string from the C char* and release resource allocated locally strg_C[attr_size] = '\0'; - strg = strg_C; - delete []strg_C; + strg = strg_C; + delete[] strg_C; } } @@ -553,7 +536,8 @@ void Attribute::p_read_fixed_len(const DataType& mem_type, H5std_string& strg) c // Separated the variable length case from the original // Attribute::read. -BMR //-------------------------------------------------------------------------- -void Attribute::p_read_variable_len(const DataType& mem_type, H5std_string& strg) const +void +Attribute::p_read_variable_len(const DataType &mem_type, H5std_string &strg) const { // Prepare and call C API to read attribute. char *strg_C; @@ -561,8 +545,7 @@ void Attribute::p_read_variable_len(const DataType& mem_type, H5std_string& strg // Read attribute, no allocation for variable-len string; C library will herr_t ret_value = H5Aread(id, mem_type.getId(), &strg_C); - if (ret_value < 0) - { + if (ret_value < 0) { throw AttributeIException("Attribute::read", "H5Aread failed"); } @@ -584,13 +567,14 @@ void Attribute::p_read_variable_len(const DataType& mem_type, H5std_string& strg // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Attribute::p_setId(const hid_t new_id) +void +Attribute::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw AttributeIException("Attribute::p_setId", close_error.getDetailMsg()); } // reset object's id to the given id @@ -605,13 +589,12 @@ void Attribute::p_setId(const hid_t new_id) ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void Attribute::close() +void +Attribute::close() { - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Aclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw AttributeIException("Attribute::close", "H5Aclose failed"); } // reset the id @@ -634,9 +617,9 @@ Attribute::~Attribute() try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { cerr << "Attribute::~Attribute - " << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h index c6fdaec..41e5a31 100644 --- a/c++/src/H5Attribute.h +++ b/c++/src/H5Attribute.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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 namespace H5 { @@ -27,78 +27,81 @@ namespace H5 { */ // Inheritance: multiple H5Location/AbstractDs -> IdComponent class H5_DLLCPP Attribute : public AbstractDs, public H5Location { - public: + public: + // Copy constructor: same as the original Attribute. + Attribute(const Attribute &original); - // Copy constructor: same as the original Attribute. - Attribute(const Attribute& original); + // Default constructor + Attribute(); - // Default constructor - Attribute(); + // Creates a copy of an existing attribute using the attribute id + Attribute(const hid_t attr_id); - // Creates a copy of an existing attribute using the attribute id - Attribute(const hid_t attr_id); + // Closes this attribute. + virtual void close(); - // Closes this attribute. - virtual void close(); + // Gets the name of this attribute. + ssize_t getName(char *attr_name, size_t buf_size = 0) const; + H5std_string getName(size_t len) const; + H5std_string getName() const; + ssize_t getName(H5std_string &attr_name, size_t len = 0) const; + // The overloaded function below is replaced by the one above and it + // is kept for backward compatibility purpose. + ssize_t getName(size_t buf_size, H5std_string &attr_name) const; - // Gets the name of this attribute. - ssize_t getName(char* attr_name, size_t buf_size = 0) const; - H5std_string getName(size_t len) const; - H5std_string getName() const; - ssize_t getName(H5std_string& attr_name, size_t len = 0) const; - // The overloaded function below is replaced by the one above and it - // is kept for backward compatibility purpose. - ssize_t getName(size_t buf_size, H5std_string& attr_name) const; + // Gets a copy of the dataspace for this attribute. + virtual DataSpace getSpace() const; - // Gets a copy of the dataspace for this attribute. - virtual DataSpace getSpace() const; + // Returns the amount of storage size required for this attribute. + virtual hsize_t getStorageSize() const; - // Returns the amount of storage size required for this attribute. - virtual hsize_t getStorageSize() const; + // Returns the in memory size of this attribute's data. + virtual size_t getInMemDataSize() const; - // Returns the in memory size of this attribute's data. - virtual size_t getInMemDataSize() const; + // Reads data from this attribute. + void read(const DataType &mem_type, void *buf) const; + void read(const DataType &mem_type, H5std_string &strg) const; - // Reads data from this attribute. - void read(const DataType& mem_type, void *buf) const; - void read(const DataType& mem_type, H5std_string& strg) const; + // Writes data to this attribute. + void write(const DataType &mem_type, const void *buf) const; + void write(const DataType &mem_type, const H5std_string &strg) const; - // Writes data to this attribute. - void write(const DataType& mem_type, const void *buf) const; - void write(const DataType& mem_type, const H5std_string& strg) const; + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("Attribute"); + } - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("Attribute"); } + // Gets the attribute id. + virtual hid_t getId() const; - // Gets the attribute id. - virtual hid_t getId() const; - - // Destructor: properly terminates access to this attribute. - virtual ~Attribute(); + // Destructor: properly terminates access to this attribute. + virtual ~Attribute(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - protected: - // Sets the attribute id. - virtual void p_setId(const hid_t new_id); + protected: + // Sets the attribute id. + virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS - private: - hid_t id; // HDF5 attribute id + private: + hid_t id; // HDF5 attribute id - // This function contains the common code that is used by - // getTypeClass and various API functions getXxxType - // defined in AbstractDs for generic datatype and specific - // sub-types - virtual hid_t p_get_type() const; + // This function contains the common code that is used by + // getTypeClass and various API functions getXxxType + // defined in AbstractDs for generic datatype and specific + // sub-types + virtual hid_t p_get_type() const; - // Reads variable or fixed len strings from this attribute. - void p_read_variable_len(const DataType& mem_type, H5std_string& strg) const; - void p_read_fixed_len(const DataType& mem_type, H5std_string& strg) const; + // Reads variable or fixed len strings from this attribute. + void p_read_variable_len(const DataType &mem_type, H5std_string &strg) const; + void p_read_fixed_len(const DataType &mem_type, H5std_string &strg) const; - // Friend function to set Attribute id. For library use only. - friend void f_Attribute_setId(Attribute* attr, hid_t new_id); + // Friend function to set Attribute id. For library use only. + friend void f_Attribute_setId(Attribute *attr, hid_t new_id); }; // end of Attribute } // namespace H5 -#endif // __H5Attribute_H +#endif // H5Attribute_H diff --git a/c++/src/H5Classes.h b/c++/src/H5Classes.h index 8b1e6ed..7820ce2 100644 --- a/c++/src/H5Classes.h +++ b/c++/src/H5Classes.h @@ -7,40 +7,40 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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 namespace H5 { - class Exception; - class IdComponent; - class H5Location; - class H5Object; - class PropList; - class FileCreatPropList; - class FileAccPropList; - class LinkAccPropList; - class DSetCreatPropList; - class DSetMemXferPropList; - class DTypePropList; - class DataType; - class DataSpace; - class AtomType; - class PredType; - class IntType; - class FloatType; - class StrType; - class EnumType; - class CompType; - class AbstractDs; - class DataSet; - class Group; - class H5File; - class Attribute; - class H5Library; -} -#endif // __H5Classes_H +class Exception; +class IdComponent; +class H5Location; +class H5Object; +class PropList; +class FileCreatPropList; +class FileAccPropList; +class LinkAccPropList; +class DSetCreatPropList; +class DSetMemXferPropList; +class DTypePropList; +class DataType; +class DataSpace; +class AtomType; +class PredType; +class IntType; +class FloatType; +class StrType; +class EnumType; +class CompType; +class AbstractDs; +class DataSet; +class Group; +class H5File; +class Attribute; +class H5Library; +} // namespace H5 +#endif // H5Classes_H diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp index 6c5fdca..fb602d9 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -6,14 +6,14 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include <string> -#include "H5private.h" // for HDstrcpy +#include "H5private.h" // for HDstrcpy #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -55,7 +55,8 @@ namespace H5 { ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType CommonFG::openDataType(const char* name) const +DataType +CommonFG::openDataType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -68,7 +69,7 @@ DataType CommonFG::openDataType(const char* name) const // No failure, create and return the DataType object DataType data_type; f_DataType_setId(&data_type, type_id); - return(data_type); + return (data_type); } //-------------------------------------------------------------------------- @@ -78,9 +79,10 @@ DataType CommonFG::openDataType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType CommonFG::openDataType(const H5std_string& name) const +DataType +CommonFG::openDataType(const H5std_string &name) const { - return(openDataType(name.c_str())); + return (openDataType(name.c_str())); } //-------------------------------------------------------------------------- @@ -91,7 +93,8 @@ DataType CommonFG::openDataType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -ArrayType CommonFG::openArrayType(const char* name) const +ArrayType +CommonFG::openArrayType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -104,7 +107,7 @@ ArrayType CommonFG::openArrayType(const char* name) const // No failure, create and return the ArrayType object ArrayType array_type; f_DataType_setId(&array_type, type_id); - return(array_type); + return (array_type); } //-------------------------------------------------------------------------- @@ -114,9 +117,10 @@ ArrayType CommonFG::openArrayType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -ArrayType CommonFG::openArrayType(const H5std_string& name) const +ArrayType +CommonFG::openArrayType(const H5std_string &name) const { - return(openArrayType(name.c_str())); + return (openArrayType(name.c_str())); } //-------------------------------------------------------------------------- @@ -127,7 +131,8 @@ ArrayType CommonFG::openArrayType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType CommonFG::openCompType(const char* name) const +CompType +CommonFG::openCompType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -140,7 +145,7 @@ CompType CommonFG::openCompType(const char* name) const // No failure, create and return the CompType object CompType comp_type; f_DataType_setId(&comp_type, type_id); - return(comp_type); + return (comp_type); } //-------------------------------------------------------------------------- @@ -150,9 +155,10 @@ CompType CommonFG::openCompType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType CommonFG::openCompType(const H5std_string& name) const +CompType +CommonFG::openCompType(const H5std_string &name) const { - return(openCompType(name.c_str())); + return (openCompType(name.c_str())); } //-------------------------------------------------------------------------- @@ -163,7 +169,8 @@ CompType CommonFG::openCompType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType CommonFG::openEnumType(const char* name) const +EnumType +CommonFG::openEnumType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -176,7 +183,7 @@ EnumType CommonFG::openEnumType(const char* name) const // No failure, create and return the EnumType object EnumType enum_type; f_DataType_setId(&enum_type, type_id); - return(enum_type); + return (enum_type); } //-------------------------------------------------------------------------- @@ -186,9 +193,10 @@ EnumType CommonFG::openEnumType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType CommonFG::openEnumType(const H5std_string& name) const +EnumType +CommonFG::openEnumType(const H5std_string &name) const { - return(openEnumType(name.c_str())); + return (openEnumType(name.c_str())); } //-------------------------------------------------------------------------- @@ -199,7 +207,8 @@ EnumType CommonFG::openEnumType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType CommonFG::openIntType(const char* name) const +IntType +CommonFG::openIntType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -212,7 +221,7 @@ IntType CommonFG::openIntType(const char* name) const // No failure, create and return the IntType object IntType int_type; f_DataType_setId(&int_type, type_id); - return(int_type); + return (int_type); } //-------------------------------------------------------------------------- @@ -222,9 +231,10 @@ IntType CommonFG::openIntType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType CommonFG::openIntType(const H5std_string& name) const +IntType +CommonFG::openIntType(const H5std_string &name) const { - return(openIntType(name.c_str())); + return (openIntType(name.c_str())); } //-------------------------------------------------------------------------- @@ -235,7 +245,8 @@ IntType CommonFG::openIntType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType CommonFG::openFloatType(const char* name) const +FloatType +CommonFG::openFloatType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -248,7 +259,7 @@ FloatType CommonFG::openFloatType(const char* name) const // No failure, create and return the FloatType object FloatType float_type; f_DataType_setId(&float_type, type_id); - return(float_type); + return (float_type); } //-------------------------------------------------------------------------- @@ -258,9 +269,10 @@ FloatType CommonFG::openFloatType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType CommonFG::openFloatType(const H5std_string& name) const +FloatType +CommonFG::openFloatType(const H5std_string &name) const { - return(openFloatType(name.c_str())); + return (openFloatType(name.c_str())); } //-------------------------------------------------------------------------- @@ -271,7 +283,8 @@ FloatType CommonFG::openFloatType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType CommonFG::openStrType(const char* name) const +StrType +CommonFG::openStrType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -284,7 +297,7 @@ StrType CommonFG::openStrType(const char* name) const // No failure, create and return the StrType object StrType str_type; f_DataType_setId(&str_type, type_id); - return(str_type); + return (str_type); } //-------------------------------------------------------------------------- @@ -294,9 +307,10 @@ StrType CommonFG::openStrType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType CommonFG::openStrType(const H5std_string& name) const +StrType +CommonFG::openStrType(const H5std_string &name) const { - return(openStrType(name.c_str())); + return (openStrType(name.c_str())); } //-------------------------------------------------------------------------- @@ -307,7 +321,8 @@ StrType CommonFG::openStrType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -VarLenType CommonFG::openVarLenType(const char* name) const +VarLenType +CommonFG::openVarLenType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -320,7 +335,7 @@ VarLenType CommonFG::openVarLenType(const char* name) const // No failure, create and return the VarLenType object VarLenType varlen_type; f_DataType_setId(&varlen_type, type_id); - return(varlen_type); + return (varlen_type); } //-------------------------------------------------------------------------- @@ -330,9 +345,10 @@ VarLenType CommonFG::openVarLenType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -VarLenType CommonFG::openVarLenType(const H5std_string& name) const +VarLenType +CommonFG::openVarLenType(const H5std_string &name) const { - return(openVarLenType(name.c_str())); + return (openVarLenType(name.c_str())); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -341,14 +357,18 @@ VarLenType CommonFG::openVarLenType(const H5std_string& name) const ///\brief Default constructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CommonFG::CommonFG() {} +CommonFG::CommonFG() +{ +} //-------------------------------------------------------------------------- // Function: CommonFG destructor ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CommonFG::~CommonFG() {} +CommonFG::~CommonFG() +{ +} //-------------------------------------------------------------------------- // Function: f_DataType_setId - friend @@ -360,7 +380,8 @@ CommonFG::~CommonFG() {} // param new_id - IN: New id to set // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void f_DataType_setId(DataType* dtype, hid_t new_id) +void +f_DataType_setId(DataType *dtype, hid_t new_id) { dtype->p_setId(new_id); } @@ -375,11 +396,12 @@ void f_DataType_setId(DataType* dtype, hid_t new_id) // param new_id - IN: New id to set // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void f_DataSet_setId(DataSet* dset, hid_t new_id) +void +f_DataSet_setId(DataSet *dset, hid_t new_id) { dset->p_setId(new_id); } #endif // DOXYGEN_SHOULD_SKIP_THIS -} // end namespace +} // namespace H5 diff --git a/c++/src/H5CommonFG.h b/c++/src/H5CommonFG.h index 68e3f19..d87f9ca 100644 --- a/c++/src/H5CommonFG.h +++ b/c++/src/H5CommonFG.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __CommonFG_H -#define __CommonFG_H +#ifndef H5CommonFG_H +#define H5CommonFG_H namespace H5 { @@ -28,63 +28,62 @@ class VarLenType; */ /* Note: This class is being deprecated gradually. */ class H5_DLLCPP CommonFG { - public: - // Opens a generic named datatype in this location. - DataType openDataType(const char* name) const; - DataType openDataType(const H5std_string& name) const; + public: + // Opens a generic named datatype in this location. + DataType openDataType(const char *name) const; + DataType openDataType(const H5std_string &name) const; - // Opens a named array datatype in this location. - ArrayType openArrayType(const char* name) const; - ArrayType openArrayType(const H5std_string& name) const; + // Opens a named array datatype in this location. + ArrayType openArrayType(const char *name) const; + ArrayType openArrayType(const H5std_string &name) const; - // Opens a named compound datatype in this location. - CompType openCompType(const char* name) const; - CompType openCompType(const H5std_string& name) const; + // Opens a named compound datatype in this location. + CompType openCompType(const char *name) const; + CompType openCompType(const H5std_string &name) const; - // Opens a named enumeration datatype in this location. - EnumType openEnumType(const char* name) const; - EnumType openEnumType(const H5std_string& name) const; + // Opens a named enumeration datatype in this location. + EnumType openEnumType(const char *name) const; + EnumType openEnumType(const H5std_string &name) const; - // Opens a named integer datatype in this location. - IntType openIntType(const char* name) const; - IntType openIntType(const H5std_string& name) const; + // Opens a named integer datatype in this location. + IntType openIntType(const char *name) const; + IntType openIntType(const H5std_string &name) const; - // Opens a named floating-point datatype in this location. - FloatType openFloatType(const char* name) const; - FloatType openFloatType(const H5std_string& name) const; + // Opens a named floating-point datatype in this location. + FloatType openFloatType(const char *name) const; + FloatType openFloatType(const H5std_string &name) const; - // Opens a named string datatype in this location. - StrType openStrType(const char* name) const; - StrType openStrType(const H5std_string& name) const; + // Opens a named string datatype in this location. + StrType openStrType(const char *name) const; + StrType openStrType(const H5std_string &name) const; - // Opens a named variable length datatype in this location. - VarLenType openVarLenType(const char* name) const; - VarLenType openVarLenType(const H5std_string& name) const; + // Opens a named variable length datatype in this location. + VarLenType openVarLenType(const char *name) const; + VarLenType openVarLenType(const H5std_string &name) const; #ifndef DOXYGEN_SHOULD_SKIP_THIS - /// For subclasses, H5File and Group, to return the correct - /// object id, i.e. file or group id. - virtual hid_t getLocId() const = 0; + /// For subclasses, H5File and Group, to return the correct + /// object id, i.e. file or group id. + virtual hid_t getLocId() const = 0; + /// For subclasses, H5File and Group, to throw appropriate exception. + virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const = 0; - /// For subclasses, H5File and Group, to throw appropriate exception. - virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const = 0; + // Default constructor. + CommonFG(); - // Default constructor. - CommonFG(); + // Noop destructor. + virtual ~CommonFG(); - // Noop destructor. - virtual ~CommonFG(); - - protected: - virtual void p_setId(const hid_t new_id) = 0; + protected: + virtual void p_setId(const hid_t new_id) = 0; #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of CommonFG } // namespace H5 -#endif // __CommonFG_H +#endif // H5CommonFG_H /*************************************************************************** Design Note diff --git a/c++/src/H5CompType.cpp b/c++/src/H5CompType.cpp index fe96bb0..3b38c6d 100644 --- a/c++/src/H5CompType.cpp +++ b/c++/src/H5CompType.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -37,7 +37,9 @@ namespace H5 { ///\brief Default constructor: Creates a stub compound datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::CompType() : DataType() {} +CompType::CompType() : DataType() +{ +} //-------------------------------------------------------------------------- // Function: CompType copy constructor @@ -45,7 +47,9 @@ CompType::CompType() : DataType() {} ///\param original - IN: Original CompType instance // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::CompType(const CompType& original) : DataType(original) {} +CompType::CompType(const CompType &original) : DataType(original) +{ +} //-------------------------------------------------------------------------- // Function: CompType overloaded constructor @@ -53,7 +57,9 @@ CompType::CompType(const CompType& original) : DataType(original) {} ///\param existing_id - IN: Id of an existing compound datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::CompType(const hid_t existing_id) : DataType(existing_id) {} +CompType::CompType(const hid_t existing_id) : DataType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: CompType overloaded constructor @@ -65,7 +71,9 @@ CompType::CompType(const hid_t existing_id) : DataType(existing_id) {} // the compound datatype. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::CompType(size_t size) : DataType(H5T_COMPOUND, size) {} +CompType::CompType(size_t size) : DataType(H5T_COMPOUND, size) +{ +} //-------------------------------------------------------------------------- // Function: CompType overloaded constructor @@ -75,14 +83,13 @@ CompType::CompType(size_t size) : DataType(H5T_COMPOUND, size) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::CompType(const DataSet& dataset) : DataType() +CompType::CompType(const DataSet &dataset) : DataType() { // Calls C function H5Dget_type to get the id of the datatype id = H5Dget_type(dataset.getId()); // If the datatype id is invalid, throw exception - if (id < 0) - { + if (id < 0) { throw DataSetIException("CompType constructor", "H5Dget_type failed"); } } @@ -101,7 +108,7 @@ CompType::CompType(const DataSet& dataset) : DataType() // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -CompType::CompType(const H5Location& loc, const char *dtype_name) : DataType() +CompType::CompType(const H5Location &loc, const char *dtype_name) : DataType() { id = p_opentype(loc, dtype_name); } @@ -120,7 +127,7 @@ CompType::CompType(const H5Location& loc, const char *dtype_name) : DataType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -CompType::CompType(const H5Location& loc, const H5std_string& dtype_name) : DataType() +CompType::CompType(const H5Location &loc, const H5std_string &dtype_name) : DataType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -133,7 +140,8 @@ CompType::CompType(const H5Location& loc, const H5std_string& dtype_name) : Data ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* CompType::decode() const +DataType * +CompType::decode() const { hid_t encoded_cmptype_id = H5I_INVALID_HID; try { @@ -144,7 +152,7 @@ DataType* CompType::decode() const } CompType *encoded_cmptype = new CompType; encoded_cmptype->p_setId(encoded_cmptype_id); - return(encoded_cmptype); + return (encoded_cmptype); } //-------------------------------------------------------------------------- @@ -154,15 +162,15 @@ DataType* CompType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int CompType::getNmembers() const +int +CompType::getNmembers() const { int num_members = H5Tget_nmembers(id); - if (num_members < 0) - { + if (num_members < 0) { throw DataTypeIException("CompType::getNmembers", - "H5Tget_nmembers returns negative number of members"); + "H5Tget_nmembers returns negative number of members"); } - return(num_members); + return (num_members); } //-------------------------------------------------------------------------- @@ -173,17 +181,18 @@ int CompType::getNmembers() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string CompType::getMemberName(unsigned member_num) const +H5std_string +CompType::getMemberName(unsigned member_num) const { - char* member_name_C = H5Tget_member_name(id, member_num); - if (member_name_C == NULL) // NULL means failure + char *member_name_C = H5Tget_member_name(id, member_num); + if (member_name_C == NULL) // NULL means failure { throw DataTypeIException("CompType::getMemberName", - "H5Tget_member_name returns NULL for member name"); + "H5Tget_member_name returns NULL for member name"); } H5std_string member_name = H5std_string(member_name_C); // convert C string to string - H5free_memory(member_name_C); // free the C string - return(member_name); // return the member name string + H5free_memory(member_name_C); // free the C string + return (member_name); // return the member name string } //-------------------------------------------------------------------------- @@ -198,19 +207,19 @@ H5std_string CompType::getMemberName(unsigned member_num) const /// function \c CompType::getNmembers. // Programmer Binh-Minh Ribler - May 16, 2002 //-------------------------------------------------------------------------- -int CompType::getMemberIndex(const char* name) const +int +CompType::getMemberIndex(const char *name) const { int member_index = H5Tget_member_index(id, name); - if (member_index < 0) - { - throw DataTypeIException("CompType::getMemberIndex", - "H5Tget_member_index returns negative value"); + if (member_index < 0) { + throw DataTypeIException("CompType::getMemberIndex", "H5Tget_member_index returns negative value"); } - return(member_index); + return (member_index); } -int CompType::getMemberIndex(const H5std_string& name) const +int +CompType::getMemberIndex(const H5std_string &name) const { - return(getMemberIndex(name.c_str())); + return (getMemberIndex(name.c_str())); } //-------------------------------------------------------------------------- @@ -228,10 +237,11 @@ int CompType::getMemberIndex(const H5std_string& name) const // Note that byte offset being returned as 0 doesn't indicate // a failure. (According to Quincey) //-------------------------------------------------------------------------- -size_t CompType::getMemberOffset(unsigned member_num) const +size_t +CompType::getMemberOffset(unsigned member_num) const { size_t offset = H5Tget_member_offset(id, member_num); - return(offset); + return (offset); } //-------------------------------------------------------------------------- @@ -244,29 +254,28 @@ size_t CompType::getMemberOffset(unsigned member_num) const // Modification // Modified to use H5Tget_member_class instead. - Jul, 2005 //-------------------------------------------------------------------------- -H5T_class_t CompType::getMemberClass(unsigned member_num) const +H5T_class_t +CompType::getMemberClass(unsigned member_num) const { H5T_class_t member_class = H5Tget_member_class(id, member_num); - if (member_class == H5T_NO_CLASS) - { - throw DataTypeIException("CompType::getMemberClass", - "H5Tget_member_class returns H5T_NO_CLASS"); + if (member_class == H5T_NO_CLASS) { + throw DataTypeIException("CompType::getMemberClass", "H5Tget_member_class returns H5T_NO_CLASS"); } - return(member_class); + return (member_class); } // This private member function calls the C API to get the identifier // of the specified member. It provides the id to construct appropriate // sub-types in the functions getMemberXxxType below, where Xxx indicates // the sub-types. -hid_t CompType::p_get_member_type(unsigned member_num) const +hid_t +CompType::p_get_member_type(unsigned member_num) const { // get the id of the specified member first hid_t member_type_id = H5Tget_member_type(id, member_num); if (member_type_id > 0) - return(member_type_id); - else - { + return (member_type_id); + else { // p_get_member_type is private, caller will catch this exception // then throw another with appropriate API name throw DataTypeIException("", "H5Tget_member_type failed"); @@ -282,14 +291,15 @@ hid_t CompType::p_get_member_type(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType CompType::getMemberDataType(unsigned member_num) const +DataType +CompType::getMemberDataType(unsigned member_num) const { try { DataType datatype; f_DataType_setId(&datatype, p_get_member_type(member_num)); - return(datatype); + return (datatype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberDataType", E.getDetailMsg()); } } @@ -303,14 +313,15 @@ DataType CompType::getMemberDataType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -ArrayType CompType::getMemberArrayType(unsigned member_num) const +ArrayType +CompType::getMemberArrayType(unsigned member_num) const { try { ArrayType arraytype; f_DataType_setId(&arraytype, p_get_member_type(member_num)); - return(arraytype); + return (arraytype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberArrayType", E.getDetailMsg()); } } @@ -324,14 +335,15 @@ ArrayType CompType::getMemberArrayType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType CompType::getMemberCompType(unsigned member_num) const +CompType +CompType::getMemberCompType(unsigned member_num) const { try { CompType comptype; f_DataType_setId(&comptype, p_get_member_type(member_num)); - return(comptype); + return (comptype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberCompType", E.getDetailMsg()); } } @@ -345,14 +357,15 @@ CompType CompType::getMemberCompType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType CompType::getMemberEnumType(unsigned member_num) const +EnumType +CompType::getMemberEnumType(unsigned member_num) const { try { EnumType enumtype; f_DataType_setId(&enumtype, p_get_member_type(member_num)); - return(enumtype); + return (enumtype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberEnumType", E.getDetailMsg()); } } @@ -366,14 +379,15 @@ EnumType CompType::getMemberEnumType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType CompType::getMemberIntType(unsigned member_num) const +IntType +CompType::getMemberIntType(unsigned member_num) const { try { IntType inttype; f_DataType_setId(&inttype, p_get_member_type(member_num)); - return(inttype); + return (inttype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberIntType", E.getDetailMsg()); } } @@ -387,14 +401,15 @@ IntType CompType::getMemberIntType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType CompType::getMemberFloatType(unsigned member_num) const +FloatType +CompType::getMemberFloatType(unsigned member_num) const { try { FloatType floatype; f_DataType_setId(&floatype, p_get_member_type(member_num)); - return(floatype); + return (floatype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberFloatType", E.getDetailMsg()); } } @@ -408,14 +423,15 @@ FloatType CompType::getMemberFloatType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType CompType::getMemberStrType(unsigned member_num) const +StrType +CompType::getMemberStrType(unsigned member_num) const { try { StrType strtype; f_DataType_setId(&strtype, p_get_member_type(member_num)); - return(strtype); + return (strtype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberStrType", E.getDetailMsg()); } } @@ -429,14 +445,15 @@ StrType CompType::getMemberStrType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -VarLenType CompType::getMemberVarLenType(unsigned member_num) const +VarLenType +CompType::getMemberVarLenType(unsigned member_num) const { try { VarLenType varlentype; f_DataType_setId(&varlentype, p_get_member_type(member_num)); - return(varlentype); + return (varlentype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberVarLenType", E.getDetailMsg()); } } @@ -483,18 +500,18 @@ void CompType::getMemberType(unsigned member_num, StrType& strtype) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void CompType::insertMember(const H5std_string& name, size_t offset, const DataType& new_member) const +void +CompType::insertMember(const H5std_string &name, size_t offset, const DataType &new_member) const { // Convert string to C-string - const char* name_C; - name_C = name.c_str(); // name_C refers to the contents of name as a C-str + const char *name_C; + name_C = name.c_str(); // name_C refers to the contents of name as a C-str - hid_t new_member_id = new_member.getId(); // get new_member id for C API + hid_t new_member_id = new_member.getId(); // get new_member id for C API // Call C routine H5Tinsert to add the new member herr_t ret_value = H5Tinsert(id, name_C, offset, new_member_id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("CompType::insertMember", "H5Tinsert failed"); } } @@ -506,12 +523,12 @@ void CompType::insertMember(const H5std_string& name, size_t offset, const DataT ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void CompType::pack() const +void +CompType::pack() const { // Calls C routine H5Tpack to remove padding herr_t ret_value = H5Tpack(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("CompType::pack", "H5Tpack failed"); } } @@ -525,12 +542,12 @@ void CompType::pack() const // H5Tset_size works on atom datatypes and compound datatypes only // Programmer Binh-Minh Ribler - 2014 //-------------------------------------------------------------------------- -void CompType::setSize(size_t size) const +void +CompType::setSize(size_t size) const { // Call C routine H5Tset_size to set the total size herr_t ret_value = H5Tset_size(id, size); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("CompType::setSize", "H5Tset_size failed"); } } @@ -540,6 +557,8 @@ void CompType::setSize(size_t size) const ///\brief Properly terminates access to this compound datatype. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::~CompType() {} +CompType::~CompType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5CompType.h b/c++/src/H5CompType.h index d85e2ed..6a4c093 100644 --- a/c++/src/H5CompType.h +++ b/c++/src/H5CompType.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5CompType_H -#define __H5CompType_H +#ifndef H5CompType_H +#define H5CompType_H namespace H5 { @@ -23,101 +23,105 @@ namespace H5 { */ // Inheritance: DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP CompType : public DataType { - public: - // Default constructor - CompType(); + public: + // Default constructor + CompType(); - // Creates a compound datatype using an existing id - CompType(const hid_t existing_id); + // Creates a compound datatype using an existing id + CompType(const hid_t existing_id); - // Creates a new compound datatype, given the type's size - CompType(size_t size); // H5Tcreate + // Creates a new compound datatype, given the type's size + CompType(size_t size); // H5Tcreate - // Gets the compound datatype of the specified dataset - CompType(const DataSet& dataset); // H5Dget_type + // Gets the compound datatype of the specified dataset + CompType(const DataSet &dataset); // H5Dget_type - // Copy constructor - same as the original CompType. - CompType(const CompType& original); + // Copy constructor - same as the original CompType. + CompType(const CompType &original); - // Constructors that open a compound datatype, given a location. - CompType(const H5Location& loc, const char* name); - CompType(const H5Location& loc, const H5std_string& name); + // Constructors that open a compound datatype, given a location. + CompType(const H5Location &loc, const char *name); + CompType(const H5Location &loc, const H5std_string &name); - // Returns a CompType object via DataType* by decoding the binary - // object description of this type. - virtual DataType* decode() const; + // Returns a CompType object via DataType* by decoding the binary + // object description of this type. + virtual DataType *decode() const; - // Returns the type class of the specified member of this compound - // datatype. It provides to the user a way of knowing what type - // to create another datatype of the same class - H5T_class_t getMemberClass(unsigned member_num) const; + // Returns the type class of the specified member of this compound + // datatype. It provides to the user a way of knowing what type + // to create another datatype of the same class + H5T_class_t getMemberClass(unsigned member_num) const; - // Returns the index of a member in this compound data type. - int getMemberIndex(const char* name) const; - int getMemberIndex(const H5std_string& name) const; + // Returns the index of a member in this compound data type. + int getMemberIndex(const char *name) const; + int getMemberIndex(const H5std_string &name) const; - // Returns the offset of a member of this compound datatype. - size_t getMemberOffset(unsigned memb_no) const; + // Returns the offset of a member of this compound datatype. + size_t getMemberOffset(unsigned memb_no) const; - // Returns the name of a member of this compound datatype. - H5std_string getMemberName(unsigned member_num) const; + // Returns the name of a member of this compound datatype. + H5std_string getMemberName(unsigned member_num) const; - // Returns the generic datatype of the specified member in - // this compound datatype. - DataType getMemberDataType(unsigned member_num) const; + // Returns the generic datatype of the specified member in + // this compound datatype. + DataType getMemberDataType(unsigned member_num) const; - // Returns the array datatype of the specified member in - // this compound datatype. - ArrayType getMemberArrayType(unsigned member_num) const; + // Returns the array datatype of the specified member in + // this compound datatype. + ArrayType getMemberArrayType(unsigned member_num) const; - // Returns the compound datatype of the specified member in - // this compound datatype. - CompType getMemberCompType(unsigned member_num) const; + // Returns the compound datatype of the specified member in + // this compound datatype. + CompType getMemberCompType(unsigned member_num) const; - // Returns the enumeration datatype of the specified member in - // this compound datatype. - EnumType getMemberEnumType(unsigned member_num) const; + // Returns the enumeration datatype of the specified member in + // this compound datatype. + EnumType getMemberEnumType(unsigned member_num) const; - // Returns the integer datatype of the specified member in - // this compound datatype. - IntType getMemberIntType(unsigned member_num) const; + // Returns the integer datatype of the specified member in + // this compound datatype. + IntType getMemberIntType(unsigned member_num) const; - // Returns the floating-point datatype of the specified member in - // this compound datatype. - FloatType getMemberFloatType(unsigned member_num) const; + // Returns the floating-point datatype of the specified member in + // this compound datatype. + FloatType getMemberFloatType(unsigned member_num) const; - // Returns the string datatype of the specified member in - // this compound datatype. - StrType getMemberStrType(unsigned member_num) const; + // Returns the string datatype of the specified member in + // this compound datatype. + StrType getMemberStrType(unsigned member_num) const; - // Returns the variable length datatype of the specified member in - // this compound datatype. - VarLenType getMemberVarLenType(unsigned member_num) const; + // Returns the variable length datatype of the specified member in + // this compound datatype. + VarLenType getMemberVarLenType(unsigned member_num) const; - // Returns the number of members in this compound datatype. - int getNmembers() const; + // Returns the number of members in this compound datatype. + int getNmembers() const; - // Adds a new member to this compound datatype. - void insertMember(const H5std_string& name, size_t offset, const DataType& new_member) const; + // Adds a new member to this compound datatype. + void insertMember(const H5std_string &name, size_t offset, const DataType &new_member) const; - // Recursively removes padding from within this compound datatype. - void pack() const; + // Recursively removes padding from within this compound datatype. + void pack() const; - // Sets the total size for this compound datatype. - void setSize(size_t size) const; + // Sets the total size for this compound datatype. + void setSize(size_t size) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("CompType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("CompType"); + } - // Noop destructor. - virtual ~CompType(); + // Noop destructor. + virtual ~CompType(); - private: - // Contains common code that is used by the member functions - // getMemberXxxType - hid_t p_get_member_type(unsigned member_num) const; + private: + // Contains common code that is used by the member functions + // getMemberXxxType + hid_t p_get_member_type(unsigned member_num) const; }; // end of CompType } // namespace H5 -#endif // __H5CompType_H +#endif // H5CompType_H diff --git a/c++/src/H5Cpp.h b/c++/src/H5Cpp.h index 01fae45..9272bdb 100644 --- a/c++/src/H5Cpp.h +++ b/c++/src/H5Cpp.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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" @@ -53,9 +53,9 @@ */ #ifndef H5_CXX_HAVE_OFFSETOF #ifdef HOFFSET - #undef HOFFSET +#undef HOFFSET #endif -#define HOFFSET(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#define HOFFSET(TYPE, MEMBER) ((size_t) & ((TYPE *)0)->MEMBER) #endif -#endif // __H5Cpp_H +#endif // H5Cpp_H diff --git a/c++/src/H5CppDoc.h b/c++/src/H5CppDoc.h index 1108181..4337a6f 100644 --- a/c++/src/H5CppDoc.h +++ b/c++/src/H5CppDoc.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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' @@ -92,4 +92,4 @@ /// This example shows how to work with groups. ///\example h5group.cpp -#endif // __H5CppDoc_H +#endif // H5CppDoc_H diff --git a/c++/src/H5DaccProp.cpp b/c++/src/H5DaccProp.cpp index c6ff705..35c071a 100644 --- a/c++/src/H5DaccProp.cpp +++ b/c++/src/H5DaccProp.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -29,7 +29,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -DSetAccPropList* DSetAccPropList::DEFAULT_ = 0; +DSetAccPropList *DSetAccPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: DSetAccPropList::getConstant @@ -43,13 +43,13 @@ DSetAccPropList* DSetAccPropList::DEFAULT_ = 0; // not happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -DSetAccPropList* DSetAccPropList::getConstant() +DSetAccPropList * +DSetAccPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -58,8 +58,9 @@ DSetAccPropList* DSetAccPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new DSetAccPropList(H5P_DATASET_ACCESS); else - throw PropListIException("DSetAccPropList::getConstant", "DSetAccPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("DSetAccPropList::getConstant", + "DSetAccPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -68,7 +69,8 @@ DSetAccPropList* DSetAccPropList::getConstant() // points to. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void DSetAccPropList::deleteConstants() +void +DSetAccPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -77,7 +79,7 @@ void DSetAccPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for dataset creation default property //-------------------------------------------------------------------------- -const DSetAccPropList& DSetAccPropList::DEFAULT = *getConstant(); +const DSetAccPropList &DSetAccPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -86,7 +88,9 @@ const DSetAccPropList& DSetAccPropList::DEFAULT = *getConstant(); ///\brief Default constructor: creates a stub dataset creation property list // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetAccPropList::DSetAccPropList() : LinkAccPropList(H5P_DATASET_ACCESS) {} +DSetAccPropList::DSetAccPropList() : LinkAccPropList(H5P_DATASET_ACCESS) +{ +} //-------------------------------------------------------------------------- // Function: DSetAccPropList copy constructor @@ -94,7 +98,9 @@ DSetAccPropList::DSetAccPropList() : LinkAccPropList(H5P_DATASET_ACCESS) {} /// DSetAccPropList object // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetAccPropList::DSetAccPropList(const DSetAccPropList& orig) : LinkAccPropList(orig) {} +DSetAccPropList::DSetAccPropList(const DSetAccPropList &orig) : LinkAccPropList(orig) +{ +} //-------------------------------------------------------------------------- // Function: DSetAccPropList overloaded constructor @@ -102,7 +108,9 @@ DSetAccPropList::DSetAccPropList(const DSetAccPropList& orig) : LinkAccPropList( /// existing dataset creation property list. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetAccPropList::DSetAccPropList(const hid_t plist_id) : LinkAccPropList(plist_id) {} +DSetAccPropList::DSetAccPropList(const hid_t plist_id) : LinkAccPropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: DSetAccPropList::setChunkCache @@ -122,11 +130,11 @@ DSetAccPropList::DSetAccPropList(const hid_t plist_id) : LinkAccPropList(plist_i /// the HDF5 C Reference Manual. // July 2018 //-------------------------------------------------------------------------- -void DSetAccPropList::setChunkCache(size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) const +void +DSetAccPropList::setChunkCache(size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) const { herr_t ret_value = H5Pset_chunk_cache(id, rdcc_nslots, rdcc_nbytes, rdcc_w0); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("DSetAccPropList::setChunkCache", "H5Pset_chunk_cache failed"); } } @@ -143,11 +151,11 @@ void DSetAccPropList::setChunkCache(size_t rdcc_nslots, size_t rdcc_nbytes, doub /// the HDF5 C Reference Manual. // July 2018 //-------------------------------------------------------------------------- -void DSetAccPropList::getChunkCache(size_t &rdcc_nslots, size_t &rdcc_nbytes, double &rdcc_w0) const +void +DSetAccPropList::getChunkCache(size_t &rdcc_nslots, size_t &rdcc_nbytes, double &rdcc_w0) const { herr_t ret_value = H5Pget_chunk_cache(id, &rdcc_nslots, &rdcc_nbytes, &rdcc_w0); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("DSetAccPropList::getChunkCache", "H5Pget_chunk_cache failed"); } } @@ -157,6 +165,8 @@ void DSetAccPropList::getChunkCache(size_t &rdcc_nslots, size_t &rdcc_nbytes, d ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetAccPropList::~DSetAccPropList() {} +DSetAccPropList::~DSetAccPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5DaccProp.h b/c++/src/H5DaccProp.h index 111b4f5..7d6b250 100644 --- a/c++/src/H5DaccProp.h +++ b/c++/src/H5DaccProp.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5DSetAccPropList_H -#define __H5DSetAccPropList_H +#ifndef H5DSetAccPropList_H +#define H5DSetAccPropList_H namespace H5 { @@ -23,46 +23,50 @@ namespace H5 { */ // Inheritance: LinkAccPropList -> PropList -> IdComponent class H5_DLLCPP DSetAccPropList : public LinkAccPropList { - public: - ///\brief Default dataset creation property list. - static const DSetAccPropList& DEFAULT; + public: + ///\brief Default dataset creation property list. + static const DSetAccPropList &DEFAULT; - // Creates a dataset creation property list. - DSetAccPropList(); + // Creates a dataset creation property list. + DSetAccPropList(); - // Sets the raw data chunk cache parameters. - void setChunkCache(size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) const; + // Sets the raw data chunk cache parameters. + void setChunkCache(size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) const; - // Retrieves the raw data chunk cache parameters. - void getChunkCache(size_t &rdcc_nslots, size_t &rdcc_nbytes, double &rdcc_w0) const; + // Retrieves the raw data chunk cache parameters. + void getChunkCache(size_t &rdcc_nslots, size_t &rdcc_nbytes, double &rdcc_w0) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DSetAccPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("DSetAccPropList"); + } - // Copy constructor - same as the original DSetAccPropList. - DSetAccPropList(const DSetAccPropList& orig); + // Copy constructor - same as the original DSetAccPropList. + DSetAccPropList(const DSetAccPropList &orig); - // Creates a copy of an existing dataset creation property list - // using the property list id. - DSetAccPropList(const hid_t plist_id); + // Creates a copy of an existing dataset creation property list + // using the property list id. + DSetAccPropList(const hid_t plist_id); - // Noop destructor. - virtual ~DSetAccPropList(); + // Noop destructor. + virtual ~DSetAccPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static DSetAccPropList* DEFAULT_; + private: + static DSetAccPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static DSetAccPropList* getConstant(); + // Creates the global constant, should only be used by the library + static DSetAccPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of DSetAccPropList } // namespace H5 -#endif // __H5DSetAccPropList_H +#endif // H5DSetAccPropList_H diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index db14577..b376e57 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -6,19 +6,15 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif #include <string> -#include "H5private.h" // for HDfree +#include "H5private.h" // for HDfree #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -46,15 +42,15 @@ using std::endl; //-------------------------------------------------------------------------- // Function: DataSet default constructor ///\brief Default constructor: creates a stub DataSet. -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSet::DataSet() : H5Object(), AbstractDs(), id(H5I_INVALID_HID) {} +DataSet::DataSet() : H5Object(), AbstractDs(), id(H5I_INVALID_HID) +{ +} //-------------------------------------------------------------------------- // Function: DataSet overloaded constructor ///\brief Creates an DataSet object using the id of an existing dataset. ///\param existing_id - IN: Id of an existing dataset -// Programmer Binh-Minh Ribler - 2000 // Description // incRefCount() is needed here to prevent the id from being closed // prematurely. That is, when application uses the id of an @@ -71,14 +67,27 @@ DataSet::DataSet(const hid_t existing_id) : H5Object(), AbstractDs(), id(existin // Function: DataSet copy constructor ///\brief Copy constructor: same HDF5 object as \a original ///\param original - IN: DataSet instance to copy -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSet::DataSet(const DataSet& original) : H5Object(), AbstractDs(), id(original.id) +DataSet::DataSet(const DataSet &original) : H5Object(), AbstractDs(), id(original.id) { incRefCount(); // increment number of references to this id } //-------------------------------------------------------------------------- +// Function: DataSet assignment operator +///\brief Assignment operator: same HDF5 object as \a original +///\param original - IN: DataSet instance to copy +//-------------------------------------------------------------------------- +DataSet & +DataSet::operator=(const DataSet &original) +{ + if (this != &original) { + setId(original.id); + } + return (*this); +} + +//-------------------------------------------------------------------------- // Function: DataSet overload constructor - dereference ///\brief Given a reference, ref, to an hdf5 location, creates a /// DataSet object @@ -91,9 +100,9 @@ DataSet::DataSet(const DataSet& original) : H5Object(), AbstractDs(), id(origina ///\par Description /// \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 //-------------------------------------------------------------------------- -DataSet::DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), AbstractDs(), id(H5I_INVALID_HID) +DataSet::DataSet(const H5Location &loc, const void *ref, H5R_type_t ref_type, const PropList &plist) + : H5Object(), AbstractDs(), id(H5I_INVALID_HID) { id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereferenced"); } @@ -107,9 +116,9 @@ DataSet::DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type, co ///\param ref_type - IN: Reference type - default to H5R_OBJECT ///\param plist - IN: Property list - default to PropList::DEFAULT ///\exception H5::ReferenceException -// Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -DataSet::DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), AbstractDs(), id(H5I_INVALID_HID) +DataSet::DataSet(const Attribute &attr, const void *ref, H5R_type_t ref_type, const PropList &plist) + : H5Object(), AbstractDs(), id(H5I_INVALID_HID) { id = H5Location::p_dereference(attr.getId(), ref, ref_type, plist, "constructor - by dereference"); } @@ -119,34 +128,33 @@ DataSet::DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type, co ///\brief Gets a copy of the dataspace of this dataset. ///\return DataSpace instance ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace DataSet::getSpace() const +DataSpace +DataSet::getSpace() const { // Calls C function H5Dget_space to get the id of the dataspace hid_t dataspace_id = H5Dget_space(id); // If the dataspace id is invalid, throw an exception - if (dataspace_id < 0) - { + if (dataspace_id < 0) { throw DataSetIException("DataSet::getSpace", "H5Dget_space failed"); } - //create dataspace object using the existing id then return the object + // create dataspace object using the existing id then return the object DataSpace data_space; f_DataSpace_setId(&data_space, dataspace_id); - return(data_space); + return (data_space); } // This private member function calls the C API to get the identifier // of the datatype that is used by this dataset. It is used // by the various AbstractDs functions to get the specific datatype. -hid_t DataSet::p_get_type() const +hid_t +DataSet::p_get_type() const { hid_t type_id = H5Dget_type(id); if (type_id > 0) - return(type_id); - else - { + return (type_id); + else { throw DataSetIException("", "H5Dget_type failed"); } } @@ -156,20 +164,19 @@ hid_t DataSet::p_get_type() const ///\brief Gets the dataset creation property list. ///\return DSetCreatPropList instance ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList DataSet::getCreatePlist() const +DSetCreatPropList +DataSet::getCreatePlist() const { hid_t create_plist_id = H5Dget_create_plist(id); - if (create_plist_id < 0) - { + if (create_plist_id < 0) { throw DataSetIException("DataSet::getCreatePlist", "H5Dget_create_plist failed"); } // create and return the DSetCreatPropList object DSetCreatPropList create_plist; f_PropList_setId(&create_plist, create_plist_id); - return(create_plist); + return (create_plist); } //-------------------------------------------------------------------------- @@ -179,18 +186,18 @@ DSetCreatPropList DataSet::getCreatePlist() const ///\exception H5::DataSetIException // July 2018 //-------------------------------------------------------------------------- -DSetAccPropList DataSet::getAccessPlist() const +DSetAccPropList +DataSet::getAccessPlist() const { hid_t access_plist_id = H5Dget_access_plist(id); - if (access_plist_id < 0) - { + if (access_plist_id < 0) { throw DataSetIException("DataSet::getAccessPlist", "H5Dget_access_plist failed"); } // create and return the DSetCreatPropList object DSetAccPropList access_plist; f_PropList_setId(&access_plist, access_plist_id); - return(access_plist); + return (access_plist); } //-------------------------------------------------------------------------- @@ -200,12 +207,12 @@ DSetAccPropList DataSet::getAccessPlist() const ///\exception H5::DataSetIException // Note: H5Dget_storage_size returns 0 when there is no data. This // function should have no failure. (from SLU) -// Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- -hsize_t DataSet::getStorageSize() const +hsize_t +DataSet::getStorageSize() const { hsize_t storage_size = H5Dget_storage_size(id); - return(storage_size); + return (storage_size); } //-------------------------------------------------------------------------- @@ -213,64 +220,56 @@ hsize_t DataSet::getStorageSize() const ///\brief Gets the size in memory of the dataset's data. ///\return Size of data (in memory) ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - Apr 2009 //-------------------------------------------------------------------------- -size_t DataSet::getInMemDataSize() const +size_t +DataSet::getInMemDataSize() const { const char *func = "DataSet::getInMemDataSize"; // Get the data type of this dataset hid_t mem_type_id = H5Dget_type(id); - if (mem_type_id < 0) - { + if (mem_type_id < 0) { throw DataSetIException(func, "H5Dget_type failed"); } // Get the data type's size by first getting its native type then getting // the native type's size. hid_t native_type = H5Tget_native_type(mem_type_id, H5T_DIR_DEFAULT); - if (native_type < 0) - { + if (native_type < 0) { throw DataSetIException(func, "H5Tget_native_type failed"); } size_t type_size = H5Tget_size(native_type); - if (type_size == 0) - { + if (type_size == 0) { throw DataSetIException(func, "H5Tget_size failed"); } // Close the native type and the datatype of this dataset. - if (H5Tclose(native_type) < 0) - { + if (H5Tclose(native_type) < 0) { throw DataSetIException(func, "H5Tclose(native_type) failed"); } - if (H5Tclose(mem_type_id) < 0) - { + if (H5Tclose(mem_type_id) < 0) { throw DataSetIException(func, "H5Tclose(mem_type_id) failed"); } // Get number of elements of the dataset by first getting its dataspace, // then getting the number of elements in the dataspace hid_t space_id = H5Dget_space(id); - if (space_id < 0) - { + if (space_id < 0) { throw DataSetIException(func, "H5Dget_space failed"); } hssize_t num_elements = H5Sget_simple_extent_npoints(space_id); - if (num_elements < 0) - { + if (num_elements < 0) { throw DataSetIException(func, "H5Sget_simple_extent_npoints failed"); } // Close the dataspace - if (H5Sclose(space_id) < 0) - { + if (H5Sclose(space_id) < 0) { throw DataSetIException(func, "H5Sclose failed"); } // Calculate and return the size of the data size_t data_size = type_size * num_elements; - return(data_size); + return (data_size); } //-------------------------------------------------------------------------- @@ -278,18 +277,17 @@ size_t DataSet::getInMemDataSize() const ///\brief Returns the address of this dataset in the file. ///\return Address of dataset ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -haddr_t DataSet::getOffset() const +haddr_t +DataSet::getOffset() const { haddr_t ds_addr; // for address of dataset ds_addr = H5Dget_offset(id); - if (ds_addr == HADDR_UNDEF) - { + if (ds_addr == HADDR_UNDEF) { throw DataSetIException("DataSet::getOffset", "H5Dget_offset returned HADDR_UNDEF"); } - return(ds_addr); + return (ds_addr); } //-------------------------------------------------------------------------- @@ -297,13 +295,12 @@ haddr_t DataSet::getOffset() const ///\brief Determines whether space has been allocated for a dataset. ///\param status - OUT: Space allocation status ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::getSpaceStatus(H5D_space_status_t& status) const +void +DataSet::getSpaceStatus(H5D_space_status_t &status) const { herr_t ret_value = H5Dget_space_status(id, &status); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::getSpaceStatus", "H5Dget_space_status failed"); } } @@ -315,22 +312,21 @@ void DataSet::getSpaceStatus(H5D_space_status_t& status) const ///\param space - IN: Selection for the memory buffer ///\return Amount of storage ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hsize_t DataSet::getVlenBufSize(const DataType& type, const DataSpace& space) const +hsize_t +DataSet::getVlenBufSize(const DataType &type, const DataSpace &space) const { // Obtain identifiers for C API - hid_t type_id = type.getId(); + hid_t type_id = type.getId(); hid_t space_id = space.getId(); hsize_t size; // for amount of storage herr_t ret_value = H5Dvlen_get_buf_size(id, type_id, space_id, &size); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::getVlenBufSize", "H5Dvlen_get_buf_size failed"); } - return(size); + return (size); } //-------------------------------------------------------------------------- @@ -340,13 +336,12 @@ hsize_t DataSet::getVlenBufSize(const DataType& type, const DataSpace& space) co // misses const's. This wrapper will be removed in future release. // Return Amount of storage // Exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 // Modification // Modified to call its replacement. -BMR, 2014/04/16 // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//hsize_t DataSet::getVlenBufSize(DataType& type, DataSpace& space) const +// hsize_t DataSet::getVlenBufSize(DataType& type, DataSpace& space) const //{ // return(getVlenBufSize(type, space)); //} @@ -360,18 +355,18 @@ hsize_t DataSet::getVlenBufSize(const DataType& type, const DataSpace& space) co ///\param xfer_plist - IN: Property list used to create the buffer ///\param buf - IN: Pointer to the buffer to be reclaimed ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::vlenReclaim(const DataType& type, const DataSpace& space, const DSetMemXferPropList& xfer_plist, void* buf) +void +DataSet::vlenReclaim(const DataType &type, const DataSpace &space, const DSetMemXferPropList &xfer_plist, + void *buf) { // Obtain identifiers for C API - hid_t type_id = type.getId(); - hid_t space_id = space.getId(); + hid_t type_id = type.getId(); + hid_t space_id = space.getId(); hid_t xfer_plist_id = xfer_plist.getId(); herr_t ret_value = H5Dvlen_reclaim(type_id, space_id, xfer_plist_id, buf); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::vlenReclaim", "H5Dvlen_reclaim failed"); } } @@ -385,21 +380,21 @@ void DataSet::vlenReclaim(const DataType& type, const DataSpace& space, const DS ///\param xfer_plist - IN: Property list used to create the buffer ///\param buf - IN: Pointer to the buffer to be reclaimed ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 //\parDescription // This function has better prototype for the users than the // other, which might be removed at some point. BMR - 2006/12/20 //-------------------------------------------------------------------------- -void DataSet::vlenReclaim(void* buf, const DataType& type, const DataSpace& space, const DSetMemXferPropList& xfer_plist) +void +DataSet::vlenReclaim(void *buf, const DataType &type, const DataSpace &space, + const DSetMemXferPropList &xfer_plist) { // Obtain identifiers for C API - hid_t type_id = type.getId(); - hid_t space_id = space.getId(); + hid_t type_id = type.getId(); + hid_t space_id = space.getId(); hid_t xfer_plist_id = xfer_plist.getId(); herr_t ret_value = H5Dvlen_reclaim(type_id, space_id, xfer_plist_id, buf); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::vlenReclaim", "H5Dvlen_reclaim failed"); } } @@ -417,19 +412,19 @@ void DataSet::vlenReclaim(void* buf, const DataType& type, const DataSpace& spac /// This function reads raw data from this dataset into the /// buffer \a buf, converting from file datatype and dataspace /// to memory datatype \a mem_type and dataspace \a mem_space. -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::read(void* buf, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist) const +void +DataSet::read(void *buf, const DataType &mem_type, const DataSpace &mem_space, const DataSpace &file_space, + const DSetMemXferPropList &xfer_plist) const { // Obtain identifiers for C API - hid_t mem_type_id = mem_type.getId(); - hid_t mem_space_id = mem_space.getId(); + hid_t mem_type_id = mem_type.getId(); + hid_t mem_space_id = mem_space.getId(); hid_t file_space_id = file_space.getId(); hid_t xfer_plist_id = xfer_plist.getId(); herr_t ret_value = H5Dread(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::read", "H5Dread failed"); } } @@ -444,7 +439,6 @@ void DataSet::read(void* buf, const DataType& mem_type, const DataSpace& mem_spa ///\param file_space - IN: Dataset's dataspace in the file ///\param xfer_plist - IN: Transfer property list for this I/O operation ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 // Modification // Jul 2009 // Follow the change to Attribute::read and use the following @@ -453,28 +447,28 @@ void DataSet::read(void* buf, const DataType& mem_type, const DataSpace& mem_spa // DataSet::p_read_fixed_len and // DataSet::p_read_variable_len //-------------------------------------------------------------------------- -void DataSet::read(H5std_string& strg, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist) const +void +DataSet::read(H5std_string &strg, const DataType &mem_type, const DataSpace &mem_space, + const DataSpace &file_space, const DSetMemXferPropList &xfer_plist) const { // Check if this dataset has variable-len string or fixed-len string and // proceed appropriately. htri_t is_variable_len = H5Tis_variable_str(mem_type.getId()); - if (is_variable_len < 0) - { + if (is_variable_len < 0) { throw DataSetIException("DataSet::read", "H5Tis_variable_str failed"); } // Obtain identifiers for C API - hid_t mem_type_id = mem_type.getId(); - hid_t mem_space_id = mem_space.getId(); + hid_t mem_type_id = mem_type.getId(); + hid_t mem_space_id = mem_space.getId(); hid_t file_space_id = file_space.getId(); hid_t xfer_plist_id = xfer_plist.getId(); - if (!is_variable_len) // only allocate for fixed-len string + if (!is_variable_len) // only allocate for fixed-len string { p_read_fixed_len(mem_type_id, mem_space_id, file_space_id, xfer_plist_id, strg); } - else - { + else { p_read_variable_len(mem_type_id, mem_space_id, file_space_id, xfer_plist_id, strg); } } @@ -493,19 +487,19 @@ void DataSet::read(H5std_string& strg, const DataType& mem_type, const DataSpace /// \a buf to a dataset, converting from memory datatype /// \a mem_type and dataspace \a mem_space to file datatype /// and dataspace. -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::write(const void* buf, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist) const +void +DataSet::write(const void *buf, const DataType &mem_type, const DataSpace &mem_space, + const DataSpace &file_space, const DSetMemXferPropList &xfer_plist) const { // Obtain identifiers for C API - hid_t mem_type_id = mem_type.getId(); - hid_t mem_space_id = mem_space.getId(); + hid_t mem_type_id = mem_type.getId(); + hid_t mem_space_id = mem_space.getId(); hid_t file_space_id = file_space.getId(); hid_t xfer_plist_id = xfer_plist.getId(); herr_t ret_value = H5Dwrite(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::write", "H5Dwrite failed"); } } @@ -514,45 +508,42 @@ void DataSet::write(const void* buf, const DataType& mem_type, const DataSpace& // Function: DataSet::write ///\brief This is an overloaded member function, provided for convenience. /// It takes a reference to a \c H5std_string for the buffer. -// Programmer Binh-Minh Ribler - 2000 // Modification // Jul 2009 // Modified to pass the buffer into H5Dwrite properly depending // whether the dataset has variable- or fixed-length string. //-------------------------------------------------------------------------- -void DataSet::write(const H5std_string& strg, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist) const +void +DataSet::write(const H5std_string &strg, const DataType &mem_type, const DataSpace &mem_space, + const DataSpace &file_space, const DSetMemXferPropList &xfer_plist) const { // Check if this attribute has variable-len string or fixed-len string and // proceed appropriately. htri_t is_variable_len = H5Tis_variable_str(mem_type.getId()); - if (is_variable_len < 0) - { + if (is_variable_len < 0) { throw DataSetIException("DataSet::write", "H5Tis_variable_str failed"); } // Obtain identifiers for C API - hid_t mem_type_id = mem_type.getId(); - hid_t mem_space_id = mem_space.getId(); + hid_t mem_type_id = mem_type.getId(); + hid_t mem_space_id = mem_space.getId(); hid_t file_space_id = file_space.getId(); hid_t xfer_plist_id = xfer_plist.getId(); // Convert string to C-string - const char* strg_C; - strg_C = strg.c_str(); // strg_C refers to the contents of strg as a C-str + const char *strg_C; + strg_C = strg.c_str(); // strg_C refers to the contents of strg as a C-str herr_t ret_value = 0; // Pass string in differently depends on variable or fixed length - if (!is_variable_len) - { + if (!is_variable_len) { ret_value = H5Dwrite(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, strg_C); } - else - { + else { // passing string argument by address ret_value = H5Dwrite(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, &strg_C); } - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::write", "H5Dwrite failed"); } } @@ -572,17 +563,18 @@ void DataSet::write(const H5std_string& strg, const DataType& mem_type, const Da ///\exception H5::DataSetIException ///\note This function may not work correctly yet - it's still /// under development. -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DataSet::iterateElems(void* buf, const DataType& type, const DataSpace& space, H5D_operator_t op, void* op_data) +int +DataSet::iterateElems(void *buf, const DataType &type, const DataSpace &space, H5D_operator_t op, + void *op_data) { // Obtain identifiers for C API - hid_t type_id = type.getId(); - hid_t space_id = space.getId(); + hid_t type_id = type.getId(); + hid_t space_id = space.getId(); herr_t ret_value = H5Diterate(buf, type_id, space_id, op, op_data); if (ret_value >= 0) - return(ret_value); - else // raise exception when H5Diterate returns a negative value + return (ret_value); + else // raise exception when H5Diterate returns a negative value { throw DataSetIException("DataSet::iterateElems", "H5Diterate failed"); } @@ -596,12 +588,12 @@ int DataSet::iterateElems(void* buf, const DataType& type, const DataSpace& spac ///\par Description /// For information, please refer to the H5Dset_extent API in /// the HDF5 C Reference Manual. -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::extend(const hsize_t* size) const +void +DataSet::extend(const hsize_t *size) const { herr_t ret_value = H5Dset_extent(id, size); - if (ret_value < 0) // raise exception when H5Dset_extent returns a neg value + if (ret_value < 0) // raise exception when H5Dset_extent returns a neg value throw DataSetIException("DataSet::extend", "H5Dset_extent failed"); } @@ -614,16 +606,16 @@ void DataSet::extend(const hsize_t* size) const ///\param buf_type - IN: Datatype of the elements in buffer ///\param space - IN: Dataspace describing memory buffer & containing selection to use ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2014 //-------------------------------------------------------------------------- -void DataSet::fillMemBuf(const void *fill, const DataType& fill_type, void *buf, const DataType& buf_type, const DataSpace& space) const +void +DataSet::fillMemBuf(const void *fill, const DataType &fill_type, void *buf, const DataType &buf_type, + const DataSpace &space) const { - hid_t fill_type_id = fill_type.getId(); - hid_t buf_type_id = buf_type.getId(); - hid_t space_id = space.getId(); - herr_t ret_value = H5Dfill(fill, fill_type_id, buf, buf_type_id, space_id); - if (ret_value < 0) - { + hid_t fill_type_id = fill_type.getId(); + hid_t buf_type_id = buf_type.getId(); + hid_t space_id = space.getId(); + herr_t ret_value = H5Dfill(fill, fill_type_id, buf, buf_type_id, space_id); + if (ret_value < 0) { throw DataSetIException("DataSet::fillMemBuf", "H5Dfill failed"); } } @@ -639,13 +631,13 @@ void DataSet::fillMemBuf(const void *fill, const DataType& fill_type, void *buf, // Param buf_type - IN: Datatype of the elements in buffer // Param space - IN: Dataspace describing memory buffer & containing selection to use // Exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 // Modification // Modified to call its replacement. -BMR, 2014/04/16 // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void DataSet::fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& space) +// void DataSet::fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& +// space) //{ // fillMemBuf(fill, (const DataType)fill_type, buf, (const DataType)buf_type, (const DataSpace)space); //} @@ -657,15 +649,14 @@ void DataSet::fillMemBuf(const void *fill, const DataType& fill_type, void *buf, ///\param buf_type - IN: Datatype of the elements in buffer ///\param space - IN: Dataspace describing memory buffer & containing selection to use ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& space) const +void +DataSet::fillMemBuf(void *buf, const DataType &buf_type, const DataSpace &space) const { - hid_t buf_type_id = buf_type.getId(); - hid_t space_id = space.getId(); - herr_t ret_value = H5Dfill(NULL, buf_type_id, buf, buf_type_id, space_id); - if (ret_value < 0) - { + hid_t buf_type_id = buf_type.getId(); + hid_t space_id = space.getId(); + herr_t ret_value = H5Dfill(NULL, buf_type_id, buf, buf_type_id, space_id); + if (ret_value < 0) { throw DataSetIException("DataSet::fillMemBuf", "H5Dfill failed"); } } @@ -679,13 +670,12 @@ void DataSet::fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& s // Param buf_type - IN: Datatype of the elements in buffer // Param space - IN: Dataspace describing memory buffer & containing selection to use // Exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 // Modification // Modified to call its replacement. -BMR, 2014/04/16 // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void DataSet::fillMemBuf(void *buf, DataType& buf_type, DataSpace& space) +// void DataSet::fillMemBuf(void *buf, DataType& buf_type, DataSpace& space) //{ // fillMemBuf(buf, (const DataType)buf_type, (const DataSpace)space); //} @@ -699,25 +689,26 @@ void DataSet::fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& s // AbstractDs and Attribute are moved out of H5Object. In // addition, member IdComponent::id is moved into subclasses, and // IdComponent::getId now becomes pure virtual function. -// Programmer Binh-Minh Ribler - May, 2008 //-------------------------------------------------------------------------- -hid_t DataSet::getId() const +hid_t +DataSet::getId() const { - return(id); + return (id); } //-------------------------------------------------------------------------- // Function: DataSet::p_read_fixed_len (private) -// brief Reads a fixed length \a H5std_string from a dataset. -// param mem_type - IN: DataSet datatype (in memory) -// param strg - IN: Buffer for read string -// exception H5::DataSetIException -// Programmer Binh-Minh Ribler - Jul, 2009 +// brief Reads a fixed length \a H5std_string from a dataset. +// param mem_type - IN: DataSet datatype (in memory) +// param strg - IN: Buffer for read string +// exceptio n H5::DataSetIException // Modification // Jul 2009 // Added in follow to the change in Attribute::read //-------------------------------------------------------------------------- -void DataSet::p_read_fixed_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 +void +DataSet::p_read_fixed_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 { // Only allocate for fixed-len string. @@ -725,37 +716,36 @@ void DataSet::p_read_fixed_len(const hid_t mem_type_id, const hid_t mem_space_id size_t data_size = getInMemDataSize(); // If there is data, allocate buffer and read it. - if (data_size > 0) - { - char *strg_C = new char [data_size+1]; - HDmemset(strg_C, 0, data_size+1); // clear buffer + if (data_size > 0) { + char *strg_C = new char[data_size + 1]; + HDmemset(strg_C, 0, data_size + 1); // clear buffer herr_t ret_value = H5Dread(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, strg_C); - if (ret_value < 0) - { - delete []strg_C; // de-allocate for fixed-len string + if (ret_value < 0) { + delete[] strg_C; // de-allocate for fixed-len string throw DataSetIException("DataSet::read", "H5Dread failed for fixed length string"); } // Get string from the C char* and release resource allocated locally strg = strg_C; - delete []strg_C; + delete[] strg_C; } } //-------------------------------------------------------------------------- // Function: DataSet::p_read_variable_len (private) -// brief Reads a variable length \a H5std_string from an dataset. -// param mem_type - IN: DataSet datatype (in memory) -// param strg - IN: Buffer for read string -// exception H5::DataSetIException -// Programmer Binh-Minh Ribler - Jul, 2009 +// brief Reads a variable length \a H5std_string from an dataset. +// param mem_type - IN: DataSet datatype (in memory) +// param strg - IN: Buffer for read string +// exception H5::DataSetIException // Modification // Jul 2009 // Added in follow to the change in Attribute::read //-------------------------------------------------------------------------- -void DataSet::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 +void +DataSet::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 { // Prepare and call C API to read dataset. char *strg_C; @@ -763,8 +753,7 @@ void DataSet::p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space // Read dataset, no allocation for variable-len string; C library will herr_t ret_value = H5Dread(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, &strg_C); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::read", "H5Dread failed for variable length string"); } @@ -784,19 +773,19 @@ void DataSet::p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space // The underlaying reference counting in the C library ensures // that the current valid id of this object is properly closed. // Then the object's id is reset to the new id. -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::p_setId(const hid_t new_id) +void +DataSet::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw DataSetIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } - // reset object's id to the given id - id = new_id; + // reset object's id to the given id + id = new_id; } //-------------------------------------------------------------------------- @@ -807,9 +796,9 @@ void DataSet::p_setId(const hid_t new_id) // Applications shouldn't need to use it. // param dset - IN/OUT: DataSet object to be changed // param new_id - IN: New id to set -// Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void f_PropList_setId(PropList* plist, hid_t new_id) +void +f_PropList_setId(PropList *plist, hid_t new_id) { plist->p_setId(new_id); } @@ -821,15 +810,13 @@ void f_PropList_setId(PropList* plist, hid_t new_id) ///\brief Closes this dataset. /// ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void DataSet::close() +void +DataSet::close() { - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Dclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::close", "H5Dclose failed"); } // reset the id @@ -840,7 +827,6 @@ void DataSet::close() //-------------------------------------------------------------------------- // Function: DataSet destructor ///\brief Properly terminates access to this dataset. -// Programmer Binh-Minh Ribler - 2000 // Modification // - Replaced resetIdComponent() with decRefCount() to use C // library ID reference counting mechanism - BMR, Jun 1, 2004 @@ -852,9 +838,9 @@ DataSet::~DataSet() try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { cerr << "DataSet::~DataSet - " << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5DataSet.h b/c++/src/H5DataSet.h index a0a962e..333ed7a 100644 --- a/c++/src/H5DataSet.h +++ b/c++/src/H5DataSet.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5DataSet_H -#define __H5DataSet_H +#ifndef H5DataSet_H +#define H5DataSet_H namespace H5 { @@ -26,111 +26,134 @@ namespace H5 { */ // Inheritance: multiple H5Object/AbstractDs -> H5Location -> IdComponent class H5_DLLCPP DataSet : public H5Object, public AbstractDs { - public: - - // Close this dataset. - virtual void close(); - - // Extends the dataset with unlimited dimension. - void extend(const hsize_t* size) const; - - // Fills a selection in memory with a value - void fillMemBuf(const void *fill, const DataType& fill_type, void *buf, const DataType& buf_type, const DataSpace& space) const; - //void fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& space); // removed from 1.8.18 and 1.10.1 - - // Fills a selection in memory with zero - void fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& space) const; - //void fillMemBuf(void *buf, DataType& buf_type, DataSpace& space); // removed from 1.8.18 and 1.10.1 - - // Gets the creation property list of this dataset. - DSetCreatPropList getCreatePlist() const; - - // Gets the access property list of this dataset. - DSetAccPropList getAccessPlist() const; - - // Returns the address of this dataset in the file. - haddr_t getOffset() const; - - // Gets the dataspace of this dataset. - virtual DataSpace getSpace() const; - - // Determines whether space has been allocated for a dataset. - void getSpaceStatus(H5D_space_status_t& status) const; - - // Returns the amount of storage size required for this dataset. - virtual hsize_t getStorageSize() const; - - // Returns the in memory size of this attribute's data. - virtual size_t getInMemDataSize() const; - - // Returns the number of bytes required to store VL data. - hsize_t getVlenBufSize(const DataType& type, const DataSpace& space) const; - //hsize_t getVlenBufSize(DataType& type, DataSpace& space) const; // removed from 1.8.18 and 1.10.1 - - // Reclaims VL datatype memory buffers. - static void vlenReclaim(const DataType& type, const DataSpace& space, const DSetMemXferPropList& xfer_plist, void* buf); - static void vlenReclaim(void *buf, const DataType& type, const DataSpace& space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT); - - // Reads the data of this dataset and stores it in the provided buffer. - // The memory and file dataspaces and the transferring property list - // can be defaults. - void read(void* buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT) const; - void read(H5std_string& buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT) const; - - // Writes the buffered data to this dataset. - // The memory and file dataspaces and the transferring property list - // can be defaults. - void write(const void* buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT) const; - void write(const H5std_string& buf, const DataType& mem_type, const DataSpace& mem_space = DataSpace::ALL, const DataSpace& file_space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT) const; - - // 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); - - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DataSet"); } - - // Creates a dataset by way of dereference. - 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(); - - // Copy constructor - same as the original DataSet. - DataSet(const DataSet& original); - - // Creates a copy of an existing DataSet using its id. - DataSet(const hid_t existing_id); - - // Gets the dataset id. - virtual hid_t getId() const; - - // Destructor: properly terminates access to this dataset. - virtual ~DataSet(); - - protected: + public: + // Close this dataset. + virtual void close(); + + // Extends the dataset with unlimited dimension. + void extend(const hsize_t *size) const; + + // Fills a selection in memory with a value + void fillMemBuf(const void *fill, const DataType &fill_type, void *buf, const DataType &buf_type, + const DataSpace &space) const; + // void fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& + // space); // removed from 1.8.18 and 1.10.1 + + // Fills a selection in memory with zero + void fillMemBuf(void *buf, const DataType &buf_type, const DataSpace &space) const; + // void fillMemBuf(void *buf, DataType& buf_type, DataSpace& space); // removed from 1.8.18 and 1.10.1 + + // Gets the creation property list of this dataset. + DSetCreatPropList getCreatePlist() const; + + // Gets the access property list of this dataset. + DSetAccPropList getAccessPlist() const; + + // Returns the address of this dataset in the file. + haddr_t getOffset() const; + + // Gets the dataspace of this dataset. + virtual DataSpace getSpace() const; + + // Determines whether space has been allocated for a dataset. + void getSpaceStatus(H5D_space_status_t &status) const; + + // Returns the amount of storage size required for this dataset. + virtual hsize_t getStorageSize() const; + + // Returns the in memory size of this attribute's data. + virtual size_t getInMemDataSize() const; + + // Returns the number of bytes required to store VL data. + hsize_t getVlenBufSize(const DataType &type, const DataSpace &space) const; + // hsize_t getVlenBufSize(DataType& type, DataSpace& space) const; // removed from 1.8.18 and 1.10.1 + + // Reclaims VL datatype memory buffers. + static void vlenReclaim(const DataType &type, const DataSpace &space, + const DSetMemXferPropList &xfer_plist, void *buf); + static void vlenReclaim(void *buf, const DataType &type, const DataSpace &space = DataSpace::ALL, + const DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT); + + // Reads the data of this dataset and stores it in the provided buffer. + // The memory and file dataspaces and the transferring property list + // can be defaults. + void read(void *buf, const DataType &mem_type, const DataSpace &mem_space = DataSpace::ALL, + const DataSpace & file_space = DataSpace::ALL, + const DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT) const; + void read(H5std_string &buf, const DataType &mem_type, const DataSpace &mem_space = DataSpace::ALL, + const DataSpace & file_space = DataSpace::ALL, + const DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT) const; + + // Writes the buffered data to this dataset. + // The memory and file dataspaces and the transferring property list + // can be defaults. + void write(const void *buf, const DataType &mem_type, const DataSpace &mem_space = DataSpace::ALL, + const DataSpace & file_space = DataSpace::ALL, + const DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT) const; + void write(const H5std_string &buf, const DataType &mem_type, const DataSpace &mem_space = DataSpace::ALL, + const DataSpace & file_space = DataSpace::ALL, + const DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT) const; + + // 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); + + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("DataSet"); + } + + // Creates a dataset by way of dereference. + 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(); + + // Copy constructor - same as the original DataSet. + DataSet(const DataSet &original); + + // Assignment operator + DataSet &operator=(const DataSet &original); + + // Creates a copy of an existing DataSet using its id. + DataSet(const hid_t existing_id); + + // Gets the dataset id. + virtual hid_t getId() const; + + // Destructor: properly terminates access to this dataset. + virtual ~DataSet(); + + protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Sets the dataset id. - virtual void p_setId(const hid_t new_id); + // Sets the dataset id. + virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS - private: - hid_t id; // HDF5 dataset id + private: + hid_t id; // HDF5 dataset id - // This function contains the common code that is used by - // getTypeClass and various API functions getXxxType - // defined in AbstractDs for generic datatype and specific - // sub-types - virtual hid_t p_get_type() const; + // This function contains the common code that is used by + // getTypeClass and various API functions getXxxType + // defined in AbstractDs for generic datatype and specific + // sub-types + virtual hid_t p_get_type() const; - // Reads variable or fixed len strings from this dataset. - void p_read_fixed_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; - 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; + // Reads variable or fixed len strings from this dataset. + void p_read_fixed_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; + 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; - // Friend function to set DataSet id. For library use only. - friend void f_DataSet_setId(DataSet* dset, hid_t new_id); + // Friend function to set DataSet id. For library use only. + friend void f_DataSet_setId(DataSet *dset, hid_t new_id); }; // end of DataSet } // namespace H5 -#endif // __H5DataSet_H +#endif // H5DataSet_H diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp index e8e5712..0485530 100644 --- a/c++/src/H5DataSpace.cpp +++ b/c++/src/H5DataSpace.cpp @@ -6,16 +6,12 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif #include <string> #include "H5Include.h" @@ -33,7 +29,7 @@ using std::endl; // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -DataSpace* DataSpace::ALL_ = 0; +DataSpace *DataSpace::ALL_ = 0; //-------------------------------------------------------------------------- // Function: DataSpace::getConstant @@ -45,13 +41,13 @@ DataSpace* DataSpace::ALL_ = 0; // a DataSpaceIException. This scenario should not happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -DataSpace* DataSpace::getConstant() +DataSpace * +DataSpace::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -60,8 +56,9 @@ DataSpace* DataSpace::getConstant() if (ALL_ == 0) ALL_ = new DataSpace(H5S_ALL); else - throw DataSpaceIException("DataSpace::getConstant", "DataSpace::getConstant is being invoked on an allocated ALL_"); - return(ALL_); + throw DataSpaceIException("DataSpace::getConstant", + "DataSpace::getConstant is being invoked on an allocated ALL_"); + return (ALL_); } //-------------------------------------------------------------------------- @@ -69,7 +66,8 @@ DataSpace* DataSpace::getConstant() // Purpose: Deletes the constant object that DataSpace::ALL_ points to // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void DataSpace::deleteConstants() +void +DataSpace::deleteConstants() { if (ALL_ != 0) delete ALL_; @@ -78,7 +76,7 @@ void DataSpace::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for default dataspace. //-------------------------------------------------------------------------- -const DataSpace& DataSpace::ALL = *getConstant(); +const DataSpace &DataSpace::ALL = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -94,8 +92,7 @@ const DataSpace& DataSpace::ALL = *getConstant(); DataSpace::DataSpace(H5S_class_t type) : IdComponent() { id = H5Screate(type); - if (id < 0) - { + if (id < 0) { throw DataSpaceIException("DataSpace constructor", "H5Screate failed"); } } @@ -109,11 +106,10 @@ DataSpace::DataSpace(H5S_class_t type) : IdComponent() ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace::DataSpace(int rank, const hsize_t * dims, const hsize_t * maxdims) : IdComponent() +DataSpace::DataSpace(int rank, const hsize_t *dims, const hsize_t *maxdims) : IdComponent() { id = H5Screate_simple(rank, dims, maxdims); - if (id < 0) - { + if (id < 0) { throw DataSpaceIException("DataSpace constructor", "H5Screate_simple failed"); } } @@ -137,7 +133,7 @@ DataSpace::DataSpace(const hid_t existing_id) : IdComponent(), id(existing_id) ///\param original - IN: DataSpace object to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace::DataSpace(const DataSpace& original) : IdComponent(), id(original.id) +DataSpace::DataSpace(const DataSpace &original) : IdComponent(), id(original.id) { incRefCount(); // increment number of references to this id } @@ -154,17 +150,18 @@ DataSpace::DataSpace(const DataSpace& original) : IdComponent(), id(original.id) // - Replaced decRefCount with close() to let the C library // handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- -void DataSpace::copy(const DataSpace& like_space) +void +DataSpace::copy(const DataSpace &like_space) { // If this object has an hdf5 valid id, close it if (id != H5S_ALL) { try { close(); } - catch (Exception& close_error) { - throw DataSpaceIException("DataSpace::copy", close_error.getDetailMsg()); + catch (Exception &close_error) { + throw DataSpaceIException("DataSpace::copy", close_error.getDetailMsg()); } - } // end if + } // end if // call C routine to copy the dataspace id = H5Scopy(like_space.getId()); @@ -184,11 +181,12 @@ void DataSpace::copy(const DataSpace& like_space) // the new id in the left hand side object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace& DataSpace::operator=(const DataSpace& rhs) +DataSpace & +DataSpace::operator=(const DataSpace &rhs) { if (this != &rhs) copy(rhs); - return(*this); + return (*this); } //-------------------------------------------------------------------------- @@ -199,17 +197,16 @@ DataSpace& DataSpace::operator=(const DataSpace& rhs) ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DataSpace::isSimple () const +bool +DataSpace::isSimple() const { htri_t simple = H5Sis_simple(id); if (simple > 0) return true; else if (simple == 0) return false; - else - { - throw DataSpaceIException("DataSpace::isSimple", - "H5Sis_simple returns negative value"); + else { + throw DataSpaceIException("DataSpace::isSimple", "H5Sis_simple returns negative value"); } } @@ -225,11 +222,11 @@ bool DataSpace::isSimple () const /// it to be re-defined. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::offsetSimple (const hssize_t* offset) const +void +DataSpace::offsetSimple(const hssize_t *offset) const { herr_t ret_value = H5Soffset_simple(id, offset); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSpaceIException("DataSpace::offsetSimple", "H5Soffset_simple failed"); } } @@ -244,15 +241,15 @@ void DataSpace::offsetSimple (const hssize_t* offset) const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DataSpace::getSimpleExtentDims (hsize_t *dims, hsize_t *maxdims) const +int +DataSpace::getSimpleExtentDims(hsize_t *dims, hsize_t *maxdims) const { int ndims = H5Sget_simple_extent_dims(id, dims, maxdims); - if (ndims < 0) - { + if (ndims < 0) { throw DataSpaceIException("DataSpace::getSimpleExtentDims", - "H5Sget_simple_extent_dims returns negative number of dimensions"); + "H5Sget_simple_extent_dims returns negative number of dimensions"); } - return(ndims); + return (ndims); } //-------------------------------------------------------------------------- @@ -262,15 +259,16 @@ int DataSpace::getSimpleExtentDims (hsize_t *dims, hsize_t *maxdims) const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DataSpace::getSimpleExtentNdims () const +int +DataSpace::getSimpleExtentNdims() const { int ndims = H5Sget_simple_extent_ndims(id); - if (ndims < 0) - { - throw DataSpaceIException("DataSpace::getSimpleExtentNdims", + if (ndims < 0) { + throw DataSpaceIException( + "DataSpace::getSimpleExtentNdims", "H5Sget_simple_extent_ndims returns negative value for dimensionality of the dataspace"); } - return(ndims); + return (ndims); } //-------------------------------------------------------------------------- @@ -284,15 +282,16 @@ int DataSpace::getSimpleExtentNdims () const // num_elements = -1 when failure occurs vs. 0 // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hssize_t DataSpace::getSimpleExtentNpoints () const +hssize_t +DataSpace::getSimpleExtentNpoints() const { hssize_t num_elements = H5Sget_simple_extent_npoints(id); if (num_elements > -1) - return(num_elements); - else - { + return (num_elements); + else { throw DataSpaceIException("DataSpace::getSimpleExtentNpoints", - "H5Sget_simple_extent_npoints returns negative value for the number of elements in the dataspace"); + "H5Sget_simple_extent_npoints returns negative value for the number of " + "elements in the dataspace"); } } @@ -303,15 +302,15 @@ hssize_t DataSpace::getSimpleExtentNpoints () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5S_class_t DataSpace::getSimpleExtentType () const +H5S_class_t +DataSpace::getSimpleExtentType() const { H5S_class_t class_name = H5Sget_simple_extent_type(id); - if (class_name == H5S_NO_CLASS) - { + if (class_name == H5S_NO_CLASS) { throw DataSpaceIException("DataSpace::getSimpleExtentType", - "H5Sget_simple_extent_type returns H5S_NO_CLASS"); + "H5Sget_simple_extent_type returns H5S_NO_CLASS"); } - return(class_name); + return (class_name); } //-------------------------------------------------------------------------- @@ -321,12 +320,12 @@ H5S_class_t DataSpace::getSimpleExtentType () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::extentCopy (const DataSpace& dest_space) const +void +DataSpace::extentCopy(const DataSpace &dest_space) const { - hid_t dest_space_id = dest_space.getId(); - herr_t ret_value = H5Sextent_copy(dest_space_id, id); - if (ret_value < 0) - { + hid_t dest_space_id = dest_space.getId(); + herr_t ret_value = H5Sextent_copy(dest_space_id, id); + if (ret_value < 0) { throw DataSpaceIException("DataSpace::extentCopy", "H5Sextent_copy failed"); } } @@ -344,7 +343,7 @@ void DataSpace::extentCopy (const DataSpace& dest_space) const // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void DataSpace::extentCopy(DataSpace& dest_space) const +// void DataSpace::extentCopy(DataSpace& dest_space) const //{ // extentCopy(dest_space); //} @@ -358,12 +357,12 @@ void DataSpace::extentCopy (const DataSpace& dest_space) const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::setExtentSimple(int rank, const hsize_t *current_size, const hsize_t *maximum_size) const +void +DataSpace::setExtentSimple(int rank, const hsize_t *current_size, const hsize_t *maximum_size) const { herr_t ret_value; ret_value = H5Sset_extent_simple(id, rank, current_size, maximum_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSpaceIException("DataSpace::setExtentSimple", "H5Sset_extent_simple failed"); } } @@ -375,11 +374,11 @@ void DataSpace::setExtentSimple(int rank, const hsize_t *current_size, const hsi ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::setExtentNone () const +void +DataSpace::setExtentNone() const { herr_t ret_value = H5Sset_extent_none(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSpaceIException("DataSpace::setExtentNone", "H5Sset_extent_none failed"); } } @@ -391,15 +390,16 @@ void DataSpace::setExtentNone () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hssize_t DataSpace::getSelectNpoints () const +hssize_t +DataSpace::getSelectNpoints() const { hssize_t num_elements = H5Sget_select_npoints(id); - if (num_elements < 0) - { - throw DataSpaceIException("DataSpace::getSelectNpoints", + if (num_elements < 0) { + throw DataSpaceIException( + "DataSpace::getSelectNpoints", "H5Sget_select_npoints returns negative value for number of elements in the dataspace selection"); } - return(num_elements); + return (num_elements); } //-------------------------------------------------------------------------- @@ -409,15 +409,16 @@ hssize_t DataSpace::getSelectNpoints () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hssize_t DataSpace::getSelectHyperNblocks () const +hssize_t +DataSpace::getSelectHyperNblocks() const { hssize_t num_blocks = H5Sget_select_hyper_nblocks(id); - if (num_blocks < 0) - { - throw DataSpaceIException("DataSpace::getSelectHyperNblocks", + if (num_blocks < 0) { + throw DataSpaceIException( + "DataSpace::getSelectHyperNblocks", "H5Sget_select_hyper_nblocks returns negative value for the number of hyperslab blocks"); } - return(num_blocks); + return (num_blocks); } //-------------------------------------------------------------------------- @@ -429,14 +430,14 @@ hssize_t DataSpace::getSelectHyperNblocks () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::getSelectHyperBlocklist(hsize_t startblock, hsize_t numblocks, hsize_t *buf) const +void +DataSpace::getSelectHyperBlocklist(hsize_t startblock, hsize_t numblocks, hsize_t *buf) const { herr_t ret_value; ret_value = H5Sget_select_hyper_blocklist(id, startblock, numblocks, buf); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSpaceIException("DataSpace::getSelectHyperBlocklist", - "H5Sget_select_hyper_blocklist failed"); + "H5Sget_select_hyper_blocklist failed"); } } @@ -447,15 +448,14 @@ void DataSpace::getSelectHyperBlocklist(hsize_t startblock, hsize_t numblocks, h ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hssize_t DataSpace::getSelectElemNpoints () const +hssize_t +DataSpace::getSelectElemNpoints() const { hssize_t num_points = H5Sget_select_elem_npoints(id); - if (num_points < 0) - { - throw DataSpaceIException("DataSpace::getSelectElemNpoints", - "H5Sget_select_elem_npoints failed"); + if (num_points < 0) { + throw DataSpaceIException("DataSpace::getSelectElemNpoints", "H5Sget_select_elem_npoints failed"); } - return(num_points); + return (num_points); } //-------------------------------------------------------------------------- @@ -470,14 +470,13 @@ hssize_t DataSpace::getSelectElemNpoints () const /// H5Sget_select_elem_pointlist in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::getSelectElemPointlist (hsize_t startpoint, hsize_t numpoints, hsize_t *buf) const +void +DataSpace::getSelectElemPointlist(hsize_t startpoint, hsize_t numpoints, hsize_t *buf) const { herr_t ret_value; ret_value = H5Sget_select_elem_pointlist(id, startpoint, numpoints, buf); - if (ret_value < 0) - { - throw DataSpaceIException("DataSpace::getSelectElemPointlist", - "H5Sget_select_elem_pointlist failed"); + if (ret_value < 0) { + throw DataSpaceIException("DataSpace::getSelectElemPointlist", "H5Sget_select_elem_pointlist failed"); } } @@ -493,13 +492,12 @@ void DataSpace::getSelectElemPointlist (hsize_t startpoint, hsize_t numpoints, h /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::getSelectBounds (hsize_t* start, hsize_t* end) const +void +DataSpace::getSelectBounds(hsize_t *start, hsize_t *end) const { herr_t ret_value = H5Sget_select_bounds(id, start, end); - if (ret_value < 0) - { - throw DataSpaceIException("DataSpace::getSelectBounds", - "H5Sget_select_bounds failed"); + if (ret_value < 0) { + throw DataSpaceIException("DataSpace::getSelectBounds", "H5Sget_select_bounds failed"); } } @@ -518,14 +516,13 @@ void DataSpace::getSelectBounds (hsize_t* start, hsize_t* end) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::selectElements (H5S_seloper_t op, const size_t num_elements, const hsize_t *coord) const +void +DataSpace::selectElements(H5S_seloper_t op, const size_t num_elements, const hsize_t *coord) const { herr_t ret_value; ret_value = H5Sselect_elements(id, op, num_elements, coord); - if (ret_value < 0) - { - throw DataSpaceIException("DataSpace::selectElements", - "H5Sselect_elements failed"); + if (ret_value < 0) { + throw DataSpaceIException("DataSpace::selectElements", "H5Sselect_elements failed"); } } @@ -536,11 +533,11 @@ void DataSpace::selectElements (H5S_seloper_t op, const size_t num_elements, con ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::selectAll () const +void +DataSpace::selectAll() const { herr_t ret_value = H5Sselect_all(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSpaceIException("DataSpace::selectAll", "H5Sselect_all failed"); } } @@ -552,13 +549,12 @@ void DataSpace::selectAll () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::selectNone () const +void +DataSpace::selectNone() const { herr_t ret_value = H5Sselect_none(id); - if (ret_value < 0) - { - throw DataSpaceIException("DataSpace::selectNone", - "H5Sselect_none failed"); + if (ret_value < 0) { + throw DataSpaceIException("DataSpace::selectNone", "H5Sselect_none failed"); } } @@ -571,17 +567,16 @@ void DataSpace::selectNone () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DataSpace::selectValid () const +bool +DataSpace::selectValid() const { htri_t ret_value = H5Sselect_valid(id); if (ret_value > 0) return true; else if (ret_value == 0) return false; - else - { - throw DataSpaceIException("DataSpace::selectValid", - "H5Sselect_valid returns negative value"); + else { + throw DataSpaceIException("DataSpace::selectValid", "H5Sselect_valid returns negative value"); } } @@ -599,14 +594,14 @@ bool DataSpace::selectValid () const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::selectHyperslab(H5S_seloper_t op, const hsize_t *count, const hsize_t *start, const hsize_t *stride, const hsize_t *block) const +void +DataSpace::selectHyperslab(H5S_seloper_t op, const hsize_t *count, const hsize_t *start, + const hsize_t *stride, const hsize_t *block) const { herr_t ret_value; ret_value = H5Sselect_hyperslab(id, op, start, stride, count, block); - if (ret_value < 0) - { - throw DataSpaceIException("DataSpace::selectHyperslab", - "H5Sselect_hyperslab failed"); + if (ret_value < 0) { + throw DataSpaceIException("DataSpace::selectHyperslab", "H5Sselect_hyperslab failed"); } } @@ -622,9 +617,10 @@ void DataSpace::selectHyperslab(H5S_seloper_t op, const hsize_t *count, const hs // IdComponent::getId now becomes pure virtual function. // Programmer Binh-Minh Ribler - May, 2008 //-------------------------------------------------------------------------- -hid_t DataSpace::getId() const +hid_t +DataSpace::getId() const { - return(id); + return (id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -640,13 +636,14 @@ hid_t DataSpace::getId() const // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::p_setId(const hid_t new_id) +void +DataSpace::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw DataSpaceIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } // reset object's id to the given id @@ -661,14 +658,13 @@ void DataSpace::p_setId(const hid_t new_id) ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void DataSpace::close() +void +DataSpace::close() { // check if id is a valid hdf5 object id before trying to close it - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Sclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSpaceIException("DataSpace::close", "H5Sclose failed"); } // reset the id @@ -690,9 +686,10 @@ DataSpace::~DataSpace() { try { close(); - } catch (Exception& close_error) { + } + catch (Exception &close_error) { cerr << "DataSpace::~DataSpace - " << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5DataSpace.h b/c++/src/H5DataSpace.h index 54c68ac..470de74 100644 --- a/c++/src/H5DataSpace.h +++ b/c++/src/H5DataSpace.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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 namespace H5 { @@ -23,131 +23,136 @@ namespace H5 { */ // Inheritance: IdComponent class H5_DLLCPP DataSpace : public IdComponent { - public: - ///\brief Default DataSpace objects - static const DataSpace& ALL; + public: + ///\brief Default DataSpace objects + static const DataSpace &ALL; - // Creates a dataspace object given the space type - DataSpace(H5S_class_t type = H5S_SCALAR); + // Creates a dataspace object given the space type + DataSpace(H5S_class_t type = H5S_SCALAR); - // Creates a simple dataspace - DataSpace(int rank, const hsize_t * dims, const hsize_t * maxdims = NULL); + // Creates a simple dataspace + DataSpace(int rank, const hsize_t *dims, const hsize_t *maxdims = NULL); - // Creates a DataSpace object using an existing dataspace id. - DataSpace(const hid_t space_id); + // Creates a DataSpace object using an existing dataspace id. + DataSpace(const hid_t space_id); - // Copy constructor - same as the original DataSpace. - DataSpace(const DataSpace& original); + // Copy constructor - same as the original DataSpace. + DataSpace(const DataSpace &original); - // Assignment operator - DataSpace& operator=(const DataSpace& rhs); + // Assignment operator + DataSpace &operator=(const DataSpace &rhs); - // Closes this dataspace. - virtual void close(); + // Closes this dataspace. + virtual void close() H5_OVERRIDE; - // Makes copy of an existing dataspace. - void copy(const DataSpace& like_space); + // Makes copy of an existing dataspace. + void copy(const DataSpace &like_space); - // Copies the extent of this dataspace. - void extentCopy(const DataSpace& dest_space) const; - // removed from 1.8.18 and 1.10.1 - //void extentCopy(DataSpace& dest_space) const; + // Copies the extent of this dataspace. + void extentCopy(const DataSpace &dest_space) const; + // removed from 1.8.18 and 1.10.1 + // void extentCopy(DataSpace& dest_space) const; - // Gets the bounding box containing the current selection. - void getSelectBounds(hsize_t* start, hsize_t* end) const; + // Gets the bounding box containing the current selection. + void getSelectBounds(hsize_t *start, hsize_t *end) const; - // Gets the number of element points in the current selection. - hssize_t getSelectElemNpoints() const; + // Gets the number of element points in the current selection. + hssize_t getSelectElemNpoints() const; - // Retrieves the list of element points currently selected. - void getSelectElemPointlist(hsize_t startpoint, hsize_t numpoints, hsize_t *buf) const; + // Retrieves the list of element points currently selected. + void getSelectElemPointlist(hsize_t startpoint, hsize_t numpoints, hsize_t *buf) const; - // Gets the list of hyperslab blocks currently selected. - void getSelectHyperBlocklist(hsize_t startblock, hsize_t numblocks, hsize_t *buf) const; + // Gets the list of hyperslab blocks currently selected. + void getSelectHyperBlocklist(hsize_t startblock, hsize_t numblocks, hsize_t *buf) const; - // Get number of hyperslab blocks. - hssize_t getSelectHyperNblocks() const; + // Get number of hyperslab blocks. + hssize_t getSelectHyperNblocks() const; - // Gets the number of elements in this dataspace selection. - hssize_t getSelectNpoints() const; + // Gets the number of elements in this dataspace selection. + hssize_t getSelectNpoints() const; - // Retrieves dataspace dimension size and maximum size. - int getSimpleExtentDims(hsize_t *dims, hsize_t *maxdims = NULL) const; + // Retrieves dataspace dimension size and maximum size. + int getSimpleExtentDims(hsize_t *dims, hsize_t *maxdims = NULL) const; - // Gets the dimensionality of this dataspace. - int getSimpleExtentNdims() const; + // Gets the dimensionality of this dataspace. + int getSimpleExtentNdims() const; - // Gets the number of elements in this dataspace. - // 12/05/00 - changed return type to hssize_t from hsize_t - C API - hssize_t getSimpleExtentNpoints() const; + // Gets the number of elements in this dataspace. + // 12/05/00 - changed return type to hssize_t from hsize_t - C API + hssize_t getSimpleExtentNpoints() const; - // Gets the current class of this dataspace. - H5S_class_t getSimpleExtentType() const; + // Gets the current class of this dataspace. + H5S_class_t getSimpleExtentType() const; - // Determines if this dataspace is a simple one. - bool isSimple() const; + // Determines if this dataspace is a simple one. + bool isSimple() const; - // Sets the offset of this simple dataspace. - void offsetSimple(const hssize_t* offset) const; + // Sets the offset of this simple dataspace. + void offsetSimple(const hssize_t *offset) const; - // Selects the entire dataspace. - void selectAll() const; + // Selects the entire dataspace. + void selectAll() const; - // Selects array elements to be included in the selection for - // this dataspace. - void selectElements(H5S_seloper_t op, const size_t num_elements, const hsize_t *coord) const; + // Selects array elements to be included in the selection for + // this dataspace. + void selectElements(H5S_seloper_t op, const size_t num_elements, const hsize_t *coord) const; - // Selects a hyperslab region to add to the current selected region. - void selectHyperslab(H5S_seloper_t op, const hsize_t *count, const hsize_t *start, const hsize_t *stride = NULL, const hsize_t *block = NULL) const; + // Selects a hyperslab region to add to the current selected region. + void selectHyperslab(H5S_seloper_t op, const hsize_t *count, const hsize_t *start, + const hsize_t *stride = NULL, const hsize_t *block = NULL) const; - // Resets the selection region to include no elements. - void selectNone() const; + // Resets the selection region to include no elements. + void selectNone() const; - // Verifies that the selection is within the extent of the dataspace. - bool selectValid() const; + // Verifies that the selection is within the extent of the dataspace. + bool selectValid() const; - // Removes the extent from this dataspace. - void setExtentNone() const; + // Removes the extent from this dataspace. + void setExtentNone() const; - // Sets or resets the size of this dataspace. - void setExtentSimple(int rank, const hsize_t *current_size, const hsize_t *maximum_size = NULL) const; + // Sets or resets the size of this dataspace. + void setExtentSimple(int rank, const hsize_t *current_size, const hsize_t *maximum_size = NULL) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DataSpace"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const H5_OVERRIDE + { + return ("DataSpace"); + } - // Gets the dataspace id. - virtual hid_t getId() const; + // Gets the dataspace id. + virtual hid_t getId() const H5_OVERRIDE; - // Deletes the global constant - static void deleteConstants(); + // Deletes the global constant + static void deleteConstants(); - // Destructor: properly terminates access to this dataspace. - virtual ~DataSpace(); + // Destructor: properly terminates access to this dataspace. + virtual ~DataSpace(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - protected: - // Sets the dataspace id. - virtual void p_setId(const hid_t new_id); + protected: + // Sets the dataspace id. + virtual void p_setId(const hid_t new_id) H5_OVERRIDE; #endif // DOXYGEN_SHOULD_SKIP_THIS - private: - hid_t id; // HDF5 dataspace id + private: + hid_t id; // HDF5 dataspace id #ifndef DOXYGEN_SHOULD_SKIP_THIS - static DataSpace* ALL_; + static DataSpace *ALL_; - // Creates the global constant - static DataSpace* getConstant(); + // Creates the global constant + static DataSpace *getConstant(); - // Friend function to set DataSpace id. For library use only. - friend void f_DataSpace_setId(DataSpace *dspace, hid_t new_id); + // Friend function to set DataSpace id. For library use only. + friend void f_DataSpace_setId(DataSpace *dspace, hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of DataSpace } // namespace H5 -#endif // __H5DataSpace_H +#endif // H5DataSpace_H diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 0472975..3228dcb 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -6,16 +6,12 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif #include <string> #include "H5Include.h" @@ -50,7 +46,9 @@ using std::endl; ///\brief Default constructor: Creates a stub datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType::DataType() : H5Object(), id(H5I_INVALID_HID), encoded_buf(NULL), buf_size(0) {} +DataType::DataType() : H5Object(), id(H5I_INVALID_HID), encoded_buf(NULL), buf_size(0) +{ +} //-------------------------------------------------------------------------- // Function: DataType overloaded constructor @@ -82,8 +80,7 @@ DataType::DataType(const H5T_class_t type_class, size_t size) : H5Object(), enco { // Call C routine to create the new datatype id = H5Tcreate(type_class, size); - if (id < 0) - { + if (id < 0) { throw DataTypeIException("DataType constructor", "H5Tcreate failed"); } } @@ -99,7 +96,8 @@ DataType::DataType(const H5T_class_t type_class, size_t size) : H5Object(), enco ///\exception H5::ReferenceException // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -DataType::DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), encoded_buf(NULL), buf_size(0) +DataType::DataType(const H5Location &loc, const void *ref, H5R_type_t ref_type, const PropList &plist) + : H5Object(), encoded_buf(NULL), buf_size(0) { id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereference"); } @@ -118,18 +116,19 @@ DataType::DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type, // Jul, 2008 // Added for application convenience. //-------------------------------------------------------------------------- - /* DataType::DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), id(H5I_INVALID_HID), encoded_buf(NULL), buf_size(0) +/* DataType::DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : +H5Object(), id(H5I_INVALID_HID), encoded_buf(NULL), buf_size(0) { - id = H5Location::p_dereference(attr.getId(), ref, ref_type, plist, "constructor - by dereference"); + id = H5Location::p_dereference(attr.getId(), ref, ref_type, plist, "constructor - by dereference"); } - */ +*/ //-------------------------------------------------------------------------- // Function: DataType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType::DataType(const DataType& original) : H5Object(), id(original.id), encoded_buf(NULL), buf_size(0) +DataType::DataType(const DataType &original) : H5Object(), id(original.id), encoded_buf(NULL), buf_size(0) { incRefCount(); // increment number of references to this id } @@ -147,7 +146,7 @@ DataType::DataType(const DataType& original) : H5Object(), id(original.id), enco // unnecessarily and will produce undefined behavior. // -BMR, Apr 2015 //-------------------------------------------------------------------------- -DataType::DataType(const PredType& pred_type) : H5Object(), encoded_buf(NULL), buf_size(0) +DataType::DataType(const PredType &pred_type) : H5Object(), encoded_buf(NULL), buf_size(0) { // Call C routine to copy the datatype id = H5Tcopy(pred_type.getId()); @@ -169,7 +168,7 @@ DataType::DataType(const PredType& pred_type) : H5Object(), encoded_buf(NULL), b // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -DataType::DataType(const H5Location& loc, const char *dtype_name) : H5Object(), encoded_buf(NULL), buf_size(0) +DataType::DataType(const H5Location &loc, const char *dtype_name) : H5Object(), encoded_buf(NULL), buf_size(0) { id = p_opentype(loc, dtype_name); } @@ -188,7 +187,8 @@ DataType::DataType(const H5Location& loc, const char *dtype_name) : H5Object(), // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -DataType::DataType(const H5Location& loc, const H5std_string& dtype_name) : H5Object(), encoded_buf(NULL), buf_size(0) +DataType::DataType(const H5Location &loc, const H5std_string &dtype_name) + : H5Object(), encoded_buf(NULL), buf_size(0) { id = p_opentype(loc, dtype_name.c_str()); } @@ -205,13 +205,14 @@ DataType::DataType(const H5Location& loc, const H5std_string& dtype_name) : H5Ob // - Replaced decRefCount with close() to let the C library // handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- -void DataType::copy(const DataType& like_type) +void +DataType::copy(const DataType &like_type) { // close the current data type before copying like_type to this object try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw DataTypeIException(inMemFunc("copy"), close_error.getDetailMsg()); } @@ -230,13 +231,14 @@ void DataType::copy(const DataType& like_type) ///\par Description /// The resulted dataset will be transient and modifiable. //-------------------------------------------------------------------------- -void DataType::copy(const DataSet& dset) +void +DataType::copy(const DataSet &dset) { // close the current data type before copying dset's datatype to this object try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw DataTypeIException(inMemFunc("copy"), close_error.getDetailMsg()); } @@ -254,11 +256,11 @@ void DataType::copy(const DataSet& dset) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -hid_t DataType::p_decode() const +hid_t +DataType::p_decode() const { // Make sure that the buffer can be decoded - if (encoded_buf == NULL) - { + if (encoded_buf == NULL) { throw DataTypeIException("DataType::p_decode", "No encoded buffer"); } @@ -266,13 +268,11 @@ hid_t DataType::p_decode() const hid_t encoded_dtype_id = H5Tdecode(encoded_buf); // If H5Tdecode fails, raise exception - if (encoded_dtype_id < 0) - { + if (encoded_dtype_id < 0) { throw DataTypeIException("DataType::p_decode", "H5Tdecode failed"); } - else - { - return(encoded_dtype_id); + else { + return (encoded_dtype_id); } } #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -285,7 +285,8 @@ hid_t DataType::p_decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* DataType::decode() const +DataType * +DataType::decode() const { hid_t encoded_dtype_id = H5I_INVALID_HID; try { @@ -296,7 +297,7 @@ DataType* DataType::decode() const } DataType *encoded_dtype = new DataType; encoded_dtype->p_setId(encoded_dtype_id); - return(encoded_dtype); + return (encoded_dtype); } //-------------------------------------------------------------------------- @@ -306,27 +307,24 @@ DataType* DataType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -void DataType::encode() +void +DataType::encode() { // Call H5Tencode passing in null to determine the size of the buffer herr_t ret_value = H5Tencode(id, NULL, &buf_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("DataType::encode", "Failed to get buf_size"); } // Allocate buffer and call C function again to encode - if (buf_size > 0) - { + if (buf_size > 0) { encoded_buf = (unsigned char *)HDcalloc((size_t)1, buf_size); - ret_value = H5Tencode(id, encoded_buf, &buf_size); - if (ret_value < 0) - { + ret_value = H5Tencode(id, encoded_buf, &buf_size); + if (ret_value < 0) { throw DataTypeIException("DataType::encode", "H5Tencode failed"); } } - else - { + else { throw DataTypeIException("DataType::encode", "Failed to allocate buffer for encoding"); } } @@ -339,7 +337,8 @@ void DataType::encode() ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -bool DataType::hasBinaryDesc() const +bool +DataType::hasBinaryDesc() const { if (encoded_buf != NULL) return true; @@ -366,13 +365,13 @@ bool DataType::hasBinaryDesc() const // transient datatype. // BMR - Mar, 2015 //-------------------------------------------------------------------------- -DataType& DataType::operator=(const DataType& rhs) +DataType & +DataType::operator=(const DataType &rhs) { - if (this != &rhs) - { + if (this != &rhs) { setId(rhs.id); } - return(*this); + return (*this); } //-------------------------------------------------------------------------- @@ -384,7 +383,8 @@ DataType& DataType::operator=(const DataType& rhs) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DataType::operator==(const DataType& compared_type) const +bool +DataType::operator==(const DataType &compared_type) const { // Call C routine H5Tequal to determines whether two datatype // identifiers refer to the same datatype @@ -393,8 +393,7 @@ bool DataType::operator==(const DataType& compared_type) const return true; else if (ret_value == 0) return false; - else - { + else { throw DataTypeIException(inMemFunc("operator=="), "H5Tequal returns negative value"); } } @@ -408,7 +407,8 @@ bool DataType::operator==(const DataType& compared_type) const ///\exception H5::DataTypeIException // July, 2018 //-------------------------------------------------------------------------- -bool DataType::operator!=(const DataType& compared_type) const +bool +DataType::operator!=(const DataType &compared_type) const { return !operator==(compared_type); } @@ -427,7 +427,8 @@ bool DataType::operator!=(const DataType& compared_type) const // to be commonly used by several overloads of DataType::commit. // BMR - Jan, 2007 //-------------------------------------------------------------------------- -void DataType::p_commit(hid_t loc_id, const char* name) +void +DataType::p_commit(hid_t loc_id, const char *name) { // Call C routine to commit the transient datatype herr_t ret_value = H5Tcommit2(loc_id, name, id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -444,7 +445,8 @@ void DataType::p_commit(hid_t loc_id, const char* name) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Jan, 2007 //-------------------------------------------------------------------------- -void DataType::commit(const H5Location& loc, const char* name) +void +DataType::commit(const H5Location &loc, const char *name) { p_commit(loc.getId(), name); } @@ -463,7 +465,7 @@ void DataType::commit(const H5Location& loc, const char* name) // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void DataType::commit(H5Location& loc, const char* name) +// void DataType::commit(H5Location& loc, const char* name) //{ // p_commit(loc.getId(), name); //} @@ -475,7 +477,8 @@ void DataType::commit(const H5Location& loc, const char* name) /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::commit(const H5Location& loc, const H5std_string& name) +void +DataType::commit(const H5Location &loc, const H5std_string &name) { p_commit(loc.getId(), name.c_str()); } @@ -494,7 +497,7 @@ void DataType::commit(const H5Location& loc, const H5std_string& name) // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void DataType::commit(H5Location& loc, const H5std_string& name) +// void DataType::commit(H5Location& loc, const H5std_string& name) //{ // p_commit(loc.getId(), name.c_str()); //} @@ -508,7 +511,8 @@ void DataType::commit(const H5Location& loc, const H5std_string& name) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DataType::committed() const +bool +DataType::committed() const { // Call C function to determine if a datatype is a named one htri_t is_committed = H5Tcommitted(id); @@ -516,8 +520,7 @@ bool DataType::committed() const return true; else if (is_committed == 0) return false; - else - { + else { throw DataTypeIException(inMemFunc("committed"), "H5Tcommitted return negative value"); } } @@ -532,15 +535,15 @@ bool DataType::committed() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_conv_t DataType::find(const DataType& dest, H5T_cdata_t **pcdata) const +H5T_conv_t +DataType::find(const DataType &dest, H5T_cdata_t **pcdata) const { // Call C routine to find the conversion function H5T_conv_t func = H5Tfind(id, dest.getId(), pcdata); - if (func == NULL) - { + if (func == NULL) { throw DataTypeIException(inMemFunc("find"), "H5Tfind returns a NULL function"); } - return(func); + return (func); } //-------------------------------------------------------------------------- @@ -556,17 +559,18 @@ H5T_conv_t DataType::find(const DataType& dest, H5T_cdata_t **pcdata) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::convert(const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist) const +void +DataType::convert(const DataType &dest, size_t nelmts, void *buf, void *background, + const PropList &plist) const { // Get identifiers for C API - hid_t dest_id = dest.getId(); + hid_t dest_id = dest.getId(); hid_t plist_id = plist.getId(); // Call C routine H5Tconvert to convert the data herr_t ret_value; ret_value = H5Tconvert(id, dest_id, nelmts, buf, background, plist_id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("convert"), "H5Tconvert failed"); } } @@ -585,12 +589,12 @@ void DataType::convert(const DataType& dest, size_t nelmts, void *buf, void *bac /// the entire library is closed. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::lock() const +void +DataType::lock() const { // Call C routine to lock the datatype herr_t ret_value = H5Tlock(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("lock"), "H5Tlock failed"); } } @@ -602,16 +606,16 @@ void DataType::lock() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_class_t DataType::getClass() const +H5T_class_t +DataType::getClass() const { H5T_class_t type_class = H5Tget_class(id); // Return datatype class identifier if successful - if (type_class == H5T_NO_CLASS) - { + if (type_class == H5T_NO_CLASS) { throw DataTypeIException(inMemFunc("getClass"), "H5Tget_class returns H5T_NO_CLASS"); } - return(type_class); + return (type_class); } //-------------------------------------------------------------------------- @@ -621,15 +625,16 @@ H5T_class_t DataType::getClass() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -size_t DataType::getSize() const +size_t +DataType::getSize() const { // Call C routine to get the datatype size size_t type_size = H5Tget_size(id); - if (type_size <= 0) // valid data types are never zero size + if (type_size <= 0) // valid data types are never zero size { throw DataTypeIException(inMemFunc("getSize"), "H5Tget_size returns invalid datatype size"); } - return(type_size); + return (type_size); } //-------------------------------------------------------------------------- @@ -639,7 +644,8 @@ size_t DataType::getSize() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType DataType::getSuper() const +DataType +DataType::getSuper() const { // Call C routine to get the base datatype from which the specified // datatype is derived. @@ -647,14 +653,12 @@ DataType DataType::getSuper() const // If H5Tget_super returns a valid datatype id, create and return // the base type, otherwise, raise exception - if (base_type_id > 0) - { + if (base_type_id > 0) { DataType base_type; base_type.p_setId(base_type_id); - return(base_type); + return (base_type); } - else - { + else { throw DataTypeIException(inMemFunc("getSuper"), "H5Tget_super failed"); } } @@ -675,14 +679,14 @@ DataType DataType::getSuper() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::registerFunc(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const +void +DataType::registerFunc(H5T_pers_t pers, const char *name, const DataType &dest, H5T_conv_t func) const { - hid_t dest_id = dest.getId(); // get id of the destination datatype + hid_t dest_id = dest.getId(); // get id of the destination datatype // Call C routine H5Tregister to register the conversion function herr_t ret_value = H5Tregister(pers, name, id, dest_id, func); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("registerFunc"), "H5Tregister failed"); } } @@ -694,7 +698,8 @@ void DataType::registerFunc(H5T_pers_t pers, const char* name, const DataType& d /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::registerFunc(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const +void +DataType::registerFunc(H5T_pers_t pers, const H5std_string &name, const DataType &dest, H5T_conv_t func) const { registerFunc(pers, name.c_str(), dest, func); } @@ -712,14 +717,14 @@ void DataType::registerFunc(H5T_pers_t pers, const H5std_string& name, const Dat ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::unregister(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const +void +DataType::unregister(H5T_pers_t pers, const char *name, const DataType &dest, H5T_conv_t func) const { - hid_t dest_id = dest.getId(); // get id of the dest datatype for C API + hid_t dest_id = dest.getId(); // get id of the dest datatype for C API // Call C routine H5Tunregister to remove the conversion function herr_t ret_value = H5Tunregister(pers, name, id, dest_id, func); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("unregister"), "H5Tunregister failed"); } } @@ -731,7 +736,8 @@ void DataType::unregister(H5T_pers_t pers, const char* name, const DataType& des /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::unregister(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const +void +DataType::unregister(H5T_pers_t pers, const H5std_string &name, const DataType &dest, H5T_conv_t func) const { unregister(pers, name.c_str(), dest, func); } @@ -744,12 +750,12 @@ void DataType::unregister(H5T_pers_t pers, const H5std_string& name, const DataT ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::setTag(const char* tag) const +void +DataType::setTag(const char *tag) const { // Call C routine H5Tset_tag to tag an opaque datatype. herr_t ret_value = H5Tset_tag(id, tag); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("setTag"), "H5Tset_tag failed"); } } @@ -761,7 +767,8 @@ void DataType::setTag(const char* tag) const /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::setTag(const H5std_string& tag) const +void +DataType::setTag(const H5std_string &tag) const { setTag(tag.c_str()); } @@ -773,20 +780,19 @@ void DataType::setTag(const H5std_string& tag) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string DataType::getTag() const +H5std_string +DataType::getTag() const { - char* tag_Cstr = H5Tget_tag(id); + char *tag_Cstr = H5Tget_tag(id); // if the tag C-string returned is not NULL, convert it to C++ string // and return it, otherwise, raise an exception - if (tag_Cstr != NULL) - { + if (tag_Cstr != NULL) { H5std_string tag = H5std_string(tag_Cstr); // C string to string object - H5free_memory(tag_Cstr); // free the C string - return (tag); // return the tag + H5free_memory(tag_Cstr); // free the C string + return (tag); // return the tag } - else - { + else { throw DataTypeIException(inMemFunc("getTag"), "H5Tget_tag returns NULL for tag"); } } @@ -800,17 +806,16 @@ H5std_string DataType::getTag() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -bool DataType::detectClass(H5T_class_t cls) const +bool +DataType::detectClass(H5T_class_t cls) const { htri_t ret_value = H5Tdetect_class(id, cls); if (ret_value > 0) return true; else if (ret_value == 0) return false; - else - { - throw DataTypeIException(inMemFunc("detectClass"), - "H5Tdetect_class returns negative value"); + else { + throw DataTypeIException(inMemFunc("detectClass"), "H5Tdetect_class returns negative value"); } } @@ -822,17 +827,16 @@ bool DataType::detectClass(H5T_class_t cls) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - August, 2017 //-------------------------------------------------------------------------- -bool DataType::detectClass(const PredType& pred_type, H5T_class_t cls) +bool +DataType::detectClass(const PredType &pred_type, H5T_class_t cls) { htri_t ret_value = H5Tdetect_class(pred_type.getId(), cls); if (ret_value > 0) return true; else if (ret_value == 0) return false; - else - { - throw DataTypeIException("detectClass on PredType", - "H5Tdetect_class returns negative value"); + else { + throw DataTypeIException("detectClass on PredType", "H5Tdetect_class returns negative value"); } } @@ -844,17 +848,16 @@ bool DataType::detectClass(const PredType& pred_type, H5T_class_t cls) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -bool DataType::isVariableStr() const +bool +DataType::isVariableStr() const { htri_t is_varlen_str = H5Tis_variable_str(id); if (is_varlen_str == 1) return true; else if (is_varlen_str == 0) return false; - else - { - throw DataTypeIException(inMemFunc("isVariableStr"), - "H5Tis_variable_str returns negative value"); + else { + throw DataTypeIException(inMemFunc("isVariableStr"), "H5Tis_variable_str returns negative value"); } } @@ -869,18 +872,17 @@ bool DataType::isVariableStr() const // Currently, there is no datatype creation property list class // in the C++ API because there is no associated functionality. //-------------------------------------------------------------------------- -PropList DataType::getCreatePlist() const +PropList +DataType::getCreatePlist() const { hid_t create_plist_id = H5Tget_create_plist(id); - if (create_plist_id < 0) - { - throw DataTypeIException(inMemFunc("getCreatePlist"), - "H5Tget_create_plist returns negative value"); + if (create_plist_id < 0) { + throw DataTypeIException(inMemFunc("getCreatePlist"), "H5Tget_create_plist returns negative value"); } // create and return the DSetCreatPropList object PropList create_plist; f_PropList_setId(&create_plist, create_plist_id); - return(create_plist); + return (create_plist); } //-------------------------------------------------------------------------- @@ -895,9 +897,10 @@ PropList DataType::getCreatePlist() const // IdComponent::getId now becomes pure virtual function. // Programmer Binh-Minh Ribler - May, 2008 //-------------------------------------------------------------------------- -hid_t DataType::getId() const +hid_t +DataType::getId() const { - return(id); + return (id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -912,13 +915,14 @@ hid_t DataType::getId() const // This function was introduced in 1.10.1 to be used by the new // XxxType constructors that open a datatype. -BMR, Dec 2016 //-------------------------------------------------------------------------- -hid_t DataType::p_opentype(const H5Location& loc, const char *dtype_name) const +hid_t +DataType::p_opentype(const H5Location &loc, const char *dtype_name) const { // Call C function to open the named datatype at this location hid_t ret_value = H5Topen2(loc.getId(), dtype_name, H5P_DEFAULT); if (ret_value < 0) throw DataTypeIException(inMemFunc("constructor"), "H5Topen2 failed"); - return(ret_value); + return (ret_value); } //-------------------------------------------------------------------------- @@ -933,13 +937,14 @@ hid_t DataType::p_opentype(const H5Location& loc, const char *dtype_name) const // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::p_setId(const hid_t new_id) +void +DataType::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw DataTypeIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } // reset object's id to the given id @@ -954,21 +959,19 @@ void DataType::p_setId(const hid_t new_id) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void DataType::close() +void +DataType::close() { - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Tclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("close"), "H5Tclose failed"); } // Reset the id id = H5I_INVALID_HID; // Free and reset buffer of encoded object description if it's been used - if (encoded_buf != NULL) - { + if (encoded_buf != NULL) { HDfree(encoded_buf); buf_size = 0; } @@ -995,13 +998,12 @@ void DataType::close() //-------------------------------------------------------------------------- DataType::~DataType() { - try - { + try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { cerr << inMemFunc("~DataType - ") << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h index e4d9e4b..49f5348 100644 --- a/c++/src/H5DataType.h +++ b/c++/src/H5DataType.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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 namespace H5 { @@ -26,154 +26,161 @@ namespace H5 { */ // Inheritance: DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP DataType : public H5Object { - public: - // Creates a datatype given its class and size - DataType(const H5T_class_t type_class, size_t size); + public: + // Creates a datatype given its class and size + DataType(const H5T_class_t type_class, size_t size); - // Copy constructor - same as the original DataType. - DataType(const DataType& original); + // Copy constructor - same as the original DataType. + DataType(const DataType &original); - // Creates a copy of a predefined type - DataType(const PredType& pred_type); + // Creates a copy of a predefined type + DataType(const PredType &pred_type); - // Constructors to open a generic named datatype at a given location. - DataType(const H5Location& loc, const char* name); - DataType(const H5Location& loc, const H5std_string& name); + // Constructors to open a generic named datatype at a given location. + DataType(const H5Location &loc, const char *name); + DataType(const H5Location &loc, const H5std_string &name); - // Creates a datatype by way of dereference. - 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); + // Creates a datatype by way of dereference. + 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(); + // Closes this datatype. + virtual void close(); - // Copies an existing datatype to this datatype object. - void copy(const DataType& like_type); + // Copies an existing datatype to this datatype object. + void copy(const DataType &like_type); - // Copies the datatype of dset to this datatype object. - void copy(const DataSet& dset); + // Copies the datatype of dset to this datatype object. + void copy(const DataSet &dset); - // Returns a DataType instance by decoding the binary object - // description of this datatype. - virtual DataType* decode() const; + // Returns a DataType instance by decoding the binary object + // description of this datatype. + virtual DataType *decode() const; - // Creates a binary object description of this datatype. - void encode(); + // Creates a binary object description of this datatype. + void encode(); - // Returns the datatype class identifier. - H5T_class_t getClass() const; + // Returns the datatype class identifier. + H5T_class_t getClass() const; - // Commits a transient datatype to a file; this datatype becomes - // a named datatype which can be accessed from the location. - void commit(const H5Location& loc, const char* name); - void commit(const H5Location& loc, const H5std_string& name); + // Commits a transient datatype to a file; this datatype becomes + // a named datatype which can be accessed from the location. + void commit(const H5Location &loc, const char *name); + void commit(const H5Location &loc, const H5std_string &name); - // These two overloaded functions are kept for backward compatibility - // only; they missed the const - removed from 1.8.18 and 1.10.1 - //void commit(H5Location& loc, const char* name); - //void commit(H5Location& loc, const H5std_string& name); + // These two overloaded functions are kept for backward compatibility + // only; they missed the const - removed from 1.8.18 and 1.10.1 + // void commit(H5Location& loc, const char* name); + // void commit(H5Location& loc, const H5std_string& name); - // Determines whether this datatype is a named datatype or - // a transient datatype. - bool committed() const; + // Determines whether this datatype is a named datatype or + // a transient datatype. + bool committed() const; - // Finds a conversion function that can handle the conversion - // this datatype to the given datatype, dest. - H5T_conv_t find(const DataType& dest, H5T_cdata_t **pcdata) const; + // Finds a conversion function that can handle the conversion + // this datatype to the given datatype, dest. + H5T_conv_t find(const DataType &dest, H5T_cdata_t **pcdata) const; - // Converts data from between specified datatypes. - void convert(const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist=PropList::DEFAULT) const; + // Converts data from between specified datatypes. + void convert(const DataType &dest, size_t nelmts, void *buf, void *background, + const PropList &plist = PropList::DEFAULT) const; - // Assignment operator - DataType& operator=(const DataType& rhs); + // Assignment operator + DataType &operator=(const DataType &rhs); - // Determines whether two datatypes are the same. - bool operator==(const DataType& compared_type) const; + // Determines whether two datatypes are the same. + bool operator==(const DataType &compared_type) const; - // Determines whether two datatypes are not the same. - bool operator!=(const DataType& compared_type) const; + // Determines whether two datatypes are not the same. + bool operator!=(const DataType &compared_type) const; - // Locks a datatype. - void lock() const; + // Locks a datatype. + void lock() const; - // Returns the size of a datatype. - size_t getSize() const; + // Returns the size of a datatype. + size_t getSize() const; - // Returns the base datatype from which a datatype is derived. - // Note: not quite right for specific types yet??? - DataType getSuper() const; + // Returns the base datatype from which a datatype is derived. + // Note: not quite right for specific types yet??? + DataType getSuper() const; - // Registers a conversion function. - void registerFunc(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const; - void registerFunc(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const; + // Registers a conversion function. + void registerFunc(H5T_pers_t pers, const char *name, const DataType &dest, H5T_conv_t func) const; + void registerFunc(H5T_pers_t pers, const H5std_string &name, const DataType &dest, H5T_conv_t func) const; - // Removes a conversion function from all conversion paths. - void unregister(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const; - void unregister(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const; + // Removes a conversion function from all conversion paths. + void unregister(H5T_pers_t pers, const char *name, const DataType &dest, H5T_conv_t func) const; + void unregister(H5T_pers_t pers, const H5std_string &name, const DataType &dest, H5T_conv_t func) const; - // Tags an opaque datatype. - void setTag(const char* tag) const; - void setTag(const H5std_string& tag) const; + // Tags an opaque datatype. + void setTag(const char *tag) const; + void setTag(const H5std_string &tag) const; - // Gets the tag associated with an opaque datatype. - H5std_string getTag() const; + // Gets the tag associated with an opaque datatype. + H5std_string getTag() const; - // Checks whether this datatype contains (or is) a certain type class. - bool detectClass(H5T_class_t cls) const; - static bool detectClass(const PredType& pred_type, H5T_class_t cls); + // Checks whether this datatype contains (or is) a certain type class. + bool detectClass(H5T_class_t cls) const; + static bool detectClass(const PredType &pred_type, H5T_class_t cls); - // Checks whether this datatype is a variable-length string. - bool isVariableStr() const; + // Checks whether this datatype is a variable-length string. + bool isVariableStr() const; - // Returns a copy of the creation property list of a datatype. - PropList getCreatePlist() const; + // Returns a copy of the creation property list of a datatype. + PropList getCreatePlist() const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DataType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("DataType"); + } - // Creates a copy of an existing DataType using its id - DataType(const hid_t type_id); + // Creates a copy of an existing DataType using its id + DataType(const hid_t type_id); - // Default constructor - DataType(); + // Default constructor + DataType(); - // Determines whether this datatype has a binary object description. - bool hasBinaryDesc() const; + // Determines whether this datatype has a binary object description. + bool hasBinaryDesc() const; - // Gets the datatype id. - virtual hid_t getId() const; + // Gets the datatype id. + virtual hid_t getId() const; - // Destructor: properly terminates access to this datatype. - virtual ~DataType(); + // Destructor: properly terminates access to this datatype. + virtual ~DataType(); - protected: + protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - hid_t id; // HDF5 datatype id + hid_t id; // HDF5 datatype id - // Returns an id of a type by decoding the binary object - // description of this datatype. - hid_t p_decode() const; + // Returns an id of a type by decoding the binary object + // description of this datatype. + hid_t p_decode() const; - // Sets the datatype id. - virtual void p_setId(const hid_t new_id); + // Sets the datatype id. + virtual void p_setId(const hid_t new_id); - // Opens a datatype and returns the id. - hid_t p_opentype(const H5Location& loc, const char* dtype_name) const; + // Opens a datatype and returns the id. + hid_t p_opentype(const H5Location &loc, const char *dtype_name) const; #endif // DOXYGEN_SHOULD_SKIP_THIS - private: - // Buffer for binary object description of this datatype, allocated - // in DataType::encode and used in DataType::decode - unsigned char *encoded_buf; - size_t buf_size; + private: + // Buffer for binary object description of this datatype, allocated + // in DataType::encode and used in DataType::decode + unsigned char *encoded_buf; + size_t buf_size; - // Friend function to set DataType id. For library use only. - friend void f_DataType_setId(DataType* dtype, hid_t new_id); + // Friend function to set DataType id. For library use only. + friend void f_DataType_setId(DataType *dtype, hid_t new_id); - void p_commit(hid_t loc_id, const char* name); + void p_commit(hid_t loc_id, const char *name); }; // end of DataType } // namespace H5 -#endif // __H5DataType_H +#endif // H5DataType_H diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp index 79ff100..4c71d5e 100644 --- a/c++/src/H5DcreatProp.cpp +++ b/c++/src/H5DcreatProp.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -35,7 +35,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -DSetCreatPropList* DSetCreatPropList::DEFAULT_ = 0; +DSetCreatPropList *DSetCreatPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: DSetCreatPropList::getConstant @@ -49,13 +49,13 @@ DSetCreatPropList* DSetCreatPropList::DEFAULT_ = 0; // not happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -DSetCreatPropList* DSetCreatPropList::getConstant() +DSetCreatPropList * +DSetCreatPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -64,8 +64,9 @@ DSetCreatPropList* DSetCreatPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new DSetCreatPropList(H5P_DATASET_CREATE); else - throw PropListIException("DSetCreatPropList::getConstant", "DSetCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("DSetCreatPropList::getConstant", + "DSetCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -74,7 +75,8 @@ DSetCreatPropList* DSetCreatPropList::getConstant() // points to. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void DSetCreatPropList::deleteConstants() +void +DSetCreatPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -83,7 +85,7 @@ void DSetCreatPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for dataset creation default property //-------------------------------------------------------------------------- -const DSetCreatPropList& DSetCreatPropList::DEFAULT = *getConstant(); +const DSetCreatPropList &DSetCreatPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -92,7 +94,9 @@ const DSetCreatPropList& DSetCreatPropList::DEFAULT = *getConstant(); ///\brief Default constructor: creates a stub dataset creation property list // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList::DSetCreatPropList() : ObjCreatPropList(H5P_DATASET_CREATE) {} +DSetCreatPropList::DSetCreatPropList() : ObjCreatPropList(H5P_DATASET_CREATE) +{ +} //-------------------------------------------------------------------------- // Function: DSetCreatPropList copy constructor @@ -100,7 +104,9 @@ DSetCreatPropList::DSetCreatPropList() : ObjCreatPropList(H5P_DATASET_CREATE) {} /// DSetCreatPropList object // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList::DSetCreatPropList(const DSetCreatPropList& orig) : ObjCreatPropList(orig) {} +DSetCreatPropList::DSetCreatPropList(const DSetCreatPropList &orig) : ObjCreatPropList(orig) +{ +} //-------------------------------------------------------------------------- // Function: DSetCreatPropList overloaded constructor @@ -108,7 +114,9 @@ DSetCreatPropList::DSetCreatPropList(const DSetCreatPropList& orig) : ObjCreatPr /// existing dataset creation property list. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList::DSetCreatPropList(const hid_t plist_id) : ObjCreatPropList(plist_id) {} +DSetCreatPropList::DSetCreatPropList(const hid_t plist_id) : ObjCreatPropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: DSetCreatPropList::setChunk @@ -125,11 +133,11 @@ DSetCreatPropList::DSetCreatPropList(const hid_t plist_id) : ObjCreatPropList(pl /// changed to \c H5D_CHUNKED, if it is not so already. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setChunk(int ndims, const hsize_t* dim) const +void +DSetCreatPropList::setChunk(int ndims, const hsize_t *dim) const { herr_t ret_value = H5Pset_chunk(id, ndims, dim); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("DSetCreatPropList::setChunk", "H5Pset_chunk failed"); } } @@ -143,15 +151,14 @@ void DSetCreatPropList::setChunk(int ndims, const hsize_t* dim) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DSetCreatPropList::getChunk(int max_ndims, hsize_t* dim) const +int +DSetCreatPropList::getChunk(int max_ndims, hsize_t *dim) const { int chunk_size = H5Pget_chunk(id, max_ndims, dim); - if (chunk_size < 0) - { - throw PropListIException("DSetCreatPropList::getChunk", - "H5Pget_chunk returns negative chunk size"); + if (chunk_size < 0) { + throw PropListIException("DSetCreatPropList::getChunk", "H5Pget_chunk returns negative chunk size"); } - return(chunk_size); + return (chunk_size); } //-------------------------------------------------------------------------- @@ -164,13 +171,12 @@ int DSetCreatPropList::getChunk(int max_ndims, hsize_t* dim) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setLayout(H5D_layout_t layout) const +void +DSetCreatPropList::setLayout(H5D_layout_t layout) const { herr_t ret_value = H5Pset_layout(id, layout); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setLayout", - "H5Pset_layout failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setLayout", "H5Pset_layout failed"); } } @@ -190,15 +196,14 @@ void DSetCreatPropList::setLayout(H5D_layout_t layout) const ///\par Description // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5D_layout_t DSetCreatPropList::getLayout() const +H5D_layout_t +DSetCreatPropList::getLayout() const { H5D_layout_t layout = H5Pget_layout(id); - if (layout == H5D_LAYOUT_ERROR) - { - throw PropListIException("DSetCreatPropList::getLayout", - "H5Pget_layout returns H5D_LAYOUT_ERROR"); + if (layout == H5D_LAYOUT_ERROR) { + throw PropListIException("DSetCreatPropList::getLayout", "H5Pget_layout returns H5D_LAYOUT_ERROR"); } - return(layout); + return (layout); } //-------------------------------------------------------------------------- @@ -213,13 +218,12 @@ H5D_layout_t DSetCreatPropList::getLayout() const /// less compression. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setDeflate(int level) const +void +DSetCreatPropList::setDeflate(int level) const { herr_t ret_value = H5Pset_deflate(id, level); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setDeflate", - "H5Pset_deflate failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setDeflate", "H5Pset_deflate failed"); } } @@ -239,13 +243,12 @@ void DSetCreatPropList::setDeflate(int level) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - Jan, 2007 //-------------------------------------------------------------------------- -void DSetCreatPropList::setSzip(unsigned int options_mask, unsigned int pixels_per_block) const +void +DSetCreatPropList::setSzip(unsigned int options_mask, unsigned int pixels_per_block) const { herr_t ret_value = H5Pset_szip(id, options_mask, pixels_per_block); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setSzip", - "H5Pset_szip failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setSzip", "H5Pset_szip failed"); } } @@ -261,13 +264,12 @@ void DSetCreatPropList::setSzip(unsigned int options_mask, unsigned int pixels_p /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - Apr, 2016 //-------------------------------------------------------------------------- -void DSetCreatPropList::setNbit() const +void +DSetCreatPropList::setNbit() const { herr_t ret_value = H5Pset_nbit(id); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setNbit", - "H5Pset_nbit failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setNbit", "H5Pset_nbit failed"); } } @@ -288,13 +290,12 @@ void DSetCreatPropList::setNbit() const /// H5Pset_fill_value API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setFillValue(const DataType& fvalue_type, const void* value) const +void +DSetCreatPropList::setFillValue(const DataType &fvalue_type, const void *value) const { herr_t ret_value = H5Pset_fill_value(id, fvalue_type.getId(), value); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setFillValue", - "H5Pset_fill_value failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setFillValue", "H5Pset_fill_value failed"); } } @@ -311,13 +312,12 @@ void DSetCreatPropList::setFillValue(const DataType& fvalue_type, const void* va /// specified by \a fvalue_type. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::getFillValue(const DataType& fvalue_type, void* value) const +void +DSetCreatPropList::getFillValue(const DataType &fvalue_type, void *value) const { herr_t ret_value = H5Pget_fill_value(id, fvalue_type.getId(), value); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::getFillValue", - "H5Pget_fill_value failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::getFillValue", "H5Pget_fill_value failed"); } } @@ -331,14 +331,14 @@ void DSetCreatPropList::getFillValue(const DataType& fvalue_type, void* value) c ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5D_fill_value_t DSetCreatPropList::isFillValueDefined() const +H5D_fill_value_t +DSetCreatPropList::isFillValueDefined() const { H5D_fill_value_t status; - herr_t ret_value = H5Pfill_value_defined(id, &status); - if (ret_value < 0) - { + herr_t ret_value = H5Pfill_value_defined(id, &status); + if (ret_value < 0) { throw PropListIException("DSetCreatPropList::isFillValueDefined", - "H5Pfill_value_defined returned H5D_FILL_VALUE_ERROR (-1)"); + "H5Pfill_value_defined returned H5D_FILL_VALUE_ERROR (-1)"); } else return (status); @@ -364,14 +364,13 @@ H5D_fill_value_t DSetCreatPropList::isFillValueDefined() const /// and the filter fails then the entire I/O operation fails. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setFilter(H5Z_filter_t filter_id, unsigned int flags, - size_t cd_nelmts, const unsigned int cd_values[]) const +void +DSetCreatPropList::setFilter(H5Z_filter_t filter_id, unsigned int flags, size_t cd_nelmts, + const unsigned int cd_values[]) const { herr_t ret_value = H5Pset_filter(id, filter_id, flags, cd_nelmts, cd_values); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setFilter", - "H5Pset_filter failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setFilter", "H5Pset_filter failed"); } } @@ -385,13 +384,12 @@ void DSetCreatPropList::setFilter(H5Z_filter_t filter_id, unsigned int flags, /// deletes all filters if \a filter_id is \c H5Z_FILTER_NONE. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::removeFilter(H5Z_filter_t filter_id) const +void +DSetCreatPropList::removeFilter(H5Z_filter_t filter_id) const { herr_t ret_value = H5Premove_filter(id, filter_id); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::removeFilter", - "H5Premove_filter failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::removeFilter", "H5Premove_filter failed"); } } @@ -402,16 +400,16 @@ void DSetCreatPropList::removeFilter(H5Z_filter_t filter_id) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DSetCreatPropList::getNfilters() const +int +DSetCreatPropList::getNfilters() const { int num_filters = H5Pget_nfilters(id); - if (num_filters < 0) - { + if (num_filters < 0) { throw PropListIException("DSetCreatPropList::getNfilters", - "H5Pget_nfilters returned negative number of filters"); + "H5Pget_nfilters returned negative number of filters"); } else - return(num_filters); + return (num_filters); } //-------------------------------------------------------------------------- @@ -434,18 +432,18 @@ int DSetCreatPropList::getNfilters() const // of unsigned int, but for backward compatibility, it cannot be // changed. -BMR (2014/04/15) //-------------------------------------------------------------------------- -H5Z_filter_t DSetCreatPropList::getFilter(int filter_number, - unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, - size_t namelen, char name[], unsigned int& filter_config) const +H5Z_filter_t +DSetCreatPropList::getFilter(int filter_number, unsigned int &flags, size_t &cd_nelmts, + unsigned int *cd_values, size_t namelen, char name[], + unsigned int &filter_config) const { H5Z_filter_t filter_id; - filter_id = H5Pget_filter2(id, filter_number, &flags, &cd_nelmts, - cd_values, namelen, name, &filter_config); + filter_id = + H5Pget_filter2(id, filter_number, &flags, &cd_nelmts, cd_values, namelen, name, &filter_config); if (filter_id == H5Z_FILTER_ERROR) - throw PropListIException("DSetCreatPropList::getFilter", - "H5Pget_filter2 returned H5Z_FILTER_ERROR"); + throw PropListIException("DSetCreatPropList::getFilter", "H5Pget_filter2 returned H5Z_FILTER_ERROR"); else - return(filter_id); + return (filter_id); } //-------------------------------------------------------------------------- @@ -463,15 +461,15 @@ H5Z_filter_t DSetCreatPropList::getFilter(int filter_number, ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::getFilterById(H5Z_filter_t filter_id, - unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, - size_t namelen, char name[], unsigned int &filter_config) const +void +DSetCreatPropList::getFilterById(H5Z_filter_t filter_id, unsigned int &flags, size_t &cd_nelmts, + unsigned int *cd_values, size_t namelen, char name[], + unsigned int &filter_config) const { - herr_t ret_value = H5Pget_filter_by_id2(id, filter_id, &flags, &cd_nelmts, - cd_values, namelen, name, &filter_config); + herr_t ret_value = + H5Pget_filter_by_id2(id, filter_id, &flags, &cd_nelmts, cd_values, namelen, name, &filter_config); if (ret_value < 0) - throw PropListIException("DSetCreatPropList::getFilterById", - "H5Pget_filter_by_id2 failed"); + throw PropListIException("DSetCreatPropList::getFilterById", "H5Pget_filter_by_id2 failed"); } //-------------------------------------------------------------------------- @@ -495,14 +493,13 @@ void DSetCreatPropList::getFilterById(H5Z_filter_t filter_id, /// and the filter fails then the entire I/O operation fails. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::modifyFilter(H5Z_filter_t filter_id, unsigned int - flags, size_t cd_nelmts, const unsigned int cd_values[]) const +void +DSetCreatPropList::modifyFilter(H5Z_filter_t filter_id, unsigned int flags, size_t cd_nelmts, + const unsigned int cd_values[]) const { herr_t ret_value = H5Pmodify_filter(id, filter_id, flags, cd_nelmts, cd_values); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::modifyFilter", - "H5Pmodify_filter failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::modifyFilter", "H5Pmodify_filter failed"); } } @@ -515,7 +512,8 @@ void DSetCreatPropList::modifyFilter(H5Z_filter_t filter_id, unsigned int ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DSetCreatPropList::allFiltersAvail() const +bool +DSetCreatPropList::allFiltersAvail() const { htri_t ret_value = H5Pall_filters_avail(id); if (ret_value > 0) @@ -524,7 +522,8 @@ bool DSetCreatPropList::allFiltersAvail() const return false; else // Raise exception when H5Pall_filters_avail returns a negative value { - throw PropListIException("DSetCreatPropList::allFiltersAvail", "H5Pall_filters_avail returned negative value"); + throw PropListIException("DSetCreatPropList::allFiltersAvail", + "H5Pall_filters_avail returned negative value"); } } @@ -538,13 +537,12 @@ bool DSetCreatPropList::allFiltersAvail() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setShuffle() const +void +DSetCreatPropList::setShuffle() const { herr_t ret_value = H5Pset_shuffle(id); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setShuffle", - "H5Pset_shuffle failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setShuffle", "H5Pset_shuffle failed"); } } @@ -562,14 +560,13 @@ void DSetCreatPropList::setShuffle() const /// \li \c H5D_ALLOC_TIME_INCR // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5D_alloc_time_t DSetCreatPropList::getAllocTime() const +H5D_alloc_time_t +DSetCreatPropList::getAllocTime() const { H5D_alloc_time_t alloc_time; - herr_t ret_value = H5Pget_alloc_time(id, &alloc_time); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::getAllocTime", - "H5Pget_alloc_time failed"); + herr_t ret_value = H5Pget_alloc_time(id, &alloc_time); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::getAllocTime", "H5Pget_alloc_time failed"); } else return (alloc_time); @@ -586,14 +583,13 @@ H5D_alloc_time_t DSetCreatPropList::getAllocTime() const /// \li \c H5D_FILL_TIME_ALLOC. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5D_fill_time_t DSetCreatPropList::getFillTime() const +H5D_fill_time_t +DSetCreatPropList::getFillTime() const { H5D_fill_time_t fill_time; - herr_t ret_value = H5Pget_fill_time(id, &fill_time); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::getFillTime", - "H5Pget_fill_time failed"); + herr_t ret_value = H5Pget_fill_time(id, &fill_time); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::getFillTime", "H5Pget_fill_time failed"); } else return (fill_time); @@ -612,13 +608,12 @@ H5D_fill_time_t DSetCreatPropList::getFillTime() const /// \li \c H5D_ALLOC_TIME_INCR // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setAllocTime(H5D_alloc_time_t alloc_time) const +void +DSetCreatPropList::setAllocTime(H5D_alloc_time_t alloc_time) const { herr_t ret_value = H5Pset_alloc_time(id, alloc_time); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setAllocTime", - "H5Pset_alloc_time failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setAllocTime", "H5Pset_alloc_time failed"); } } @@ -633,13 +628,12 @@ void DSetCreatPropList::setAllocTime(H5D_alloc_time_t alloc_time) const /// \li \c H5D_FILL_TIME_ALLOC. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setFillTime(H5D_fill_time_t fill_time) const +void +DSetCreatPropList::setFillTime(H5D_fill_time_t fill_time) const { herr_t ret_value = H5Pset_fill_time(id, fill_time); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setFillTime", - "H5Pset_fill_time failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setFillTime", "H5Pset_fill_time failed"); } } @@ -650,13 +644,12 @@ void DSetCreatPropList::setFillTime(H5D_fill_time_t fill_time) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setFletcher32() const +void +DSetCreatPropList::setFletcher32() const { herr_t ret_value = H5Pset_fletcher32(id); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setFletcher32", - "H5Pset_fletcher32 failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setFletcher32", "H5Pset_fletcher32 failed"); } } @@ -676,13 +669,12 @@ void DSetCreatPropList::setFletcher32() const /// the extending). // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setExternal(const char* name, off_t offset, hsize_t size) const +void +DSetCreatPropList::setExternal(const char *name, off_t offset, hsize_t size) const { herr_t ret_value = H5Pset_external(id, name, offset, size); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setExternal", - "H5Pset_external failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setExternal", "H5Pset_external failed"); } } @@ -693,16 +685,16 @@ void DSetCreatPropList::setExternal(const char* name, off_t offset, hsize_t size ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DSetCreatPropList::getExternalCount() const +int +DSetCreatPropList::getExternalCount() const { int num_ext_files = H5Pget_external_count(id); - if (num_ext_files < 0) - { + if (num_ext_files < 0) { throw PropListIException("DSetCreatPropList::getExternalCount", - "H5Pget_external_count returns negative number of external files"); + "H5Pget_external_count returns negative number of external files"); } else - return(num_ext_files); + return (num_ext_files); } //-------------------------------------------------------------------------- @@ -727,13 +719,12 @@ int DSetCreatPropList::getExternalCount() const /// will not be returned. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::getExternal(unsigned idx, size_t name_size, char* name, off_t& offset, hsize_t& size) const +void +DSetCreatPropList::getExternal(unsigned idx, size_t name_size, char *name, off_t &offset, hsize_t &size) const { herr_t ret_value = H5Pget_external(id, idx, name_size, name, &offset, &size); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::getExternal", - "H5Pget_external failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::getExternal", "H5Pget_external failed"); } } @@ -755,13 +746,13 @@ void DSetCreatPropList::getExternal(unsigned idx, size_t name_size, char* name, /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - Mar, 2017 //-------------------------------------------------------------------------- -void DSetCreatPropList::setVirtual(const DataSpace& vspace, const char *src_fname, const char *src_dsname, const DataSpace& sspace) const +void +DSetCreatPropList::setVirtual(const DataSpace &vspace, const char *src_fname, const char *src_dsname, + const DataSpace &sspace) const { herr_t ret_value = H5Pset_virtual(id, vspace.getId(), src_fname, src_dsname, sspace.getId()); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setVirtual", - "H5Pset_virtual failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setVirtual", "H5Pset_virtual failed"); } } @@ -783,7 +774,9 @@ void DSetCreatPropList::setVirtual(const DataSpace& vspace, const char *src_fnam /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - Mar, 2017 //-------------------------------------------------------------------------- -void DSetCreatPropList::setVirtual(const DataSpace& vspace, const H5std_string src_fname, const H5std_string src_dsname, const DataSpace& sspace) const +void +DSetCreatPropList::setVirtual(const DataSpace &vspace, const H5std_string src_fname, + const H5std_string src_dsname, const DataSpace &sspace) const { setVirtual(vspace, src_fname.c_str(), src_dsname.c_str(), sspace); } @@ -793,6 +786,8 @@ void DSetCreatPropList::setVirtual(const DataSpace& vspace, const H5std_string s ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList::~DSetCreatPropList() {} +DSetCreatPropList::~DSetCreatPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h index 9f54e8d..3c032ee 100644 --- a/c++/src/H5DcreatProp.h +++ b/c++/src/H5DcreatProp.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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 namespace H5 { @@ -27,125 +27,136 @@ class DataSpace; */ // Inheritance: ObjCreatPropList -> PropList -> IdComponent class H5_DLLCPP DSetCreatPropList : public ObjCreatPropList { - public: - ///\brief Default dataset creation property list. - static const DSetCreatPropList& DEFAULT; + public: + ///\brief Default dataset creation property list. + static const DSetCreatPropList &DEFAULT; - // Creates a dataset creation property list. - DSetCreatPropList(); + // Creates a dataset creation property list. + DSetCreatPropList(); - // Queries whether all the filters set in this property list are - // available currently. - bool allFiltersAvail() const; + // Queries whether all the filters set in this property list are + // available currently. + bool allFiltersAvail() const; - // Get space allocation time for this property. - H5D_alloc_time_t getAllocTime() const; + // Get space allocation time for this property. + H5D_alloc_time_t getAllocTime() const; - // Set space allocation time for dataset during creation. - void setAllocTime(H5D_alloc_time_t alloc_time) const; + // Set space allocation time for dataset during creation. + void setAllocTime(H5D_alloc_time_t alloc_time) const; - // Retrieves the size of the chunks used to store a chunked layout dataset. - int getChunk(int max_ndims, hsize_t* dim) const; + // Retrieves the size of the chunks used to store a chunked layout dataset. + int getChunk(int max_ndims, hsize_t *dim) const; - // Sets the size of the chunks used to store a chunked layout dataset. - void setChunk(int ndims, const hsize_t* dim) const; + // Sets the size of the chunks used to store a chunked layout dataset. + void setChunk(int ndims, const hsize_t *dim) const; - // Returns information about an external file. - void getExternal(unsigned idx, size_t name_size, char* name, off_t& offset, hsize_t& size) const; + // Returns information about an external file. + void getExternal(unsigned idx, size_t name_size, char *name, off_t &offset, hsize_t &size) const; - // Returns the number of external files for a dataset. - int getExternalCount() const; + // Returns the number of external files for a dataset. + int getExternalCount() const; - // Gets fill value writing time. - H5D_fill_time_t getFillTime() const; + // Gets fill value writing time. + H5D_fill_time_t getFillTime() const; - // Sets fill value writing time for dataset. - void setFillTime(H5D_fill_time_t fill_time) const; + // Sets fill value writing time for dataset. + void setFillTime(H5D_fill_time_t fill_time) const; - // Retrieves a dataset fill value. - void getFillValue(const DataType& fvalue_type, void* value) const; + // Retrieves a dataset fill value. + void getFillValue(const DataType &fvalue_type, void *value) const; - // Sets a dataset fill value. - void setFillValue(const DataType& fvalue_type, const void* value) const; + // Sets a dataset fill value. + void setFillValue(const DataType &fvalue_type, const void *value) const; - // Returns information about a filter in a pipeline. - H5Z_filter_t getFilter(int filter_number, unsigned int& flags, size_t& cd_nelmts, unsigned int* cd_values, size_t namelen, char name[], unsigned int &filter_config) const; + // Returns information about a filter in a pipeline. + H5Z_filter_t getFilter(int filter_number, unsigned int &flags, size_t &cd_nelmts, unsigned int *cd_values, + size_t namelen, char name[], unsigned int &filter_config) const; - // Returns information about a filter in a pipeline given the filter id. - void getFilterById(H5Z_filter_t filter_id, unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, size_t namelen, char name[], unsigned int &filter_config) const; + // Returns information about a filter in a pipeline given the filter id. + void getFilterById(H5Z_filter_t filter_id, unsigned int &flags, size_t &cd_nelmts, + unsigned int *cd_values, size_t namelen, char name[], + unsigned int &filter_config) const; - // Gets the layout of the raw data storage of the data that uses this - // property list. - H5D_layout_t getLayout() const; + // Gets the layout of the raw data storage of the data that uses this + // property list. + H5D_layout_t getLayout() const; - // Sets the type of storage used to store the raw data for the - // dataset that uses this property list. - void setLayout(H5D_layout_t layout) const; + // Sets the type of storage used to store the raw data for the + // dataset that uses this property list. + void setLayout(H5D_layout_t layout) const; - // Returns the number of filters in the pipeline. - int getNfilters() const; + // Returns the number of filters in the pipeline. + int getNfilters() const; - // Checks if fill value has been defined for this property. - H5D_fill_value_t isFillValueDefined() const; + // Checks if fill value has been defined for this property. + H5D_fill_value_t isFillValueDefined() const; - // Modifies the specified filter. - void modifyFilter(H5Z_filter_t filter_id, unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[]) const; + // Modifies the specified filter. + void modifyFilter(H5Z_filter_t filter_id, unsigned int flags, size_t cd_nelmts, + const unsigned int cd_values[]) const; - // Remove one or all filters from the filter pipeline. - void removeFilter(H5Z_filter_t filter_id) const; + // Remove one or all filters from the filter pipeline. + void removeFilter(H5Z_filter_t filter_id) const; - // Sets compression method and compression level. - void setDeflate(int level) const; + // Sets compression method and compression level. + void setDeflate(int level) const; - // Adds an external file to the list of external files. - void setExternal(const char* name, off_t offset, hsize_t size) const; + // Adds an external file to the list of external files. + void setExternal(const char *name, off_t offset, hsize_t size) const; - // Adds a filter to the filter pipeline. - void setFilter(H5Z_filter_t filter, unsigned int flags = 0, size_t cd_nelmts = 0, const unsigned int cd_values[] = NULL) const; + // Adds a filter to the filter pipeline. + void setFilter(H5Z_filter_t filter, unsigned int flags = 0, size_t cd_nelmts = 0, + const unsigned int cd_values[] = NULL) const; - // Sets Fletcher32 checksum of EDC for this property list. - void setFletcher32() const; + // Sets Fletcher32 checksum of EDC for this property list. + void setFletcher32() const; - // Sets method of the shuffle filter. - void setShuffle() const; + // Sets method of the shuffle filter. + void setShuffle() const; - // Sets SZIP compression method. - void setSzip(unsigned int options_mask, unsigned int pixels_per_block) const; + // Sets SZIP compression method. + void setSzip(unsigned int options_mask, unsigned int pixels_per_block) const; - // Sets N-bit compression method. - void setNbit() const; + // Sets N-bit compression method. + void setNbit() const; - // Maps elements of a virtual dataset to elements of the source dataset. - void setVirtual(const DataSpace& vspace, const char *src_fname, const char *src_dsname, const DataSpace& sspace) const; - void setVirtual(const DataSpace& vspace, const H5std_string src_fname, const H5std_string src_dsname, const DataSpace& sspace) const; + // Maps elements of a virtual dataset to elements of the source dataset. + void setVirtual(const DataSpace &vspace, const char *src_fname, const char *src_dsname, + const DataSpace &sspace) const; + void setVirtual(const DataSpace &vspace, const H5std_string src_fname, const H5std_string src_dsname, + const DataSpace &sspace) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DSetCreatPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("DSetCreatPropList"); + } - // Copy constructor - same as the original DSetCreatPropList. - DSetCreatPropList(const DSetCreatPropList& orig); + // Copy constructor - same as the original DSetCreatPropList. + DSetCreatPropList(const DSetCreatPropList &orig); - // Creates a copy of an existing dataset creation property list - // using the property list id. - DSetCreatPropList(const hid_t plist_id); + // Creates a copy of an existing dataset creation property list + // using the property list id. + DSetCreatPropList(const hid_t plist_id); - // Noop destructor. - virtual ~DSetCreatPropList(); + // Noop destructor. + virtual ~DSetCreatPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static DSetCreatPropList* DEFAULT_; + private: + static DSetCreatPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static DSetCreatPropList* getConstant(); + // Creates the global constant, should only be used by the library + static DSetCreatPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of DSetCreatPropList } // namespace H5 -#endif // __H5DSCreatPropList_H +#endif // H5DSCreatPropList_H diff --git a/c++/src/H5DxferProp.cpp b/c++/src/H5DxferProp.cpp index 9cc6961..2b50de4 100644 --- a/c++/src/H5DxferProp.cpp +++ b/c++/src/H5DxferProp.cpp @@ -6,14 +6,14 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include <string> -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -28,7 +28,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -DSetMemXferPropList* DSetMemXferPropList::DEFAULT_ = 0; +DSetMemXferPropList *DSetMemXferPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: DSetMemXferPropList::getConstant @@ -42,13 +42,13 @@ DSetMemXferPropList* DSetMemXferPropList::DEFAULT_ = 0; // happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -DSetMemXferPropList* DSetMemXferPropList::getConstant() +DSetMemXferPropList * +DSetMemXferPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -57,8 +57,10 @@ DSetMemXferPropList* DSetMemXferPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new DSetMemXferPropList(H5P_DATASET_XFER); else - throw PropListIException("DSetMemXferPropList::getConstant", "DSetMemXferPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException( + "DSetMemXferPropList::getConstant", + "DSetMemXferPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -67,7 +69,8 @@ DSetMemXferPropList* DSetMemXferPropList::getConstant() // points to. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void DSetMemXferPropList::deleteConstants() +void +DSetMemXferPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -76,7 +79,7 @@ void DSetMemXferPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for default dataset memory and transfer property list. //-------------------------------------------------------------------------- -const DSetMemXferPropList& DSetMemXferPropList::DEFAULT = *getConstant(); +const DSetMemXferPropList &DSetMemXferPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -86,7 +89,9 @@ const DSetMemXferPropList& DSetMemXferPropList::DEFAULT = *getConstant(); /// transfer property list object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetMemXferPropList::DSetMemXferPropList() : PropList(H5P_DATASET_XFER) {} +DSetMemXferPropList::DSetMemXferPropList() : PropList(H5P_DATASET_XFER) +{ +} //-------------------------------------------------------------------------- // Function DSetMemXferPropList constructor @@ -94,7 +99,7 @@ DSetMemXferPropList::DSetMemXferPropList() : PropList(H5P_DATASET_XFER) {} /// expression. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetMemXferPropList::DSetMemXferPropList(const char* exp) : PropList(H5P_DATASET_XFER) +DSetMemXferPropList::DSetMemXferPropList(const char *exp) : PropList(H5P_DATASET_XFER) { setDataTransform(exp); } @@ -107,7 +112,9 @@ DSetMemXferPropList::DSetMemXferPropList(const char* exp) : PropList(H5P_DATASET /// list object to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetMemXferPropList::DSetMemXferPropList(const DSetMemXferPropList& original) : PropList(original ) {} +DSetMemXferPropList::DSetMemXferPropList(const DSetMemXferPropList &original) : PropList(original) +{ +} //-------------------------------------------------------------------------- // Function DSetMemXferPropList overloaded constructor @@ -117,7 +124,9 @@ DSetMemXferPropList::DSetMemXferPropList(const DSetMemXferPropList& original) : /// property list // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetMemXferPropList::DSetMemXferPropList(const hid_t plist_id) : PropList(plist_id) {} +DSetMemXferPropList::DSetMemXferPropList(const hid_t plist_id) : PropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: DSetMemXferPropList::setBuffer @@ -128,13 +137,12 @@ DSetMemXferPropList::DSetMemXferPropList(const hid_t plist_id) : PropList(plist_ ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setBuffer(size_t size, void* tconv, void* bkg) const +void +DSetMemXferPropList::setBuffer(size_t size, void *tconv, void *bkg) const { herr_t ret_value = H5Pset_buffer(id, size, tconv, bkg); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setBuffer", - "H5Pset_buffer failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setBuffer", "H5Pset_buffer failed"); } } @@ -147,15 +155,15 @@ void DSetMemXferPropList::setBuffer(size_t size, void* tconv, void* bkg) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -size_t DSetMemXferPropList::getBuffer(void** tconv, void** bkg) const +size_t +DSetMemXferPropList::getBuffer(void **tconv, void **bkg) const { size_t buffer_size = H5Pget_buffer(id, tconv, bkg); - if(buffer_size == 0) - { + if (buffer_size == 0) { throw PropListIException("DSetMemXferPropList::getBuffer", - "H5Pget_buffer returned 0 for buffer size - failure"); + "H5Pget_buffer returned 0 for buffer size - failure"); } - return(buffer_size); + return (buffer_size); } //-------------------------------------------------------------------------- @@ -165,13 +173,12 @@ size_t DSetMemXferPropList::getBuffer(void** tconv, void** bkg) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setPreserve(bool status) const +void +DSetMemXferPropList::setPreserve(bool status) const { - herr_t ret_value = H5Pset_preserve(id, (hbool_t) status); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setPreserve", - "H5Pset_preserve failed"); + herr_t ret_value = H5Pset_preserve(id, (hbool_t)status); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setPreserve", "H5Pset_preserve failed"); } } @@ -182,17 +189,17 @@ void DSetMemXferPropList::setPreserve(bool status) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DSetMemXferPropList::getPreserve() const +bool +DSetMemXferPropList::getPreserve() const { int ret_value = H5Pget_preserve(id); - if(ret_value > 0) + if (ret_value > 0) return true; - else if(ret_value == 0) + else if (ret_value == 0) return false; - else - { + else { throw PropListIException("DSetMemXferPropList::getPreserve", - "H5Pget_preserve returned negative value for status"); + "H5Pget_preserve returned negative value for status"); } } @@ -205,13 +212,12 @@ bool DSetMemXferPropList::getPreserve() const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setBtreeRatios(double left, double middle, double right) const +void +DSetMemXferPropList::setBtreeRatios(double left, double middle, double right) const { herr_t ret_value = H5Pset_btree_ratios(id, left, middle, right); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setBtreeRatios", - "H5Pset_btree_ratios failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setBtreeRatios", "H5Pset_btree_ratios failed"); } } @@ -224,13 +230,12 @@ void DSetMemXferPropList::setBtreeRatios(double left, double middle, double righ ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::getBtreeRatios(double& left, double& middle, double& right) const +void +DSetMemXferPropList::getBtreeRatios(double &left, double &middle, double &right) const { herr_t ret_value = H5Pget_btree_ratios(id, &left, &middle, &right); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::getBtreeRatios", - "H5Pget_btree_ratios failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::getBtreeRatios", "H5Pget_btree_ratios failed"); } } @@ -241,13 +246,12 @@ void DSetMemXferPropList::getBtreeRatios(double& left, double& middle, double& r ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setDataTransform(const char* expression) const +void +DSetMemXferPropList::setDataTransform(const char *expression) const { herr_t ret_value = H5Pset_data_transform(id, expression); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setDataTransform", - "H5Pset_data_transform failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setDataTransform", "H5Pset_data_transform failed"); } } @@ -259,7 +263,8 @@ void DSetMemXferPropList::setDataTransform(const char* expression) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setDataTransform(const H5std_string& expression) const +void +DSetMemXferPropList::setDataTransform(const H5std_string &expression) const { setDataTransform(expression.c_str()); } @@ -273,7 +278,8 @@ void DSetMemXferPropList::setDataTransform(const H5std_string& expression) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -ssize_t DSetMemXferPropList::getDataTransform(char* exp, size_t buf_size) const +ssize_t +DSetMemXferPropList::getDataTransform(char *exp, size_t buf_size) const { // H5Pget_data_transform will get buf_size characters of the expression // including the null terminator @@ -281,10 +287,8 @@ ssize_t DSetMemXferPropList::getDataTransform(char* exp, size_t buf_size) const exp_len = H5Pget_data_transform(id, exp, buf_size); // H5Pget_data_transform returns a negative value, raise an exception - if (exp_len < 0) - { - throw PropListIException("DSetMemXferPropList::getDataTransform", - "H5Pget_data_transform failed"); + if (exp_len < 0) { + throw PropListIException("DSetMemXferPropList::getDataTransform", "H5Pget_data_transform failed"); } // H5Pget_data_transform will put a null terminator at the end of the @@ -292,7 +296,7 @@ ssize_t DSetMemXferPropList::getDataTransform(char* exp, size_t buf_size) const // of the buffer. // Return the expression length, which might be different from buf_size - return(exp_len); + return (exp_len); } //-------------------------------------------------------------------------- @@ -303,39 +307,38 @@ ssize_t DSetMemXferPropList::getDataTransform(char* exp, size_t buf_size) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -H5std_string DSetMemXferPropList::getDataTransform() const +H5std_string +DSetMemXferPropList::getDataTransform() const { // Initialize string to "", so that if there is no expression, the returned // string will be empty - H5std_string expression(""); + H5std_string expression; // Preliminary call to get the expression's length ssize_t exp_len = H5Pget_data_transform(id, NULL, (size_t)0); // If H5Pget_data_transform returns a negative value, raise an exception - if (exp_len < 0) - { + if (exp_len < 0) { throw PropListIException("DSetMemXferPropList::getDataTransform", "H5Pget_data_transform failed"); } // If expression exists, calls C routine again to get it - else if (exp_len > 0) - { + else if (exp_len > 0) { // Temporary buffer for char* expression - char* exp_C = new char[exp_len+1]; - HDmemset(exp_C, 0, exp_len+1); // clear buffer + char *exp_C = new char[exp_len + 1]; + HDmemset(exp_C, 0, exp_len + 1); // clear buffer // Used overloaded function - exp_len = getDataTransform(exp_C, exp_len+1); + exp_len = getDataTransform(exp_C, exp_len + 1); // Convert the C expression to return expression = exp_C; // Clean up resource - delete []exp_C; + delete[] exp_C; } // Return the string expression - return(expression); + return (expression); } //-------------------------------------------------------------------------- @@ -347,13 +350,12 @@ H5std_string DSetMemXferPropList::getDataTransform() const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setTypeConvCB(H5T_conv_except_func_t op, void *user_data) const +void +DSetMemXferPropList::setTypeConvCB(H5T_conv_except_func_t op, void *user_data) const { herr_t ret_value = H5Pset_type_conv_cb(id, op, user_data); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setTypeConvCB", - "H5Pset_type_conv_cb failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setTypeConvCB", "H5Pset_type_conv_cb failed"); } } @@ -365,13 +367,12 @@ void DSetMemXferPropList::setTypeConvCB(H5T_conv_except_func_t op, void *user_da ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::getTypeConvCB(H5T_conv_except_func_t *op, void **user_data) const +void +DSetMemXferPropList::getTypeConvCB(H5T_conv_except_func_t *op, void **user_data) const { herr_t ret_value = H5Pget_type_conv_cb(id, op, user_data); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::getTypeConvCB", - "H5Pget_type_conv_cb failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::getTypeConvCB", "H5Pget_type_conv_cb failed"); } } @@ -385,14 +386,13 @@ void DSetMemXferPropList::getTypeConvCB(H5T_conv_except_func_t *op, void **user_ ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setVlenMemManager(H5MM_allocate_t alloc_func, void* alloc_info, H5MM_free_t free_func, void* free_info) const +void +DSetMemXferPropList::setVlenMemManager(H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, + void *free_info) const { - herr_t ret_value = H5Pset_vlen_mem_manager(id, alloc_func, alloc_info, - free_func, free_info); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setVlenMemManager", - "H5Pset_vlen_mem_manager failed"); + herr_t ret_value = H5Pset_vlen_mem_manager(id, alloc_func, alloc_info, free_func, free_info); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setVlenMemManager", "H5Pset_vlen_mem_manager failed"); } } @@ -404,9 +404,10 @@ void DSetMemXferPropList::setVlenMemManager(H5MM_allocate_t alloc_func, void* al ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setVlenMemManager() const +void +DSetMemXferPropList::setVlenMemManager() const { - setVlenMemManager(NULL, NULL, NULL, NULL); + setVlenMemManager(NULL, NULL, NULL, NULL); } //-------------------------------------------------------------------------- @@ -419,13 +420,13 @@ void DSetMemXferPropList::setVlenMemManager() const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::getVlenMemManager(H5MM_allocate_t& alloc_func, void** alloc_info, H5MM_free_t& free_func, void** free_info) const +void +DSetMemXferPropList::getVlenMemManager(H5MM_allocate_t &alloc_func, void **alloc_info, H5MM_free_t &free_func, + void **free_info) const { herr_t ret_value = H5Pget_vlen_mem_manager(id, &alloc_func, alloc_info, &free_func, free_info); - if (ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::getVlenMemManager", - "H5Pget_vlen_mem_manager failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::getVlenMemManager", "H5Pget_vlen_mem_manager failed"); } } @@ -439,13 +440,13 @@ void DSetMemXferPropList::getVlenMemManager(H5MM_allocate_t& alloc_func, void** /// API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setSmallDataBlockSize(hsize_t size) const +void +DSetMemXferPropList::setSmallDataBlockSize(hsize_t size) const { herr_t ret_value = H5Pset_small_data_block_size(id, size); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("DSetMemXferPropList::setSmallDataBlockSize", - "H5Pset_small_data_block_size failed"); + "H5Pset_small_data_block_size failed"); } } @@ -456,16 +457,16 @@ void DSetMemXferPropList::setSmallDataBlockSize(hsize_t size) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -hsize_t DSetMemXferPropList::getSmallDataBlockSize() const +hsize_t +DSetMemXferPropList::getSmallDataBlockSize() const { hsize_t size; - herr_t ret_value = H5Pget_small_data_block_size(id, &size); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_small_data_block_size(id, &size); + if (ret_value < 0) { throw PropListIException("DSetMemXferPropList::getSmallDataBlockSize", - "H5Pget_small_data_block_size failed"); + "H5Pget_small_data_block_size failed"); } - return(size); + return (size); } //-------------------------------------------------------------------------- @@ -478,13 +479,13 @@ hsize_t DSetMemXferPropList::getSmallDataBlockSize() const /// API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setHyperVectorSize(size_t vector_size) const +void +DSetMemXferPropList::setHyperVectorSize(size_t vector_size) const { herr_t ret_value = H5Pset_hyper_vector_size(id, vector_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("DSetMemXferPropList::setHyperVectorSize", - "H5Pset_hyper_vector_size failed"); + "H5Pset_hyper_vector_size failed"); } } @@ -496,16 +497,16 @@ void DSetMemXferPropList::setHyperVectorSize(size_t vector_size) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -size_t DSetMemXferPropList::getHyperVectorSize() const +size_t +DSetMemXferPropList::getHyperVectorSize() const { size_t vector_size; herr_t ret_value = H5Pget_hyper_vector_size(id, &vector_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("DSetMemXferPropList::getHyperVectorSize", - "H5Pget_hyper_vector_size failed"); + "H5Pget_hyper_vector_size failed"); } - return(vector_size); + return (vector_size); } //-------------------------------------------------------------------------- @@ -526,13 +527,12 @@ size_t DSetMemXferPropList::getHyperVectorSize() const /// \li \c H5Z_DISABLE_EDC // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setEDCCheck(H5Z_EDC_t check) const +void +DSetMemXferPropList::setEDCCheck(H5Z_EDC_t check) const { herr_t ret_value = H5Pset_edc_check(id, check); - if (ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setEDCCheck", - "H5Pset_edc_check failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setEDCCheck", "H5Pset_edc_check failed"); } } @@ -543,15 +543,14 @@ void DSetMemXferPropList::setEDCCheck(H5Z_EDC_t check) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5Z_EDC_t DSetMemXferPropList::getEDCCheck() const +H5Z_EDC_t +DSetMemXferPropList::getEDCCheck() const { H5Z_EDC_t check = H5Pget_edc_check(id); - if (check < 0) - { - throw PropListIException("DSetMemXferPropList::getEDCCheck", - "H5Pget_edc_check failed"); + if (check < 0) { + throw PropListIException("DSetMemXferPropList::getEDCCheck", "H5Pget_edc_check failed"); } - return(check); + return (check); } //-------------------------------------------------------------------------- @@ -559,7 +558,8 @@ H5Z_EDC_t DSetMemXferPropList::getEDCCheck() const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetMemXferPropList::~DSetMemXferPropList() {} - -} // end namespace +DSetMemXferPropList::~DSetMemXferPropList() +{ +} +} // namespace H5 diff --git a/c++/src/H5DxferProp.h b/c++/src/H5DxferProp.h index 6955778..11bad65 100644 --- a/c++/src/H5DxferProp.h +++ b/c++/src/H5DxferProp.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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 namespace H5 { @@ -23,109 +23,112 @@ namespace H5 { */ // Inheritance: PropList -> IdComponent class H5_DLLCPP DSetMemXferPropList : public PropList { - public: - ///\brief Default dataset memory and transfer property list. - static const DSetMemXferPropList& DEFAULT; + public: + ///\brief Default dataset memory and transfer property list. + static const DSetMemXferPropList &DEFAULT; - // Creates a dataset memory and transfer property list. - DSetMemXferPropList(); + // Creates a dataset memory and transfer property list. + DSetMemXferPropList(); - // Creates a dataset transform property list. - DSetMemXferPropList(const char* expression); + // Creates a dataset transform property list. + DSetMemXferPropList(const char *expression); - // Sets type conversion and background buffers. - void setBuffer(size_t size, void* tconv, void* bkg) const; + // Sets type conversion and background buffers. + void setBuffer(size_t size, void *tconv, void *bkg) const; - // Reads buffer settings. - size_t getBuffer(void** tconv, void** bkg) const; + // Reads buffer settings. + size_t getBuffer(void **tconv, void **bkg) const; - // Sets B-tree split ratios for a dataset transfer property list. - void setBtreeRatios(double left, double middle, double right) const; + // Sets B-tree split ratios for a dataset transfer property list. + void setBtreeRatios(double left, double middle, double right) const; - // Gets B-tree split ratios for a dataset transfer property list. - void getBtreeRatios(double& left, double& middle, double& right) const; + // Gets B-tree split ratios for a dataset transfer property list. + void getBtreeRatios(double &left, double &middle, double &right) const; - // Sets data transform expression. - void setDataTransform(const char* expression) const; - void setDataTransform(const H5std_string& expression) const; + // Sets data transform expression. + void setDataTransform(const char *expression) const; + void setDataTransform(const H5std_string &expression) const; - // Gets data transform expression. - ssize_t getDataTransform(char* exp, size_t buf_size=0) const; - H5std_string getDataTransform() const; + // Gets data transform expression. + ssize_t getDataTransform(char *exp, size_t buf_size = 0) const; + H5std_string getDataTransform() const; - // Sets the dataset transfer property list status to TRUE or FALSE. - void setPreserve(bool status) const; + // Sets the dataset transfer property list status to TRUE or FALSE. + void setPreserve(bool status) const; - // Checks status of the dataset transfer property list. - bool getPreserve() const; + // Checks status of the dataset transfer property list. + bool getPreserve() const; - // Sets an exception handling callback for datatype conversion. - void setTypeConvCB(H5T_conv_except_func_t op, void *user_data) const; + // Sets an exception handling callback for datatype conversion. + void setTypeConvCB(H5T_conv_except_func_t op, void *user_data) const; - // Gets the exception handling callback for datatype conversion. - void getTypeConvCB(H5T_conv_except_func_t *op, void **user_data) const; + // Gets the exception handling callback for datatype conversion. + void getTypeConvCB(H5T_conv_except_func_t *op, void **user_data) const; - // Sets the memory manager for variable-length datatype - // allocation in H5Dread and H5Dvlen_reclaim. - void setVlenMemManager(H5MM_allocate_t alloc, void* alloc_info, - H5MM_free_t free, void* free_info) const; + // Sets the memory manager for variable-length datatype + // allocation in H5Dread and H5Dvlen_reclaim. + void setVlenMemManager(H5MM_allocate_t alloc, void *alloc_info, H5MM_free_t free, void *free_info) const; - // alloc and free are set to NULL, indicating that system - // malloc and free are to be used. - void setVlenMemManager() const; + // alloc and free are set to NULL, indicating that system + // malloc and free are to be used. + void setVlenMemManager() const; - // Gets the memory manager for variable-length datatype - // allocation in H5Dread and H5Tvlen_reclaim. - void getVlenMemManager(H5MM_allocate_t& alloc, void** alloc_info, - H5MM_free_t& free, void** free_info) const; + // Gets the memory manager for variable-length datatype + // allocation in H5Dread and H5Tvlen_reclaim. + void getVlenMemManager(H5MM_allocate_t &alloc, void **alloc_info, H5MM_free_t &free, + void **free_info) const; - // Sets the size of a contiguous block reserved for small data. - void setSmallDataBlockSize(hsize_t size) const; + // Sets the size of a contiguous block reserved for small data. + void setSmallDataBlockSize(hsize_t size) const; - // Returns the current small data block size setting. - hsize_t getSmallDataBlockSize() const; + // Returns the current small data block size setting. + hsize_t getSmallDataBlockSize() const; - // Sets number of I/O vectors to be read/written in hyperslab I/O. - void setHyperVectorSize(size_t vector_size) const; + // Sets number of I/O vectors to be read/written in hyperslab I/O. + void setHyperVectorSize(size_t vector_size) const; - // Returns the number of I/O vectors to be read/written in - // hyperslab I/O. - size_t getHyperVectorSize() const; + // Returns the number of I/O vectors to be read/written in + // hyperslab I/O. + size_t getHyperVectorSize() const; - // Enables or disables error-detecting for a dataset reading - // process. - void setEDCCheck(H5Z_EDC_t check) const; + // Enables or disables error-detecting for a dataset reading + // process. + void setEDCCheck(H5Z_EDC_t check) const; - // Determines whether error-detection is enabled for dataset reads. - H5Z_EDC_t getEDCCheck() const; + // Determines whether error-detection is enabled for dataset reads. + H5Z_EDC_t getEDCCheck() const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DSetMemXferPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("DSetMemXferPropList"); + } - // Copy constructor - same as the original DSetMemXferPropList. - DSetMemXferPropList(const DSetMemXferPropList& orig); + // Copy constructor - same as the original DSetMemXferPropList. + DSetMemXferPropList(const DSetMemXferPropList &orig); - // Creates a copy of an existing dataset memory and transfer - // property list using the property list id. - DSetMemXferPropList(const hid_t plist_id); + // Creates a copy of an existing dataset memory and transfer + // property list using the property list id. + DSetMemXferPropList(const hid_t plist_id); - // Noop destructor - virtual ~DSetMemXferPropList(); + // Noop destructor + virtual ~DSetMemXferPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static DSetMemXferPropList* DEFAULT_; + private: + static DSetMemXferPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static DSetMemXferPropList* getConstant(); + // Creates the global constant, should only be used by the library + static DSetMemXferPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of DSetMemXferPropList } // namespace H5 -#endif // __H5DSetMemXferPropList_H +#endif // H5DSetMemXferPropList_H diff --git a/c++/src/H5EnumType.cpp b/c++/src/H5EnumType.cpp index f9adc47..6c7b533 100644 --- a/c++/src/H5EnumType.cpp +++ b/c++/src/H5EnumType.cpp @@ -6,14 +6,14 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include <string> -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -41,7 +41,9 @@ namespace H5 { ///\brief Default constructor: Creates a stub datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType() : DataType() {} +EnumType::EnumType() : DataType() +{ +} //-------------------------------------------------------------------------- // Function: EnumType overloaded constructor @@ -50,14 +52,18 @@ EnumType::EnumType() : DataType() {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType(const hid_t existing_id) : DataType( existing_id ) {} +EnumType::EnumType(const hid_t existing_id) : DataType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: EnumType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType(const EnumType& original) : DataType( original ) {} +EnumType::EnumType(const EnumType &original) : DataType(original) +{ +} //-------------------------------------------------------------------------- // Function: EnumType overloaded constructor @@ -69,7 +75,9 @@ EnumType::EnumType(const EnumType& original) : DataType( original ) {} // the enum datatype. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType(size_t size) : DataType( H5T_ENUM, size ) {} +EnumType::EnumType(size_t size) : DataType(H5T_ENUM, size) +{ +} //-------------------------------------------------------------------------- // Function: EnumType overloaded constructor @@ -78,14 +86,13 @@ EnumType::EnumType(size_t size) : DataType( H5T_ENUM, size ) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType(const DataSet& dataset) : DataType() +EnumType::EnumType(const DataSet &dataset) : DataType() { // Calls C function H5Dget_type to get the id of the datatype id = H5Dget_type(dataset.getId()); // If the datatype id is not valid, throw an exception - if (id < 0) - { + if (id < 0) { throw DataSetIException("EnumType constructor", "H5Dget_type failed"); } } @@ -97,14 +104,13 @@ EnumType::EnumType(const DataSet& dataset) : DataType() ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType(const IntType& data_type) : DataType() +EnumType::EnumType(const IntType &data_type) : DataType() { // Calls C function H5Tenum_create to get the id of the datatype id = H5Tenum_create(data_type.getId()); // If the datatype id is not valid, throw an exception - if (id < 0) - { + if (id < 0) { throw DataSetIException("EnumType constructor", "H5Tenum_create failed"); } } @@ -123,7 +129,7 @@ EnumType::EnumType(const IntType& data_type) : DataType() // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -EnumType::EnumType(const H5Location& loc, const char *dtype_name) : DataType() +EnumType::EnumType(const H5Location &loc, const char *dtype_name) : DataType() { id = p_opentype(loc, dtype_name); } @@ -142,7 +148,7 @@ EnumType::EnumType(const H5Location& loc, const char *dtype_name) : DataType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -EnumType::EnumType(const H5Location& loc, const H5std_string& dtype_name) : DataType() +EnumType::EnumType(const H5Location &loc, const H5std_string &dtype_name) : DataType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -155,7 +161,8 @@ EnumType::EnumType(const H5Location& loc, const H5std_string& dtype_name) : Data ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* EnumType::decode() const +DataType * +EnumType::decode() const { hid_t encoded_enumtype_id = H5I_INVALID_HID; try { @@ -166,7 +173,7 @@ DataType* EnumType::decode() const } EnumType *encoded_enumtype = new EnumType; encoded_enumtype->p_setId(encoded_enumtype_id); - return(encoded_enumtype); + return (encoded_enumtype); } //-------------------------------------------------------------------------- @@ -177,12 +184,12 @@ DataType* EnumType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::insert(const char* name, void *value) const +void +EnumType::insert(const char *name, void *value) const { // Calls C routine H5Tenum_insert to insert the new enum datatype member. herr_t ret_value = H5Tenum_insert(id, name, value); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("EnumType::insert", "H5Tenum_insert failed"); } } @@ -194,7 +201,8 @@ void EnumType::insert(const char* name, void *value) const /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::insert(const H5std_string& name, void *value) const +void +EnumType::insert(const H5std_string &name, void *value) const { insert(name.c_str(), value); } @@ -208,24 +216,24 @@ void EnumType::insert(const H5std_string& name, void *value) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string EnumType::nameOf(void *value, size_t size) const +H5std_string +EnumType::nameOf(void *value, size_t size) const { - char* name_C = new char[size+1]; // temporary C-string for C API - HDmemset(name_C, 0, size+1); // clear buffer + char *name_C = new char[size + 1]; // temporary C-string for C API + HDmemset(name_C, 0, size + 1); // clear buffer // Calls C routine H5Tenum_nameof to get the name of the specified enum type herr_t ret_value = H5Tenum_nameof(id, value, name_C, size); // If H5Tenum_nameof returns a negative value, raise an exception, - if (ret_value < 0) - { - delete []name_C; + if (ret_value < 0) { + delete[] name_C; throw DataTypeIException("EnumType::nameOf", "H5Tenum_nameof failed"); } // otherwise, create the string to hold the datatype name and return it H5std_string name(name_C); - delete []name_C; - return(name); + delete[] name_C; + return (name); } //-------------------------------------------------------------------------- @@ -237,12 +245,12 @@ H5std_string EnumType::nameOf(void *value, size_t size) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::valueOf(const char* name, void *value) const +void +EnumType::valueOf(const char *name, void *value) const { // Calls C routine H5Tenum_valueof to get the enum datatype value herr_t ret_value = H5Tenum_valueof(id, name, value); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("EnumType::valueOf", "H5Tenum_valueof failed"); } } @@ -254,7 +262,8 @@ void EnumType::valueOf(const char* name, void *value) const /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::valueOf(const H5std_string& name, void *value) const +void +EnumType::valueOf(const H5std_string &name, void *value) const { valueOf(name.c_str(), value); } @@ -269,15 +278,14 @@ void EnumType::valueOf(const H5std_string& name, void *value) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May 16, 2002 //-------------------------------------------------------------------------- -int EnumType::getMemberIndex(const char *name) const +int +EnumType::getMemberIndex(const char *name) const { int member_index = H5Tget_member_index(id, name); - if (member_index < 0) - { - throw DataTypeIException("EnumType::getMemberIndex", - "H5Tget_member_index returns negative value"); + if (member_index < 0) { + throw DataTypeIException("EnumType::getMemberIndex", "H5Tget_member_index returns negative value"); } - return(member_index); + return (member_index); } //-------------------------------------------------------------------------- @@ -287,9 +295,10 @@ int EnumType::getMemberIndex(const char *name) const /// argument \a name. // Programmer Binh-Minh Ribler - May 16, 2002 //-------------------------------------------------------------------------- -int EnumType::getMemberIndex(const H5std_string& name) const +int +EnumType::getMemberIndex(const H5std_string &name) const { - return(EnumType::getMemberIndex(name.c_str())); + return (EnumType::getMemberIndex(name.c_str())); } //-------------------------------------------------------------------------- @@ -299,15 +308,15 @@ int EnumType::getMemberIndex(const H5std_string& name) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -int EnumType::getNmembers() const +int +EnumType::getNmembers() const { int num_members = H5Tget_nmembers(id); - if (num_members < 0) - { + if (num_members < 0) { throw DataTypeIException("EnumType::getNmembers", - "H5Tget_nmembers returns negative number of members"); + "H5Tget_nmembers returns negative number of members"); } - return(num_members); + return (num_members); } //-------------------------------------------------------------------------- @@ -319,12 +328,12 @@ int EnumType::getNmembers() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::getMemberValue(unsigned memb_no, void *value) const +void +EnumType::getMemberValue(unsigned memb_no, void *value) const { // Call C routine H5Tget_member_value to get the datatype member's value hid_t ret_value = H5Tget_member_value(id, memb_no, value); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("EnumType::getMemberValue", "H5Tget_member_value failed"); } } @@ -334,6 +343,8 @@ void EnumType::getMemberValue(unsigned memb_no, void *value) const ///\brief Properly terminates access to this enum datatype. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::~EnumType() {} +EnumType::~EnumType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5EnumType.h b/c++/src/H5EnumType.h index 4797ee7..484405a 100644 --- a/c++/src/H5EnumType.h +++ b/c++/src/H5EnumType.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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 namespace H5 { @@ -24,63 +24,67 @@ namespace H5 { // Inheritance: DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP EnumType : public DataType { - public: - // Creates an empty enumeration datatype based on a native signed - // integer type, whose size is given by size. - EnumType(size_t size); + public: + // Creates an empty enumeration datatype based on a native signed + // integer type, whose size is given by size. + EnumType(size_t size); - // Gets the enum datatype of the specified dataset - EnumType(const DataSet& dataset); // H5Dget_type + // Gets the enum datatype of the specified dataset + EnumType(const DataSet &dataset); // H5Dget_type - // Creates a new enum datatype based on an integer datatype - EnumType(const IntType& data_type); // H5Tenum_create + // Creates a new enum datatype based on an integer datatype + EnumType(const IntType &data_type); // H5Tenum_create - // Constructors that open an enum datatype, given a location. - EnumType(const H5Location& loc, const char* name); - EnumType(const H5Location& loc, const H5std_string& name); + // Constructors that open an enum datatype, given a location. + EnumType(const H5Location &loc, const char *name); + EnumType(const H5Location &loc, const H5std_string &name); - // Returns an EnumType object via DataType* by decoding the - // binary object description of this type. - virtual DataType* decode() const; + // Returns an EnumType object via DataType* by decoding the + // binary object description of this type. + virtual DataType *decode() const; - // Returns the number of members in this enumeration datatype. - int getNmembers () const; + // Returns the number of members in this enumeration datatype. + int getNmembers() const; - // Returns the index of a member in this enumeration data type. - int getMemberIndex(const char* name) const; - int getMemberIndex(const H5std_string& name) const; + // Returns the index of a member in this enumeration data type. + int getMemberIndex(const char *name) const; + int getMemberIndex(const H5std_string &name) const; - // Returns the value of an enumeration datatype member - void getMemberValue(unsigned memb_no, void *value) const; + // Returns the value of an enumeration datatype member + void getMemberValue(unsigned memb_no, void *value) const; - // Inserts a new member to this enumeration type. - void insert(const char* name, void *value) const; - void insert(const H5std_string& name, void *value) const; + // Inserts a new member to this enumeration type. + void insert(const char *name, void *value) const; + void insert(const H5std_string &name, void *value) const; - // Returns the symbol name corresponding to a specified member - // of this enumeration datatype. - H5std_string nameOf(void *value, size_t size) const; + // Returns the symbol name corresponding to a specified member + // of this enumeration datatype. + H5std_string nameOf(void *value, size_t size) const; - // Returns the value corresponding to a specified member of this - // enumeration datatype. - void valueOf(const char* name, void *value) const; - void valueOf(const H5std_string& name, void *value) const; + // Returns the value corresponding to a specified member of this + // enumeration datatype. + void valueOf(const char *name, void *value) const; + void valueOf(const H5std_string &name, void *value) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("EnumType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("EnumType"); + } - // Default constructor - EnumType(); + // Default constructor + EnumType(); - // Creates an enumeration datatype using an existing id - EnumType(const hid_t existing_id); + // Creates an enumeration datatype using an existing id + EnumType(const hid_t existing_id); - // Copy constructor: same as the original EnumType. - EnumType(const EnumType& original); + // Copy constructor: same as the original EnumType. + EnumType(const EnumType &original); - virtual ~EnumType(); + virtual ~EnumType(); }; // end of EnumType } // namespace H5 -#endif // __H5EnumType_H +#endif // H5EnumType_H diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index 7431e6c..6769439 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,7 +25,9 @@ const char Exception::DEFAULT_MSG[] = "No detailed information provided"; ///\brief Default constructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Exception::Exception() : detail_message(""), func_name("") {} +Exception::Exception() +{ +} //-------------------------------------------------------------------------- // Function: Exception overloaded constructor @@ -35,7 +37,10 @@ Exception::Exception() : detail_message(""), func_name("") {} ///\param message - IN: Message on the failure // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Exception::Exception(const H5std_string& func, const H5std_string& message) : detail_message(message), func_name(func) {} +Exception::Exception(const H5std_string &func, const H5std_string &message) + : detail_message(message), func_name(func) +{ +} //-------------------------------------------------------------------------- // Function: Exception copy constructor @@ -43,7 +48,9 @@ Exception::Exception(const H5std_string& func, const H5std_string& message) : de ///\param orig - IN: Exception instance to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Exception::Exception(const Exception& orig) : detail_message(orig.detail_message), func_name(orig.func_name) {} +Exception::Exception(const Exception &orig) : detail_message(orig.detail_message), func_name(orig.func_name) +{ +} //-------------------------------------------------------------------------- // Function: Exception::getMajorString @@ -56,32 +63,30 @@ Exception::Exception(const Exception& orig) : detail_message(orig.detail_message /// will be returned. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string Exception::getMajorString(hid_t err_major) const +H5std_string +Exception::getMajorString(hid_t err_major) const { // Preliminary call to H5Eget_msg() to get the length of the message ssize_t mesg_size = H5Eget_msg(err_major, NULL, NULL, 0); // If H5Eget_msg() returns a negative value, raise an exception, if (mesg_size < 0) - throw IdComponentException("Exception::getMajorString", - "H5Eget_msg failed"); + throw IdComponentException("Exception::getMajorString", "H5Eget_msg failed"); // Call H5Eget_msg again to get the actual message - char* mesg_C = new char[mesg_size+1]; // temporary C-string for C API - mesg_size = H5Eget_msg(err_major, NULL, mesg_C, mesg_size+1); + char *mesg_C = new char[mesg_size + 1]; // temporary C-string for C API + mesg_size = H5Eget_msg(err_major, NULL, mesg_C, mesg_size + 1); // Check for failure again - if (mesg_size < 0) - { - delete []mesg_C; - throw IdComponentException("Exception::getMajorString", - "H5Eget_msg failed"); + if (mesg_size < 0) { + delete[] mesg_C; + throw IdComponentException("Exception::getMajorString", "H5Eget_msg failed"); } // Convert the C error description and return H5std_string major_str(mesg_C); - delete []mesg_C; - return(major_str); + delete[] mesg_C; + return (major_str); } //-------------------------------------------------------------------------- @@ -95,32 +100,30 @@ H5std_string Exception::getMajorString(hid_t err_major) const /// will be returned. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string Exception::getMinorString(hid_t err_minor) const +H5std_string +Exception::getMinorString(hid_t err_minor) const { // Preliminary call to H5Eget_msg() to get the length of the message ssize_t mesg_size = H5Eget_msg(err_minor, NULL, NULL, 0); // If H5Eget_msg() returns a negative value, raise an exception, if (mesg_size < 0) - throw IdComponentException("Exception::getMinorString", - "H5Eget_msg failed"); + throw IdComponentException("Exception::getMinorString", "H5Eget_msg failed"); // Call H5Eget_msg again to get the actual message - char* mesg_C = new char[mesg_size+1]; // temporary C-string for C API - mesg_size = H5Eget_msg(err_minor, NULL, mesg_C, mesg_size+1); + char *mesg_C = new char[mesg_size + 1]; // temporary C-string for C API + mesg_size = H5Eget_msg(err_minor, NULL, mesg_C, mesg_size + 1); // Check for failure again - if (mesg_size < 0) - { - delete []mesg_C; - throw IdComponentException("Exception::getMinorString", - "H5Eget_msg failed"); + if (mesg_size < 0) { + delete[] mesg_C; + throw IdComponentException("Exception::getMinorString", "H5Eget_msg failed"); } // Convert the C error description and return H5std_string minor_str(mesg_C); - delete []mesg_C; - return(minor_str); + delete[] mesg_C; + return (minor_str); } //-------------------------------------------------------------------------- @@ -139,7 +142,8 @@ H5std_string Exception::getMinorString(hid_t err_minor) const /// handlers // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::setAutoPrint(H5E_auto2_t& func, void* client_data) +void +Exception::setAutoPrint(H5E_auto2_t &func, void *client_data) { // calls the C API routine H5Eset_auto to set the auto printing to // the specified function. @@ -153,7 +157,8 @@ void Exception::setAutoPrint(H5E_auto2_t& func, void* client_data) ///\brief Turns off the automatic error printing from the C library. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::dontPrint() +void +Exception::dontPrint() { // calls the C API routine H5Eset_auto with NULL parameters to turn // off the automatic error printing. @@ -172,7 +177,8 @@ void Exception::dontPrint() /// the error function // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::getAutoPrint(H5E_auto2_t& func, void** client_data) +void +Exception::getAutoPrint(H5E_auto2_t &func, void **client_data) { // calls the C API routine H5Eget_auto to get the current setting of // the automatic error printing @@ -189,7 +195,8 @@ void Exception::getAutoPrint(H5E_auto2_t& func, void** client_data) /// called, with certain exceptions (for instance, \c H5Eprint). // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::clearErrorStack() +void +Exception::clearErrorStack() { // calls the C API routine H5Eclear to clear the error stack herr_t ret_value = H5Eclear2(H5E_DEFAULT); @@ -238,7 +245,8 @@ void Exception::clearErrorStack() ///\endcode // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::walkErrorStack(H5E_direction_t direction, H5E_walk2_t func, void* client_data) +void +Exception::walkErrorStack(H5E_direction_t direction, H5E_walk2_t func, void *client_data) { // calls the C API routine H5Ewalk to walk the error stack herr_t ret_value = H5Ewalk2(H5E_DEFAULT, direction, func, client_data); @@ -253,9 +261,10 @@ void Exception::walkErrorStack(H5E_direction_t direction, H5E_walk2_t func, void ///\return Text message - \c H5std_string // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string Exception::getDetailMsg() const +H5std_string +Exception::getDetailMsg() const { - return(detail_message); + return (detail_message); } //-------------------------------------------------------------------------- @@ -265,9 +274,10 @@ H5std_string Exception::getDetailMsg() const ///\return Text message - \c char pointer // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -const char* Exception::getCDetailMsg() const +const char * +Exception::getCDetailMsg() const { - return(detail_message.c_str()); + return (detail_message.c_str()); } //-------------------------------------------------------------------------- @@ -276,9 +286,10 @@ const char* Exception::getCDetailMsg() const ///\return Text message - \c H5std_string // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string Exception::getFuncName() const +H5std_string +Exception::getFuncName() const { - return(func_name); + return (func_name); } //-------------------------------------------------------------------------- @@ -287,9 +298,10 @@ H5std_string Exception::getFuncName() const ///\return Text message - \c char pointer // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -const char* Exception::getCFuncName() const +const char * +Exception::getCFuncName() const { - return(func_name.c_str()); + return (func_name.c_str()); } //-------------------------------------------------------------------------- @@ -299,7 +311,8 @@ const char* Exception::getCFuncName() const ///\param err_stack - IN: Error stack ID, default to H5E_DEFAULT(0) // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::printErrorStack(FILE* stream, hid_t err_stack) +void +Exception::printErrorStack(FILE *stream, hid_t err_stack) { herr_t ret_value = H5Eprint2(err_stack, stream); if (ret_value < 0) @@ -319,7 +332,7 @@ void Exception::printErrorStack(FILE* stream, hid_t err_stack) // Removed from documentation. -BMR, 2016/03/23 // Removed from code. -BMR, 2017/08/11 1.8.20 and 1.10.2 //-------------------------------------------------------------------------- -//void Exception::printError(FILE* stream) const +// void Exception::printError(FILE* stream) const //{ // Exception::printErrorStack(stream, H5E_DEFAULT); //} @@ -329,7 +342,9 @@ void Exception::printErrorStack(FILE* stream, hid_t err_stack) ///\brief Noop destructor // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Exception::~Exception() throw() {} +Exception::~Exception() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: FileIException @@ -339,7 +354,9 @@ Exception::~Exception() throw() {} // Function: FileIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -FileIException::FileIException():Exception(){} +FileIException::FileIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: FileIException overloaded constructor ///\brief Creates a FileIException with the name of the function, @@ -347,12 +364,17 @@ FileIException::FileIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -FileIException::FileIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +FileIException::FileIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: FileIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -FileIException::~FileIException() throw() {} +FileIException::~FileIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: GroupIException @@ -362,7 +384,9 @@ FileIException::~FileIException() throw() {} // Function: GroupIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -GroupIException::GroupIException():Exception(){} +GroupIException::GroupIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: GroupIException overloaded constructor ///\brief Creates a GroupIException with the name of the function, @@ -370,12 +394,17 @@ GroupIException::GroupIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -GroupIException::GroupIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +GroupIException::GroupIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: GroupIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -GroupIException::~GroupIException() throw() {} +GroupIException::~GroupIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: DataSpaceIException @@ -385,7 +414,9 @@ GroupIException::~GroupIException() throw() {} // Function: DataSpaceIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -DataSpaceIException::DataSpaceIException():Exception(){} +DataSpaceIException::DataSpaceIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: DataSpaceIException overloaded constructor ///\brief Creates a DataSpaceIException with the name of the function, @@ -393,12 +424,17 @@ DataSpaceIException::DataSpaceIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -DataSpaceIException::DataSpaceIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +DataSpaceIException::DataSpaceIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: DataSpaceIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -DataSpaceIException::~DataSpaceIException() throw() {} +DataSpaceIException::~DataSpaceIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: DataTypeIException @@ -408,7 +444,9 @@ DataSpaceIException::~DataSpaceIException() throw() {} // Function: DataTypeIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -DataTypeIException::DataTypeIException():Exception(){} +DataTypeIException::DataTypeIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: DataTypeIException overloaded constructor ///\brief Creates a DataTypeIException with the name of the function, @@ -416,12 +454,17 @@ DataTypeIException::DataTypeIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -DataTypeIException::DataTypeIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +DataTypeIException::DataTypeIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: DataTypeIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -DataTypeIException::~DataTypeIException() throw() {} +DataTypeIException::~DataTypeIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: ObjHeaderIException @@ -431,7 +474,9 @@ DataTypeIException::~DataTypeIException() throw() {} // Function: ObjHeaderIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -ObjHeaderIException::ObjHeaderIException():Exception(){} +ObjHeaderIException::ObjHeaderIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: ObjHeaderIException overloaded constructor ///\brief Creates an ObjHeaderIException with the name of the function, @@ -439,12 +484,17 @@ ObjHeaderIException::ObjHeaderIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -ObjHeaderIException::ObjHeaderIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +ObjHeaderIException::ObjHeaderIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: ObjHeaderIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -ObjHeaderIException::~ObjHeaderIException() throw() {} +ObjHeaderIException::~ObjHeaderIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: PropListIException @@ -454,7 +504,9 @@ ObjHeaderIException::~ObjHeaderIException() throw() {} // Function: PropListIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -PropListIException::PropListIException():Exception(){} +PropListIException::PropListIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: PropListIException overloaded constructor ///\brief Creates a PropListIException with the name of the function, @@ -462,12 +514,17 @@ PropListIException::PropListIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -PropListIException::PropListIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +PropListIException::PropListIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: PropListIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -PropListIException::~PropListIException() throw() {} +PropListIException::~PropListIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: DataSetIException @@ -477,7 +534,9 @@ PropListIException::~PropListIException() throw() {} // Function: DataSetIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -DataSetIException::DataSetIException():Exception(){} +DataSetIException::DataSetIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: DataSetIException overloaded constructor ///\brief Creates a DataSetIException with the name of the function, @@ -485,12 +544,17 @@ DataSetIException::DataSetIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -DataSetIException::DataSetIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +DataSetIException::DataSetIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: DataSetIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -DataSetIException::~DataSetIException() throw() {} +DataSetIException::~DataSetIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: AttributeIException @@ -500,7 +564,9 @@ DataSetIException::~DataSetIException() throw() {} // Function: AttributeIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -AttributeIException::AttributeIException():Exception(){} +AttributeIException::AttributeIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: AttributeIException overloaded constructor ///\brief Creates an AttributeIException with the name of the function, @@ -508,12 +574,17 @@ AttributeIException::AttributeIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -AttributeIException::AttributeIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +AttributeIException::AttributeIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: AttributeIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -AttributeIException::~AttributeIException() throw() {} +AttributeIException::~AttributeIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: ReferenceException @@ -523,7 +594,9 @@ AttributeIException::~AttributeIException() throw() {} // Function: ReferenceException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -ReferenceException::ReferenceException():Exception(){} +ReferenceException::ReferenceException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: ReferenceException overloaded constructor ///\brief Creates a ReferenceException with the name of the function, @@ -531,12 +604,17 @@ ReferenceException::ReferenceException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -ReferenceException::ReferenceException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +ReferenceException::ReferenceException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: ReferenceException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -ReferenceException::~ReferenceException() throw() {} +ReferenceException::~ReferenceException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: LibraryIException @@ -546,7 +624,9 @@ ReferenceException::~ReferenceException() throw() {} // Function: LibraryIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -LibraryIException::LibraryIException():Exception(){} +LibraryIException::LibraryIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: LibraryIException overloaded constructor ///\brief Creates a LibraryIException with the name of the function, @@ -554,12 +634,17 @@ LibraryIException::LibraryIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -LibraryIException::LibraryIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +LibraryIException::LibraryIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: LibraryIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -LibraryIException::~LibraryIException() throw() {} +LibraryIException::~LibraryIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: LocationException @@ -569,7 +654,9 @@ LibraryIException::~LibraryIException() throw() {} // Function: LocationException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -LocationException::LocationException():Exception(){} +LocationException::LocationException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: LocationException overloaded constructor ///\brief Creates a LocationException with the name of the function, @@ -577,12 +664,17 @@ LocationException::LocationException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -LocationException::LocationException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +LocationException::LocationException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: LocationException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -LocationException::~LocationException() throw() {} +LocationException::~LocationException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: IdComponentException @@ -592,7 +684,9 @@ LocationException::~LocationException() throw() {} // Function: IdComponentException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -IdComponentException::IdComponentException(): Exception() {} +IdComponentException::IdComponentException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: IdComponentException overloaded constructor ///\brief Creates a IdComponentException with the name of the function, @@ -600,11 +694,16 @@ IdComponentException::IdComponentException(): Exception() {} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -IdComponentException::IdComponentException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +IdComponentException::IdComponentException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: IdComponentException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -IdComponentException::~IdComponentException() throw() {} +IdComponentException::~IdComponentException() throw() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Exception.h b/c++/src/H5Exception.h index cb14a4c..9970d22 100644 --- a/c++/src/H5Exception.h +++ b/c++/src/H5Exception.h @@ -7,22 +7,18 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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> namespace H5 { -#ifdef H5_NO_STD - #define H5std_string ::string -#else - #define H5std_string std::string -#endif +#define H5std_string std::string /*! \class Exception \brief Exception provides wrappers of HDF5 error handling functions. @@ -30,152 +26,150 @@ namespace H5 { Many classes are derived from Exception for specific HDF5 C interfaces. */ class H5_DLLCPP Exception { - public: - // Creates an exception with a function name where the failure occurs - // and an optional detailed message - Exception(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - - // Returns a character string that describes the error specified by - // a major error number. - H5std_string getMajorString(hid_t err_major_id) const; - - // Returns a character string that describes the error specified by - // a minor error number. - H5std_string getMinorString(hid_t err_minor_id) const; - - // Returns the detailed message set at the time the exception is thrown - H5std_string getDetailMsg() const; - const char* getCDetailMsg() const; // C string of detailed message - H5std_string getFuncName() const; // function name as a string object - const char* getCFuncName() const; // function name as a char string - - // Turns on the automatic error printing. - static void setAutoPrint(H5E_auto2_t& func, void* client_data); - - // Turns off the automatic error printing. - static void dontPrint(); - - // Retrieves the current settings for the automatic error stack - // traversal function and its data. - static void getAutoPrint(H5E_auto2_t& func, void** client_data); - - // Clears the error stack for the current thread. - static void clearErrorStack(); - - // Walks the error stack for the current thread, calling the - // specified function. - static void walkErrorStack(H5E_direction_t direction, - H5E_walk2_t func, void* client_data); - - // Prints the error stack in a default manner. - static void printErrorStack(FILE* stream = stderr, - hid_t err_stack = H5E_DEFAULT); - // Deprecated in favor of printErrorStack. - // Removed from code. -BMR, 2017/08/11 1.8.20 and 1.10.2 - // virtual void printError(FILE* stream = NULL) const; - - // Default constructor - Exception(); - - // copy constructor - Exception(const Exception& orig); - - // virtual Destructor - virtual ~Exception() throw(); - - protected: - // Default value for detail_message - static const char DEFAULT_MSG[]; - - private: - H5std_string detail_message; - H5std_string func_name; + public: + // Creates an exception with a function name where the failure occurs + // and an optional detailed message + Exception(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + + // Returns a character string that describes the error specified by + // a major error number. + H5std_string getMajorString(hid_t err_major_id) const; + + // Returns a character string that describes the error specified by + // a minor error number. + H5std_string getMinorString(hid_t err_minor_id) const; + + // Returns the detailed message set at the time the exception is thrown + H5std_string getDetailMsg() const; + const char * getCDetailMsg() const; // C string of detailed message + H5std_string getFuncName() const; // function name as a string object + const char * getCFuncName() const; // function name as a char string + + // Turns on the automatic error printing. + static void setAutoPrint(H5E_auto2_t &func, void *client_data); + + // Turns off the automatic error printing. + static void dontPrint(); + + // Retrieves the current settings for the automatic error stack + // traversal function and its data. + static void getAutoPrint(H5E_auto2_t &func, void **client_data); + + // Clears the error stack for the current thread. + static void clearErrorStack(); + + // Walks the error stack for the current thread, calling the + // specified function. + static void walkErrorStack(H5E_direction_t direction, H5E_walk2_t func, void *client_data); + + // Prints the error stack in a default manner. + static void printErrorStack(FILE *stream = stderr, hid_t err_stack = H5E_DEFAULT); + // Deprecated in favor of printErrorStack. + // Removed from code. -BMR, 2017/08/11 1.8.20 and 1.10.2 + // virtual void printError(FILE* stream = NULL) const; + + // Default constructor + Exception(); + + // copy constructor + Exception(const Exception &orig); + + // virtual Destructor + virtual ~Exception() throw(); + + protected: + // Default value for detail_message + static const char DEFAULT_MSG[]; + + private: + H5std_string detail_message; + H5std_string func_name; }; class H5_DLLCPP FileIException : public Exception { - public: - FileIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - FileIException(); - virtual ~FileIException() throw(); + public: + FileIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + FileIException(); + virtual ~FileIException() throw() H5_OVERRIDE; }; class H5_DLLCPP GroupIException : public Exception { - public: - GroupIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - GroupIException(); - virtual ~GroupIException() throw(); + public: + GroupIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + GroupIException(); + virtual ~GroupIException() throw() H5_OVERRIDE; }; class H5_DLLCPP DataSpaceIException : public Exception { - public: - DataSpaceIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - DataSpaceIException(); - virtual ~DataSpaceIException() throw(); + public: + DataSpaceIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + DataSpaceIException(); + virtual ~DataSpaceIException() throw() H5_OVERRIDE; }; class H5_DLLCPP DataTypeIException : public Exception { - public: - DataTypeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - DataTypeIException(); - virtual ~DataTypeIException() throw(); + public: + DataTypeIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + DataTypeIException(); + virtual ~DataTypeIException() throw() H5_OVERRIDE; }; class H5_DLLCPP ObjHeaderIException : public Exception { - public: - ObjHeaderIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - ObjHeaderIException(); - virtual ~ObjHeaderIException() throw(); + public: + ObjHeaderIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + ObjHeaderIException(); + virtual ~ObjHeaderIException() throw() H5_OVERRIDE; }; class H5_DLLCPP PropListIException : public Exception { - public: - PropListIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - PropListIException(); - virtual ~PropListIException() throw(); + public: + PropListIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + PropListIException(); + virtual ~PropListIException() throw() H5_OVERRIDE; }; class H5_DLLCPP DataSetIException : public Exception { - public: - DataSetIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - DataSetIException(); - virtual ~DataSetIException() throw(); + public: + DataSetIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + DataSetIException(); + virtual ~DataSetIException() throw() H5_OVERRIDE; }; class H5_DLLCPP AttributeIException : public Exception { - public: - AttributeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - AttributeIException(); - virtual ~AttributeIException() throw(); + public: + AttributeIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + AttributeIException(); + virtual ~AttributeIException() throw() H5_OVERRIDE; }; class H5_DLLCPP ReferenceException : public Exception { - public: - ReferenceException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - ReferenceException(); - virtual ~ReferenceException() throw(); + public: + ReferenceException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + ReferenceException(); + virtual ~ReferenceException() throw() H5_OVERRIDE; }; class H5_DLLCPP LibraryIException : public Exception { - public: - LibraryIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - LibraryIException(); - virtual ~LibraryIException() throw(); + public: + LibraryIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + LibraryIException(); + virtual ~LibraryIException() throw() H5_OVERRIDE; }; class H5_DLLCPP LocationException : public Exception { - public: - LocationException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - LocationException(); - virtual ~LocationException() throw(); + public: + LocationException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + LocationException(); + virtual ~LocationException() throw() H5_OVERRIDE; }; class H5_DLLCPP IdComponentException : public Exception { - public: - IdComponentException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - IdComponentException(); - virtual ~IdComponentException() throw(); + public: + IdComponentException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + IdComponentException(); + virtual ~IdComponentException() throw() H5_OVERRIDE; }; // end of IdComponentException } // namespace H5 -#endif // __H5Exception_H +#endif // H5Exception_H diff --git a/c++/src/H5FaccProp.cpp b/c++/src/H5FaccProp.cpp index 6128d65..3eaf23a 100644 --- a/c++/src/H5FaccProp.cpp +++ b/c++/src/H5FaccProp.cpp @@ -6,16 +6,12 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif #include <string> using std::cerr; @@ -37,7 +33,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -FileAccPropList* FileAccPropList::DEFAULT_ = 0; +FileAccPropList *FileAccPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: FileAccPropList::getConstant @@ -50,13 +46,13 @@ FileAccPropList* FileAccPropList::DEFAULT_ = 0; // happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -FileAccPropList* FileAccPropList::getConstant() +FileAccPropList * +FileAccPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -65,8 +61,9 @@ FileAccPropList* FileAccPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new FileAccPropList(H5P_FILE_ACCESS); else - throw PropListIException("FileAccPropList::getConstant", "FileAccPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("FileAccPropList::getConstant", + "FileAccPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -76,7 +73,8 @@ FileAccPropList* FileAccPropList::getConstant() // exception H5::PropListIException // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void FileAccPropList::deleteConstants() +void +FileAccPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -85,7 +83,7 @@ void FileAccPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for default property //-------------------------------------------------------------------------- -const FileAccPropList& FileAccPropList::DEFAULT = *getConstant(); +const FileAccPropList &FileAccPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -94,7 +92,9 @@ const FileAccPropList& FileAccPropList::DEFAULT = *getConstant(); ///\brief Creates a file access property list // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileAccPropList::FileAccPropList() : PropList(H5P_FILE_ACCESS) {} +FileAccPropList::FileAccPropList() : PropList(H5P_FILE_ACCESS) +{ +} //-------------------------------------------------------------------------- // Function: FileAccPropList copy constructor @@ -102,7 +102,9 @@ FileAccPropList::FileAccPropList() : PropList(H5P_FILE_ACCESS) {} ///\param original - IN: FileAccPropList instance to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileAccPropList::FileAccPropList(const FileAccPropList& original) : PropList(original) {} +FileAccPropList::FileAccPropList(const FileAccPropList &original) : PropList(original) +{ +} //-------------------------------------------------------------------------- // Function: FileAccPropList overloaded constructor @@ -110,7 +112,9 @@ FileAccPropList::FileAccPropList(const FileAccPropList& original) : PropList(ori /// existing one. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileAccPropList::FileAccPropList(const hid_t plist_id) : PropList(plist_id) {} +FileAccPropList::FileAccPropList(const hid_t plist_id) : PropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: FileAccPropList::setStdio @@ -119,11 +123,11 @@ FileAccPropList::FileAccPropList(const hid_t plist_id) : PropList(plist_id) {} ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setStdio() const +void +FileAccPropList::setStdio() const { herr_t ret_value = H5Pset_fapl_stdio(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setStdio", "H5Pset_fapl_stdio failed"); } } @@ -139,14 +143,14 @@ void FileAccPropList::setStdio() const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -hid_t FileAccPropList::getDriver() const +hid_t +FileAccPropList::getDriver() const { hid_t driver = H5Pget_driver(id); - if (driver < 0) - { + if (driver < 0) { throw PropListIException("FileAccPropList::getDriver", "H5Pget_driver failed"); } - return(driver); + return (driver); } //-------------------------------------------------------------------------- @@ -160,11 +164,11 @@ hid_t FileAccPropList::getDriver() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setDriver(hid_t new_driver_id, const void *new_driver_info) const +void +FileAccPropList::setDriver(hid_t new_driver_id, const void *new_driver_info) const { herr_t ret_value = H5Pset_driver(id, new_driver_id, new_driver_info); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setDriver", "H5Pset_driver failed"); } } @@ -176,11 +180,11 @@ void FileAccPropList::setDriver(hid_t new_driver_id, const void *new_driver_info ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setFamilyOffset(hsize_t offset) const +void +FileAccPropList::setFamilyOffset(hsize_t offset) const { herr_t ret_value = H5Pset_family_offset(id, offset); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setFamilyOffset", "H5Pset_family_offset failed"); } } @@ -192,15 +196,15 @@ void FileAccPropList::setFamilyOffset(hsize_t offset) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -hsize_t FileAccPropList::getFamilyOffset() const +hsize_t +FileAccPropList::getFamilyOffset() const { hsize_t offset; - herr_t ret_value = H5Pget_family_offset(id, &offset); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_family_offset(id, &offset); + if (ret_value < 0) { throw PropListIException("FileAccPropList::getFamilyOffset", "H5Pget_family_offset failed"); } - return(offset); + return (offset); } //-------------------------------------------------------------------------- @@ -217,12 +221,12 @@ hsize_t FileAccPropList::getFamilyOffset() const /// refer to the H5Pset_fapl_core API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setCore (size_t increment, hbool_t backing_store) const +void +FileAccPropList::setCore(size_t increment, hbool_t backing_store) const { - herr_t ret_value = H5Pset_fapl_core (id, increment, backing_store); - if (ret_value < 0) - { - throw PropListIException ("FileAccPropList::setCore", "H5Pset_fapl_core failed"); + herr_t ret_value = H5Pset_fapl_core(id, increment, backing_store); + if (ret_value < 0) { + throw PropListIException("FileAccPropList::setCore", "H5Pset_fapl_core failed"); } } @@ -235,11 +239,11 @@ void FileAccPropList::setCore (size_t increment, hbool_t backing_store) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::getCore (size_t& increment, hbool_t& backing_store) const +void +FileAccPropList::getCore(size_t &increment, hbool_t &backing_store) const { herr_t ret_value = H5Pget_fapl_core(id, &increment, &backing_store); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getCore", "H5Pget_fapl_core failed"); } } @@ -255,11 +259,11 @@ void FileAccPropList::getCore (size_t& increment, hbool_t& backing_store) const /// Note that \a memb_size is used only when creating a new file. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setFamily(hsize_t memb_size, const FileAccPropList& memb_plist) const +void +FileAccPropList::setFamily(hsize_t memb_size, const FileAccPropList &memb_plist) const { - herr_t ret_value = H5Pset_fapl_family (id, memb_size, memb_plist.getId()); - if (ret_value < 0) - { + herr_t ret_value = H5Pset_fapl_family(id, memb_size, memb_plist.getId()); + if (ret_value < 0) { throw PropListIException("FileAccPropList::setFamily", "H5Pset_fapl_family failed"); } } @@ -274,12 +278,12 @@ void FileAccPropList::setFamily(hsize_t memb_size, const FileAccPropList& memb_p ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::getFamily(hsize_t& memb_size, FileAccPropList& memb_plist) const +void +FileAccPropList::getFamily(hsize_t &memb_size, FileAccPropList &memb_plist) const { - hid_t memb_plist_id; + hid_t memb_plist_id; herr_t ret_value = H5Pget_fapl_family(id, &memb_size, &memb_plist_id); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getFamily", "H5Pget_fapl_family failed"); } memb_plist.p_setId(memb_plist_id); @@ -295,16 +299,16 @@ void FileAccPropList::getFamily(hsize_t& memb_size, FileAccPropList& memb_plist) ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -FileAccPropList FileAccPropList::getFamily(hsize_t& memb_size) const +FileAccPropList +FileAccPropList::getFamily(hsize_t &memb_size) const { - hid_t memb_plist_id; + hid_t memb_plist_id; herr_t ret_value = H5Pget_fapl_family(id, &memb_size, &memb_plist_id); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getFamily", "H5Pget_fapl_family failed"); } FileAccPropList memb_plist(memb_plist_id); - return(memb_plist); + return (memb_plist); } //-------------------------------------------------------------------------- @@ -321,13 +325,14 @@ FileAccPropList FileAccPropList::getFamily(hsize_t& memb_size) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccPropList& raw_plist, const char* meta_ext, const char* raw_ext) const +void +FileAccPropList::setSplit(const FileAccPropList &meta_plist, const FileAccPropList &raw_plist, + const char *meta_ext, const char *raw_ext) const { - hid_t meta_pid = meta_plist.getId(); - hid_t raw_pid = raw_plist.getId(); + hid_t meta_pid = meta_plist.getId(); + hid_t raw_pid = raw_plist.getId(); herr_t ret_value = H5Pset_fapl_split(id, meta_ext, meta_pid, raw_ext, raw_pid); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setSplit", "H5Pset_fapl_split failed"); } } @@ -343,7 +348,9 @@ void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccP ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccPropList& raw_plist, const H5std_string& meta_ext, const H5std_string& raw_ext) const +void +FileAccPropList::setSplit(const FileAccPropList &meta_plist, const FileAccPropList &raw_plist, + const H5std_string &meta_ext, const H5std_string &raw_ext) const { setSplit(meta_plist, raw_plist, meta_ext.c_str(), raw_ext.c_str()); } @@ -360,15 +367,15 @@ void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccP ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -size_t FileAccPropList::getSieveBufSize() const +size_t +FileAccPropList::getSieveBufSize() const { size_t bufsize; herr_t ret_value = H5Pget_sieve_buf_size(id, &bufsize); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getSieveBufSize", "H5Pget_sieve_buf_size failed"); } - return(bufsize); + return (bufsize); } //-------------------------------------------------------------------------- @@ -381,11 +388,11 @@ size_t FileAccPropList::getSieveBufSize() const /// API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setSieveBufSize(size_t bufsize) const +void +FileAccPropList::setSieveBufSize(size_t bufsize) const { herr_t ret_value = H5Pset_sieve_buf_size(id, bufsize); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getSieveBufSize", "H5Pget_sieve_buf_size failed"); } } @@ -401,11 +408,11 @@ void FileAccPropList::setSieveBufSize(size_t bufsize) const /// API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setMetaBlockSize(hsize_t &block_size) const +void +FileAccPropList::setMetaBlockSize(hsize_t &block_size) const { herr_t ret_value = H5Pset_meta_block_size(id, block_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setMetaBlockSize", "H5Pset_meta_block_size failed"); } } @@ -417,15 +424,15 @@ void FileAccPropList::setMetaBlockSize(hsize_t &block_size) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -hsize_t FileAccPropList::getMetaBlockSize() const +hsize_t +FileAccPropList::getMetaBlockSize() const { hsize_t block_size; - herr_t ret_value = H5Pget_meta_block_size(id, &block_size); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_meta_block_size(id, &block_size); + if (ret_value < 0) { throw PropListIException("FileAccPropList::getMetaBlockSize", "H5Pget_meta_block_size failed"); } - return(block_size); + return (block_size); } //-------------------------------------------------------------------------- @@ -441,11 +448,11 @@ hsize_t FileAccPropList::getMetaBlockSize() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setLog(const char *logfile, unsigned flags, size_t buf_size) const +void +FileAccPropList::setLog(const char *logfile, unsigned flags, size_t buf_size) const { herr_t ret_value = H5Pset_fapl_log(id, logfile, flags, buf_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setLog", "H5Pset_fapl_log failed"); } } @@ -460,7 +467,8 @@ void FileAccPropList::setLog(const char *logfile, unsigned flags, size_t buf_siz ///\param buf_size - IN: Size of the logging buffer // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setLog(const H5std_string& logfile, unsigned flags, size_t buf_size) const +void +FileAccPropList::setLog(const H5std_string &logfile, unsigned flags, size_t buf_size) const { setLog(logfile.c_str(), flags, buf_size); } @@ -473,11 +481,11 @@ void FileAccPropList::setLog(const H5std_string& logfile, unsigned flags, size_t ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setSec2() const +void +FileAccPropList::setSec2() const { herr_t ret_value = H5Pset_fapl_sec2(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setSec2", "H5Pset_fapl_sec2 failed"); } } @@ -498,11 +506,11 @@ void FileAccPropList::setSec2() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::setAlignment(hsize_t threshold, hsize_t alignment) const +void +FileAccPropList::setAlignment(hsize_t threshold, hsize_t alignment) const { herr_t ret_value = H5Pset_alignment(id, threshold, alignment); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setAlignment", "H5Pset_alignment failed"); } } @@ -516,11 +524,11 @@ void FileAccPropList::setAlignment(hsize_t threshold, hsize_t alignment) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::getAlignment(hsize_t &threshold, hsize_t &alignment) const +void +FileAccPropList::getAlignment(hsize_t &threshold, hsize_t &alignment) const { herr_t ret_value = H5Pget_alignment(id, &threshold, &alignment); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getAlignment", "H5Pget_alignment failed"); } } @@ -535,11 +543,11 @@ void FileAccPropList::getAlignment(hsize_t &threshold, hsize_t &alignment) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setMultiType(H5FD_mem_t dtype) const +void +FileAccPropList::setMultiType(H5FD_mem_t dtype) const { herr_t ret_value = H5Pset_multi_type(id, dtype); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setMultiType", "H5Pset_multi_type failed"); } } @@ -554,15 +562,15 @@ void FileAccPropList::setMultiType(H5FD_mem_t dtype) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5FD_mem_t FileAccPropList::getMultiType() const +H5FD_mem_t +FileAccPropList::getMultiType() const { H5FD_mem_t dtype; - herr_t ret_value = H5Pget_multi_type(id, &dtype); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_multi_type(id, &dtype); + if (ret_value < 0) { throw PropListIException("FileAccPropList::getMultiType", "H5Pget_multi_type failed"); } - return(dtype); + return (dtype); } //-------------------------------------------------------------------------- @@ -582,11 +590,11 @@ H5FD_mem_t FileAccPropList::getMultiType() const /// means fully read chunks are always preempted before other chunks. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::setCache(int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0) const +void +FileAccPropList::setCache(int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0) const { herr_t ret_value = H5Pset_cache(id, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setCache", "H5Pset_cache failed"); } } @@ -601,11 +609,11 @@ void FileAccPropList::setCache(int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_n ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::getCache(int& mdc_nelmts, size_t& rdcc_nelmts, size_t& rdcc_nbytes, double& rdcc_w0) const +void +FileAccPropList::getCache(int &mdc_nelmts, size_t &rdcc_nelmts, size_t &rdcc_nbytes, double &rdcc_w0) const { herr_t ret_value = H5Pget_cache(id, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getCache", "H5Pget_cache failed"); } } @@ -617,11 +625,11 @@ void FileAccPropList::getCache(int& mdc_nelmts, size_t& rdcc_nelmts, size_t& rdc ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setFcloseDegree(H5F_close_degree_t degree) const +void +FileAccPropList::setFcloseDegree(H5F_close_degree_t degree) const { herr_t ret_value = H5Pset_fclose_degree(id, degree); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setFcloseDegree", "H5Pset_fclose_degree failed"); } } @@ -633,15 +641,15 @@ void FileAccPropList::setFcloseDegree(H5F_close_degree_t degree) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5F_close_degree_t FileAccPropList::getFcloseDegree() const +H5F_close_degree_t +FileAccPropList::getFcloseDegree() const { H5F_close_degree_t degree; - herr_t ret_value = H5Pget_fclose_degree(id, °ree); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_fclose_degree(id, °ree); + if (ret_value < 0) { throw PropListIException("FileAccPropList::getFcloseDegree", "H5Pget_fclose_degree failed"); } - return(degree); + return (degree); } //-------------------------------------------------------------------------- @@ -655,11 +663,11 @@ H5F_close_degree_t FileAccPropList::getFcloseDegree() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::setGcReferences(unsigned gc_ref) const +void +FileAccPropList::setGcReferences(unsigned gc_ref) const { herr_t ret_value = H5Pset_gc_references(id, gc_ref); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setGcReferences", "H5Pset_gc_references failed"); } } @@ -671,17 +679,17 @@ void FileAccPropList::setGcReferences(unsigned gc_ref) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -unsigned FileAccPropList::getGcReferences() const +unsigned +FileAccPropList::getGcReferences() const { unsigned gc_ref; // the name of this routine will be changed to H5Pget_gc_references??? herr_t ret_value = H5Pget_gc_references(id, &gc_ref); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getGcReferences", "H5Pget_gc_references failed"); } - return(gc_ref); + return (gc_ref); } //-------------------------------------------------------------------------- @@ -697,12 +705,12 @@ unsigned FileAccPropList::getGcReferences() const /// the HDF5 C Reference Manual. // Programmer Dana Robinson - 2020 //-------------------------------------------------------------------------- -void FileAccPropList::setFileLocking(hbool_t use_file_locking, hbool_t ignore_when_disabled) const +void +FileAccPropList::setFileLocking(hbool_t use_file_locking, hbool_t ignore_when_disabled) const { herr_t ret_value = H5Pset_file_locking(id, use_file_locking, ignore_when_disabled); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setFileLocking", "H5Pset_file_locking failed"); } } @@ -720,17 +728,16 @@ void FileAccPropList::setFileLocking(hbool_t use_file_locking, hbool_t ignore_wh /// the HDF5 C Reference Manual. // Programmer Dana Robinson - 2020 //-------------------------------------------------------------------------- -void FileAccPropList::getFileLocking(hbool_t& use_file_locking, hbool_t& ignore_when_disabled) const +void +FileAccPropList::getFileLocking(hbool_t &use_file_locking, hbool_t &ignore_when_disabled) const { herr_t ret_value = H5Pget_file_locking(id, &use_file_locking, &ignore_when_disabled); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getFileLocking", "H5Pget_file_locking failed"); } } - //-------------------------------------------------------------------------- // Function: FileAccPropList::setLibverBounds ///\brief Sets bounds on versions of library format to be used when creating @@ -753,11 +760,11 @@ void FileAccPropList::getFileLocking(hbool_t& use_file_locking, hbool_t& ignore_ /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - March, 2015 //-------------------------------------------------------------------------- -void FileAccPropList::setLibverBounds(H5F_libver_t libver_low, H5F_libver_t libver_high) const +void +FileAccPropList::setLibverBounds(H5F_libver_t libver_low, H5F_libver_t libver_high) const { herr_t ret_value = H5Pset_libver_bounds(id, libver_low, libver_high); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setLibverBounds", "H5Pset_libver_bounds failed"); } } @@ -783,11 +790,11 @@ void FileAccPropList::setLibverBounds(H5F_libver_t libver_low, H5F_libver_t libv /// \li \c H5F_LIBVER_LATEST // Programmer Binh-Minh Ribler - March, 2015 //-------------------------------------------------------------------------- -void FileAccPropList::getLibverBounds(H5F_libver_t& libver_low, H5F_libver_t& libver_high) const +void +FileAccPropList::getLibverBounds(H5F_libver_t &libver_low, H5F_libver_t &libver_high) const { herr_t ret_value = H5Pget_libver_bounds(id, &libver_low, &libver_high); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getLibverBounds", "H5Pget_libver_bounds failed"); } } @@ -797,6 +804,8 @@ void FileAccPropList::getLibverBounds(H5F_libver_t& libver_low, H5F_libver_t& li ///\brief Noop destructor // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileAccPropList::~FileAccPropList() {} +FileAccPropList::~FileAccPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5FaccProp.h b/c++/src/H5FaccProp.h index ee90fa4..998f870 100644 --- a/c++/src/H5FaccProp.h +++ b/c++/src/H5FaccProp.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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 namespace H5 { @@ -23,149 +23,149 @@ namespace H5 { */ // Inheritance: PropList -> IdComponent class H5_DLLCPP FileAccPropList : public PropList { - public: - ///\brief Default file access property list. - static const FileAccPropList& DEFAULT; + public: + ///\brief Default file access property list. + static const FileAccPropList &DEFAULT; - // Creates a file access property list. - FileAccPropList(); + // Creates a file access property list. + FileAccPropList(); - // Modifies this property list to use the H5FD_STDIO driver - void setStdio() const; + // Modifies this property list to use the H5FD_STDIO driver + void setStdio() const; - // Set file driver for this property list - void setDriver(hid_t new_driver_id, const void *new_driver_info) const; + // Set file driver for this property list + void setDriver(hid_t new_driver_id, const void *new_driver_info) const; - // Returns a low-level file driver identifier. - hid_t getDriver() const; + // Returns a low-level file driver identifier. + hid_t getDriver() const; - // Sets offset for family driver. - void setFamilyOffset(hsize_t offset) const; + // Sets offset for family driver. + void setFamilyOffset(hsize_t offset) const; - // Gets offset for family driver. - hsize_t getFamilyOffset() const; + // Gets offset for family driver. + hsize_t getFamilyOffset() const; - // Modifies this file access property list to use the sec2 driver. - void setSec2() const; + // Modifies this file access property list to use the sec2 driver. + void setSec2() const; - // Modifies this file access property list to use the H5FD_CORE - // driver. - void setCore (size_t increment, hbool_t backing_store) const; + // Modifies this file access property list to use the H5FD_CORE + // driver. + void setCore(size_t increment, hbool_t backing_store) const; - // Queries H5FD_CORE driver properties. - void getCore (size_t& increment, hbool_t& backing_store) const; + // Queries H5FD_CORE driver properties. + void getCore(size_t &increment, hbool_t &backing_store) const; - // Sets this file access properties list to the family driver. - void setFamily(hsize_t memb_size, const FileAccPropList& memb_plist) const; + // Sets this file access properties list to the family driver. + void setFamily(hsize_t memb_size, const FileAccPropList &memb_plist) const; - // Returns information about the family file access property list. - void getFamily(hsize_t& memb_size, FileAccPropList& memb_plist) const; - FileAccPropList getFamily(hsize_t& memb_size) const; + // Returns information about the family file access property list. + void getFamily(hsize_t &memb_size, FileAccPropList &memb_plist) const; + FileAccPropList getFamily(hsize_t &memb_size) const; - // Emulates the old split file driver, - void setSplit(const FileAccPropList& meta_plist, - const FileAccPropList& raw_plist, - const char* meta_ext = ".meta", - const char* raw_ext = ".raw") const; - void setSplit(const FileAccPropList& meta_plist, - const FileAccPropList& raw_plist, - const H5std_string& meta_ext = ".meta", - const H5std_string& raw_ext = ".raw") const; + // Emulates the old split file driver, + void setSplit(const FileAccPropList &meta_plist, const FileAccPropList &raw_plist, + const char *meta_ext = ".meta", const char *raw_ext = ".raw") const; + void setSplit(const FileAccPropList &meta_plist, const FileAccPropList &raw_plist, + const H5std_string &meta_ext = ".meta", const H5std_string &raw_ext = ".raw") const; - // Sets the maximum size of the data sieve buffer. - void setSieveBufSize(size_t bufsize) const; + // Sets the maximum size of the data sieve buffer. + void setSieveBufSize(size_t bufsize) const; - // Returns the current settings for the data sieve buffer size - // property - size_t getSieveBufSize() const; + // Returns the current settings for the data sieve buffer size + // property + size_t getSieveBufSize() const; - // Sets the minimum size of metadata block allocations. - void setMetaBlockSize(hsize_t &block_size) const; + // Sets the minimum size of metadata block allocations. + void setMetaBlockSize(hsize_t &block_size) const; - // Returns the current metadata block size setting. - hsize_t getMetaBlockSize() const; + // Returns the current metadata block size setting. + hsize_t getMetaBlockSize() const; - // Modifies this file access property list to use the logging driver. - void setLog(const char *logfile, unsigned flags, size_t buf_size) const; - void setLog(const H5std_string& logfile, unsigned flags, size_t buf_size) const; + // Modifies this file access property list to use the logging driver. + void setLog(const char *logfile, unsigned flags, size_t buf_size) const; + void setLog(const H5std_string &logfile, unsigned flags, size_t buf_size) const; - // Sets alignment properties of this file access property list - void setAlignment(hsize_t threshold = 1, hsize_t alignment = 1) const; + // Sets alignment properties of this file access property list + void setAlignment(hsize_t threshold = 1, hsize_t alignment = 1) const; - // Retrieves the current settings for alignment properties from - // this property list. - void getAlignment(hsize_t& threshold, hsize_t& alignment) const; + // Retrieves the current settings for alignment properties from + // this property list. + void getAlignment(hsize_t &threshold, hsize_t &alignment) const; - // Sets data type for multi driver. - void setMultiType(H5FD_mem_t dtype) const; + // Sets data type for multi driver. + void setMultiType(H5FD_mem_t dtype) const; - // Returns the data type property for MULTI driver. - H5FD_mem_t getMultiType() const; + // Returns the data type property for MULTI driver. + H5FD_mem_t getMultiType() const; - // Sets the meta data cache and raw data chunk cache parameters. - void setCache(int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0) const; + // Sets the meta data cache and raw data chunk cache parameters. + void setCache(int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0) const; - // Queries the meta data cache and raw data chunk cache parameters. - void getCache(int& mdc_nelmts, size_t& rdcc_nelmts, size_t& rdcc_nbytes, double& rdcc_w0) const; + // Queries the meta data cache and raw data chunk cache parameters. + void getCache(int &mdc_nelmts, size_t &rdcc_nelmts, size_t &rdcc_nbytes, double &rdcc_w0) const; - // Sets the degree for the file close behavior. - void setFcloseDegree(H5F_close_degree_t degree) const; + // Sets the degree for the file close behavior. + void setFcloseDegree(H5F_close_degree_t degree) const; - // Returns the degree for the file close behavior. - H5F_close_degree_t getFcloseDegree() const; + // Returns the degree for the file close behavior. + H5F_close_degree_t getFcloseDegree() const; - // Sets file access property list to use the H5FD_DIRECT driver. - void setFileAccDirect(size_t boundary, size_t block_size, size_t cbuf_size) const; + // Sets file access property list to use the H5FD_DIRECT driver. + void setFileAccDirect(size_t boundary, size_t block_size, size_t cbuf_size) const; - // Retrieves information about the direct file access property list. - void getFileAccDirect(size_t &boundary, size_t &block_size, size_t &cbuf_size) const; + // Retrieves information about the direct file access property list. + void getFileAccDirect(size_t &boundary, size_t &block_size, size_t &cbuf_size) const; - // Sets garbage collecting references flag. - void setGcReferences(unsigned gc_ref = 0) const; + // Sets garbage collecting references flag. + void setGcReferences(unsigned gc_ref = 0) const; - // Returns garbage collecting references setting. - unsigned getGcReferences() const; + // Returns garbage collecting references setting. + unsigned getGcReferences() const; - // Sets file locking parameters. - void setFileLocking(hbool_t use_file_locking, hbool_t ignore_when_disabled) const; + // Sets file locking parameters. + void setFileLocking(hbool_t use_file_locking, hbool_t ignore_when_disabled) const; - // Gets file locking parameters. - void getFileLocking(hbool_t& use_file_locking, hbool_t& ignore_when_disabled) const; + // Gets file locking parameters. + void getFileLocking(hbool_t &use_file_locking, hbool_t &ignore_when_disabled) const; - // Sets bounds on versions of library format to be used when creating - // or writing objects. - void setLibverBounds(H5F_libver_t libver_low, H5F_libver_t libver_high) const; + // Sets bounds on versions of library format to be used when creating + // or writing objects. + void setLibverBounds(H5F_libver_t libver_low, H5F_libver_t libver_high) const; - // Gets the current settings for the library version format bounds. - void getLibverBounds(H5F_libver_t& libver_low, H5F_libver_t& libver_high) const; + // Gets the current settings for the library version format bounds. + void getLibverBounds(H5F_libver_t &libver_low, H5F_libver_t &libver_high) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("FileAccPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("FileAccPropList"); + } - // Copy constructor: same as the original FileAccPropList. - FileAccPropList(const FileAccPropList& original); + // Copy constructor: same as the original FileAccPropList. + FileAccPropList(const FileAccPropList &original); - // Creates a copy of an existing file access property list - // using the property list id. - FileAccPropList (const hid_t plist_id); + // Creates a copy of an existing file access property list + // using the property list id. + FileAccPropList(const hid_t plist_id); - // Noop destructor - virtual ~FileAccPropList(); + // Noop destructor + virtual ~FileAccPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static FileAccPropList* DEFAULT_; + private: + static FileAccPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static FileAccPropList* getConstant(); + // Creates the global constant, should only be used by the library + static FileAccPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of FileAccPropList } // namespace H5 -#endif // __H5FileAccPropList_H +#endif // H5FileAccPropList_H diff --git a/c++/src/H5FcreatProp.cpp b/c++/src/H5FcreatProp.cpp index 9b0fecc..b9be563 100644 --- a/c++/src/H5FcreatProp.cpp +++ b/c++/src/H5FcreatProp.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,7 +27,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -FileCreatPropList* FileCreatPropList::DEFAULT_ = 0; +FileCreatPropList *FileCreatPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: FileCreatPropList::getConstant @@ -39,13 +39,13 @@ FileCreatPropList* FileCreatPropList::DEFAULT_ = 0; // object, throw a PropListIException. This scenario should not happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -FileCreatPropList* FileCreatPropList::getConstant() +FileCreatPropList * +FileCreatPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -54,8 +54,9 @@ FileCreatPropList* FileCreatPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new FileCreatPropList(H5P_FILE_CREATE); else - throw PropListIException("FileCreatPropList::getConstant", "FileCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("FileCreatPropList::getConstant", + "FileCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -64,7 +65,8 @@ FileCreatPropList* FileCreatPropList::getConstant() // points to. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void FileCreatPropList::deleteConstants() +void +FileCreatPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -73,7 +75,7 @@ void FileCreatPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for default property //-------------------------------------------------------------------------- -const FileCreatPropList& FileCreatPropList::DEFAULT = *getConstant(); +const FileCreatPropList &FileCreatPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -82,7 +84,9 @@ const FileCreatPropList& FileCreatPropList::DEFAULT = *getConstant(); ///\brief Default constructor: Creates a file create property list // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileCreatPropList::FileCreatPropList() : PropList(H5P_FILE_CREATE) {} +FileCreatPropList::FileCreatPropList() : PropList(H5P_FILE_CREATE) +{ +} //-------------------------------------------------------------------------- // Function: FileCreatPropList copy constructor @@ -91,7 +95,9 @@ FileCreatPropList::FileCreatPropList() : PropList(H5P_FILE_CREATE) {} ///\param original - IN: FileCreatPropList instance to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileCreatPropList::FileCreatPropList(const FileCreatPropList& original) : PropList( original ) {} +FileCreatPropList::FileCreatPropList(const FileCreatPropList &original) : PropList(original) +{ +} //-------------------------------------------------------------------------- // Function: FileCreatPropList overloaded constructor @@ -100,7 +106,9 @@ FileCreatPropList::FileCreatPropList(const FileCreatPropList& original) : PropLi ///\param plist_id - IN: FileCreatPropList id to use // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileCreatPropList::FileCreatPropList(const hid_t plist_id) : PropList(plist_id) {} +FileCreatPropList::FileCreatPropList(const hid_t plist_id) : PropList(plist_id) +{ +} #ifndef H5_NO_DEPRECATED_SYMBOLS //-------------------------------------------------------------------------- @@ -115,13 +123,12 @@ FileCreatPropList::FileCreatPropList(const hid_t plist_id) : PropList(plist_id) /// Any (or even all) of the output arguments can be null pointers. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::getVersion(unsigned& super, unsigned& freelist, unsigned& stab, unsigned& shhdr) const +void +FileCreatPropList::getVersion(unsigned &super, unsigned &freelist, unsigned &stab, unsigned &shhdr) const { herr_t ret_value = H5Pget_version(id, &super, &freelist, &stab, &shhdr); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::getVersion", - "H5Pget_version failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::getVersion", "H5Pget_version failed"); } } #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -136,13 +143,12 @@ void FileCreatPropList::getVersion(unsigned& super, unsigned& freelist, unsigned /// of 2 equal to 512 or greater (512, 1024, 2048, etc.) // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::setUserblock(hsize_t size) const +void +FileCreatPropList::setUserblock(hsize_t size) const { herr_t ret_value = H5Pset_userblock(id, size); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::setUserblock", - "H5Pset_userblock failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::setUserblock", "H5Pset_userblock failed"); } } @@ -153,16 +159,15 @@ void FileCreatPropList::setUserblock(hsize_t size) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hsize_t FileCreatPropList::getUserblock() const +hsize_t +FileCreatPropList::getUserblock() const { hsize_t userblock_size; - herr_t ret_value = H5Pget_userblock(id, &userblock_size); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::getUserblock", - "H5Pget_userblock failed"); + herr_t ret_value = H5Pget_userblock(id, &userblock_size); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::getUserblock", "H5Pget_userblock failed"); } - return(userblock_size); + return (userblock_size); } //-------------------------------------------------------------------------- @@ -177,13 +182,12 @@ hsize_t FileCreatPropList::getUserblock() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::setSizes(size_t sizeof_addr, size_t sizeof_size) const +void +FileCreatPropList::setSizes(size_t sizeof_addr, size_t sizeof_size) const { herr_t ret_value = H5Pset_sizes(id, sizeof_addr, sizeof_size); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::setSizes", - "H5Pset_sizes failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::setSizes", "H5Pset_sizes failed"); } } @@ -195,13 +199,12 @@ void FileCreatPropList::setSizes(size_t sizeof_addr, size_t sizeof_size) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::getSizes(size_t& sizeof_addr, size_t& sizeof_size) const +void +FileCreatPropList::getSizes(size_t &sizeof_addr, size_t &sizeof_size) const { herr_t ret_value = H5Pget_sizes(id, &sizeof_addr, &sizeof_size); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::getSizes", - "H5Pget_sizes failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::getSizes", "H5Pget_sizes failed"); } } @@ -217,13 +220,12 @@ void FileCreatPropList::getSizes(size_t& sizeof_addr, size_t& sizeof_size) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::setSymk(unsigned ik, unsigned lk) const +void +FileCreatPropList::setSymk(unsigned ik, unsigned lk) const { herr_t ret_value = H5Pset_sym_k(id, ik, lk); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::setSymk", - "H5Pset_sym_k failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::setSymk", "H5Pset_sym_k failed"); } } @@ -238,13 +240,12 @@ void FileCreatPropList::setSymk(unsigned ik, unsigned lk) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::getSymk(unsigned& ik, unsigned& lk) const +void +FileCreatPropList::getSymk(unsigned &ik, unsigned &lk) const { herr_t ret_value = H5Pget_sym_k(id, &ik, &lk); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::getSymk", - "H5Pget_sym_k failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::getSymk", "H5Pget_sym_k failed"); } } @@ -259,13 +260,12 @@ void FileCreatPropList::getSymk(unsigned& ik, unsigned& lk) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::setIstorek(unsigned ik) const +void +FileCreatPropList::setIstorek(unsigned ik) const { herr_t ret_value = H5Pset_istore_k(id, ik); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::setIstorek", - "H5Pset_istore_k failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::setIstorek", "H5Pset_istore_k failed"); } } @@ -279,16 +279,15 @@ void FileCreatPropList::setIstorek(unsigned ik) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -unsigned FileCreatPropList::getIstorek() const +unsigned +FileCreatPropList::getIstorek() const { unsigned ik; - herr_t ret_value = H5Pget_istore_k(id, &ik); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::getIstorek", - "H5Pget_istore_k failed"); + herr_t ret_value = H5Pget_istore_k(id, &ik); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::getIstorek", "H5Pget_istore_k failed"); } - return(ik); + return (ik); } //-------------------------------------------------------------------------- @@ -309,13 +308,14 @@ unsigned FileCreatPropList::getIstorek() const /// API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -void FileCreatPropList::setFileSpaceStrategy(H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold) const +void +FileCreatPropList::setFileSpaceStrategy(H5F_fspace_strategy_t strategy, hbool_t persist, + hsize_t threshold) const { herr_t ret_value = H5Pset_file_space_strategy(id, strategy, persist, threshold); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileCreatPropList::setFileSpaceStrategy", - "H5Pset_file_space_strategy failed"); + "H5Pset_file_space_strategy failed"); } } @@ -329,13 +329,14 @@ void FileCreatPropList::setFileSpaceStrategy(H5F_fspace_strategy_t strategy, hbo ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -void FileCreatPropList::getFileSpaceStrategy(H5F_fspace_strategy_t& strategy, hbool_t& persist, hsize_t& threshold) const +void +FileCreatPropList::getFileSpaceStrategy(H5F_fspace_strategy_t &strategy, hbool_t &persist, + hsize_t &threshold) const { herr_t ret_value = H5Pget_file_space_strategy(id, &strategy, &persist, &threshold); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileCreatPropList::getFileSpaceStrategy", - "H5Pget_file_space_strategy failed"); + "H5Pget_file_space_strategy failed"); } } @@ -346,13 +347,13 @@ void FileCreatPropList::getFileSpaceStrategy(H5F_fspace_strategy_t& strategy, hb ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -void FileCreatPropList::setFileSpacePagesize(hsize_t fsp_psize) const +void +FileCreatPropList::setFileSpacePagesize(hsize_t fsp_psize) const { herr_t ret_value = H5Pset_file_space_page_size(id, fsp_psize); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileCreatPropList::setFileSpacePagesize", - "H5Pset_file_space_page_size failed"); + "H5Pset_file_space_page_size failed"); } } @@ -364,16 +365,16 @@ void FileCreatPropList::setFileSpacePagesize(hsize_t fsp_psize) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -hsize_t FileCreatPropList::getFileSpacePagesize() const +hsize_t +FileCreatPropList::getFileSpacePagesize() const { hsize_t fsp_psize = 0; - herr_t ret_value = H5Pget_file_space_page_size(id, &fsp_psize); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_file_space_page_size(id, &fsp_psize); + if (ret_value < 0) { throw PropListIException("FileCreatPropList::getFileSpacePagesize", - "H5Pget_file_space_page_size failed"); + "H5Pget_file_space_page_size failed"); } - return(fsp_psize); + return (fsp_psize); } //-------------------------------------------------------------------------- @@ -381,6 +382,8 @@ hsize_t FileCreatPropList::getFileSpacePagesize() const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileCreatPropList::~FileCreatPropList() {} +FileCreatPropList::~FileCreatPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5FcreatProp.h b/c++/src/H5FcreatProp.h index cc28920..00ae0b1 100644 --- a/c++/src/H5FcreatProp.h +++ b/c++/src/H5FcreatProp.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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 namespace H5 { @@ -23,86 +23,90 @@ namespace H5 { */ // Inheritance: PropList -> IdComponent class H5_DLLCPP FileCreatPropList : public PropList { - public: - ///\brief Default file creation property list. - static const FileCreatPropList& DEFAULT; + public: + ///\brief Default file creation property list. + static const FileCreatPropList &DEFAULT; - // Creates a file create property list. - FileCreatPropList(); + // Creates a file create property list. + FileCreatPropList(); #ifndef H5_NO_DEPRECATED_SYMBOLS - // Retrieves version information for various parts of a file. - void getVersion(unsigned& super, unsigned& freelist, unsigned& stab, unsigned& shhdr) const; + // Retrieves version information for various parts of a file. + void getVersion(unsigned &super, unsigned &freelist, unsigned &stab, unsigned &shhdr) const; #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Sets the userblock size field of a file creation property list. - void setUserblock(hsize_t size) const; + // Sets the userblock size field of a file creation property list. + void setUserblock(hsize_t size) const; - // Gets the size of a user block in this file creation property list. - hsize_t getUserblock() const; + // Gets the size of a user block in this file creation property list. + hsize_t getUserblock() const; - // Retrieves the size-of address and size quantities stored in a - // file according to this file creation property list. - void getSizes(size_t& sizeof_addr, size_t& sizeof_size) const; + // Retrieves the size-of address and size quantities stored in a + // file according to this file creation property list. + void getSizes(size_t &sizeof_addr, size_t &sizeof_size) const; - // Sets file size-of addresses and sizes. - void setSizes(size_t sizeof_addr = 4, size_t sizeof_size = 4) const; + // Sets file size-of addresses and sizes. + void setSizes(size_t sizeof_addr = 4, size_t sizeof_size = 4) const; - // Retrieves the size of the symbol table B-tree 1/2 rank and the - // symbol table leaf node 1/2 size. - void getSymk(unsigned& int_nodes_k, unsigned& leaf_nodes_k) const; + // Retrieves the size of the symbol table B-tree 1/2 rank and the + // symbol table leaf node 1/2 size. + void getSymk(unsigned &int_nodes_k, unsigned &leaf_nodes_k) const; - // Sets the size of parameters used to control the symbol table nodes. - void setSymk(unsigned int_nodes_k, unsigned leaf_nodes_k) const; + // Sets the size of parameters used to control the symbol table nodes. + void setSymk(unsigned int_nodes_k, unsigned leaf_nodes_k) const; - // Returns the 1/2 rank of an indexed storage B-tree. - unsigned getIstorek() const; + // Returns the 1/2 rank of an indexed storage B-tree. + unsigned getIstorek() const; - // Sets the size of parameter used to control the B-trees for - // indexing chunked datasets. - void setIstorek(unsigned ik) const; + // Sets the size of parameter used to control the B-trees for + // indexing chunked datasets. + void setIstorek(unsigned ik) const; - // Sets the strategy and the threshold value that the library will - // will employ in managing file space. - void setFileSpaceStrategy(H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold) const; + // Sets the strategy and the threshold value that the library will + // will employ in managing file space. + void setFileSpaceStrategy(H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold) const; - // Returns the strategy that the library uses in managing file space. - void getFileSpaceStrategy(H5F_fspace_strategy_t& strategy, hbool_t& persist, hsize_t& threshold) const; + // Returns the strategy that the library uses in managing file space. + void getFileSpaceStrategy(H5F_fspace_strategy_t &strategy, hbool_t &persist, hsize_t &threshold) const; - // Sets the file space page size for paged aggregation. - void setFileSpacePagesize(hsize_t fsp_psize) const; + // Sets the file space page size for paged aggregation. + void setFileSpacePagesize(hsize_t fsp_psize) const; - // Returns the threshold value that the library uses in tracking free - // space sections. - hsize_t getFileSpacePagesize() const; + // Returns the threshold value that the library uses in tracking free + // space sections. + hsize_t getFileSpacePagesize() const; - ///\brief Returns this class name. - virtual H5std_string fromClass() const { return("FileCreatPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("FileCreatPropList"); + } - // Copy constructor: same as the original FileCreatPropList. - FileCreatPropList(const FileCreatPropList& orig); + // Copy constructor: same as the original FileCreatPropList. + FileCreatPropList(const FileCreatPropList &orig); - // Creates a copy of an existing file create property list - // using the property list id. - FileCreatPropList(const hid_t plist_id); + // Creates a copy of an existing file create property list + // using the property list id. + FileCreatPropList(const hid_t plist_id); - // Noop destructor - virtual ~FileCreatPropList(); + // Noop destructor + virtual ~FileCreatPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static FileCreatPropList* DEFAULT_; + private: + static FileCreatPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static FileCreatPropList* getConstant(); + // Creates the global constant, should only be used by the library + static FileCreatPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of FileCreatPropList } // namespace H5 -#endif // __H5FileCreatPropList_H +#endif // H5FileCreatPropList_H diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index 07d7e84..c7f0f95 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -6,16 +6,12 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif #include <string> #include "H5Include.h" @@ -41,15 +37,17 @@ #include "H5Alltypes.h" namespace H5 { - using std::cerr; - using std::endl; +using std::cerr; +using std::endl; //-------------------------------------------------------------------------- // Function H5File default constructor ///\brief Default constructor: creates a stub H5File object. // December 2000 //-------------------------------------------------------------------------- -H5File::H5File() : Group(), id(H5I_INVALID_HID) {} +H5File::H5File() : Group(), id(H5I_INVALID_HID) +{ +} //-------------------------------------------------------------------------- // Function: H5File overloaded constructor @@ -81,11 +79,14 @@ H5File::H5File() : Group(), id(H5I_INVALID_HID) {} // block here to catch then re-throw it. -BMR 2013/03/21 // December 2000 //-------------------------------------------------------------------------- -H5File::H5File(const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist) : Group(), id(H5I_INVALID_HID) +H5File::H5File(const char *name, unsigned int flags, const FileCreatPropList &create_plist, + const FileAccPropList &access_plist) + : Group(), id(H5I_INVALID_HID) { try { p_get_file(name, flags, create_plist, access_plist); - } catch (FileIException& open_file) { + } + catch (FileIException &open_file) { throw open_file; } } @@ -106,11 +107,14 @@ H5File::H5File(const char* name, unsigned int flags, const FileCreatPropList& cr // block here to catch then re-throw it. -BMR 2013/03/21 // December 2000 //-------------------------------------------------------------------------- -H5File::H5File(const H5std_string& name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist) : Group(), id(H5I_INVALID_HID) +H5File::H5File(const H5std_string &name, unsigned int flags, const FileCreatPropList &create_plist, + const FileAccPropList &access_plist) + : Group(), id(H5I_INVALID_HID) { try { p_get_file(name.c_str(), flags, create_plist, access_plist); - } catch (FileIException& open_file) { + } + catch (FileIException &open_file) { throw open_file; } } @@ -123,26 +127,26 @@ H5File::H5File(const H5std_string& name, unsigned int flags, const FileCreatProp // - removed H5F_ACC_CREAT because H5Fcreate will fail with // H5F_ACC_CREAT. - BMR, Sep 17, 2014 //-------------------------------------------------------------------------- -void H5File::p_get_file(const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist) +void +H5File::p_get_file(const char *name, unsigned int flags, const FileCreatPropList &create_plist, + const FileAccPropList &access_plist) { // These bits only set for creation, so if any of them are set, // create the file. - if (flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC)) - { + if (flags & (H5F_ACC_EXCL | H5F_ACC_TRUNC)) { hid_t create_plist_id = create_plist.getId(); hid_t access_plist_id = access_plist.getId(); - id = H5Fcreate(name, flags, create_plist_id, access_plist_id); - if (id < 0) // throw an exception when open/create fail + id = H5Fcreate(name, flags, create_plist_id, access_plist_id); + if (id < 0) // throw an exception when open/create fail { throw FileIException("H5File constructor", "H5Fcreate failed"); } } // Open the file if none of the bits above are set. - else - { + else { hid_t access_plist_id = access_plist.getId(); - id = H5Fopen(name, flags, access_plist_id); - if (id < 0) // throw an exception when open/create fail + id = H5Fopen(name, flags, access_plist_id); + if (id < 0) // throw an exception when open/create fail { throw FileIException("H5File constructor", "H5Fopen failed"); } @@ -176,7 +180,7 @@ H5File::H5File(hid_t existing_id) : Group() ///\param original - IN: H5File instance to copy // December 2000 //-------------------------------------------------------------------------- -H5File::H5File(const H5File& original) : Group() +H5File::H5File(const H5File &original) : Group(original) { id = original.getId(); incRefCount(); // increment number of references to this id @@ -190,7 +194,8 @@ H5File::H5File(const H5File& original) : Group() ///\exception H5::FileIException // December 2000 //-------------------------------------------------------------------------- -bool H5File::isHdf5(const char* name) +bool +H5File::isHdf5(const char *name) { // Calls C routine H5Fis_hdf5 to determine whether the file is in // HDF5 format. It returns positive value, 0, or negative value @@ -212,9 +217,10 @@ bool H5File::isHdf5(const char* name) ///\param name - IN: Name of the file - \c H5std_string // December 2000 //-------------------------------------------------------------------------- -bool H5File::isHdf5(const H5std_string& name) +bool +H5File::isHdf5(const H5std_string &name) { - return(isHdf5( name.c_str())); + return (isHdf5(name.c_str())); } //-------------------------------------------------------------------------- @@ -235,18 +241,19 @@ bool H5File::isHdf5(const H5std_string& name) /// // October 2005 //-------------------------------------------------------------------------- -void H5File::openFile(const char* name, unsigned int flags, const FileAccPropList& access_plist) +void +H5File::openFile(const char *name, unsigned int flags, const FileAccPropList &access_plist) { try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw FileIException("H5File::openFile", close_error.getDetailMsg()); } hid_t access_plist_id = access_plist.getId(); - id = H5Fopen (name, flags, access_plist_id); - if (id < 0) // throw an exception when open fails + id = H5Fopen(name, flags, access_plist_id); + if (id < 0) // throw an exception when open fails { throw FileIException("H5File::openFile", "H5Fopen failed"); } @@ -262,7 +269,8 @@ void H5File::openFile(const char* name, unsigned int flags, const FileAccPropLis /// FileAccPropList::DEFAULT // December 2000 //-------------------------------------------------------------------------- -void H5File::openFile(const H5std_string& name, unsigned int flags, const FileAccPropList& access_plist) +void +H5File::openFile(const H5std_string &name, unsigned int flags, const FileAccPropList &access_plist) { openFile(name.c_str(), flags, access_plist); } @@ -283,12 +291,13 @@ void H5File::openFile(const H5std_string& name, unsigned int flags, const FileAc // - Replaced decRefCount with close() to let the C library // handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- -void H5File::reOpen() +void +H5File::reOpen() { try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw FileIException("H5File::reOpen", close_error.getDetailMsg()); } @@ -306,19 +315,18 @@ void H5File::reOpen() ///\exception H5::FileIException // December 2000 //-------------------------------------------------------------------------- -FileCreatPropList H5File::getCreatePlist() const +FileCreatPropList +H5File::getCreatePlist() const { hid_t create_plist_id = H5Fget_create_plist(id); // if H5Fget_create_plist returns a valid id, create and return // the FileCreatPropList object for this property list - if (create_plist_id > 0) - { - FileCreatPropList create_plist(create_plist_id); - return(create_plist); + if (create_plist_id > 0) { + FileCreatPropList create_plist(create_plist_id); + return (create_plist); } - else - { + else { throw FileIException("H5File::getCreatePlist", "H5Fget_create_plist failed"); } } @@ -330,16 +338,16 @@ FileCreatPropList H5File::getCreatePlist() const ///\exception H5::FileIException // December 2000 //-------------------------------------------------------------------------- -FileAccPropList H5File::getAccessPlist() const +FileAccPropList +H5File::getAccessPlist() const { hid_t access_plist_id = H5Fget_access_plist(id); // if H5Fget_access_plist returns a valid id, create and return // the FileAccPropList object for this property list - if (access_plist_id > 0) - { - FileAccPropList access_plist(access_plist_id); - return access_plist; + if (access_plist_id > 0) { + FileAccPropList access_plist(access_plist_id); + return access_plist; } else // Raise an exception { @@ -357,11 +365,11 @@ FileAccPropList H5File::getAccessPlist() const /// superblock extension, free space management, and shared object // February 2017 //-------------------------------------------------------------------------- -void H5File::getFileInfo(H5F_info2_t& file_info) const +void +H5File::getFileInfo(H5F_info2_t &file_info) const { herr_t ret_value = H5Fget_info2(id, &file_info); - if (ret_value < 0) - { + if (ret_value < 0) { throw FileIException("H5File::getFileInfo", "H5Fget_info2 failed"); } } @@ -373,17 +381,16 @@ void H5File::getFileInfo(H5F_info2_t& file_info) const ///\exception H5::FileIException // May 2004 //-------------------------------------------------------------------------- -hssize_t H5File::getFreeSpace() const +hssize_t +H5File::getFreeSpace() const { hssize_t free_space = H5Fget_freespace(id); - if (free_space < 0) - { + if (free_space < 0) { throw FileIException("H5File::getFreeSpace", "H5Fget_freespace failed"); } return (free_space); } - //-------------------------------------------------------------------------- // Function: H5File::getObjCount ///\brief Returns the number of opened object IDs (files, datasets, @@ -405,11 +412,11 @@ hssize_t H5File::getFreeSpace() const /// Multiple object types can be combined with the logical OR operator (|). // May 2004 //-------------------------------------------------------------------------- -ssize_t H5File::getObjCount(unsigned types) const +ssize_t +H5File::getObjCount(unsigned types) const { ssize_t num_objs = H5Fget_obj_count(id, types); - if (num_objs < 0) - { + if (num_objs < 0) { throw FileIException("H5File::getObjCount", "H5Fget_obj_count failed"); } return (num_objs); @@ -440,11 +447,11 @@ ssize_t H5File::getObjCount(unsigned types) const // Notes: will do the overload for this one after hearing from Quincey??? // May 2004 //-------------------------------------------------------------------------- -void H5File::getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const +void +H5File::getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const { ssize_t ret_value = H5Fget_obj_ids(id, types, max_objs, oid_list); - if (ret_value < 0) - { + if (ret_value < 0) { throw FileIException("H5File::getObjIDs", "H5Fget_obj_ids failed"); } } @@ -468,12 +475,12 @@ void H5File::getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const /// closed and reopened or opened during a subsequent session. // May 2004 //-------------------------------------------------------------------------- -void H5File::getVFDHandle(const FileAccPropList& fapl, void **file_handle) const +void +H5File::getVFDHandle(const FileAccPropList &fapl, void **file_handle) const { - hid_t fapl_id = fapl.getId(); + hid_t fapl_id = fapl.getId(); herr_t ret_value = H5Fget_vfd_handle(id, fapl_id, file_handle); - if (ret_value < 0) - { + if (ret_value < 0) { throw FileIException("H5File::getVFDHandle", "H5Fget_vfd_handle failed"); } } @@ -493,7 +500,7 @@ void H5File::getVFDHandle(const FileAccPropList& fapl, void **file_handle) const // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void H5File::getVFDHandle(FileAccPropList& fapl, void **file_handle) const +// void H5File::getVFDHandle(FileAccPropList& fapl, void **file_handle) const //{ // getVFDHandle((const FileAccPropList)fapl, file_handle); //} @@ -508,11 +515,11 @@ void H5File::getVFDHandle(const FileAccPropList& fapl, void **file_handle) const ///\exception H5::FileIException // May 2004 //-------------------------------------------------------------------------- -void H5File::getVFDHandle(void **file_handle) const +void +H5File::getVFDHandle(void **file_handle) const { herr_t ret_value = H5Fget_vfd_handle(id, H5P_DEFAULT, file_handle); - if (ret_value < 0) - { + if (ret_value < 0) { throw FileIException("H5File::getVFDHandle", "H5Fget_vfd_handle failed"); } } @@ -527,12 +534,12 @@ void H5File::getVFDHandle(void **file_handle) const /// order to learn the true size of the underlying file. // Programmer Raymond Lu - June 24, 2004 //-------------------------------------------------------------------------- -hsize_t H5File::getFileSize() const +hsize_t +H5File::getFileSize() const { hsize_t file_size; - herr_t ret_value = H5Fget_filesize(id, &file_size); - if (ret_value < 0) - { + herr_t ret_value = H5Fget_filesize(id, &file_size); + if (ret_value < 0) { throw FileIException("H5File::getFileSize", "H5Fget_filesize failed"); } return (file_size); @@ -550,9 +557,10 @@ hsize_t H5File::getFileSize() const // IdComponent::getId now becomes pure virtual function. // May, 2008 //-------------------------------------------------------------------------- -hid_t H5File::getId() const +hid_t +H5File::getId() const { - return(id); + return (id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -564,7 +572,8 @@ hid_t H5File::getId() const // This function is replaced by the above function reOpen. // December 2000 //-------------------------------------------------------------------------- -void H5File::reopen() +void +H5File::reopen() { H5File::reOpen(); } @@ -581,9 +590,10 @@ void H5File::reopen() // After HDFFV-9920, the Group's methods can use getId() and // getLocId() is kept for backward compatibility. //-------------------------------------------------------------------------- -hid_t H5File::getLocId() const +hid_t +H5File::getLocId() const { - return(getId()); + return (getId()); } //-------------------------------------------------------------------------- @@ -598,13 +608,14 @@ hid_t H5File::getLocId() const // Then the object's id is reset to the new id. // December 2000 //-------------------------------------------------------------------------- -void H5File::p_setId(const hid_t new_id) +void +H5File::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& E) { + catch (Exception &E) { throw FileIException("H5File::p_setId", E.getDetailMsg()); } // reset object's id to the given id @@ -619,13 +630,12 @@ void H5File::p_setId(const hid_t new_id) ///\exception H5::FileIException // March 2005 //-------------------------------------------------------------------------- -void H5File::close() +void +H5File::close() { - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Fclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw FileIException("H5File::close", "H5Fclose failed"); } // reset the id @@ -646,7 +656,8 @@ void H5File::close() // an implementation of H5File. // December 2000 //-------------------------------------------------------------------------- -void H5File::throwException(const H5std_string& func_name, const H5std_string& msg) const +void +H5File::throwException(const H5std_string &func_name, const H5std_string &msg) const { H5std_string full_name = func_name; full_name.insert(0, "H5File::"); @@ -667,9 +678,10 @@ H5File::~H5File() { try { close(); - } catch (Exception& close_error) { + } + catch (Exception &close_error) { cerr << "H5File::~H5File - " << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5File.h b/c++/src/H5File.h index 473428a..ee35700 100644 --- a/c++/src/H5File.h +++ b/c++/src/H5File.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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 namespace H5 { @@ -23,104 +23,108 @@ namespace H5 { */ // Inheritance: Group -> CommonFG/H5Object -> H5Location -> IdComponent class H5_DLLCPP H5File : public Group { - public: - // Creates or opens an HDF5 file. - H5File(const char* name, unsigned int flags, - const FileCreatPropList& create_plist = FileCreatPropList::DEFAULT, - const FileAccPropList& access_plist = FileAccPropList::DEFAULT); - H5File(const H5std_string& name, unsigned int flags, - const FileCreatPropList& create_plist = FileCreatPropList::DEFAULT, - const FileAccPropList& access_plist = FileAccPropList::DEFAULT); + public: + // Creates or opens an HDF5 file. + H5File(const char *name, unsigned int flags, + const FileCreatPropList &create_plist = FileCreatPropList::DEFAULT, + const FileAccPropList & access_plist = FileAccPropList::DEFAULT); + H5File(const H5std_string &name, unsigned int flags, + const FileCreatPropList &create_plist = FileCreatPropList::DEFAULT, + const FileAccPropList & access_plist = FileAccPropList::DEFAULT); - // Open the file - void openFile(const H5std_string& name, unsigned int flags, - const FileAccPropList& access_plist = FileAccPropList::DEFAULT); - void openFile(const char* name, unsigned int flags, - const FileAccPropList& access_plist = FileAccPropList::DEFAULT); + // Open the file + void openFile(const H5std_string &name, unsigned int flags, + const FileAccPropList &access_plist = FileAccPropList::DEFAULT); + void openFile(const char *name, unsigned int flags, + const FileAccPropList &access_plist = FileAccPropList::DEFAULT); - // Close this file. - virtual void close(); + // Close this file. + virtual void close() H5_OVERRIDE; - // Gets a copy of the access property list of this file. - FileAccPropList getAccessPlist() const; + // Gets a copy of the access property list of this file. + FileAccPropList getAccessPlist() const; - // Gets a copy of the creation property list of this file. - FileCreatPropList getCreatePlist() const; + // Gets a copy of the creation property list of this file. + FileCreatPropList getCreatePlist() const; - // Gets general information about this file. - void getFileInfo(H5F_info2_t& file_info) const; + // Gets general information about this file. + void getFileInfo(H5F_info2_t &file_info) const; - // Returns the amount of free space in the file. - hssize_t getFreeSpace() const; + // Returns the amount of free space in the file. + hssize_t getFreeSpace() const; - // Returns the number of opened object IDs (files, datasets, groups - // and datatypes) in the same file. - ssize_t getObjCount(unsigned types = H5F_OBJ_ALL) const; + // Returns the number of opened object IDs (files, datasets, groups + // and datatypes) in the same file. + ssize_t getObjCount(unsigned types = H5F_OBJ_ALL) const; - // Retrieves a list of opened object IDs (files, datasets, groups - // and datatypes) in the same file. - void getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const; + // Retrieves a list of opened object IDs (files, datasets, groups + // and datatypes) in the same file. + void getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const; - // Returns the pointer to the file handle of the low-level file driver. - void getVFDHandle(void **file_handle) const; - void getVFDHandle(const FileAccPropList& fapl, void **file_handle) const; - //void getVFDHandle(FileAccPropList& fapl, void **file_handle) const; // removed from 1.8.18 and 1.10.1 + // Returns the pointer to the file handle of the low-level file driver. + void getVFDHandle(void **file_handle) const; + void getVFDHandle(const FileAccPropList &fapl, void **file_handle) const; + // void getVFDHandle(FileAccPropList& fapl, void **file_handle) const; // removed from 1.8.18 and 1.10.1 - // Returns the file size of the HDF5 file. - hsize_t getFileSize() const; + // Returns the file size of the HDF5 file. + hsize_t getFileSize() const; - // Determines if a file, specified by its name, is in HDF5 format - static bool isHdf5(const char* name); - static bool isHdf5(const H5std_string& name); + // Determines if a file, specified by its name, is in HDF5 format + static bool isHdf5(const char *name); + static bool isHdf5(const H5std_string &name); - // Reopens this file. - void reOpen(); // added for better name + // Reopens this file. + void reOpen(); // added for better name #ifndef DOXYGEN_SHOULD_SKIP_THIS - void reopen(); // obsolete in favor of reOpen() + void reopen(); // obsolete in favor of reOpen() - // Creates an H5File using an existing file id. Not recommended - // in applications. - H5File(hid_t existing_id); + // Creates an H5File using an existing file id. Not recommended + // in applications. + H5File(hid_t existing_id); #endif // DOXYGEN_SHOULD_SKIP_THIS - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("H5File"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const H5_OVERRIDE + { + return ("H5File"); + } - // Throw file exception. - virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const; + // Throw file exception. + virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const H5_OVERRIDE; - // For CommonFG to get the file id. - virtual hid_t getLocId() const; + // For CommonFG to get the file id. + virtual hid_t getLocId() const H5_OVERRIDE; - // Default constructor - H5File(); + // Default constructor + H5File(); - // Copy constructor: same as the original H5File. - H5File(const H5File& original); + // Copy constructor: same as the original H5File. + H5File(const H5File &original); - // Gets the HDF5 file id. - virtual hid_t getId() const; + // Gets the HDF5 file id. + virtual hid_t getId() const H5_OVERRIDE; - // H5File destructor. - virtual ~H5File(); + // H5File destructor. + virtual ~H5File(); - protected: + protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Sets the HDF5 file id. - virtual void p_setId(const hid_t new_id); + // Sets the HDF5 file id. + virtual void p_setId(const hid_t new_id) H5_OVERRIDE; #endif // DOXYGEN_SHOULD_SKIP_THIS - private: - hid_t id; // HDF5 file id + private: + hid_t id; // HDF5 file id - // 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); + // 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); }; // end of H5File } // namespace H5 -#endif // __H5File_H - +#endif // H5File_H diff --git a/c++/src/H5FloatType.cpp b/c++/src/H5FloatType.cpp index aba826e..33f8377 100644 --- a/c++/src/H5FloatType.cpp +++ b/c++/src/H5FloatType.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -40,7 +40,9 @@ namespace H5 { ///\brief Default constructor: Creates a stub floating-point datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::FloatType() {} +FloatType::FloatType() +{ +} //-------------------------------------------------------------------------- // Function: FloatType overloaded constructor @@ -49,7 +51,7 @@ FloatType::FloatType() {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::FloatType(const PredType& pred_type) : AtomType() +FloatType::FloatType(const PredType &pred_type) : AtomType() { // use DataType::copy to make a copy of this predefined type copy(pred_type); @@ -63,14 +65,18 @@ FloatType::FloatType(const PredType& pred_type) : AtomType() ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::FloatType(const hid_t existing_id) : AtomType( existing_id ) {} +FloatType::FloatType(const hid_t existing_id) : AtomType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: FloatType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::FloatType(const FloatType& original) : AtomType( original ){} +FloatType::FloatType(const FloatType &original) : AtomType(original) +{ +} //-------------------------------------------------------------------------- // Function: FloatType overloaded constructor @@ -80,13 +86,12 @@ FloatType::FloatType(const FloatType& original) : AtomType( original ){} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::FloatType(const DataSet& dataset) : AtomType() +FloatType::FloatType(const DataSet &dataset) : AtomType() { // Calls C function H5Dget_type to get the id of the datatype id = H5Dget_type(dataset.getId()); - if (id < 0) - { + if (id < 0) { throw DataSetIException("FloatType constructor", "H5Dget_type failed"); } } @@ -105,7 +110,7 @@ FloatType::FloatType(const DataSet& dataset) : AtomType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -FloatType::FloatType(const H5Location& loc, const char *dtype_name) : AtomType() +FloatType::FloatType(const H5Location &loc, const char *dtype_name) : AtomType() { id = p_opentype(loc, dtype_name); } @@ -124,7 +129,7 @@ FloatType::FloatType(const H5Location& loc, const char *dtype_name) : AtomType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -FloatType::FloatType(const H5Location& loc, const H5std_string& dtype_name) : AtomType() +FloatType::FloatType(const H5Location &loc, const H5std_string &dtype_name) : AtomType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -137,7 +142,8 @@ FloatType::FloatType(const H5Location& loc, const H5std_string& dtype_name) : At ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* FloatType::decode() const +DataType * +FloatType::decode() const { hid_t encoded_flttype_id = H5I_INVALID_HID; try { @@ -148,7 +154,7 @@ DataType* FloatType::decode() const } FloatType *encoded_flttype = new FloatType; encoded_flttype->p_setId(encoded_flttype_id); - return(encoded_flttype); + return (encoded_flttype); } //-------------------------------------------------------------------------- @@ -162,11 +168,11 @@ DataType* FloatType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FloatType::getFields(size_t& spos, size_t& epos, size_t& esize, size_t& mpos, size_t& msize) const +void +FloatType::getFields(size_t &spos, size_t &epos, size_t &esize, size_t &mpos, size_t &msize) const { herr_t ret_value = H5Tget_fields(id, &spos, &epos, &esize, &mpos, &msize); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("FloatType::getFields", "H5Tget_fields failed"); } } @@ -183,11 +189,11 @@ void FloatType::getFields(size_t& spos, size_t& epos, size_t& esize, size_t& mpo ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FloatType::setFields(size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize) const +void +FloatType::setFields(size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize) const { herr_t ret_value = H5Tset_fields(id, spos, epos, esize, mpos, msize); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("FloatType::setFields", "H5Tset_fields failed"); } } @@ -199,15 +205,15 @@ void FloatType::setFields(size_t spos, size_t epos, size_t esize, size_t mpos, s ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -size_t FloatType::getEbias() const +size_t +FloatType::getEbias() const { size_t ebias = H5Tget_ebias(id); // Returns the bias if successful - if (ebias == 0) - { + if (ebias == 0) { throw DataTypeIException("FloatType::getEbias", "H5Tget_ebias failed - returned exponent bias as 0"); } - return(ebias); + return (ebias); } //-------------------------------------------------------------------------- @@ -217,11 +223,11 @@ size_t FloatType::getEbias() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FloatType::setEbias(size_t ebias) const +void +FloatType::setEbias(size_t ebias) const { herr_t ret_value = H5Tset_ebias(id, ebias); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("FloatType::setEbias", "H5Tset_ebias failed"); } } @@ -241,12 +247,12 @@ void FloatType::setEbias(size_t ebias) const /// \a norm_string. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_norm_t FloatType::getNorm(H5std_string& norm_string) const +H5T_norm_t +FloatType::getNorm(H5std_string &norm_string) const { - H5T_norm_t norm = H5Tget_norm(id); // C routine + H5T_norm_t norm = H5Tget_norm(id); // C routine // Returns a valid normalization type if successful - if (norm == H5T_NORM_ERROR) - { + if (norm == H5T_NORM_ERROR) { throw DataTypeIException("FloatType::getNorm", "H5Tget_norm failed - returned H5T_NORM_ERROR"); } if (norm == H5T_NORM_IMPLIED) @@ -255,7 +261,7 @@ H5T_norm_t FloatType::getNorm(H5std_string& norm_string) const norm_string = "H5T_NORM_MSBSET (1)"; else if (norm == H5T_NORM_NONE) norm_string = "H5T_NORM_NONE (2)"; - return(norm); + return (norm); } //-------------------------------------------------------------------------- @@ -270,11 +276,11 @@ H5T_norm_t FloatType::getNorm(H5std_string& norm_string) const /// \li \c H5T_NORM_NONE (2) - Mantissa is not normalized // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FloatType::setNorm(H5T_norm_t norm) const +void +FloatType::setNorm(H5T_norm_t norm) const { herr_t ret_value = H5Tset_norm(id, norm); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("FloatType::setNorm", "H5Tset_norm failed"); } } @@ -294,12 +300,12 @@ void FloatType::setNorm(H5T_norm_t norm) const /// \a pad_string. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_pad_t FloatType::getInpad(H5std_string& pad_string) const +H5T_pad_t +FloatType::getInpad(H5std_string &pad_string) const { H5T_pad_t pad_type = H5Tget_inpad(id); // Returns a valid padding type if successful - if (pad_type == H5T_PAD_ERROR) - { + if (pad_type == H5T_PAD_ERROR) { throw DataTypeIException("FloatType::getInpad", "H5Tget_inpad failed - returned H5T_PAD_ERROR"); } if (pad_type == H5T_PAD_ZERO) @@ -308,7 +314,7 @@ H5T_pad_t FloatType::getInpad(H5std_string& pad_string) const pad_string = "H5T_PAD_ONE (1)"; else if (pad_type == H5T_PAD_BACKGROUND) pad_string = "H5T_PAD_BACKGROUD (2)"; - return(pad_type); + return (pad_type); } //-------------------------------------------------------------------------- @@ -328,11 +334,11 @@ H5T_pad_t FloatType::getInpad(H5std_string& pad_string) const /// \li \c H5T_PAD_BACKGROUND (2) - Leave background alone // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FloatType::setInpad(H5T_pad_t inpad) const +void +FloatType::setInpad(H5T_pad_t inpad) const { herr_t ret_value = H5Tset_inpad(id, inpad); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("FloatType::setInpad", "H5Tset_inpad failed"); } } @@ -342,6 +348,8 @@ void FloatType::setInpad(H5T_pad_t inpad) const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::~FloatType() {} +FloatType::~FloatType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5FloatType.h b/c++/src/H5FloatType.h index f74a9ae..c76be95 100644 --- a/c++/src/H5FloatType.h +++ b/c++/src/H5FloatType.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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 namespace H5 { @@ -23,61 +23,65 @@ namespace H5 { */ // Inheritance: AtomType -> DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP FloatType : public AtomType { - public: - // Creates a floating-point type using a predefined type. - FloatType(const PredType& pred_type); + public: + // Creates a floating-point type using a predefined type. + FloatType(const PredType &pred_type); - // Gets the floating-point datatype of the specified dataset. - FloatType(const DataSet& dataset); + // Gets the floating-point datatype of the specified dataset. + FloatType(const DataSet &dataset); - // Constructors that open an HDF5 float datatype, given a location. - FloatType(const H5Location& loc, const char* name); - FloatType(const H5Location& loc, const H5std_string& name); + // Constructors that open an HDF5 float datatype, given a location. + FloatType(const H5Location &loc, const char *name); + FloatType(const H5Location &loc, const H5std_string &name); - // Returns an FloatType object via DataType* by decoding the - // binary object description of this type. - virtual DataType* decode() const; + // Returns an FloatType object via DataType* by decoding the + // binary object description of this type. + virtual DataType *decode() const; - // Retrieves the exponent bias of a floating-point type. - size_t getEbias() const; + // Retrieves the exponent bias of a floating-point type. + size_t getEbias() const; - // Sets the exponent bias of a floating-point type. - void setEbias(size_t ebias) const; + // Sets the exponent bias of a floating-point type. + void setEbias(size_t ebias) const; - // Retrieves floating point datatype bit field information. - void getFields(size_t& spos, size_t& epos, size_t& esize, size_t& mpos, size_t& msize) const; + // Retrieves floating point datatype bit field information. + void getFields(size_t &spos, size_t &epos, size_t &esize, size_t &mpos, size_t &msize) const; - // Sets locations and sizes of floating point bit fields. - void setFields(size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize) const; + // Sets locations and sizes of floating point bit fields. + void setFields(size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize) const; - // Retrieves the internal padding type for unused bits in floating-point datatypes. - H5T_pad_t getInpad(H5std_string& pad_string) const; + // Retrieves the internal padding type for unused bits in floating-point datatypes. + H5T_pad_t getInpad(H5std_string &pad_string) const; - // Fills unused internal floating point bits. - void setInpad(H5T_pad_t inpad) const; + // Fills unused internal floating point bits. + void setInpad(H5T_pad_t inpad) const; - // Retrieves mantissa normalization of a floating-point datatype. - H5T_norm_t getNorm(H5std_string& norm_string) const; + // Retrieves mantissa normalization of a floating-point datatype. + H5T_norm_t getNorm(H5std_string &norm_string) const; - // Sets the mantissa normalization of a floating-point datatype. - void setNorm(H5T_norm_t norm) const; + // Sets the mantissa normalization of a floating-point datatype. + void setNorm(H5T_norm_t norm) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("FloatType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("FloatType"); + } - // Default constructor - FloatType(); + // Default constructor + FloatType(); - // Creates a floating-point datatype using an existing id. - FloatType(const hid_t existing_id); + // Creates a floating-point datatype using an existing id. + FloatType(const hid_t existing_id); - // Copy constructor: same as the original FloatType. - FloatType(const FloatType& original); + // Copy constructor: same as the original FloatType. + FloatType(const FloatType &original); - // Noop destructor. - virtual ~FloatType(); + // Noop destructor. + virtual ~FloatType(); }; // end of FloatType } // namespace H5 -#endif // __H5FloatType_H +#endif // H5FloatType_H diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index 7132bdf..fe791da 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -6,16 +6,12 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif #include <string> #include "H5Include.h" @@ -42,15 +38,17 @@ #include "H5Alltypes.h" namespace H5 { - using std::cerr; - using std::endl; +using std::cerr; +using std::endl; //-------------------------------------------------------------------------- // Function: Group default constructor ///\brief Default constructor: creates a stub Group. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group::Group() : H5Object(), CommonFG(), id(H5I_INVALID_HID) {} +Group::Group() : H5Object(), CommonFG(), id(H5I_INVALID_HID) +{ +} //-------------------------------------------------------------------------- // Function: Group copy constructor @@ -58,7 +56,7 @@ Group::Group() : H5Object(), CommonFG(), id(H5I_INVALID_HID) {} ///\param original - IN: Original group to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group::Group(const Group& original) : H5Object(), CommonFG(), id(original.id) +Group::Group(const Group &original) : H5Object(), CommonFG(), id(original.id) { incRefCount(); // increment number of references to this id } @@ -70,11 +68,11 @@ Group::Group(const Group& original) : H5Object(), CommonFG(), id(original.id) ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - March, 2017 //-------------------------------------------------------------------------- -void Group::closeObjId(hid_t obj_id) const +void +Group::closeObjId(hid_t obj_id) const { herr_t ret_value = H5Oclose(obj_id); - if (ret_value < 0) - { + if (ret_value < 0) { throwException("Group::closeObjId", "H5Oclose failed"); } } @@ -91,9 +89,10 @@ void Group::closeObjId(hid_t obj_id) const // After HDFFV-9920, the Group's methods can use getId() and // getLocId() is kept for backward compatibility. //-------------------------------------------------------------------------- -hid_t Group::getLocId() const +hid_t +Group::getLocId() const { - return(getId()); + return (getId()); } //-------------------------------------------------------------------------- @@ -120,7 +119,8 @@ Group::Group(const hid_t existing_id) : H5Object(), CommonFG(), id(existing_id) /// is a datatype that has been named by DataType::commit. // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -Group::Group(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), CommonFG(), id(H5I_INVALID_HID) +Group::Group(const H5Location &loc, const void *ref, H5R_type_t ref_type, const PropList &plist) + : H5Object(), CommonFG(), id(H5I_INVALID_HID) { id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereference"); } @@ -132,12 +132,13 @@ Group::Group(const H5Location& loc, const void* ref, H5R_type_t ref_type, const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- -hsize_t Group::getNumObjs() const +hsize_t +Group::getNumObjs() const { - H5G_info_t ginfo; // Group information + H5G_info_t ginfo; // Group information herr_t ret_value = H5Gget_info(getId(), &ginfo); - if(ret_value < 0) + if (ret_value < 0) throwException("getNumObjs", "H5Gget_info failed"); return (ginfo.nlinks); } @@ -155,14 +156,14 @@ hsize_t Group::getNumObjs() const /// the object's type. // Programmer Binh-Minh Ribler - March, 2017 //-------------------------------------------------------------------------- -hid_t Group::getObjId(const char* obj_name, const PropList& plist) const +hid_t +Group::getObjId(const char *obj_name, const PropList &plist) const { hid_t ret_value = H5Oopen(getId(), obj_name, plist.getId()); - if (ret_value < 0) - { + if (ret_value < 0) { throwException("Group::getObjId", "H5Oopen failed"); } - return(ret_value); + return (ret_value); } //-------------------------------------------------------------------------- @@ -175,9 +176,10 @@ hid_t Group::getObjId(const char* obj_name, const PropList& plist) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - March, 2017 //-------------------------------------------------------------------------- -hid_t Group::getObjId(const H5std_string& obj_name, const PropList& plist) const +hid_t +Group::getObjId(const H5std_string &obj_name, const PropList &plist) const { - return(getObjId(obj_name.c_str(), plist)); + return (getObjId(obj_name.c_str(), plist)); } //-------------------------------------------------------------------------- @@ -192,9 +194,10 @@ hid_t Group::getObjId(const H5std_string& obj_name, const PropList& plist) const // IdComponent::getId now becomes pure virtual function. // Programmer Binh-Minh Ribler - May, 2008 //-------------------------------------------------------------------------- -hid_t Group::getId() const +hid_t +Group::getId() const { - return(id); + return (id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -210,13 +213,14 @@ hid_t Group::getId() const // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Group::p_setId(const hid_t new_id) +void +Group::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throwException("Group::p_setId", close_error.getDetailMsg()); } // reset object's id to the given id @@ -231,13 +235,12 @@ void Group::p_setId(const hid_t new_id) ///\exception H5::GroupIException // Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void Group::close() +void +Group::close() { - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Gclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throwException("Group::close", "H5Gclose failed"); } // reset the id @@ -258,7 +261,8 @@ void Group::close() // an implementation of Group. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Group::throwException(const H5std_string& func_name, const H5std_string& msg) const +void +Group::throwException(const H5std_string &func_name, const H5std_string &msg) const { H5std_string full_name = func_name; full_name.insert(0, "Group::"); @@ -280,9 +284,9 @@ Group::~Group() try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { cerr << "Group::~Group - " << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h index 70b6bff..b5f7e51 100644 --- a/c++/src/H5Group.h +++ b/c++/src/H5Group.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __Group_H -#define __Group_H +#ifndef H5Group_H +#define H5Group_H namespace H5 { @@ -22,59 +22,65 @@ namespace H5 { */ // Inheritance: CommonFG/H5Object -> H5Location -> IdComponent class H5_DLLCPP Group : public H5Object, public CommonFG { - public: - // Close this group. - virtual void close(); + public: + // Close this group. + virtual void close() H5_OVERRIDE; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("Group"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const H5_OVERRIDE + { + return ("Group"); + } - // Throw group exception. - virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const; + // Throw group exception. + virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const H5_OVERRIDE; - // for CommonFG to get the file id. - virtual hid_t getLocId() const; + // for CommonFG to get the file id. + virtual hid_t getLocId() const H5_OVERRIDE; - // Creates a group by way of dereference. - Group(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); - // Removed in 1.10.1, because H5Location is baseclass -// Group(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); + // Creates a group by way of dereference. + Group(const H5Location &loc, const void *ref, H5R_type_t ref_type = H5R_OBJECT, + const PropList &plist = PropList::DEFAULT); + // Removed in 1.10.1, because H5Location is baseclass + // Group(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& + // plist = PropList::DEFAULT); - // Returns the number of objects in this group. - hsize_t getNumObjs() const; + // Returns the number of objects in this group. + hsize_t getNumObjs() const; - // Opens an object within a group or a file, i.e., root group. - hid_t getObjId(const char* name, const PropList& plist = PropList::DEFAULT) const; - hid_t getObjId(const H5std_string& name, const PropList& plist = PropList::DEFAULT) const; + // Opens an object within a group or a file, i.e., root group. + hid_t getObjId(const char *name, const PropList &plist = PropList::DEFAULT) const; + hid_t getObjId(const H5std_string &name, const PropList &plist = PropList::DEFAULT) const; - // Closes an object opened by getObjId(). - void closeObjId(hid_t obj_id) const; + // Closes an object opened by getObjId(). + void closeObjId(hid_t obj_id) const; - // default constructor - Group(); + // default constructor + Group(); - // Copy constructor: same as the original Group. - Group(const Group& original); + // Copy constructor: same as the original Group. + Group(const Group &original); - // Gets the group id. - virtual hid_t getId() const; + // Gets the group id. + virtual hid_t getId() const H5_OVERRIDE; - // Destructor - virtual ~Group(); + // Destructor + virtual ~Group() H5_OVERRIDE; - // Creates a copy of an existing group using its id. - Group(const hid_t group_id); + // Creates a copy of an existing group using its id. + Group(const hid_t group_id); - protected: + protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Sets the group id. - virtual void p_setId(const hid_t new_id); + // Sets the group id. + virtual void p_setId(const hid_t new_id) H5_OVERRIDE; #endif // DOXYGEN_SHOULD_SKIP_THIS - private: - hid_t id; // HDF5 group id + private: + hid_t id; // HDF5 group id }; // end of Group } // namespace H5 -#endif // __Group_H +#endif // H5Group_H diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index a041273..839ac03 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -6,14 +6,14 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include <string> -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5Library.h" @@ -38,7 +38,8 @@ bool IdComponent::H5dontAtexit_called = false; ///\brief Increment reference counter for a given id. // Programmer Binh-Minh Ribler - May 2005 //-------------------------------------------------------------------------- -void IdComponent::incRefCount(const hid_t obj_id) const +void +IdComponent::incRefCount(const hid_t obj_id) const { if (p_valid_id(obj_id)) if (H5Iinc_ref(obj_id) < 0) @@ -50,7 +51,8 @@ void IdComponent::incRefCount(const hid_t obj_id) const ///\brief Increment reference counter for the id of this object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void IdComponent::incRefCount() const +void +IdComponent::incRefCount() const { incRefCount(getId()); } @@ -63,17 +65,15 @@ void IdComponent::incRefCount() const // Added the check for ref counter to give a little more info // on why H5Idec_ref fails in some cases - BMR 5/19/2005 //-------------------------------------------------------------------------- -void IdComponent::decRefCount(const hid_t obj_id) const +void +IdComponent::decRefCount(const hid_t obj_id) const { if (p_valid_id(obj_id)) - if (H5Idec_ref(obj_id) < 0) - { + if (H5Idec_ref(obj_id) < 0) { if (H5Iget_ref(obj_id) <= 0) - throw IdComponentException(inMemFunc("decRefCount"), - "object ref count is 0 or negative"); + throw IdComponentException(inMemFunc("decRefCount"), "object ref count is 0 or negative"); else - throw IdComponentException(inMemFunc("decRefCount"), - "decrementing object ref count failed"); + throw IdComponentException(inMemFunc("decRefCount"), "decrementing object ref count failed"); } } @@ -82,7 +82,8 @@ void IdComponent::decRefCount(const hid_t obj_id) const ///\brief Decrement reference counter for the id of this object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void IdComponent::decRefCount() const +void +IdComponent::decRefCount() const { decRefCount(getId()); } @@ -93,14 +94,15 @@ void IdComponent::decRefCount() const ///\return Reference count // Programmer Binh-Minh Ribler - May 2005 //-------------------------------------------------------------------------- -int IdComponent::getCounter(const hid_t obj_id) const +int +IdComponent::getCounter(const hid_t obj_id) const { int counter = 0; - if (p_valid_id(obj_id)) - { + if (p_valid_id(obj_id)) { counter = H5Iget_ref(obj_id); if (counter < 0) - throw IdComponentException(inMemFunc("incRefCount"), "getting object ref count failed - negative"); + throw IdComponentException(inMemFunc("incRefCount"), + "getting object ref count failed - negative"); } return (counter); } @@ -111,7 +113,8 @@ int IdComponent::getCounter(const hid_t obj_id) const ///\return Reference count // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int IdComponent::getCounter() const +int +IdComponent::getCounter() const { return (getCounter(getId())); } @@ -130,7 +133,8 @@ int IdComponent::getCounter() const /// input object id is invalid. // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -H5I_type_t IdComponent::getHDFObjType(const hid_t obj_id) +H5I_type_t +IdComponent::getHDFObjType(const hid_t obj_id) { if (obj_id <= 0) return H5I_BADID; // invalid @@ -156,9 +160,10 @@ H5I_type_t IdComponent::getHDFObjType(const hid_t obj_id) /// input object id is invalid. // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -H5I_type_t IdComponent::getHDFObjType() const +H5I_type_t +IdComponent::getHDFObjType() const { - return(getHDFObjType(getId())); + return (getHDFObjType(getId())); } //-------------------------------------------------------------------------- @@ -183,14 +188,15 @@ H5I_type_t IdComponent::getHDFObjType() const /// \li \c H5I_ERROR_STACK // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -hsize_t IdComponent::getNumMembers(H5I_type_t type) +hsize_t +IdComponent::getNumMembers(H5I_type_t type) { - hsize_t nmembers = 0; - herr_t ret_value = H5Inmembers(type, &nmembers); + hsize_t nmembers = 0; + herr_t ret_value = H5Inmembers(type, &nmembers); if (ret_value < 0) throw IdComponentException("getNumMembers", "H5Inmembers failed"); else - return(nmembers); + return (nmembers); } //-------------------------------------------------------------------------- @@ -202,7 +208,8 @@ hsize_t IdComponent::getNumMembers(H5I_type_t type) /// reference count of at least 1. // Programmer Binh-Minh Ribler - Mar 1, 2017 //-------------------------------------------------------------------------- -bool IdComponent::isValid(hid_t an_id) +bool +IdComponent::isValid(hid_t an_id) { // Call C function htri_t ret_value = H5Iis_valid(an_id); @@ -236,7 +243,8 @@ bool IdComponent::isValid(hid_t an_id) /// \li \c H5I_ERROR_STACK // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -bool IdComponent::typeExists(H5I_type_t type) +bool +IdComponent::typeExists(H5I_type_t type) { // Call C function htri_t ret_value = H5Itype_exists(type); @@ -266,17 +274,17 @@ bool IdComponent::typeExists(H5I_type_t type) // care of close() and setId takes care incRefCount(). // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IdComponent& IdComponent::operator=(const IdComponent& rhs) +IdComponent & +IdComponent::operator=(const IdComponent &rhs) { - if (this != &rhs) - { + if (this != &rhs) { // handling references to this id try { setId(rhs.getId()); // Note: a = b, so there are two objects with the same hdf5 id // that's why incRefCount is needed, and it is called by setId } - catch (Exception& close_error) { + catch (Exception &close_error) { throw FileIException(inMemFunc("operator="), close_error.getDetailMsg()); } } @@ -304,7 +312,8 @@ IdComponent& IdComponent::operator=(const IdComponent& rhs) // the id passed to setId is that of another C++ API object, so // setId must call incRefCount. //-------------------------------------------------------------------------- -void IdComponent::setId(const hid_t new_id) +void +IdComponent::setId(const hid_t new_id) { // set to new_id p_setId(new_id); @@ -318,7 +327,9 @@ void IdComponent::setId(const hid_t new_id) ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IdComponent::~IdComponent() {} +IdComponent::~IdComponent() +{ +} // // Implementation of protected functions for HDF5 Reference Interface @@ -338,7 +349,8 @@ IdComponent::~IdComponent() {} /// an exception is thrown. // Programmer Binh-Minh Ribler - Aug 6, 2005 //-------------------------------------------------------------------------- -H5std_string IdComponent::inMemFunc(const char* func_name) const +H5std_string +IdComponent::inMemFunc(const char *func_name) const { H5std_string full_name = func_name; full_name.insert(0, "::"); @@ -355,8 +367,7 @@ IdComponent::IdComponent() { // initH5cpp will register the terminating functions with atexit(). // This should only be done once. - if (!H5cppinit) - { + if (!H5cppinit) { H5Library::initH5cpp(); H5cppinit = true; } @@ -374,7 +385,8 @@ IdComponent::IdComponent() // inherits from H5Location. // Programmer Binh-Minh Ribler - Jul, 2004 //-------------------------------------------------------------------------- -H5std_string IdComponent::p_get_file_name() const +H5std_string +IdComponent::p_get_file_name() const { hid_t temp_id = getId(); @@ -382,28 +394,26 @@ H5std_string IdComponent::p_get_file_name() const ssize_t name_size = H5Fget_name(temp_id, NULL, 0); // If H5Aget_name returns a negative value, raise an exception, - if (name_size < 0) - { + if (name_size < 0) { throw IdComponentException("", "H5Fget_name failed"); } // Call H5Fget_name again to get the actual file name - char* name_C = new char[name_size+1]; // temporary C-string for C API - HDmemset(name_C, 0, name_size+1); // clear buffer + char *name_C = new char[name_size + 1]; // temporary C-string for C API + HDmemset(name_C, 0, name_size + 1); // clear buffer - name_size = H5Fget_name(temp_id, name_C, name_size+1); + name_size = H5Fget_name(temp_id, name_C, name_size + 1); // Check for failure again - if (name_size < 0) - { - delete []name_C; + if (name_size < 0) { + delete[] name_C; throw IdComponentException("", "H5Fget_name failed"); } // Convert the C file name and return H5std_string file_name(name_C); - delete []name_C; - return(file_name); + delete[] name_C; + return (file_name); } // @@ -417,7 +427,8 @@ H5std_string IdComponent::p_get_file_name() const // Return true if id is valid, false, otherwise // Programmer Binh-Minh Ribler - May, 2005 //-------------------------------------------------------------------------- -bool IdComponent::p_valid_id(const hid_t obj_id) +bool +IdComponent::p_valid_id(const hid_t obj_id) { if (obj_id <= 0) return false; @@ -439,4 +450,4 @@ bool IdComponent::p_valid_id(const hid_t obj_id) #endif // DOXYGEN_SHOULD_SKIP_THIS -} +} // namespace H5 diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h index b4070b0..383d42d 100644 --- a/c++/src/H5IdComponent.h +++ b/c++/src/H5IdComponent.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __IdComponent_H -#define __IdComponent_H +#ifndef H5IdComponent_H +#define H5IdComponent_H namespace H5 { @@ -25,89 +25,92 @@ namespace H5 { rarely needs them. */ class H5_DLLCPP IdComponent { - public: + public: + // Increment reference counter. + void incRefCount(const hid_t obj_id) const; + void incRefCount() const; - // Increment reference counter. - void incRefCount(const hid_t obj_id) const; - void incRefCount() const; + // Decrement reference counter. + void decRefCount(const hid_t obj_id) const; + void decRefCount() const; - // Decrement reference counter. - void decRefCount(const hid_t obj_id) const; - void decRefCount() const; + // Get the reference counter to this identifier. + int getCounter(const hid_t obj_id) const; + int getCounter() const; - // Get the reference counter to this identifier. - int getCounter(const hid_t obj_id) const; - int getCounter() const; + // Returns an HDF5 object type, given the object id. + static H5I_type_t getHDFObjType(const hid_t obj_id); - // Returns an HDF5 object type, given the object id. - static H5I_type_t getHDFObjType(const hid_t obj_id); + // Returns an HDF5 object type of this object. + H5I_type_t getHDFObjType() const; - // Returns an HDF5 object type of this object. - H5I_type_t getHDFObjType() const; + // Returns the number of members in a type. + static hsize_t getNumMembers(H5I_type_t type); - // Returns the number of members in a type. - static hsize_t getNumMembers(H5I_type_t type); + // Checks if the given ID is valid. + static bool isValid(hid_t an_id); - // Checks if the given ID is valid. - static bool isValid(hid_t an_id); + // Determines if an type exists. + static bool typeExists(H5I_type_t type); - // Determines if an type exists. - static bool typeExists(H5I_type_t type); + // Assignment operator. + IdComponent &operator=(const IdComponent &rhs); - // Assignment operator. - IdComponent& operator=(const IdComponent& rhs); - - // Sets the identifier of this object to a new value. - void setId(const hid_t new_id); + // Sets the identifier of this object to a new value. + void setId(const hid_t new_id); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Gets the identifier of this object. - virtual hid_t getId () const = 0; + // Gets the identifier of this object. + virtual hid_t getId() const = 0; - // Pure virtual function for there are various H5*close for the - // subclasses. - virtual void close() = 0; + // Pure virtual function for there are various H5*close for the + // subclasses. + virtual void close() = 0; - // Makes and returns the string "<class-name>::<func_name>"; - // <class-name> is returned by fromClass(). - H5std_string inMemFunc(const char* func_name) const; + // Makes and returns the string "<class-name>::<func_name>"; + // <class-name> is returned by fromClass(). + H5std_string inMemFunc(const char *func_name) const; - ///\brief Returns this class name. - virtual H5std_string fromClass() const { return("IdComponent");} + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("IdComponent"); + } #endif // DOXYGEN_SHOULD_SKIP_THIS - // Destructor - virtual ~IdComponent(); + // Destructor + virtual ~IdComponent(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - protected: - // Default constructor. - IdComponent(); + protected: + // Default constructor. + IdComponent(); - // Gets the name of the file, in which an HDF5 object belongs. - H5std_string p_get_file_name() const; + // Gets the name of the file, in which an HDF5 object belongs. + H5std_string p_get_file_name() const; - // Verifies that the given id is valid. - static bool p_valid_id(const hid_t obj_id); + // Verifies that the given id is valid. + static bool p_valid_id(const hid_t obj_id); - // Sets the identifier of this object to a new value. - this one - // doesn't increment reference count - virtual void p_setId(const hid_t new_id) = 0; + // Sets the identifier of this object to a new value. - this one + // doesn't increment reference count + virtual void p_setId(const hid_t new_id) = 0; - // This flag is used to decide whether H5dont_atexit should be called - static bool H5dontAtexit_called; + // This flag is used to decide whether H5dont_atexit should be called + static bool H5dontAtexit_called; - private: - // This flag indicates whether H5Library::initH5cpp has been called - // to register various terminating functions with atexit() - static bool H5cppinit; + private: + // This flag indicates whether H5Library::initH5cpp has been called + // to register various terminating functions with atexit() + static bool H5cppinit; #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end class IdComponent } // namespace H5 -#endif // __IdComponent_H +#endif // H5IdComponent_H diff --git a/c++/src/H5Include.h b/c++/src/H5Include.h index a180430..0dc930d 100644 --- a/c++/src/H5Include.h +++ b/c++/src/H5Include.h @@ -7,34 +7,27 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include <hdf5.h> -// Define bool type for platforms that don't support bool yet -#ifdef BOOL_NOTDEFINED -#ifdef false -#undef false -#endif -#ifdef true -#undef true -#endif -typedef int bool; -const bool false = 0; -const bool true = 1; -#endif - // These are defined in H5Opkg.h, which should not be included in the C++ API, // so re-define them here for now. /* Initial version of the object header format */ -#define H5O_VERSION_1 1 +#define H5O_VERSION_1 1 /* Revised version - leaves out reserved bytes and alignment padding, and adds * magic number as prefix and checksum as suffix for all chunks. */ -#define H5O_VERSION_2 2 +#define H5O_VERSION_2 2 +// Define H5_OVERRIDE to override for C++11. +#if defined(__cplusplus) && (201103L <= __cplusplus) +#define H5_OVERRIDE override +#else +#define H5_OVERRIDE +#endif diff --git a/c++/src/H5IntType.cpp b/c++/src/H5IntType.cpp index 01c20e9..27c4491 100644 --- a/c++/src/H5IntType.cpp +++ b/c++/src/H5IntType.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -40,14 +40,18 @@ namespace H5 { ///\brief Default constructor: Creates a stub integer datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::IntType() {} +IntType::IntType() +{ +} //-------------------------------------------------------------------------- // Function: IntType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::IntType(const IntType& original) : AtomType( original ) {} +IntType::IntType(const IntType &original) : AtomType(original) +{ +} //-------------------------------------------------------------------------- // Function: IntType overloaded constructor @@ -56,7 +60,7 @@ IntType::IntType(const IntType& original) : AtomType( original ) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::IntType(const PredType& pred_type) : AtomType() +IntType::IntType(const PredType &pred_type) : AtomType() { // use DataType::copy to make a copy of this predefined type copy(pred_type); @@ -70,7 +74,9 @@ IntType::IntType(const PredType& pred_type) : AtomType() ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::IntType(const hid_t existing_id) : AtomType( existing_id ) {} +IntType::IntType(const hid_t existing_id) : AtomType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: IntType overloaded constructor @@ -79,13 +85,12 @@ IntType::IntType(const hid_t existing_id) : AtomType( existing_id ) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::IntType(const DataSet& dataset) : AtomType() +IntType::IntType(const DataSet &dataset) : AtomType() { // Calls C function H5Dget_type to get the id of the datatype id = H5Dget_type(dataset.getId()); - if (id < 0) - { + if (id < 0) { throw DataSetIException("IntType constructor", "H5Dget_type failed"); } } @@ -104,7 +109,7 @@ IntType::IntType(const DataSet& dataset) : AtomType() // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -IntType::IntType(const H5Location& loc, const char *dtype_name) : AtomType() +IntType::IntType(const H5Location &loc, const char *dtype_name) : AtomType() { id = p_opentype(loc, dtype_name); } @@ -123,7 +128,7 @@ IntType::IntType(const H5Location& loc, const char *dtype_name) : AtomType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -IntType::IntType(const H5Location& loc, const H5std_string& dtype_name) : AtomType() +IntType::IntType(const H5Location &loc, const H5std_string &dtype_name) : AtomType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -136,7 +141,8 @@ IntType::IntType(const H5Location& loc, const H5std_string& dtype_name) : AtomTy ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* IntType::decode() const +DataType * +IntType::decode() const { hid_t encoded_inttype_id = H5I_INVALID_HID; try { @@ -147,7 +153,7 @@ DataType* IntType::decode() const } IntType *encoded_inttype = new IntType; encoded_inttype->p_setId(encoded_inttype_id); - return(encoded_inttype); + return (encoded_inttype); } //-------------------------------------------------------------------------- @@ -157,17 +163,17 @@ DataType* IntType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_sign_t IntType::getSign() const +H5T_sign_t +IntType::getSign() const { - H5T_sign_t type_sign = H5Tget_sign(id); // C routine + H5T_sign_t type_sign = H5Tget_sign(id); // C routine // Returns a valid sign type if no errors - if (type_sign == H5T_SGN_ERROR) - { + if (type_sign == H5T_SGN_ERROR) { throw DataTypeIException("IntType::getSign", - "H5Tget_sign failed - returned H5T_SGN_ERROR for the sign type"); + "H5Tget_sign failed - returned H5T_SGN_ERROR for the sign type"); } - return(type_sign); + return (type_sign); } //-------------------------------------------------------------------------- @@ -177,12 +183,12 @@ H5T_sign_t IntType::getSign() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void IntType::setSign(H5T_sign_t sign) const +void +IntType::setSign(H5T_sign_t sign) const { // Call C routine to set the sign property herr_t ret_value = H5Tset_sign(id, sign); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("IntType::setSign", "H5Tset_sign failed"); } } @@ -192,6 +198,8 @@ void IntType::setSign(H5T_sign_t sign) const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::~IntType() {} +IntType::~IntType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5IntType.h b/c++/src/H5IntType.h index 496872b..185c8f0 100644 --- a/c++/src/H5IntType.h +++ b/c++/src/H5IntType.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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 namespace H5 { @@ -23,43 +23,47 @@ namespace H5 { */ // Inheritance: AtomType -> DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP IntType : public AtomType { - public: - // Creates an integer type using a predefined type - IntType(const PredType& pred_type); + public: + // Creates an integer type using a predefined type + IntType(const PredType &pred_type); - // Gets the integer datatype of the specified dataset - IntType(const DataSet& dataset); + // Gets the integer datatype of the specified dataset + IntType(const DataSet &dataset); - // Constructors that open an HDF5 integer datatype, given a location. - IntType(const H5Location& loc, const char* name); - IntType(const H5Location& loc, const H5std_string& name); + // Constructors that open an HDF5 integer datatype, given a location. + IntType(const H5Location &loc, const char *name); + IntType(const H5Location &loc, const H5std_string &name); - // Returns an IntType object via DataType* by decoding the - // binary object description of this type. - virtual DataType* decode() const; + // Returns an IntType object via DataType* by decoding the + // binary object description of this type. + virtual DataType *decode() const; - // Retrieves the sign type for an integer type - H5T_sign_t getSign() const; + // Retrieves the sign type for an integer type + H5T_sign_t getSign() const; - // Sets the sign proprety for an integer type. - void setSign(H5T_sign_t sign) const; + // Sets the sign proprety for an integer type. + void setSign(H5T_sign_t sign) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("IntType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("IntType"); + } - // Default constructor - IntType(); + // Default constructor + IntType(); - // Creates a integer datatype using an existing id - IntType(const hid_t existing_id); + // Creates a integer datatype using an existing id + IntType(const hid_t existing_id); - // Copy constructor: same as the original IntType. - IntType(const IntType& original); + // Copy constructor: same as the original IntType. + IntType(const IntType &original); - // Noop destructor. - virtual ~IntType(); + // Noop destructor. + virtual ~IntType(); }; // end of IntType } // namespace H5 -#endif // __H5IntType_H +#endif // H5IntType_H diff --git a/c++/src/H5LaccProp.cpp b/c++/src/H5LaccProp.cpp index 1905cce..feaa555 100644 --- a/c++/src/H5LaccProp.cpp +++ b/c++/src/H5LaccProp.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,7 +27,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -LinkAccPropList* LinkAccPropList::DEFAULT_ = 0; +LinkAccPropList *LinkAccPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: LinkAccPropList::getConstant @@ -40,13 +40,13 @@ LinkAccPropList* LinkAccPropList::DEFAULT_ = 0; // happen. // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -LinkAccPropList* LinkAccPropList::getConstant() +LinkAccPropList * +LinkAccPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -55,8 +55,9 @@ LinkAccPropList* LinkAccPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new LinkAccPropList(H5P_LINK_ACCESS); else - throw PropListIException("LinkAccPropList::getConstant", "LinkAccPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("LinkAccPropList::getConstant", + "LinkAccPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -66,7 +67,8 @@ LinkAccPropList* LinkAccPropList::getConstant() // exception H5::PropListIException // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -void LinkAccPropList::deleteConstants() +void +LinkAccPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -75,7 +77,7 @@ void LinkAccPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose: Constant for default property //-------------------------------------------------------------------------- -const LinkAccPropList& LinkAccPropList::DEFAULT = *getConstant(); +const LinkAccPropList &LinkAccPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -84,7 +86,9 @@ const LinkAccPropList& LinkAccPropList::DEFAULT = *getConstant(); ///\brief Creates a file access property list // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -LinkAccPropList::LinkAccPropList() : PropList(H5P_LINK_ACCESS) {} +LinkAccPropList::LinkAccPropList() : PropList(H5P_LINK_ACCESS) +{ +} //-------------------------------------------------------------------------- // Function: LinkAccPropList copy constructor @@ -92,7 +96,9 @@ LinkAccPropList::LinkAccPropList() : PropList(H5P_LINK_ACCESS) {} ///\param original - IN: LinkAccPropList instance to copy // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -LinkAccPropList::LinkAccPropList(const LinkAccPropList& original) : PropList(original) {} +LinkAccPropList::LinkAccPropList(const LinkAccPropList &original) : PropList(original) +{ +} //-------------------------------------------------------------------------- // Function: LinkAccPropList overloaded constructor @@ -100,7 +106,9 @@ LinkAccPropList::LinkAccPropList(const LinkAccPropList& original) : PropList(ori /// existing one. // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -LinkAccPropList::LinkAccPropList(const hid_t plist_id) : PropList(plist_id) {} +LinkAccPropList::LinkAccPropList(const hid_t plist_id) : PropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: LinkAccPropList::setNumLinks @@ -111,12 +119,12 @@ LinkAccPropList::LinkAccPropList(const hid_t plist_id) : PropList(plist_id) {} ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - March 1, 2017 //-------------------------------------------------------------------------- -void LinkAccPropList::setNumLinks(size_t nlinks) const +void +LinkAccPropList::setNumLinks(size_t nlinks) const { herr_t ret_value = H5Pset_nlinks(id, nlinks); // Throw exception if H5Pset_nlinks returns failure - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("setNumLinks", "H5Pset_nlinks failed"); } } @@ -129,16 +137,16 @@ void LinkAccPropList::setNumLinks(size_t nlinks) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - March 1, 2017 //-------------------------------------------------------------------------- -size_t LinkAccPropList::getNumLinks() const +size_t +LinkAccPropList::getNumLinks() const { - size_t nlinks = 0; + size_t nlinks = 0; herr_t ret_value = H5Pget_nlinks(id, &nlinks); // Throw exception if H5Pget_nlinks returns failure - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("getNumLinks", "H5Pget_nlinks failed"); } - return(nlinks); + return (nlinks); } //-------------------------------------------------------------------------- @@ -146,6 +154,8 @@ size_t LinkAccPropList::getNumLinks() const ///\brief Noop destructor // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -LinkAccPropList::~LinkAccPropList() {} +LinkAccPropList::~LinkAccPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5LaccProp.h b/c++/src/H5LaccProp.h index ec5e54f..4fa516c 100644 --- a/c++/src/H5LaccProp.h +++ b/c++/src/H5LaccProp.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5LinkAccPropList_H -#define __H5LinkAccPropList_H +#ifndef H5LinkAccPropList_H +#define H5LinkAccPropList_H namespace H5 { @@ -23,47 +23,51 @@ namespace H5 { */ // Inheritance: PropList -> IdComponent class H5_DLLCPP LinkAccPropList : public PropList { - public: - ///\brief Default link access property list. - static const LinkAccPropList& DEFAULT; + public: + ///\brief Default link access property list. + static const LinkAccPropList &DEFAULT; - // Creates a link access property list. - LinkAccPropList(); + // Creates a link access property list. + LinkAccPropList(); - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("LinkAccPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("LinkAccPropList"); + } - // Copy constructor: same as the original LinkAccPropList. - LinkAccPropList(const LinkAccPropList& original); + // Copy constructor: same as the original LinkAccPropList. + LinkAccPropList(const LinkAccPropList &original); - // Creates a copy of an existing link access property list - // using the property list id. - LinkAccPropList (const hid_t plist_id); + // Creates a copy of an existing link access property list + // using the property list id. + LinkAccPropList(const hid_t plist_id); - // Sets the number of soft or user-defined links that can be - // traversed before a failure occurs. - void setNumLinks(size_t nlinks) const; + // Sets the number of soft or user-defined links that can be + // traversed before a failure occurs. + void setNumLinks(size_t nlinks) const; - // Gets the number of soft or user-defined link traversals allowed - size_t getNumLinks() const; + // Gets the number of soft or user-defined link traversals allowed + size_t getNumLinks() const; - // Noop destructor - virtual ~LinkAccPropList(); + // Noop destructor + virtual ~LinkAccPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static LinkAccPropList* DEFAULT_; + private: + static LinkAccPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static LinkAccPropList* getConstant(); + // Creates the global constant, should only be used by the library + static LinkAccPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of LinkAccPropList } // namespace H5 -#endif // __H5LinkAccPropList_H +#endif // H5LinkAccPropList_H diff --git a/c++/src/H5LcreatProp.cpp b/c++/src/H5LcreatProp.cpp index bde9339..29721c1 100644 --- a/c++/src/H5LcreatProp.cpp +++ b/c++/src/H5LcreatProp.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,7 +27,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -LinkCreatPropList* LinkCreatPropList::DEFAULT_ = 0; +LinkCreatPropList *LinkCreatPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: LinkCreatPropList::getConstant @@ -40,13 +40,13 @@ LinkCreatPropList* LinkCreatPropList::DEFAULT_ = 0; // happen. // December, 2016 //-------------------------------------------------------------------------- -LinkCreatPropList* LinkCreatPropList::getConstant() +LinkCreatPropList * +LinkCreatPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -55,8 +55,9 @@ LinkCreatPropList* LinkCreatPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new LinkCreatPropList(H5P_LINK_CREATE); else - throw PropListIException("LinkCreatPropList::getConstant", "LinkCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("LinkCreatPropList::getConstant", + "LinkCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -66,7 +67,8 @@ LinkCreatPropList* LinkCreatPropList::getConstant() // exception H5::PropListIException // December, 2016 //-------------------------------------------------------------------------- -void LinkCreatPropList::deleteConstants() +void +LinkCreatPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -75,7 +77,7 @@ void LinkCreatPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose: Constant for default property //-------------------------------------------------------------------------- -const LinkCreatPropList& LinkCreatPropList::DEFAULT = *getConstant(); +const LinkCreatPropList &LinkCreatPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -84,7 +86,9 @@ const LinkCreatPropList& LinkCreatPropList::DEFAULT = *getConstant(); ///\brief Creates a file access property list // December, 2016 //-------------------------------------------------------------------------- -LinkCreatPropList::LinkCreatPropList() : PropList(H5P_LINK_CREATE) {} +LinkCreatPropList::LinkCreatPropList() : PropList(H5P_LINK_CREATE) +{ +} //-------------------------------------------------------------------------- // Function: LinkCreatPropList copy constructor @@ -92,7 +96,9 @@ LinkCreatPropList::LinkCreatPropList() : PropList(H5P_LINK_CREATE) {} ///\param original - IN: LinkCreatPropList instance to copy // December, 2016 //-------------------------------------------------------------------------- -LinkCreatPropList::LinkCreatPropList(const LinkCreatPropList& original) : PropList(original) {} +LinkCreatPropList::LinkCreatPropList(const LinkCreatPropList &original) : PropList(original) +{ +} //-------------------------------------------------------------------------- // Function: LinkCreatPropList overloaded constructor @@ -100,7 +106,9 @@ LinkCreatPropList::LinkCreatPropList(const LinkCreatPropList& original) : PropLi /// existing one. // December, 2016 //-------------------------------------------------------------------------- -LinkCreatPropList::LinkCreatPropList(const hid_t plist_id) : PropList(plist_id) {} +LinkCreatPropList::LinkCreatPropList(const hid_t plist_id) : PropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: LinkCreatPropList::setCreateIntermediateGroup @@ -111,12 +119,12 @@ LinkCreatPropList::LinkCreatPropList(const hid_t plist_id) : PropList(plist_id) ///\exception H5::PropListIException // April, 2019 //-------------------------------------------------------------------------- -void LinkCreatPropList::setCreateIntermediateGroup(bool crt_intmd_group) const +void +LinkCreatPropList::setCreateIntermediateGroup(bool crt_intmd_group) const { herr_t ret_value = H5Pset_create_intermediate_group(id, (unsigned)crt_intmd_group); // Throw exception if H5Pset_create_intermediate_group returns failure - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("setCreateIntermediateGroup", "H5Pset_create_intermediate_group failed"); } } @@ -129,17 +137,17 @@ void LinkCreatPropList::setCreateIntermediateGroup(bool crt_intmd_group) const ///\exception H5::PropListIException // April, 2019 //-------------------------------------------------------------------------- -bool LinkCreatPropList::getCreateIntermediateGroup() const +bool +LinkCreatPropList::getCreateIntermediateGroup() const { unsigned crt_intmd_group; - herr_t ret_value = H5Pget_create_intermediate_group(id, &crt_intmd_group); + herr_t ret_value = H5Pget_create_intermediate_group(id, &crt_intmd_group); // Throw exception if H5Pget_create_intermediate_group returns failure - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("getCreateIntermediateGroup", "H5Pget_create_intermediate_group failed"); } - return((bool)crt_intmd_group); + return ((bool)crt_intmd_group); } //-------------------------------------------------------------------------- @@ -149,12 +157,12 @@ bool LinkCreatPropList::getCreateIntermediateGroup() const ///\exception H5::PropListIException // March, 2018 //-------------------------------------------------------------------------- -void LinkCreatPropList::setCharEncoding(H5T_cset_t encoding) const +void +LinkCreatPropList::setCharEncoding(H5T_cset_t encoding) const { herr_t ret_value = H5Pset_char_encoding(id, encoding); // Throw exception if H5Pset_char_encoding returns failure - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("setCharEncoding", "H5Pset_char_encoding failed"); } } @@ -166,16 +174,16 @@ void LinkCreatPropList::setCharEncoding(H5T_cset_t encoding) const ///\exception H5::PropListIException // March, 2018 //-------------------------------------------------------------------------- -H5T_cset_t LinkCreatPropList::getCharEncoding() const +H5T_cset_t +LinkCreatPropList::getCharEncoding() const { H5T_cset_t encoding; - herr_t ret_value = H5Pget_char_encoding(id, &encoding); + herr_t ret_value = H5Pget_char_encoding(id, &encoding); // Throw exception if H5Pget_char_encoding returns failure - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("getCharEncoding", "H5Pget_char_encoding failed"); } - return(encoding); + return (encoding); } //-------------------------------------------------------------------------- @@ -183,6 +191,8 @@ H5T_cset_t LinkCreatPropList::getCharEncoding() const ///\brief Noop destructor // December, 2016 //-------------------------------------------------------------------------- -LinkCreatPropList::~LinkCreatPropList() {} +LinkCreatPropList::~LinkCreatPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5LcreatProp.h b/c++/src/H5LcreatProp.h index 908ef63..aea38e7 100644 --- a/c++/src/H5LcreatProp.h +++ b/c++/src/H5LcreatProp.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5LinkCreatPropList_H -#define __H5LinkCreatPropList_H +#ifndef H5LinkCreatPropList_H +#define H5LinkCreatPropList_H namespace H5 { @@ -23,54 +23,58 @@ namespace H5 { */ // Inheritance: PropList -> IdComponent class H5_DLLCPP LinkCreatPropList : public PropList { - public: - ///\brief Default link creation property list. - static const LinkCreatPropList& DEFAULT; + public: + ///\brief Default link creation property list. + static const LinkCreatPropList &DEFAULT; - // Creates a link creation property list. - LinkCreatPropList(); + // Creates a link creation property list. + LinkCreatPropList(); - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("LinkCreatPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("LinkCreatPropList"); + } - // Copy constructor: same as the original LinkCreatPropList. - LinkCreatPropList(const LinkCreatPropList& original); + // Copy constructor: same as the original LinkCreatPropList. + LinkCreatPropList(const LinkCreatPropList &original); - // Creates a copy of an existing link creation property list - // using the property list id. - LinkCreatPropList (const hid_t plist_id); + // Creates a copy of an existing link creation property list + // using the property list id. + LinkCreatPropList(const hid_t plist_id); - // Specifies in property list whether to create missing - // intermediate groups - void setCreateIntermediateGroup(bool crt_intmd_group) const; + // Specifies in property list whether to create missing + // intermediate groups + void setCreateIntermediateGroup(bool crt_intmd_group) const; - // Determines whether property is set to enable creating missing - // intermediate groups - bool getCreateIntermediateGroup() const; + // Determines whether property is set to enable creating missing + // intermediate groups + bool getCreateIntermediateGroup() const; - // Sets the character encoding of the string. - void setCharEncoding(H5T_cset_t encoding) const; + // Sets the character encoding of the string. + void setCharEncoding(H5T_cset_t encoding) const; - // Gets the character encoding of the string. - H5T_cset_t getCharEncoding() const; + // Gets the character encoding of the string. + H5T_cset_t getCharEncoding() const; - // Noop destructor - virtual ~LinkCreatPropList(); + // Noop destructor + virtual ~LinkCreatPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static LinkCreatPropList* DEFAULT_; + private: + static LinkCreatPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static LinkCreatPropList* getConstant(); + // Creates the global constant, should only be used by the library + static LinkCreatPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of LinkCreatPropList } // namespace H5 -#endif // __H5LinkCreatPropList_H +#endif // H5LinkCreatPropList_H diff --git a/c++/src/H5Library.cpp b/c++/src/H5Library.cpp index fde5599..37516be 100644 --- a/c++/src/H5Library.cpp +++ b/c++/src/H5Library.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,7 +14,7 @@ #include <string> #include <cstdlib> -#include "H5CppDoc.h" // included only for Doxygen to generate part of RM +#include "H5CppDoc.h" // included only for Doxygen to generate part of RM #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -44,11 +44,11 @@ namespace H5 { ///\exception H5::LibraryIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Library::open() +void +H5Library::open() { herr_t ret_value = H5open(); - if (ret_value < 0) - { + if (ret_value < 0) { throw LibraryIException("H5Library::open", "H5open failed"); } } @@ -60,11 +60,11 @@ void H5Library::open() ///\exception H5::LibraryIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Library::close() +void +H5Library::close() { herr_t ret_value = H5close(); - if (ret_value < 0) - { + if (ret_value < 0) { throw LibraryIException("H5Library::close", "H5close failed"); } } @@ -79,9 +79,10 @@ void H5Library::close() // Removed the check for failure returned from H5dont_atexit. // will be fixed to not fail (HDFFV-9540) //-------------------------------------------------------------------------- -void H5Library::dontAtExit() +void +H5Library::dontAtExit() { - (void)H5dont_atexit(); + (void)H5dont_atexit(); } //-------------------------------------------------------------------------- @@ -93,11 +94,11 @@ void H5Library::dontAtExit() ///\exception H5::LibraryIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Library::getLibVersion(unsigned& majnum, unsigned& minnum, unsigned& relnum) +void +H5Library::getLibVersion(unsigned &majnum, unsigned &minnum, unsigned &relnum) { herr_t ret_value = H5get_libversion(&majnum, &minnum, &relnum); - if (ret_value < 0) - { + if (ret_value < 0) { throw LibraryIException("H5Library::getLibVersion", "H5get_libversion failed"); } } @@ -115,11 +116,11 @@ void H5Library::getLibVersion(unsigned& majnum, unsigned& minnum, unsigned& reln /// the H5check_version API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Library::checkVersion(unsigned majnum, unsigned minnum, unsigned relnum) +void +H5Library::checkVersion(unsigned majnum, unsigned minnum, unsigned relnum) { herr_t ret_value = H5check_version(majnum, minnum, relnum); - if (ret_value < 0) - { + if (ret_value < 0) { throw LibraryIException("H5Library::checkVersion", "H5check_version failed"); } } @@ -144,11 +145,11 @@ void H5Library::checkVersion(unsigned majnum, unsigned minnum, unsigned relnum) /// lists when the application ends. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -void H5Library::garbageCollect() +void +H5Library::garbageCollect() { herr_t ret_value = H5garbage_collect(); - if (ret_value < 0) - { + if (ret_value < 0) { throw LibraryIException("H5Library::garbageCollect", "H5garbage_collect failed"); } } @@ -168,12 +169,13 @@ void H5Library::garbageCollect() // // Programmer Binh-Minh Ribler - September, 2015 //-------------------------------------------------------------------------- -void H5Library::initH5cpp() +void +H5Library::initH5cpp() { // Register terminating functions with atexit(); they will be invoked in // the reversed order int ret_value = 0; - ret_value = std::atexit(termH5cpp); + ret_value = std::atexit(termH5cpp); if (ret_value != 0) throw LibraryIException("H5Library::initH5cpp", "Registering termH5cpp failed"); @@ -187,35 +189,43 @@ void H5Library::initH5cpp() ret_value = std::atexit(DSetAccPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering DSetAccPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering DSetAccPropList::deleteConstants failed"); ret_value = std::atexit(LinkAccPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering LinkAccPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering LinkAccPropList::deleteConstants failed"); ret_value = std::atexit(LinkCreatPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering LinkCreatPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering LinkCreatPropList::deleteConstants failed"); ret_value = std::atexit(FileAccPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering FileAccPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering FileAccPropList::deleteConstants failed"); ret_value = std::atexit(FileCreatPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering FileCreatPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering FileCreatPropList::deleteConstants failed"); ret_value = std::atexit(DSetMemXferPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering DSetMemXferPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering DSetMemXferPropList::deleteConstants failed"); ret_value = std::atexit(DSetCreatPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering DSetCreatPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering DSetCreatPropList::deleteConstants failed"); ret_value = std::atexit(ObjCreatPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering ObjCreatPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering ObjCreatPropList::deleteConstants failed"); ret_value = std::atexit(DataSpace::deleteConstants); if (ret_value != 0) @@ -229,7 +239,8 @@ void H5Library::initH5cpp() /// If the C library fails to terminate, exit with a failure. // Programmer Binh-Minh Ribler - September, 2015 //-------------------------------------------------------------------------- -void H5Library::termH5cpp() +void +H5Library::termH5cpp() { // Close the C library herr_t ret_value = H5close(); @@ -253,13 +264,13 @@ void H5Library::termH5cpp() /// the H5set_free_list_limits API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -void H5Library::setFreeListLimits(int reg_global_lim, int reg_list_lim, - int arr_global_lim, int arr_list_lim, int blk_global_lim, - int blk_list_lim) +void +H5Library::setFreeListLimits(int reg_global_lim, int reg_list_lim, int arr_global_lim, int arr_list_lim, + int blk_global_lim, int blk_list_lim) { - herr_t ret_value = H5set_free_list_limits(reg_global_lim, reg_list_lim, arr_global_lim, arr_list_lim, blk_global_lim, blk_list_lim); - if (ret_value < 0) - { + herr_t ret_value = H5set_free_list_limits(reg_global_lim, reg_list_lim, arr_global_lim, arr_list_lim, + blk_global_lim, blk_list_lim); + if (ret_value < 0) { throw LibraryIException("H5Library::setFreeListLimits", "H5set_free_list_limits failed"); } } @@ -270,14 +281,18 @@ void H5Library::setFreeListLimits(int reg_global_lim, int reg_list_lim, ///\brief Default constructor: Creates a stub H5Library object // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5Library::H5Library(){} +H5Library::H5Library() +{ +} //-------------------------------------------------------------------------- // Function: H5Library destructor ///\brief Noop destructor // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5Library::~H5Library(){} +H5Library::~H5Library() +{ +} #endif // DOXYGEN_SHOULD_SKIP_THIS -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Library.h b/c++/src/H5Library.h index b9be3d0..3df8d56 100644 --- a/c++/src/H5Library.h +++ b/c++/src/H5Library.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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 namespace H5 { @@ -24,50 +24,49 @@ namespace H5 { methods. */ class H5_DLLCPP H5Library { - public: - // Initializes the HDF5 library. - static void open(); + public: + // Initializes the HDF5 library. + static void open(); - // Flushes all data to disk, closes files, and cleans up memory. - static void close(); + // Flushes all data to disk, closes files, and cleans up memory. + static void close(); - // Instructs library not to install atexit cleanup routine - static void dontAtExit(); + // Instructs library not to install atexit cleanup routine + static void dontAtExit(); - // Returns the HDF library release number. - static void getLibVersion(unsigned& majnum, unsigned& minnum, unsigned& relnum); + // Returns the HDF library release number. + static void getLibVersion(unsigned &majnum, unsigned &minnum, unsigned &relnum); - // Verifies that the arguments match the version numbers compiled - // into the library - static void checkVersion(unsigned majnum, unsigned minnum, unsigned relnum); + // Verifies that the arguments match the version numbers compiled + // into the library + static void checkVersion(unsigned majnum, unsigned minnum, unsigned relnum); - // Walks through all the garbage collection routines for the library, - // which are supposed to free any unused memory they have allocated. - static void garbageCollect(); + // Walks through all the garbage collection routines for the library, + // which are supposed to free any unused memory they have allocated. + static void garbageCollect(); - // Sets limits on the different kinds of free lists. - static void setFreeListLimits(int reg_global_lim, int reg_list_lim, int - arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim); + // Sets limits on the different kinds of free lists. + static void setFreeListLimits(int reg_global_lim, int reg_list_lim, int arr_global_lim, int arr_list_lim, + int blk_global_lim, int blk_list_lim); - // Initializes C++ library and registers terminating functions at exit. - // Only for the library functions, not for user-defined functions. - static void initH5cpp(void); + // Initializes C++ library and registers terminating functions at exit. + // Only for the library functions, not for user-defined functions. + static void initH5cpp(void); - // Sends request for terminating the HDF5 library. - static void termH5cpp(void); + // Sends request for terminating the HDF5 library. + static void termH5cpp(void); #ifndef DOXYGEN_SHOULD_SKIP_THIS - private: + private: + // Default constructor - no instance ever created from outsiders + H5Library(); - // Default constructor - no instance ever created from outsiders - H5Library(); - - // Destructor - ~H5Library(); + // Destructor + ~H5Library(); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of H5Library } // namespace H5 -#endif // __H5Library_H +#endif // H5Library_H diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index 100c0b9..98da713 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,7 +15,7 @@ #include <iostream> using namespace std; -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -45,7 +45,9 @@ namespace H5 { // Function: H5Location default constructor (protected) // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5Location::H5Location() : IdComponent() {} +H5Location::H5Location() : IdComponent() +{ +} //-------------------------------------------------------------------------- // Function: H5Location overloaded constructor (protected) @@ -88,7 +90,8 @@ H5Location::H5Location() : IdComponent() {} // Modification // Renamed from exists() in 1.10.2 -BMR //-------------------------------------------------------------------------- -bool H5Location::nameExists(const char* name, const LinkAccPropList& lapl) const +bool +H5Location::nameExists(const char *name, const LinkAccPropList &lapl) const { htri_t ret_value = H5Lexists(getId(), name, lapl.getId()); if (ret_value > 0) @@ -110,9 +113,10 @@ bool H5Location::nameExists(const char* name, const LinkAccPropList& lapl) const // Modification // Renamed from exists() in 1.10.2 -BMR //-------------------------------------------------------------------------- -bool H5Location::nameExists(const H5std_string& name, const LinkAccPropList& lapl) const +bool +H5Location::nameExists(const H5std_string &name, const LinkAccPropList &lapl) const { - return(nameExists(name.c_str(), lapl)); + return (nameExists(name.c_str(), lapl)); } //-------------------------------------------------------------------------- @@ -126,9 +130,10 @@ bool H5Location::nameExists(const H5std_string& name, const LinkAccPropList& lap // Modification // Renamed to nameExists() in 1.10.2 -BMR //-------------------------------------------------------------------------- -bool H5Location::exists(const char* name, const LinkAccPropList& lapl) const +bool +H5Location::exists(const char *name, const LinkAccPropList &lapl) const { - return(nameExists(name, lapl)); + return (nameExists(name, lapl)); } //-------------------------------------------------------------------------- @@ -142,9 +147,10 @@ bool H5Location::exists(const char* name, const LinkAccPropList& lapl) const // Modification // Renamed to nameExists() in 1.10.2 -BMR //-------------------------------------------------------------------------- -bool H5Location::exists(const H5std_string& name, const LinkAccPropList& lapl) const +bool +H5Location::exists(const H5std_string &name, const LinkAccPropList &lapl) const { - return(nameExists(name.c_str(), lapl)); + return (nameExists(name.c_str(), lapl)); } //-------------------------------------------------------------------------- @@ -162,11 +168,11 @@ bool H5Location::exists(const H5std_string& name, const LinkAccPropList& lapl) c // Sep 2012 - BMR // Moved from H5File/H5Object //-------------------------------------------------------------------------- -void H5Location::flush(H5F_scope_t scope) const +void +H5Location::flush(H5F_scope_t scope) const { herr_t ret_value = H5Fflush(getId(), scope); - if (ret_value < 0) - { + if (ret_value < 0) { throw LocationException(inMemFunc("flush"), "H5Fflush failed"); } } @@ -179,12 +185,13 @@ void H5Location::flush(H5F_scope_t scope) const ///\exception H5::LocationException // Programmer Binh-Minh Ribler - Jul, 2004 //-------------------------------------------------------------------------- -H5std_string H5Location::getFileName() const +H5std_string +H5Location::getFileName() const { try { - return(p_get_file_name()); + return (p_get_file_name()); } - catch (IdComponentException& E) { + catch (IdComponentException &E) { throw LocationException(inMemFunc("getFileName"), E.getDetailMsg()); } } @@ -209,7 +216,8 @@ H5std_string H5Location::getFileName() const // to another class to accommodate attribute, dataset, and named // datatype. - BMR //-------------------------------------------------------------------------- -void H5Location::setComment(const char* name, const char* comment) const +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) @@ -223,7 +231,8 @@ void H5Location::setComment(const char* name, const char* comment) const /// \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 +void +H5Location::setComment(const H5std_string &name, const H5std_string &comment) const { setComment(name.c_str(), comment.c_str()); } @@ -235,7 +244,8 @@ void H5Location::setComment(const H5std_string& name, const H5std_string& commen /// an object name. // Programmer Binh-Minh Ribler - Sep 2013 //-------------------------------------------------------------------------- -void H5Location::setComment(const char* comment) const +void +H5Location::setComment(const char *comment) const { herr_t ret_value = H5Oset_comment_by_name(getId(), ".", comment, H5P_DEFAULT); if (ret_value < 0) @@ -249,7 +259,8 @@ void H5Location::setComment(const char* comment) const /// \c H5std_string for \a comment. // Programmer Binh-Minh Ribler - Sep 2013 //-------------------------------------------------------------------------- -void H5Location::setComment(const H5std_string& comment) const +void +H5Location::setComment(const H5std_string &comment) const { setComment(comment.c_str()); } @@ -265,7 +276,8 @@ void H5Location::setComment(const H5std_string& comment) const // to another class to accommodate attribute, dataset, and named // datatype. - BMR //-------------------------------------------------------------------------- -void H5Location::removeComment(const char* name) const +void +H5Location::removeComment(const char *name) const { herr_t ret_value = H5Oset_comment_by_name(getId(), name, NULL, H5P_DEFAULT); if (ret_value < 0) @@ -279,9 +291,10 @@ void H5Location::removeComment(const char* name) const /// \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 +void +H5Location::removeComment(const H5std_string &name) const { - removeComment (name.c_str()); + removeComment(name.c_str()); } //-------------------------------------------------------------------------- @@ -299,7 +312,8 @@ void H5Location::removeComment(const H5std_string& name) const /// will be truncated to accommodate the null terminator. // Programmer Binh-Minh Ribler - Mar 2014 //-------------------------------------------------------------------------- -ssize_t H5Location::getComment(const char* name, size_t buf_size, char* comment) const +ssize_t +H5Location::getComment(const char *name, size_t buf_size, char *comment) const { // H5Oget_comment_by_name will get buf_size chars of the comment including // the null terminator @@ -307,17 +321,16 @@ ssize_t H5Location::getComment(const char* name, size_t buf_size, char* comment) comment_len = H5Oget_comment_by_name(getId(), name, comment, buf_size, H5P_DEFAULT); // If H5Oget_comment_by_name returns a negative value, raise an exception - if (comment_len < 0) - { + if (comment_len < 0) { throw LocationException("H5Location::getComment", "H5Oget_comment_by_name failed"); } // If the comment is longer than the provided buffer size, the C library // will not null terminate it if (static_cast<size_t>(comment_len) >= buf_size) - comment[buf_size-1] = '\0'; + comment[buf_size - 1] = '\0'; // Return the actual comment length, which might be different from buf_size - return(comment_len); + return (comment_len); } //-------------------------------------------------------------------------- @@ -330,24 +343,23 @@ ssize_t H5Location::getComment(const char* name, size_t buf_size, char* comment) ///\exception H5::LocationException // Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013) //-------------------------------------------------------------------------- -H5std_string H5Location::getComment(const char* name, size_t buf_size) const +H5std_string +H5Location::getComment(const char *name, size_t buf_size) const { // Initialize string to "", so that if there is no comment, the returned // string will be empty - H5std_string comment(""); + H5std_string comment; // Preliminary call to get the comment's length ssize_t comment_len = H5Oget_comment_by_name(getId(), name, NULL, (size_t)0, H5P_DEFAULT); // If H5Oget_comment_by_name returns a negative value, raise an exception - if (comment_len < 0) - { + if (comment_len < 0) { throw LocationException("H5Location::getComment", "H5Oget_comment_by_name failed"); } // If comment exists, calls C routine again to get it - else if (comment_len > 0) - { + else if (comment_len > 0) { size_t tmp_len = buf_size; // If buffer size is not provided, use comment length @@ -355,14 +367,13 @@ H5std_string H5Location::getComment(const char* name, size_t buf_size) const tmp_len = comment_len; // Temporary buffer for char* comment - char* comment_C = new char[tmp_len+1]; - HDmemset(comment_C, 0, tmp_len+1); // clear buffer + char *comment_C = new char[tmp_len + 1]; + HDmemset(comment_C, 0, tmp_len + 1); // clear buffer // Used overloaded function - ssize_t temp_len = getComment(name, tmp_len+1, comment_C); - if (temp_len < 0) - { - delete []comment_C; + ssize_t temp_len = getComment(name, tmp_len + 1, comment_C); + if (temp_len < 0) { + delete[] comment_C; throw LocationException("H5Location::getComment", "H5Oget_comment_by_name failed"); } @@ -370,11 +381,11 @@ H5std_string H5Location::getComment(const char* name, size_t buf_size) const comment = comment_C; // Clean up resource - delete []comment_C; + delete[] comment_C; } // Return the string comment - return(comment); + return (comment); } //-------------------------------------------------------------------------- @@ -384,10 +395,12 @@ H5std_string H5Location::getComment(const char* name, size_t buf_size) const /// \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 buf_size) const +H5std_string +H5Location::getComment(const H5std_string &name, size_t buf_size) const { - return(getComment(name.c_str(), buf_size)); + return (getComment(name.c_str(), buf_size)); } + #ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- @@ -400,11 +413,11 @@ H5std_string H5Location::getComment(const H5std_string& name, size_t buf_size) c // Exception H5::ReferenceException // 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 +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) - { + if (ret_value < 0) { throw ReferenceException(inMemFunc("reference"), "H5Rcreate failed"); } } @@ -425,12 +438,13 @@ void H5Location::p_reference(void* ref, const char* name, hid_t space_id, H5R_ty ///\note 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 +void +H5Location::reference(void *ref, const char *name, const DataSpace &dataspace, H5R_type_t ref_type) const { try { p_reference(ref, name, dataspace.getId(), ref_type); } - catch (ReferenceException& E) { + catch (ReferenceException &E) { throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); } } @@ -451,12 +465,14 @@ void H5Location::reference(void* ref, const char* name, const DataSpace& dataspa ///\note This method is more suitable for a dataset region reference. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -void H5Location::reference(void* ref, const H5std_string& name, const DataSpace& dataspace, H5R_type_t ref_type) const +void +H5Location::reference(void *ref, const H5std_string &name, const DataSpace &dataspace, + H5R_type_t ref_type) const { try { p_reference(ref, name.c_str(), dataspace.getId(), ref_type); } - catch (ReferenceException& E) { + catch (ReferenceException &E) { throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); } } @@ -475,12 +491,13 @@ void H5Location::reference(void* ref, const H5std_string& name, const DataSpace& ///\note 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 +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) { + catch (ReferenceException &E) { throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); } } @@ -498,9 +515,10 @@ void H5Location::reference(void* ref, const char* name, H5R_type_t ref_type) con ///\note This method is more suitable for an object reference. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -void H5Location::reference(void* ref, const H5std_string& name, H5R_type_t ref_type) const +void +H5Location::reference(void *ref, const H5std_string &name, H5R_type_t ref_type) const { - reference(ref, name.c_str(), ref_type); + reference(ref, name.c_str(), ref_type); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -517,7 +535,9 @@ void H5Location::reference(void* ref, const H5std_string& name, H5R_type_t ref_t // Exception H5::ReferenceException // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -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 +H5Location::p_dereference(hid_t loc_id, const void *ref, H5R_type_t ref_type, const PropList &plist, + const char *from_func) { hid_t plist_id; if (p_valid_id(plist.getId())) @@ -526,12 +546,11 @@ hid_t H5Location::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_ty plist_id = H5P_DEFAULT; hid_t temp_id = H5Rdereference2(loc_id, plist_id, ref_type, ref); - if (temp_id < 0) - { + if (temp_id < 0) { throw ReferenceException(inMemFunc(from_func), "H5Rdereference2 failed"); } - return(temp_id); + return (temp_id); } #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -545,7 +564,8 @@ hid_t H5Location::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_ty ///\exception H5::ReferenceException // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -void H5Location::dereference(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) +void +H5Location::dereference(const H5Location &loc, const void *ref, H5R_type_t ref_type, const PropList &plist) { p_setId(p_dereference(loc.getId(), ref, ref_type, plist, "dereference")); } @@ -564,11 +584,12 @@ void H5Location::dereference(const H5Location& loc, const void* ref, H5R_type_t // Removed in 1.10.1 because H5Location is Attribute's baseclass // now. -BMR //-------------------------------------------------------------------------- - /* void H5Location::dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) +/* void H5Location::dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& +plist) { - p_setId(p_dereference(attr.getId(), ref, ref_type, plist, "dereference")); + p_setId(p_dereference(attr.getId(), ref, ref_type, plist, "dereference")); } - */ +*/ #ifndef H5_NO_DEPRECATED_SYMBOLS //-------------------------------------------------------------------------- @@ -590,12 +611,13 @@ void H5Location::dereference(const H5Location& loc, const void* ref, H5R_type_t // Modification // Sep 2012: Moved up from H5File, Group, DataSet, and DataType //-------------------------------------------------------------------------- -H5G_obj_t H5Location::getObjType(void *ref, H5R_type_t ref_type) const +H5G_obj_t +H5Location::getObjType(void *ref, H5R_type_t ref_type) const { try { - return(p_get_obj_type(ref, ref_type)); + return (p_get_obj_type(ref, ref_type)); } - catch (ReferenceException& E) { + catch (ReferenceException &E) { throw ReferenceException(inMemFunc("getObjType"), E.getDetailMsg()); } } @@ -617,16 +639,17 @@ H5G_obj_t H5Location::getObjType(void *ref, H5R_type_t ref_type) const // 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 +H5G_obj_t +H5Location::p_get_obj_type(void *ref, H5R_type_t ref_type) const { - H5G_obj_t obj_type = H5Rget_obj_type1(getId(), ref_type, ref); - if (obj_type == H5G_UNKNOWN) - { + H5G_obj_t obj_type = H5Rget_obj_type1(getId(), ref_type, ref); + if (obj_type == H5G_UNKNOWN) { throw ReferenceException(inMemFunc("getObjType"), "H5Rget_obj_type1 failed"); } - return(obj_type); + return (obj_type); } #endif // DOXYGEN_SHOULD_SKIP_THIS + #endif /* H5_NO_DEPRECATED_SYMBOLS */ //-------------------------------------------------------------------------- @@ -645,12 +668,13 @@ H5G_obj_t H5Location::p_get_obj_type(void *ref, H5R_type_t ref_type) const ///\exception H5::ReferenceException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -H5O_type_t H5Location::getRefObjType(void *ref, H5R_type_t ref_type) const +H5O_type_t +H5Location::getRefObjType(void *ref, H5R_type_t ref_type) const { try { - return(p_get_ref_obj_type(ref, ref_type)); + return (p_get_ref_obj_type(ref, ref_type)); } - catch (ReferenceException& E) { + catch (ReferenceException &E) { throw ReferenceException(inMemFunc("getRefObjType"), E.getDetailMsg()); } } @@ -671,21 +695,20 @@ H5O_type_t H5Location::getRefObjType(void *ref, H5R_type_t ref_type) const // 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 +H5O_type_t +H5Location::p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const { - H5O_type_t obj_type = H5O_TYPE_UNKNOWN; - herr_t ret_value = H5Rget_obj_type2(getId(), ref_type, ref, &obj_type); - if (ret_value < 0) - { + H5O_type_t obj_type = H5O_TYPE_UNKNOWN; + herr_t ret_value = H5Rget_obj_type2(getId(), ref_type, ref, &obj_type); + if (ret_value < 0) { throw ReferenceException(inMemFunc("getRefObjType"), "H5Rget_obj_type2 failed"); } - if (obj_type == H5O_TYPE_UNKNOWN || obj_type >= H5O_TYPE_NTYPES) - { + if (obj_type == H5O_TYPE_UNKNOWN || obj_type >= H5O_TYPE_NTYPES) { throw ReferenceException(inMemFunc("getRefObjType"), "H5Rget_obj_type2 returned invalid type"); } - return(obj_type); + return (obj_type); } - +#endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: H5Location::getRegion @@ -703,24 +726,23 @@ H5O_type_t H5Location::p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const // ref count, as a work-around for a problem described in the JIRA // issue HDFFV-7947. -BMR //-------------------------------------------------------------------------- -DataSpace H5Location::getRegion(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) - { + if (space_id < 0) { throw ReferenceException(inMemFunc("getRegion"), "H5Rget_region failed"); } try { DataSpace dataspace; f_DataSpace_setId(&dataspace, space_id); - return(dataspace); + return (dataspace); } - catch (DataSpaceIException& E) { + catch (DataSpaceIException &E) { throw ReferenceException(inMemFunc("getRegion"), E.getDetailMsg()); } } - // From H5CommonFG.cpp // Notes with "***Updated" are new and for Group.cpp // Original notes are from December 2000 @@ -768,7 +790,8 @@ DataSpace H5Location::getRegion(void *ref, H5R_type_t ref_type) const /// then a default size is chosen. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::createGroup(const char* name, const LinkCreatPropList& lcpl) const +Group +H5Location::createGroup(const char *name, const LinkCreatPropList &lcpl) const { // Call C routine H5Gcreate2 to create the named group, giving the // location id which can be a file id or a group id @@ -779,10 +802,10 @@ Group H5Location::createGroup(const char* name, const LinkCreatPropList& lcpl) c throwException("createGroup", "H5Gcreate2 failed"); // No failure, create and return the Group object - Group group; + Group group; H5Location *ptr = &group; ptr->p_setId(group_id); - return(group); + return (group); } //-------------------------------------------------------------------------- @@ -792,9 +815,10 @@ Group H5Location::createGroup(const char* name, const LinkCreatPropList& lcpl) c /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::createGroup(const H5std_string& name, const LinkCreatPropList& lcpl) const +Group +H5Location::createGroup(const H5std_string &name, const LinkCreatPropList &lcpl) const { - return(createGroup( name.c_str(), lcpl)); + return (createGroup(name.c_str(), lcpl)); } //-------------------------------------------------------------------------- @@ -813,22 +837,22 @@ Group H5Location::createGroup(const H5std_string& name, const LinkCreatPropList& /// then a default size is chosen. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::createGroup(const char* name, size_t size_hint) const +Group +H5Location::createGroup(const char *name, size_t size_hint) const { // Group creation property list for size hint hid_t gcpl_id = 0; // Set the local heap size hint - if (size_hint > 0) - { - // If the creation of the property list failed, throw an exception - if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) - throwException("createGroup", "H5Pcreate failed"); - - if (H5Pset_local_heap_size_hint(gcpl_id, size_hint) < 0) { - H5Pclose(gcpl_id); - throwException("createGroup", "H5Pset_local_heap_size_hint failed"); - } + if (size_hint > 0) { + // If the creation of the property list failed, throw an exception + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + throwException("createGroup", "H5Pcreate failed"); + + if (H5Pset_local_heap_size_hint(gcpl_id, size_hint) < 0) { + H5Pclose(gcpl_id); + throwException("createGroup", "H5Pset_local_heap_size_hint failed"); + } } // Call C routine H5Gcreate2 to create the named group, giving the @@ -836,18 +860,18 @@ Group H5Location::createGroup(const char* name, size_t size_hint) const hid_t group_id = H5Gcreate2(getId(), name, H5P_DEFAULT, gcpl_id, H5P_DEFAULT); // Close the group creation property list, if necessary - if(gcpl_id > 0) - H5Pclose(gcpl_id); + if (gcpl_id > 0) + H5Pclose(gcpl_id); // If the creation of the group failed, throw an exception if (group_id < 0) throwException("createGroup", "H5Gcreate2 failed"); // No failure, create and return the Group object - Group group; + Group group; H5Location *ptr = &group; ptr->p_setId(group_id); - return(group); + return (group); } //-------------------------------------------------------------------------- @@ -857,9 +881,10 @@ Group H5Location::createGroup(const char* name, size_t size_hint) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::createGroup(const H5std_string& name, size_t size_hint) const +Group +H5Location::createGroup(const H5std_string &name, size_t size_hint) const { - return(createGroup( name.c_str(), size_hint)); + return (createGroup(name.c_str(), size_hint)); } //-------------------------------------------------------------------------- @@ -871,7 +896,8 @@ Group H5Location::createGroup(const H5std_string& name, size_t size_hint) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::openGroup(const char* name) const +Group +H5Location::openGroup(const char *name) const { // Call C routine H5Gopen2 to open the named group, giving the // location id which can be a file id or a group id @@ -883,10 +909,10 @@ Group H5Location::openGroup(const char* name) const // No failure, create and return the Group object Group group; - //group.p_setId(group_id); + // group.p_setId(group_id); H5Location *ptr = &group; ptr->p_setId(group_id); - return(group); + return (group); } //-------------------------------------------------------------------------- @@ -896,9 +922,10 @@ Group H5Location::openGroup(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::openGroup(const H5std_string& name) const +Group +H5Location::openGroup(const H5std_string &name) const { - return(openGroup( name.c_str())); + return (openGroup(name.c_str())); } //-------------------------------------------------------------------------- @@ -919,14 +946,17 @@ Group H5Location::openGroup(const H5std_string& name) const // follow the order in the C function: lcpl, dcpl, dapl, to // accommodate the existing createDataSet calls. //-------------------------------------------------------------------------- -DataSet H5Location::createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& dcpl, const DSetAccPropList& dapl, const LinkCreatPropList& lcpl) const +DataSet +H5Location::createDataSet(const char *name, const DataType &data_type, const DataSpace &data_space, + const DSetCreatPropList &dcpl, const DSetAccPropList &dapl, + const LinkCreatPropList &lcpl) const { - // Obtain identifiers for C API - hid_t type_id = data_type.getId(); + // Obtain identifiers for C API + hid_t type_id = data_type.getId(); hid_t space_id = data_space.getId(); - hid_t dcpl_id = dcpl.getId(); - hid_t lcpl_id = lcpl.getId(); - hid_t dapl_id = dapl.getId(); + hid_t dcpl_id = dcpl.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t dapl_id = dapl.getId(); // Call C routine H5Dcreate2 to create the named dataset hid_t dataset_id = H5Dcreate2(getId(), name, type_id, space_id, lcpl_id, dcpl_id, dapl_id); @@ -938,7 +968,7 @@ DataSet H5Location::createDataSet(const char* name, const DataType& data_type, c // No failure, create and return the DataSet object DataSet dataset; f_DataSet_setId(&dataset, dataset_id); - return(dataset); + return (dataset); } //-------------------------------------------------------------------------- @@ -953,9 +983,12 @@ DataSet H5Location::createDataSet(const char* name, const DataType& data_type, c // follow the order in the C function: lcpl, dcpl, dapl, to // accommodate the existing createDataSet calls. //-------------------------------------------------------------------------- -DataSet H5Location::createDataSet(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& dcpl, const DSetAccPropList& dapl, const LinkCreatPropList& lcpl) const +DataSet +H5Location::createDataSet(const H5std_string &name, const DataType &data_type, const DataSpace &data_space, + const DSetCreatPropList &dcpl, const DSetAccPropList &dapl, + const LinkCreatPropList &lcpl) const { - return(createDataSet(name.c_str(), data_type, data_space, dcpl, dapl, lcpl)); + return (createDataSet(name.c_str(), data_type, data_space, dcpl, dapl, lcpl)); } //-------------------------------------------------------------------------- @@ -969,21 +1002,22 @@ DataSet H5Location::createDataSet(const H5std_string& name, const DataType& data // Jul 2018 // Added DSetAccPropList argument //-------------------------------------------------------------------------- -DataSet H5Location::openDataSet(const char* name, const DSetAccPropList& dapl) const +DataSet +H5Location::openDataSet(const char *name, const DSetAccPropList &dapl) const { // Call C function H5Dopen2 to open the specified dataset, giving // the location id and the dataset's name - hid_t dapl_id = dapl.getId(); + hid_t dapl_id = dapl.getId(); hid_t dataset_id = H5Dopen2(getId(), name, dapl_id); // If the dataset's opening failed, throw an exception - if(dataset_id < 0) + if (dataset_id < 0) throwException("openDataSet", "H5Dopen2 failed"); // No failure, create and return the DataSet object DataSet dataset; f_DataSet_setId(&dataset, dataset_id); - return(dataset); + return (dataset); } //-------------------------------------------------------------------------- @@ -996,9 +1030,10 @@ DataSet H5Location::openDataSet(const char* name, const DSetAccPropList& dapl) c // Jul 2018 // Added DSetAccPropList argument //-------------------------------------------------------------------------- -DataSet H5Location::openDataSet(const H5std_string& name, const DSetAccPropList& dapl) const +DataSet +H5Location::openDataSet(const H5std_string &name, const DSetAccPropList &dapl) const { - return(openDataSet(name.c_str(), dapl)); + return (openDataSet(name.c_str(), dapl)); } //-------------------------------------------------------------------------- @@ -1016,12 +1051,13 @@ DataSet H5Location::openDataSet(const H5std_string& name, const DSetAccPropList& /// H5Lcreate_soft APIs in the HDF5 C Reference Manual. // March 2018 //-------------------------------------------------------------------------- -void H5Location::link(const char *target_name, const char *link_name, - const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::link(const char *target_name, const char *link_name, const LinkCreatPropList &lcpl, + const LinkAccPropList &lapl) const { herr_t ret_value = -1; - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lcreate_soft(target_name, getId(), link_name, lcpl_id, lapl_id); if (ret_value < 0) @@ -1036,8 +1072,9 @@ void H5Location::link(const char *target_name, const char *link_name, ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::link(const H5std_string& target_name, const H5std_string& - link_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::link(const H5std_string &target_name, const H5std_string &link_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { link(target_name.c_str(), link_name.c_str(), lcpl, lapl); } @@ -1058,16 +1095,17 @@ void H5Location::link(const H5std_string& target_name, const H5std_string& /// H5Lcreate_hard APIs in the HDF5 C Reference Manual. // March 2018 //-------------------------------------------------------------------------- -void H5Location::link(const char *curr_name, const Group& new_loc, - const char *new_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::link(const char *curr_name, const Group &new_loc, const char *new_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { - herr_t ret_value = -1; - hid_t new_loc_id = new_loc.getId(); - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + herr_t ret_value = -1; + hid_t new_loc_id = new_loc.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lcreate_hard(getId(), curr_name, new_loc_id, new_name, lcpl_id, lapl_id); - if (ret_value < 0) + if (ret_value < 0) throwException("link", "creating link failed"); } @@ -1079,8 +1117,9 @@ void H5Location::link(const char *curr_name, const Group& new_loc, ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::link(const H5std_string& curr_name, const Group& new_loc, - const H5std_string& new_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::link(const H5std_string &curr_name, const Group &new_loc, const H5std_string &new_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { link(curr_name.c_str(), new_loc, new_name.c_str(), lcpl, lapl); } @@ -1102,15 +1141,17 @@ void H5Location::link(const H5std_string& curr_name, const Group& new_loc, /// H5Lcreate_hard APIs in the HDF5 C Reference Manual. // March 2018 //-------------------------------------------------------------------------- -void H5Location::link(const char *curr_name, const hid_t same_loc, const char *new_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::link(const char *curr_name, const hid_t same_loc, const char *new_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { herr_t ret_value = -1; - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lcreate_hard(getId(), curr_name, same_loc, new_name, lcpl_id, lapl_id); - if (ret_value < 0) + if (ret_value < 0) throwException("link", "creating link failed"); } @@ -1122,8 +1163,9 @@ void H5Location::link(const char *curr_name, const hid_t same_loc, const char *n ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::link(const H5std_string& curr_name, const hid_t same_loc, - const H5std_string& new_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::link(const H5std_string &curr_name, const hid_t same_loc, const H5std_string &new_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { link(curr_name.c_str(), same_loc, new_name.c_str(), lcpl, lapl); } @@ -1152,17 +1194,18 @@ void H5Location::link(const H5std_string& curr_name, const hid_t same_loc, // H5L_SAME_LOC. This function will be retired in favor of // its replacement. - BMR //-------------------------------------------------------------------------- -void H5Location::link(H5L_type_t link_type, const char* curr_name, const char* new_name) const +void +H5Location::link(H5L_type_t link_type, const char *curr_name, const char *new_name) const { herr_t ret_value = -1; - switch(link_type) { + switch (link_type) { case H5L_TYPE_HARD: ret_value = H5Lcreate_hard(getId(), curr_name, H5L_SAME_LOC, new_name, H5P_DEFAULT, H5P_DEFAULT); break; case H5L_TYPE_SOFT: - ret_value = H5Lcreate_soft(curr_name,getId(), new_name, H5P_DEFAULT, H5P_DEFAULT); + ret_value = H5Lcreate_soft(curr_name, getId(), new_name, H5P_DEFAULT, H5P_DEFAULT); break; case H5L_TYPE_ERROR: @@ -1173,7 +1216,7 @@ void H5Location::link(H5L_type_t link_type, const char* curr_name, const char* n break; } /* end switch */ - if (ret_value < 0) + if (ret_value < 0) throwException("link", "creating link failed"); } @@ -1184,7 +1227,8 @@ void H5Location::link(H5L_type_t link_type, const char* curr_name, const char* n /// \c H5std_string for \a curr_name and \a new_name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::link(H5L_type_t link_type, const H5std_string& curr_name, const H5std_string& new_name) const +void +H5Location::link(H5L_type_t link_type, const H5std_string &curr_name, const H5std_string &new_name) const { link(link_type, curr_name.c_str(), new_name.c_str()); } @@ -1200,17 +1244,17 @@ void H5Location::link(H5L_type_t link_type, const H5std_string& curr_name, const ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::copyLink(const char *src_name, - const Group& dst, const char *dst_name, const LinkCreatPropList& lcpl, - const LinkAccPropList& lapl) const +void +H5Location::copyLink(const char *src_name, const Group &dst, const char *dst_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { herr_t ret_value; - hid_t dst_id = dst.getId(); - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + hid_t dst_id = dst.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lcopy(getId(), src_name, dst_id, dst_name, lcpl_id, lapl_id); - if(ret_value < 0) + if (ret_value < 0) throwException("copyLink", "H5Lcopy failed"); } @@ -1222,9 +1266,9 @@ void H5Location::copyLink(const char *src_name, ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::copyLink(const H5std_string& src_name, - const Group& dst, const H5std_string& dst_name, const LinkCreatPropList& lcpl, - const LinkAccPropList& lapl) const +void +H5Location::copyLink(const H5std_string &src_name, const Group &dst, const H5std_string &dst_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { copyLink(src_name.c_str(), dst, dst_name.c_str(), lcpl, lapl); } @@ -1239,16 +1283,16 @@ void H5Location::copyLink(const H5std_string& src_name, ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::copyLink(const char *src_name, - const char *dst_name, const LinkCreatPropList& lcpl, - const LinkAccPropList& lapl) const +void +H5Location::copyLink(const char *src_name, const char *dst_name, const LinkCreatPropList &lcpl, + const LinkAccPropList &lapl) const { herr_t ret_value; - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lcopy(getId(), src_name, H5L_SAME_LOC, dst_name, lcpl_id, lapl_id); - if(ret_value < 0) + if (ret_value < 0) throwException("copyLink", "H5Lcopy H5L_SAME_LOC failed"); } @@ -1260,9 +1304,9 @@ void H5Location::copyLink(const char *src_name, ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::copyLink(const H5std_string& src_name, - const H5std_string& dst_name, const LinkCreatPropList& lcpl, - const LinkAccPropList& lapl) const +void +H5Location::copyLink(const H5std_string &src_name, const H5std_string &dst_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { copyLink(src_name.c_str(), dst_name.c_str(), lcpl, lapl); } @@ -1282,12 +1326,14 @@ void H5Location::copyLink(const H5std_string& src_name, /// to the Group Interface in the HDF5 User's Guide for details. // March, 2018 //-------------------------------------------------------------------------- -void H5Location::moveLink(const char* src_name, const Group& dst, const char* dst_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::moveLink(const char *src_name, const Group &dst, const char *dst_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { herr_t ret_value; - hid_t dst_id = dst.getId(); - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + hid_t dst_id = dst.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lmove(getId(), src_name, dst_id, dst_name, lcpl_id, lapl_id); if (ret_value < 0) @@ -1302,7 +1348,9 @@ void H5Location::moveLink(const char* src_name, const Group& dst, const char* ds ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::moveLink(const H5std_string& src_name, const Group& dst, const H5std_string& dst_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::moveLink(const H5std_string &src_name, const Group &dst, const H5std_string &dst_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { moveLink(src_name.c_str(), dst, dst_name.c_str(), lcpl, lapl); } @@ -1321,11 +1369,13 @@ void H5Location::moveLink(const H5std_string& src_name, const Group& dst, const /// to the Group Interface in the HDF5 User's Guide for details. // March, 2018 //-------------------------------------------------------------------------- -void H5Location::moveLink(const char* src_name, const char* dst_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::moveLink(const char *src_name, const char *dst_name, const LinkCreatPropList &lcpl, + const LinkAccPropList &lapl) const { herr_t ret_value; - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lmove(getId(), src_name, H5L_SAME_LOC, dst_name, lcpl_id, lapl_id); if (ret_value < 0) @@ -1340,7 +1390,9 @@ void H5Location::moveLink(const char* src_name, const char* dst_name, const Link ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::moveLink(const H5std_string& src_name, const H5std_string& dst_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::moveLink(const H5std_string &src_name, const H5std_string &dst_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { moveLink(src_name.c_str(), dst_name.c_str(), lcpl, lapl); } @@ -1359,7 +1411,8 @@ void H5Location::moveLink(const H5std_string& src_name, const H5std_string& dst_ // 2007: QAK modified to use H5L APIs - BMR // 2018: Will be replaced by H5Location::moveLink() -BMR //-------------------------------------------------------------------------- -void H5Location::move(const char* src, const char* dst) const +void +H5Location::move(const char *src, const char *dst) const { moveLink(src, dst, LinkCreatPropList::DEFAULT, LinkAccPropList::DEFAULT); } @@ -1372,7 +1425,8 @@ void H5Location::move(const char* src, const char* dst) const // Modification // 2018: Will be replaced by H5Location::moveLink() -BMR //-------------------------------------------------------------------------- -void H5Location::move(const H5std_string& src, const H5std_string& dst) const +void +H5Location::move(const H5std_string &src, const H5std_string &dst) const { moveLink(src.c_str(), dst.c_str(), LinkCreatPropList::DEFAULT, LinkAccPropList::DEFAULT); } @@ -1384,7 +1438,8 @@ void H5Location::move(const H5std_string& src, const H5std_string& dst) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::unlink(const char* name, const LinkAccPropList& lapl) const +void +H5Location::unlink(const char *name, const LinkAccPropList &lapl) const { herr_t ret_value = H5Ldelete(getId(), name, lapl.getId()); if (ret_value < 0) @@ -1398,7 +1453,8 @@ void H5Location::unlink(const char* name, const LinkAccPropList& lapl) const /// \c H5std_string for \a name. // March, 2018 //-------------------------------------------------------------------------- -void H5Location::unlink(const H5std_string& name, const LinkAccPropList& lapl) const +void +H5Location::unlink(const H5std_string &name, const LinkAccPropList &lapl) const { unlink(name.c_str(), lapl); } @@ -1418,7 +1474,8 @@ void H5Location::unlink(const H5std_string& name, const LinkAccPropList& lapl) c /// \li \c H5O_INFO_ALL // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(H5O_info_t& objinfo, unsigned fields) const +void +H5Location::getObjinfo(H5O_info_t &objinfo, unsigned fields) const { // Use C API to get information of the object @@ -1447,7 +1504,9 @@ void H5Location::getObjinfo(H5O_info_t& objinfo, unsigned fields) const /// \li \c H5O_INFO_ALL // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const char* name, H5O_info_t& objinfo, unsigned fields, const LinkAccPropList& lapl) const +void +H5Location::getObjinfo(const char *name, H5O_info_t &objinfo, unsigned fields, + const LinkAccPropList &lapl) const { // Use C API to get information of the object herr_t ret_value = H5Oget_info_by_name2(getId(), name, &objinfo, fields, lapl.getId()); @@ -1469,7 +1528,9 @@ void H5Location::getObjinfo(const char* name, H5O_info_t& objinfo, unsigned fiel ///\param lapl - IN: Link access property list // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const H5std_string& name, H5O_info_t& objinfo, unsigned fields, const LinkAccPropList& lapl) const +void +H5Location::getObjinfo(const H5std_string &name, H5O_info_t &objinfo, unsigned fields, + const LinkAccPropList &lapl) const { getObjinfo(name.c_str(), objinfo, fields, lapl); } @@ -1495,13 +1556,13 @@ void H5Location::getObjinfo(const H5std_string& name, H5O_info_t& objinfo, unsig /// \li \c H5O_INFO_ALL // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const char* grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_info_t& objinfo, unsigned fields, - const LinkAccPropList& lapl) const +void +H5Location::getObjinfo(const char *grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + H5O_info_t &objinfo, unsigned fields, const LinkAccPropList &lapl) const { // Use C API to get information of the object - herr_t ret_value = H5Oget_info_by_idx2(getId(), grp_name, idx_type, order, - idx, &objinfo, fields, lapl.getId()); + herr_t ret_value = + H5Oget_info_by_idx2(getId(), grp_name, idx_type, order, idx, &objinfo, fields, lapl.getId()); // Throw exception if C API returns failure if (ret_value < 0) @@ -1520,9 +1581,9 @@ void H5Location::getObjinfo(const char* grp_name, H5_index_t idx_type, ///\param lapl - IN: Link access property list // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const H5std_string& grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_info_t& objinfo, unsigned fields, - const LinkAccPropList& lapl) const +void +H5Location::getObjinfo(const H5std_string &grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + H5O_info_t &objinfo, unsigned fields, const LinkAccPropList &lapl) const { getObjinfo(grp_name.c_str(), idx_type, order, idx, objinfo, fields, lapl); } @@ -1540,7 +1601,8 @@ void H5Location::getObjinfo(const H5std_string& grp_name, H5_index_t idx_type, /// the HDF5 C Reference Manual. // 2000 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const char* name, hbool_t follow_link, H5G_stat_t& statbuf) const +void +H5Location::getObjinfo(const char *name, hbool_t follow_link, H5G_stat_t &statbuf) const { herr_t ret_value = H5Gget_objinfo(getId(), name, follow_link, &statbuf); if (ret_value < 0) @@ -1554,7 +1616,8 @@ void H5Location::getObjinfo(const char* name, hbool_t follow_link, H5G_stat_t& s /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const H5std_string& name, hbool_t follow_link, H5G_stat_t& statbuf) const +void +H5Location::getObjinfo(const H5std_string &name, hbool_t follow_link, H5G_stat_t &statbuf) const { getObjinfo(name.c_str(), follow_link, statbuf); } @@ -1566,7 +1629,8 @@ void H5Location::getObjinfo(const H5std_string& name, hbool_t follow_link, H5G_s /// the paramemter \a follow_link. // Nov, 2005 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const char* name, H5G_stat_t& statbuf) const +void +H5Location::getObjinfo(const char *name, H5G_stat_t &statbuf) const { herr_t ret_value = H5Gget_objinfo(getId(), name, 0, &statbuf); if (ret_value < 0) @@ -1580,7 +1644,8 @@ void H5Location::getObjinfo(const char* name, H5G_stat_t& statbuf) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - Nov, 2005 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const H5std_string& name, H5G_stat_t& statbuf) const +void +H5Location::getObjinfo(const H5std_string &name, H5G_stat_t &statbuf) const { getObjinfo(name.c_str(), statbuf); } @@ -1596,7 +1661,8 @@ void H5Location::getObjinfo(const H5std_string& name, H5G_stat_t& statbuf) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // 2000 //-------------------------------------------------------------------------- -H5L_info_t H5Location::getLinkInfo(const char* link_name, const LinkAccPropList& lapl) const +H5L_info_t +H5Location::getLinkInfo(const char *link_name, const LinkAccPropList &lapl) const { H5L_info_t linkinfo; // link info structure @@ -1604,7 +1670,7 @@ H5L_info_t H5Location::getLinkInfo(const char* link_name, const LinkAccPropList& if (ret_value < 0) throwException("getLinkInfo", "H5Lget_info to find buffer size failed"); - return(linkinfo); + return (linkinfo); } //-------------------------------------------------------------------------- @@ -1613,9 +1679,10 @@ H5L_info_t H5Location::getLinkInfo(const char* link_name, const LinkAccPropList& /// It differs from the above function in that it takes an /// \c H5std_string for \a link_name. //-------------------------------------------------------------------------- -H5L_info_t H5Location::getLinkInfo(const H5std_string& link_name, const LinkAccPropList& lapl) const +H5L_info_t +H5Location::getLinkInfo(const H5std_string &link_name, const LinkAccPropList &lapl) const { - return(getLinkInfo(link_name.c_str(), lapl)); + return (getLinkInfo(link_name.c_str(), lapl)); } //-------------------------------------------------------------------------- @@ -1627,17 +1694,17 @@ H5L_info_t H5Location::getLinkInfo(const H5std_string& link_name, const LinkAccP ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // 2000 //-------------------------------------------------------------------------- -H5std_string H5Location::getLinkval(const char* name, size_t size) const +H5std_string +H5Location::getLinkval(const char *name, size_t size) const { - H5L_info_t linkinfo; - char *value_C; // value in C string - size_t val_size = size; - H5std_string value = ""; - herr_t ret_value; + H5L_info_t linkinfo; + char * value_C; // value in C string + size_t val_size = size; + H5std_string value; + herr_t ret_value; // if user doesn't provide buffer size, determine it - if (size == 0) - { + if (size == 0) { ret_value = H5Lget_info(getId(), name, &linkinfo, H5P_DEFAULT); if (ret_value < 0) throwException("getLinkval", "H5Lget_info to find buffer size failed"); @@ -1646,22 +1713,20 @@ H5std_string H5Location::getLinkval(const char* name, size_t size) const } // if link has value, retrieve the value, otherwise, return null string - if (val_size > 0) - { - value_C = new char[val_size+1]; // temporary C-string for C API - HDmemset(value_C, 0, val_size+1); // clear buffer + if (val_size > 0) { + value_C = new char[val_size + 1]; // temporary C-string for C API + HDmemset(value_C, 0, val_size + 1); // clear buffer ret_value = H5Lget_val(getId(), name, value_C, val_size, H5P_DEFAULT); - if (ret_value < 0) - { - delete []value_C; + if (ret_value < 0) { + delete[] value_C; throwException("getLinkval", "H5Lget_val failed"); } value = H5std_string(value_C); - delete []value_C; + delete[] value_C; } - return(value); + return (value); } //-------------------------------------------------------------------------- @@ -1671,9 +1736,10 @@ H5std_string H5Location::getLinkval(const char* name, size_t size) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string H5Location::getLinkval(const H5std_string& name, size_t size) const +H5std_string +H5Location::getLinkval(const H5std_string &name, size_t size) const { - return(getLinkval( name.c_str(), size)); + return (getLinkval(name.c_str(), size)); } //-------------------------------------------------------------------------- @@ -1685,7 +1751,8 @@ H5std_string H5Location::getLinkval(const H5std_string& name, size_t size) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2014 (original 2000) //-------------------------------------------------------------------------- -void H5Location::mount(const char* name, const H5File& child, const PropList& plist) const +void +H5Location::mount(const char *name, const H5File &child, const PropList &plist) const { // Obtain identifiers for C API hid_t plist_id = plist.getId(); @@ -1714,7 +1781,7 @@ void H5Location::mount(const char* name, const H5File& child, const PropList& pl // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void H5Location::mount(const char* name, H5File& child, PropList& plist) const +// void H5Location::mount(const char* name, H5File& child, PropList& plist) const //{ // mount(name, child, plist); //} @@ -1725,7 +1792,8 @@ void H5Location::mount(const char* name, const H5File& child, const PropList& pl /// It takes an \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::mount(const H5std_string& name, const H5File& child, const PropList& plist) const +void +H5Location::mount(const H5std_string &name, const H5File &child, const PropList &plist) const { mount(name.c_str(), child, plist); } @@ -1741,7 +1809,7 @@ void H5Location::mount(const H5std_string& name, const H5File& child, const Prop // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void H5Location::mount(const H5std_string& name, H5File& child, PropList& plist) const +// void H5Location::mount(const H5std_string& name, H5File& child, PropList& plist) const //{ // mount(name.c_str(), child, plist); //} @@ -1753,7 +1821,8 @@ void H5Location::mount(const H5std_string& name, const H5File& child, const Prop ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::unmount(const char* name) const +void +H5Location::unmount(const char *name) const { // Call C routine H5Fmount to do the mouting herr_t ret_value = H5Funmount(getId(), name); @@ -1770,7 +1839,8 @@ void H5Location::unmount(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::unmount(const H5std_string& name) const +void +H5Location::unmount(const H5std_string &name) const { unmount(name.c_str()); } @@ -1789,14 +1859,14 @@ void H5Location::unmount(const H5std_string& name) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int H5Location::iterateElems(const char* name, int *idx, H5G_iterate_t op , void* op_data) +int +H5Location::iterateElems(const char *name, int *idx, H5G_iterate_t op, void *op_data) { int ret_value = H5Giterate(getId(), name, idx, op, op_data); - if (ret_value < 0) - { + if (ret_value < 0) { throwException("iterateElems", "H5Giterate failed"); } - return(ret_value); + return (ret_value); } //-------------------------------------------------------------------------- @@ -1806,9 +1876,10 @@ int H5Location::iterateElems(const char* name, int *idx, H5G_iterate_t op , void /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int H5Location::iterateElems(const H5std_string& name, int *idx, H5G_iterate_t op , void* op_data) +int +H5Location::iterateElems(const H5std_string &name, int *idx, H5G_iterate_t op, void *op_data) { - return(iterateElems( name.c_str(), idx, op, op_data)); + return (iterateElems(name.c_str(), idx, op, op_data)); } #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -1819,12 +1890,13 @@ int H5Location::iterateElems(const H5std_string& name, int *idx, H5G_iterate_t o ///\exception Deprecated // Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- -hsize_t H5Location::getNumObjs() const +hsize_t +H5Location::getNumObjs() const { - H5G_info_t ginfo; // Group information + H5G_info_t ginfo; // Group information herr_t ret_value = H5Gget_info(getId(), &ginfo); - if(ret_value < 0) + if (ret_value < 0) throwException("getNumObjs", "H5Gget_info failed"); return (ginfo.nlinks); } @@ -1844,28 +1916,30 @@ hsize_t H5Location::getNumObjs() const /// each time the group is opened. // Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- -H5std_string H5Location::getObjnameByIdx(hsize_t idx) const +H5std_string +H5Location::getObjnameByIdx(hsize_t idx) const { // call H5Lget_name_by_idx with name as NULL to get its length - ssize_t name_len = H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, NULL, 0, H5P_DEFAULT); - if(name_len < 0) + ssize_t name_len = + H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, NULL, 0, H5P_DEFAULT); + if (name_len < 0) throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); // now, allocate C buffer to get the name - char* name_C = new char[name_len+1]; - HDmemset(name_C, 0, name_len+1); // clear buffer + char *name_C = new char[name_len + 1]; + HDmemset(name_C, 0, name_len + 1); // clear buffer - name_len = H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name_C, name_len+1, H5P_DEFAULT); + name_len = + H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name_C, name_len + 1, H5P_DEFAULT); - if (name_len < 0) - { - delete []name_C; + if (name_len < 0) { + delete[] name_C; throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); } // clean up and return the string H5std_string name = H5std_string(name_C); - delete []name_C; + delete[] name_C; return (name); } @@ -1886,10 +1960,12 @@ H5std_string H5Location::getObjnameByIdx(hsize_t idx) const /// each time the group is opened. // Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- -ssize_t H5Location::getObjnameByIdx(hsize_t idx, char* name, size_t size) const +ssize_t +H5Location::getObjnameByIdx(hsize_t idx, char *name, size_t size) const { - ssize_t name_len = H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name, size, H5P_DEFAULT); - if(name_len < 0) + ssize_t name_len = + H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name, size, H5P_DEFAULT); + if (name_len < 0) throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); return (name_len); @@ -1902,22 +1978,22 @@ ssize_t H5Location::getObjnameByIdx(hsize_t idx, char* name, size_t size) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- -ssize_t H5Location::getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size) const +ssize_t +H5Location::getObjnameByIdx(hsize_t idx, H5std_string &name, size_t size) const { - char* name_C = new char[size+1]; // temporary C-string for object name - HDmemset(name_C, 0, size+1); // clear buffer + char *name_C = new char[size + 1]; // temporary C-string for object name + HDmemset(name_C, 0, size + 1); // clear buffer // call overloaded function to get the name - ssize_t name_len = getObjnameByIdx(idx, name_C, size+1); - if(name_len < 0) - { - delete []name_C; + ssize_t name_len = getObjnameByIdx(idx, name_C, size + 1); + if (name_len < 0) { + delete[] name_C; throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); } // clean up and return the string name = H5std_string(name_C); - delete []name_C; + delete[] name_C; return (name_len); } @@ -1939,7 +2015,8 @@ ssize_t H5Location::getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size /// - object type is not one of the valid values above // Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- -H5O_type_t H5Location::childObjType(const char* objname) const +H5O_type_t +H5Location::childObjType(const char *objname) const { H5O_info_t objinfo; H5O_type_t objtype = H5O_TYPE_UNKNOWN; @@ -1952,19 +2029,18 @@ H5O_type_t H5Location::childObjType(const char* objname) const throwException("childObjType", "H5Oget_info_by_name failed"); // Return a valid type or throw an exception for unknown type else - switch (objinfo.type) - { - case H5O_TYPE_GROUP: - case H5O_TYPE_DATASET: - case H5O_TYPE_NAMED_DATATYPE: - objtype = objinfo.type; - break; - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - throwException("childObjType", "Unknown type of object"); + switch (objinfo.type) { + case H5O_TYPE_GROUP: + case H5O_TYPE_DATASET: + case H5O_TYPE_NAMED_DATATYPE: + objtype = objinfo.type; + break; + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + default: + throwException("childObjType", "Unknown type of object"); } - return(objtype); + return (objtype); } //-------------------------------------------------------------------------- @@ -1977,11 +2053,12 @@ H5O_type_t H5Location::childObjType(const char* objname) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- -H5O_type_t H5Location::childObjType(const H5std_string& objname) const +H5O_type_t +H5Location::childObjType(const H5std_string &objname) const { // Use overloaded function H5O_type_t objtype = childObjType(objname.c_str()); - return(objtype); + return (objtype); } //-------------------------------------------------------------------------- @@ -2013,33 +2090,35 @@ H5O_type_t H5Location::childObjType(const H5std_string& objname) const // can be added later when needed. // Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- -H5O_type_t H5Location::childObjType(hsize_t index, H5_index_t index_type, H5_iter_order_t order, const char* objname) const +H5O_type_t +H5Location::childObjType(hsize_t index, H5_index_t index_type, H5_iter_order_t order, + const char *objname) const { - herr_t ret_value; + herr_t ret_value; H5O_info_t objinfo; H5O_type_t objtype = H5O_TYPE_UNKNOWN; // Use C API to get information of the object - ret_value = H5Oget_info_by_idx2(getId(), objname, index_type, order, index, &objinfo, H5O_INFO_BASIC, H5P_DEFAULT); + ret_value = H5Oget_info_by_idx2(getId(), objname, index_type, order, index, &objinfo, H5O_INFO_BASIC, + H5P_DEFAULT); // Throw exception if C API returns failure if (ret_value < 0) throwException("childObjType", "H5Oget_info_by_idx failed"); // Return a valid type or throw an exception for unknown type else - switch (objinfo.type) - { - case H5O_TYPE_GROUP: - case H5O_TYPE_DATASET: - case H5O_TYPE_NAMED_DATATYPE: - objtype = objinfo.type; - break; - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - throwException("childObjType", "Unknown type of object"); + switch (objinfo.type) { + case H5O_TYPE_GROUP: + case H5O_TYPE_DATASET: + case H5O_TYPE_NAMED_DATATYPE: + objtype = objinfo.type; + break; + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + default: + throwException("childObjType", "Unknown type of object"); } - return(objtype); + return (objtype); } //-------------------------------------------------------------------------- @@ -2056,10 +2135,11 @@ H5O_type_t H5Location::childObjType(hsize_t index, H5_index_t index_type, H5_ite /// - version number is not one of the valid values above // Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- -unsigned H5Location::childObjVersion(const char* objname) const +unsigned +H5Location::childObjVersion(const char *objname) const { H5O_info_t objinfo; - unsigned version = 0; + unsigned version = 0; // Use C API to get information of the object herr_t ret_value = H5Oget_info_by_name2(getId(), objname, &objinfo, H5O_INFO_HDR, H5P_DEFAULT); @@ -2068,13 +2148,12 @@ unsigned H5Location::childObjVersion(const char* objname) const if (ret_value < 0) throwException("childObjVersion", "H5Oget_info_by_name failed"); // Return a valid version or throw an exception for invalid value - else - { + else { version = objinfo.hdr.version; if (version != H5O_VERSION_1 && version != H5O_VERSION_2) throwException("childObjVersion", "Invalid version for object"); } - return(version); + return (version); } //-------------------------------------------------------------------------- @@ -2087,15 +2166,15 @@ unsigned H5Location::childObjVersion(const char* objname) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- -unsigned H5Location::childObjVersion(const H5std_string& objname) const +unsigned +H5Location::childObjVersion(const H5std_string &objname) const { // Use overloaded function unsigned version = childObjVersion(objname.c_str()); - return(version); + return (version); } #ifndef H5_NO_DEPRECATED_SYMBOLS -#ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: H5Location::getObjTypeByIdx ///\brief Returns the type of an object in this group, given the @@ -2105,13 +2184,14 @@ unsigned H5Location::childObjVersion(const H5std_string& objname) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- -H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx) const +H5G_obj_t +H5Location::getObjTypeByIdx(hsize_t idx) const { - H5G_obj_t obj_type = H5Gget_objtype_by_idx(getId(), idx); - if (obj_type == H5G_UNKNOWN) + H5G_obj_t obj_type = H5Gget_objtype_by_idx(getId(), idx); + if (obj_type == H5G_UNKNOWN) throwException("getObjTypeByIdx", "H5Gget_objtype_by_idx failed"); - return (obj_type); + return (obj_type); } //-------------------------------------------------------------------------- @@ -2127,10 +2207,11 @@ H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx) const // Modification // Modified to use the other function. -BMR, 2016/03/07 //-------------------------------------------------------------------------- -H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx, char* type_name) const +H5G_obj_t +H5Location::getObjTypeByIdx(hsize_t idx, char *type_name) const { H5std_string stype_name(type_name); - return(getObjTypeByIdx(idx, stype_name)); + return (getObjTypeByIdx(idx, stype_name)); } //-------------------------------------------------------------------------- // Function: H5Location::getObjTypeByIdx @@ -2143,27 +2224,34 @@ H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx, char* type_name) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- -H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx, H5std_string& type_name) const +H5G_obj_t +H5Location::getObjTypeByIdx(hsize_t idx, H5std_string &type_name) const { H5G_obj_t obj_type = H5Gget_objtype_by_idx(getId(), idx); - switch (obj_type) - { - case H5G_LINK: type_name = H5std_string("symbolic link"); break; - case H5G_GROUP: type_name = H5std_string("group"); break; - case H5G_DATASET: type_name = H5std_string("dataset"); break; - case H5G_TYPE: type_name = H5std_string("datatype"); break; - case H5G_UNKNOWN: - case H5G_UDLINK: - case H5G_RESERVED_5: - case H5G_RESERVED_6: - case H5G_RESERVED_7: - default: - throwException("getObjTypeByIdx", "H5Gget_objtype_by_idx failed"); + switch (obj_type) { + case H5G_LINK: + type_name = H5std_string("symbolic link"); + break; + case H5G_GROUP: + type_name = H5std_string("group"); + break; + case H5G_DATASET: + type_name = H5std_string("dataset"); + break; + case H5G_TYPE: + type_name = H5std_string("datatype"); + break; + case H5G_UNKNOWN: + case H5G_UDLINK: + case H5G_RESERVED_5: + case H5G_RESERVED_6: + case H5G_RESERVED_7: + default: + throwException("getObjTypeByIdx", "H5Gget_objtype_by_idx failed"); } return (obj_type); } -#endif // DOXYGEN_SHOULD_SKIP_THIS #endif /* H5_NO_DEPRECATED_SYMBOLS */ //-------------------------------------------------------------------------- @@ -2179,7 +2267,8 @@ H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx, H5std_string& type_name) cons // maintain backward compatibility. For other subclasses, throw // LocationException. //-------------------------------------------------------------------------- -void H5Location::throwException(const H5std_string& func_name, const H5std_string& msg) const +void +H5Location::throwException(const H5std_string &func_name, const H5std_string &msg) const { throw LocationException(inMemFunc(func_name.c_str()), msg); } @@ -2210,7 +2299,8 @@ void H5Location::throwException(const H5std_string& func_name, const H5std_strin // param new_id - IN: New id to set // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void f_DataSpace_setId(DataSpace* dspace, hid_t new_id) +void +f_DataSpace_setId(DataSpace *dspace, hid_t new_id) { dspace->p_setId(new_id); } @@ -2220,8 +2310,8 @@ void f_DataSpace_setId(DataSpace* dspace, hid_t new_id) ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5Location::~H5Location() {} - -#endif // DOXYGEN_SHOULD_SKIP_THIS +H5Location::~H5Location() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Location.h b/c++/src/H5Location.h index c21cf06..7d40fb0 100644 --- a/c++/src/H5Location.h +++ b/c++/src/H5Location.h @@ -7,15 +7,15 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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 +#include "H5Classes.h" // constains forward class declarations namespace H5 { @@ -29,300 +29,296 @@ namespace H5 { */ // Inheritance: IdComponent class H5_DLLCPP H5Location : public IdComponent { - public: - // Checks if a link of a given name exists in a location - bool nameExists(const char* name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - bool nameExists(const H5std_string& name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + public: + // Checks if a link of a given name exists in a location + bool nameExists(const char *name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + bool nameExists(const H5std_string &name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; - // Checks if a link of a given name exists in a location - // Deprecated in favor of nameExists for better name. - bool exists(const char* name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - bool exists(const H5std_string& name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + // Checks if a link of a given name exists in a location + // Deprecated in favor of nameExists for better name. + bool exists(const char *name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + bool exists(const H5std_string &name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; - // Flushes all buffers associated with this location to disk. - void flush(H5F_scope_t scope) const; + // Flushes all buffers associated with this location to disk. + void flush(H5F_scope_t scope) const; - // Gets the name of the file, specified by this location. - H5std_string getFileName() const; + // Gets the name of the file, specified by this location. + H5std_string getFileName() const; #ifndef H5_NO_DEPRECATED_SYMBOLS - // Retrieves the type of object that an object reference points to. - H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; + // Retrieves the type of object that an object reference points to. + H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Retrieves the type of object that an object reference points to. - H5O_type_t getRefObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; - // Note: getRefObjType deprecates getObjType, but getObjType's name is - // misleading, so getRefObjType is used in the new function instead. - - // 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. - ssize_t getComment(const char* name, size_t buf_size, char* comment) const; - H5std_string getComment(const char* name, size_t buf_size=0) const; - H5std_string getComment(const H5std_string& name, size_t buf_size=0) 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_OBJECT) 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 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(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); - // Removed in 1.10.1, because H5Location is baseclass - //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; - - // Create a new group with using link create property list. - Group createGroup(const char* name, const LinkCreatPropList& lcpl) const; - Group createGroup(const H5std_string& name, const LinkCreatPropList& lcpl) const; - -// From CommonFG - // Creates a new group at this location which can be a file - // or another group. - Group createGroup(const char* name, size_t size_hint = 0) const; - Group createGroup(const H5std_string& name, size_t size_hint = 0) const; - - // Opens an existing group in a location which can be a file - // or another group. - Group openGroup(const char* name) const; - Group openGroup(const H5std_string& name) const; - - // Creates a new dataset in this location. - DataSet createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT, const DSetAccPropList& dapl = DSetAccPropList::DEFAULT, const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT) const; - DataSet createDataSet(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT, const DSetAccPropList& dapl = DSetAccPropList::DEFAULT, const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT) const; - - // Deprecated to add LinkCreatPropList and DSetAccPropList - 1.10.3 - // DataSet createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const; - // DataSet createDataSet(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const; - - // Opens an existing dataset at this location. - // DSetAccPropList is added - 1.10.3 - DataSet openDataSet(const char* name, const DSetAccPropList& dapl = DSetAccPropList::DEFAULT) const; - DataSet openDataSet(const H5std_string& name, const DSetAccPropList& dapl = DSetAccPropList::DEFAULT) const; - - H5L_info_t getLinkInfo(const char* link_name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - H5L_info_t getLinkInfo(const H5std_string& link_name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) 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; - - // Returns the number of objects in this group. - // Deprecated - moved to H5::Group in 1.10.2. - hsize_t getNumObjs() const; - - // Retrieves the name of an object in this group, given the - // object's index. - H5std_string getObjnameByIdx(hsize_t idx) const; - ssize_t getObjnameByIdx(hsize_t idx, char* name, size_t size) const; - ssize_t getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size) const; - - // Retrieves the type of an object in this file or group, given the - // object's name - H5O_type_t childObjType(const H5std_string& objname) const; - H5O_type_t childObjType(const char* objname) const; - H5O_type_t childObjType(hsize_t index, H5_index_t index_type=H5_INDEX_NAME, H5_iter_order_t order=H5_ITER_INC, const char* objname=".") const; - - // Returns the object header version of an object in this file or group, - // given the object's name. - unsigned childObjVersion(const char* objname) const; - unsigned childObjVersion(const H5std_string& objname) const; - - // Retrieves information about an HDF5 object. - void getObjinfo(H5O_info_t& objinfo, unsigned fields = H5O_INFO_BASIC) const; - - // Retrieves information about an HDF5 object, given its name. - void getObjinfo(const char* name, H5O_info_t& objinfo, - unsigned fields = H5O_INFO_BASIC, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void getObjinfo(const H5std_string& name, H5O_info_t& objinfo, - unsigned fields = H5O_INFO_BASIC, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Retrieves information about an HDF5 object, given its index. - void getObjinfo(const char* grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_info_t& objinfo, - unsigned fields = H5O_INFO_BASIC, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void getObjinfo(const H5std_string& grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_info_t& objinfo, - unsigned fields = H5O_INFO_BASIC, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + // Retrieves the type of object that an object reference points to. + H5O_type_t getRefObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; + // Note: getRefObjType deprecates getObjType, but getObjType's name is + // misleading, so getRefObjType is used in the new function instead. + + // 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. + ssize_t getComment(const char *name, size_t buf_size, char *comment) const; + H5std_string getComment(const char *name, size_t buf_size = 0) const; + H5std_string getComment(const H5std_string &name, size_t buf_size = 0) 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_OBJECT) 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 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(const H5Location &loc, const void *ref, H5R_type_t ref_type = H5R_OBJECT, + const PropList &plist = PropList::DEFAULT); + // Removed in 1.10.1, because H5Location is baseclass + // 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; + + // Create a new group with using link create property list. + Group createGroup(const char *name, const LinkCreatPropList &lcpl) const; + Group createGroup(const H5std_string &name, const LinkCreatPropList &lcpl) const; + + // From CommonFG + // Creates a new group at this location which can be a file + // or another group. + Group createGroup(const char *name, size_t size_hint = 0) const; + Group createGroup(const H5std_string &name, size_t size_hint = 0) const; + + // Opens an existing group in a location which can be a file + // or another group. + Group openGroup(const char *name) const; + Group openGroup(const H5std_string &name) const; + + // Creates a new dataset in this location. + DataSet createDataSet(const char *name, const DataType &data_type, const DataSpace &data_space, + const DSetCreatPropList &create_plist = DSetCreatPropList::DEFAULT, + const DSetAccPropList & dapl = DSetAccPropList::DEFAULT, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT) const; + DataSet createDataSet(const H5std_string &name, const DataType &data_type, const DataSpace &data_space, + const DSetCreatPropList &create_plist = DSetCreatPropList::DEFAULT, + const DSetAccPropList & dapl = DSetAccPropList::DEFAULT, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT) const; + + // Deprecated to add LinkCreatPropList and DSetAccPropList - 1.10.3 + // DataSet createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const + // DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const; DataSet createDataSet(const + // H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& + // create_plist = DSetCreatPropList::DEFAULT) const; + + // Opens an existing dataset at this location. + // DSetAccPropList is added - 1.10.3 + DataSet openDataSet(const char *name, const DSetAccPropList &dapl = DSetAccPropList::DEFAULT) const; + DataSet openDataSet(const H5std_string & name, + const DSetAccPropList &dapl = DSetAccPropList::DEFAULT) const; + + H5L_info_t getLinkInfo(const char * link_name, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + H5L_info_t getLinkInfo(const H5std_string & link_name, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) 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; + + // Returns the number of objects in this group. + // Deprecated - moved to H5::Group in 1.10.2. + hsize_t getNumObjs() const; + + // Retrieves the name of an object in this group, given the + // object's index. + H5std_string getObjnameByIdx(hsize_t idx) const; + ssize_t getObjnameByIdx(hsize_t idx, char *name, size_t size) const; + ssize_t getObjnameByIdx(hsize_t idx, H5std_string &name, size_t size) const; + + // Retrieves the type of an object in this file or group, given the + // object's name + H5O_type_t childObjType(const H5std_string &objname) const; + H5O_type_t childObjType(const char *objname) const; + H5O_type_t childObjType(hsize_t index, H5_index_t index_type = H5_INDEX_NAME, + H5_iter_order_t order = H5_ITER_INC, const char *objname = ".") const; + + // Returns the object header version of an object in this file or group, + // given the object's name. + unsigned childObjVersion(const char *objname) const; + unsigned childObjVersion(const H5std_string &objname) const; + + // Retrieves information about an HDF5 object. + void getObjinfo(H5O_info_t &objinfo, unsigned fields = H5O_INFO_BASIC) const; + + // Retrieves information about an HDF5 object, given its name. + void getObjinfo(const char *name, H5O_info_t &objinfo, unsigned fields = H5O_INFO_BASIC, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + void getObjinfo(const H5std_string &name, H5O_info_t &objinfo, unsigned fields = H5O_INFO_BASIC, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + + // Retrieves information about an HDF5 object, given its index. + void getObjinfo(const char *grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + H5O_info_t &objinfo, unsigned fields = H5O_INFO_BASIC, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + void getObjinfo(const H5std_string &grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + H5O_info_t &objinfo, unsigned fields = H5O_INFO_BASIC, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; #ifndef H5_NO_DEPRECATED_SYMBOLS - // Returns the type of an object in this group, given the - // object's index. - H5G_obj_t getObjTypeByIdx(hsize_t idx) const; - H5G_obj_t getObjTypeByIdx(hsize_t idx, char* type_name) const; - H5G_obj_t getObjTypeByIdx(hsize_t idx, H5std_string& type_name) const; - - // Returns information about an HDF5 object, given by its name, - // at this location. - Deprecated - void getObjinfo(const char* name, hbool_t follow_link, H5G_stat_t& statbuf) const; - void getObjinfo(const H5std_string& name, hbool_t follow_link, H5G_stat_t& statbuf) const; - void getObjinfo(const char* name, H5G_stat_t& statbuf) const; - void getObjinfo(const H5std_string& name, H5G_stat_t& statbuf) const; - - // Iterates over the elements of this group - not implemented in - // C++ style yet. - int iterateElems(const char* name, int *idx, H5G_iterate_t op, void *op_data); - int iterateElems(const H5std_string& name, int *idx, H5G_iterate_t op, void *op_data); + // Returns the type of an object in this group, given the + // object's index. + H5G_obj_t getObjTypeByIdx(hsize_t idx) const; + H5G_obj_t getObjTypeByIdx(hsize_t idx, char *type_name) const; + H5G_obj_t getObjTypeByIdx(hsize_t idx, H5std_string &type_name) const; + + // Returns information about an HDF5 object, given by its name, + // at this location. - Deprecated + void getObjinfo(const char *name, hbool_t follow_link, H5G_stat_t &statbuf) const; + void getObjinfo(const H5std_string &name, hbool_t follow_link, H5G_stat_t &statbuf) const; + void getObjinfo(const char *name, H5G_stat_t &statbuf) const; + void getObjinfo(const H5std_string &name, H5G_stat_t &statbuf) const; + + // Iterates over the elements of this group - not implemented in + // C++ style yet. + int iterateElems(const char *name, int *idx, H5G_iterate_t op, void *op_data); + int iterateElems(const H5std_string &name, int *idx, H5G_iterate_t op, void *op_data); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Creates a soft link from link_name to target_name. - void link(const char *target_name, const char *link_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void link(const H5std_string& target_name, - const H5std_string& link_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Creates a hard link from new_name to curr_name. - void link(const char *curr_name, - const Group& new_loc, const char *new_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void link(const H5std_string& curr_name, - const Group& new_loc, const H5std_string& new_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Creates a hard link from new_name to curr_name in same location. - void link(const char *curr_name, - const hid_t same_loc, const char *new_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void link(const H5std_string& curr_name, - const hid_t same_loc, const H5std_string& new_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Creates a link of the specified type from new_name to current_name; - // both names are interpreted relative to the specified location id. - // Deprecated due to inadequate functionality. - void link(H5L_type_t link_type, const char* curr_name, const char* new_name) const; - void link(H5L_type_t link_type, const H5std_string& curr_name, const H5std_string& new_name) const; - - // Removes the specified link from this location. - void unlink(const char *link_name, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void unlink(const H5std_string& link_name, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Mounts the file 'child' onto this location. - void mount(const char* name, const H5File& child, const PropList& plist) const; - void mount(const H5std_string& name, const H5File& child, const PropList& plist) const; - - // Unmounts the file named 'name' from this parent location. - void unmount(const char* name) const; - void unmount(const H5std_string& name) const; - - // Copies a link from a group to another. - void copyLink(const char *src_name, - const Group& dst, const char *dst_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void copyLink(const H5std_string& src_name, - const Group& dst, const H5std_string& dst_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Makes a copy of a link in the same group. - void copyLink(const char *src_name, const char *dst_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void copyLink(const H5std_string& src_name, - const H5std_string& dst_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Renames a link in this group and moves to a new location. - void moveLink(const char* src_name, - const Group& dst, const char* dst_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void moveLink(const H5std_string& src_name, - const Group& dst, const H5std_string& dst_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Renames a link in this group. - void moveLink(const char* src_name, const char* dst_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void moveLink(const H5std_string& src_name, - const H5std_string& dst_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Renames an object at this location. - // Deprecated due to inadequate functionality. - void move(const char* src, const char* dst) const; - void move(const H5std_string& src, const H5std_string& dst) const; - -// end From CommonFG - - /// For subclasses, H5File and Group, to throw appropriate exception. - virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const; - - // Default constructor - H5Location(); - - protected: + // Creates a soft link from link_name to target_name. + void link(const char *target_name, const char *link_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + void link(const H5std_string &target_name, const H5std_string &link_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + + // Creates a hard link from new_name to curr_name. + void link(const char *curr_name, const Group &new_loc, const char *new_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + void link(const H5std_string &curr_name, const Group &new_loc, const H5std_string &new_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + + // Creates a hard link from new_name to curr_name in same location. + void link(const char *curr_name, const hid_t same_loc, const char *new_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + void link(const H5std_string &curr_name, const hid_t same_loc, const H5std_string &new_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + + // Creates a link of the specified type from new_name to current_name; + // both names are interpreted relative to the specified location id. + // Deprecated due to inadequate functionality. + void link(H5L_type_t link_type, const char *curr_name, const char *new_name) const; + void link(H5L_type_t link_type, const H5std_string &curr_name, const H5std_string &new_name) const; + + // Removes the specified link from this location. + void unlink(const char *link_name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + void unlink(const H5std_string &link_name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + + // Mounts the file 'child' onto this location. + void mount(const char *name, const H5File &child, const PropList &plist) const; + void mount(const H5std_string &name, const H5File &child, const PropList &plist) const; + + // Unmounts the file named 'name' from this parent location. + void unmount(const char *name) const; + void unmount(const H5std_string &name) const; + + // Copies a link from a group to another. + void copyLink(const char *src_name, const Group &dst, const char *dst_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + void copyLink(const H5std_string &src_name, const Group &dst, const H5std_string &dst_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + + // Makes a copy of a link in the same group. + void copyLink(const char *src_name, const char *dst_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + void copyLink(const H5std_string &src_name, const H5std_string &dst_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + + // Renames a link in this group and moves to a new location. + void moveLink(const char *src_name, const Group &dst, const char *dst_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + void moveLink(const H5std_string &src_name, const Group &dst, const H5std_string &dst_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + + // Renames a link in this group. + void moveLink(const char *src_name, const char *dst_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + void moveLink(const H5std_string &src_name, const H5std_string &dst_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + + // Renames an object at this location. + // Deprecated due to inadequate functionality. + void move(const char *src, const char *dst) const; + void move(const H5std_string &src, const H5std_string &dst) const; + + // end From CommonFG + + /// For subclasses, H5File and Group, to throw appropriate exception. + virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const; + + // Default constructor + H5Location(); + + protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // *** Deprecation warning *** - // The following two constructors are no longer appropriate after the - // data member "id" had been moved to the sub-classes. - // The copy constructor is a noop and is removed in 1.8.15 and the - // other will be removed from 1.10 release, and then from 1.8 if its - // removal does not raise any problems in two 1.10 releases. + // *** Deprecation warning *** + // The following two constructors are no longer appropriate after the + // data member "id" had been moved to the sub-classes. + // The copy constructor is a noop and is removed in 1.8.15 and the + // other will be removed from 1.10 release, and then from 1.8 if its + // removal does not raise any problems in two 1.10 releases. - // Creates a copy of an existing object giving the location id. - // H5Location(const hid_t loc_id); + // Creates a copy of an existing object giving the location id. + // H5Location(const hid_t loc_id); - // Creates a reference to an HDF5 object or a dataset region. - void p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const; + // Creates a reference to an HDF5 object or a dataset region. + 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, const PropList& plist, const char* from_func); + // Dereferences a ref into an HDF5 id. + 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. - H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const; + // Retrieves the type of object that an object reference points to. + H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const; #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // 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 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; - // Sets the identifier of this object to a new value. - this one - // doesn't increment reference count - //virtual void p_setId(const hid_t new_id); + // Sets the identifier of this object to a new value. - this one + // doesn't increment reference count + // virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS - // Noop destructor. - virtual ~H5Location(); + // Noop destructor. + virtual ~H5Location(); }; // end of H5Location } // namespace H5 -#endif // __H5Location_H +#endif // H5Location_H diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp index 8d3334b..4fa44aa 100644 --- a/c++/src/H5Object.cpp +++ b/c++/src/H5Object.cpp @@ -6,14 +6,14 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include <string> -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -42,31 +42,38 @@ namespace H5 { #ifndef DOXYGEN_SHOULD_SKIP_THIS // userAttrOpWrpr interfaces between the user's function and the // C library function H5Aiterate2 -extern "C" herr_t userAttrOpWrpr(hid_t loc_id, const char *attr_name, - const H5A_info_t *ainfo, void *op_data) +extern "C" { + +static herr_t +userAttrOpWrpr(H5_ATTR_UNUSED hid_t loc_id, const char *attr_name, H5_ATTR_UNUSED const H5A_info_t *ainfo, + void *op_data) { - H5std_string s_attr_name = H5std_string(attr_name); - UserData4Aiterate* myData = reinterpret_cast<UserData4Aiterate *> (op_data); + H5std_string s_attr_name = H5std_string(attr_name); + UserData4Aiterate *myData = reinterpret_cast<UserData4Aiterate *>(op_data); myData->op(*myData->location, s_attr_name, myData->opData); return 0; } // userVisitOpWrpr interfaces between the user's function and the -// C library function H5Ovisit2 -extern "C" herr_t userVisitOpWrpr(hid_t obj_id, const char *attr_name, - const H5O_info_t *obj_info, void *op_data) +// C library function H5Ovisit3 +static herr_t +userVisitOpWrpr(H5_ATTR_UNUSED hid_t obj_id, const char *attr_name, const H5O_info_t *obj_info, void *op_data) { - H5std_string s_attr_name = H5std_string(attr_name); - UserData4Visit* myData = reinterpret_cast<UserData4Visit *> (op_data); - int status = myData->op(*myData->obj, s_attr_name, obj_info, myData->opData); + H5std_string s_attr_name = H5std_string(attr_name); + UserData4Visit *myData = reinterpret_cast<UserData4Visit *>(op_data); + int status = myData->op(*myData->obj, s_attr_name, obj_info, myData->opData); return status; } +} // extern "C" + //-------------------------------------------------------------------------- // Function: H5Object default constructor (protected) // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5Object::H5Object() : H5Location() {} +H5Object::H5Object() : H5Location() +{ +} //-------------------------------------------------------------------------- // Function: f_Attribute_setId - friend @@ -78,7 +85,8 @@ H5Object::H5Object() : H5Location() {} // param new_id - IN: New id to set // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void f_Attribute_setId(Attribute* attr, hid_t new_id) +void +f_Attribute_setId(Attribute *attr, hid_t new_id) { attr->p_setId(new_id); } @@ -105,19 +113,20 @@ void f_Attribute_setId(Attribute* attr, hid_t new_id) /// recreate it with this function. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute H5Object::createAttribute(const char* name, const DataType& data_type, const DataSpace& data_space, const PropList& create_plist) const +Attribute +H5Object::createAttribute(const char *name, const DataType &data_type, const DataSpace &data_space, + const PropList &create_plist) const { - hid_t type_id = data_type.getId(); + hid_t type_id = data_type.getId(); hid_t space_id = data_space.getId(); hid_t plist_id = create_plist.getId(); - hid_t attr_id = H5Acreate2(getId(), name, type_id, space_id, plist_id, H5P_DEFAULT); + hid_t attr_id = H5Acreate2(getId(), name, type_id, space_id, plist_id, H5P_DEFAULT); // If the attribute id is valid, create and return the Attribute object - if (attr_id > 0) - { + if (attr_id > 0) { Attribute attr; f_Attribute_setId(&attr, attr_id); - return(attr); + return (attr); } else throw AttributeIException(inMemFunc("createAttribute"), "H5Acreate2 failed"); @@ -130,9 +139,11 @@ Attribute H5Object::createAttribute(const char* name, const DataType& data_type, /// a reference to an \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute H5Object::createAttribute(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const PropList& create_plist) const +Attribute +H5Object::createAttribute(const H5std_string &name, const DataType &data_type, const DataSpace &data_space, + const PropList &create_plist) const { - return(createAttribute(name.c_str(), data_type, data_space, create_plist)); + return (createAttribute(name.c_str(), data_type, data_space, create_plist)); } //-------------------------------------------------------------------------- @@ -143,17 +154,16 @@ Attribute H5Object::createAttribute(const H5std_string& name, const DataType& da ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute H5Object::openAttribute(const char* name) const +Attribute +H5Object::openAttribute(const char *name) const { hid_t attr_id = H5Aopen(getId(), name, H5P_DEFAULT); - if (attr_id > 0) - { + if (attr_id > 0) { Attribute attr; f_Attribute_setId(&attr, attr_id); - return(attr); + return (attr); } - else - { + else { throw AttributeIException(inMemFunc("openAttribute"), "H5Aopen failed"); } } @@ -165,9 +175,10 @@ Attribute H5Object::openAttribute(const char* name) const /// a reference to an \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute H5Object::openAttribute(const H5std_string& name) const +Attribute +H5Object::openAttribute(const H5std_string &name) const { - return(openAttribute(name.c_str())); + return (openAttribute(name.c_str())); } //-------------------------------------------------------------------------- @@ -178,18 +189,17 @@ Attribute H5Object::openAttribute(const H5std_string& name) const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute H5Object::openAttribute(const unsigned int idx) const +Attribute +H5Object::openAttribute(const unsigned int idx) const { - hid_t attr_id = H5Aopen_by_idx(getId(), ".", H5_INDEX_CRT_ORDER, - H5_ITER_INC, static_cast<hsize_t>(idx), H5P_DEFAULT, H5P_DEFAULT); - if (attr_id > 0) - { + hid_t attr_id = H5Aopen_by_idx(getId(), ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, static_cast<hsize_t>(idx), + H5P_DEFAULT, H5P_DEFAULT); + if (attr_id > 0) { Attribute attr; f_Attribute_setId(&attr, attr_id); - return(attr); + return (attr); } - else - { + else { throw AttributeIException(inMemFunc("openAttribute"), "H5Aopen_by_idx failed"); } } @@ -209,18 +219,19 @@ Attribute H5Object::openAttribute(const unsigned int idx) const /// void (*)(H5::H5Location&, H5std_string, void*). // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int H5Object::iterateAttrs(attr_operator_t user_op, unsigned *_idx, void *op_data) +int +H5Object::iterateAttrs(attr_operator_t user_op, unsigned *_idx, void *op_data) { // store the user's function and data - UserData4Aiterate* userData = new UserData4Aiterate; - userData->opData = op_data; - userData->op = user_op; - userData->location = this; + UserData4Aiterate *userData = new UserData4Aiterate; + userData->opData = op_data; + userData->op = user_op; + userData->location = this; // call the C library routine H5Aiterate2 to iterate the attributes hsize_t idx = _idx ? static_cast<hsize_t>(*_idx) : 0; - int ret_value = H5Aiterate2(getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, - userAttrOpWrpr, static_cast<void *>(userData)); + int ret_value = + H5Aiterate2(getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, userAttrOpWrpr, static_cast<void *>(userData)); // release memory delete userData; @@ -229,9 +240,9 @@ int H5Object::iterateAttrs(attr_operator_t user_op, unsigned *_idx, void *op_dat /* Pass back update index value to calling code */ if (_idx) *_idx = static_cast<unsigned>(idx); - return(ret_value); + return (ret_value); } - else // raise exception when H5Aiterate returns a negative value + else // raise exception when H5Aiterate returns a negative value throw AttributeIException(inMemFunc("iterateAttrs"), "H5Aiterate2 failed"); } @@ -256,7 +267,8 @@ int H5Object::iterateAttrs(attr_operator_t user_op, unsigned *_idx, void *op_dat /// \li \c H5O_INFO_NUM_ATTRS num_attrs field /// \li \c H5O_INFO_HDR hdr field /// \li \c H5O_INFO_META_SIZE meta_size field -/// \li \c H5O_INFO_ALL H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS | H5O_INFO_HDR | H5O_INFO_META_SIZE +/// \li \c H5O_INFO_ALL H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS | H5O_INFO_HDR +/// | H5O_INFO_META_SIZE ///\return /// \li On success: /// \li the return value of the first operator that returns a positive value @@ -270,16 +282,19 @@ int H5Object::iterateAttrs(attr_operator_t user_op, unsigned *_idx, void *op_dat /// C Reference Manual. // Programmer Binh-Minh Ribler - Feb, 2019 //-------------------------------------------------------------------------- -void H5Object::visit(H5_index_t idx_type, H5_iter_order_t order, visit_operator_t user_op, void *op_data, unsigned int fields) +void +H5Object::visit(H5_index_t idx_type, H5_iter_order_t order, visit_operator_t user_op, void *op_data, + unsigned int fields) { // Store the user's function and data - UserData4Visit* userData = new UserData4Visit; - userData->opData = op_data; - userData->op = user_op; - userData->obj = this; + UserData4Visit *userData = new UserData4Visit; + userData->opData = op_data; + userData->op = user_op; + userData->obj = this; // Call the C API passing in op wrapper and info - herr_t ret_value = H5Ovisit2(getId(), idx_type, order, userVisitOpWrpr, static_cast<void *>(userData), fields); + herr_t ret_value = + H5Ovisit2(getId(), idx_type, order, userVisitOpWrpr, static_cast<void *>(userData), fields); // Release memory delete userData; @@ -302,10 +317,11 @@ void H5Object::visit(H5_index_t idx_type, H5_iter_order_t order, visit_operator_ /// - version number is not one of the valid values above // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -unsigned H5Object::objVersion() const +unsigned +H5Object::objVersion() const { H5O_info_t objinfo; - unsigned version = 0; + unsigned version = 0; // Use C API to get information of the object herr_t ret_value = H5Oget_info2(getId(), &objinfo, H5O_INFO_HDR); @@ -314,13 +330,12 @@ unsigned H5Object::objVersion() const if (ret_value < 0) throw Exception(inMemFunc("objVersion"), "H5Oget_info failed"); // Return a valid version or throw an exception for invalid value - else - { + else { version = objinfo.hdr.version; if (version != H5O_VERSION_1 && version != H5O_VERSION_2) throw ObjHeaderIException("objVersion", "Invalid version for object"); } - return(version); + return (version); } //-------------------------------------------------------------------------- @@ -330,14 +345,15 @@ unsigned H5Object::objVersion() const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int H5Object::getNumAttrs() const +int +H5Object::getNumAttrs() const { - H5O_info_t oinfo; /* Object info */ + H5O_info_t oinfo; /* Object info */ - if(H5Oget_info2(getId(), &oinfo, H5O_INFO_NUM_ATTRS) < 0) + if (H5Oget_info2(getId(), &oinfo, H5O_INFO_NUM_ATTRS) < 0) throw AttributeIException(inMemFunc("getNumAttrs"), "H5Oget_info failed"); else - return(static_cast<int>(oinfo.num_attrs)); + return (static_cast<int>(oinfo.num_attrs)); } //-------------------------------------------------------------------------- @@ -347,7 +363,8 @@ int H5Object::getNumAttrs() const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2013 //-------------------------------------------------------------------------- -bool H5Object::attrExists(const char* name) const +bool +H5Object::attrExists(const char *name) const { // Call C routine H5Aexists to determine whether an attribute exists // at this location, which could be specified by a file, group, dataset, @@ -355,7 +372,7 @@ bool H5Object::attrExists(const char* name) const herr_t ret_value = H5Aexists(getId(), name); if (ret_value > 0) return true; - else if(ret_value == 0) + else if (ret_value == 0) return false; else // Raise exception when H5Aexists returns a negative value throw AttributeIException(inMemFunc("attrExists"), "H5Aexists failed"); @@ -368,9 +385,10 @@ bool H5Object::attrExists(const char* name) const /// a reference to an \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool H5Object::attrExists(const H5std_string& name) const +bool +H5Object::attrExists(const H5std_string &name) const { - return(attrExists(name.c_str())); + return (attrExists(name.c_str())); } //-------------------------------------------------------------------------- @@ -380,7 +398,8 @@ bool H5Object::attrExists(const H5std_string& name) const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Object::removeAttr(const char* name) const +void +H5Object::removeAttr(const char *name) const { herr_t ret_value = H5Adelete(getId(), name); if (ret_value < 0) @@ -394,7 +413,8 @@ void H5Object::removeAttr(const char* name) const /// a reference to an \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Object::removeAttr(const H5std_string& name) const +void +H5Object::removeAttr(const H5std_string &name) const { removeAttr(name.c_str()); } @@ -407,7 +427,8 @@ void H5Object::removeAttr(const H5std_string& name) const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- -void H5Object::renameAttr(const char* oldname, const char* newname) const +void +H5Object::renameAttr(const char *oldname, const char *newname) const { herr_t ret_value = H5Arename(getId(), oldname, newname); if (ret_value < 0) @@ -421,9 +442,10 @@ void H5Object::renameAttr(const char* oldname, const char* newname) const /// a reference to an \c H5std_string for the names. // Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- -void H5Object::renameAttr(const H5std_string& oldname, const H5std_string& newname) const +void +H5Object::renameAttr(const H5std_string &oldname, const H5std_string &newname) const { - renameAttr (oldname.c_str(), newname.c_str()); + renameAttr(oldname.c_str(), newname.c_str()); } //-------------------------------------------------------------------------- @@ -432,22 +454,21 @@ void H5Object::renameAttr(const H5std_string& oldname, const H5std_string& newna ///\return The name of the object // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -ssize_t H5Object::getObjName(char *obj_name, size_t buf_size) const +ssize_t +H5Object::getObjName(char *obj_name, size_t buf_size) const { // H5Iget_name will get buf_size-1 chars of the name to null terminate it ssize_t name_size = H5Iget_name(getId(), obj_name, buf_size); // If H5Iget_name returns a negative value, raise an exception - if (name_size < 0) - { + if (name_size < 0) { throw Exception(inMemFunc("getObjName"), "H5Iget_name failed"); } - else if (name_size == 0) - { + else if (name_size == 0) { throw Exception(inMemFunc("getObjName"), "Object must have a name, but name length is 0"); } // Return length of the name - return(name_size); + return (name_size); } //-------------------------------------------------------------------------- @@ -457,39 +478,37 @@ ssize_t H5Object::getObjName(char *obj_name, size_t buf_size) const ///\exception H5::Exception // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -H5std_string H5Object::getObjName() const +H5std_string +H5Object::getObjName() const { - H5std_string obj_name(""); // object name to return + H5std_string obj_name; // object name to return // Preliminary call to get the size of the object name ssize_t name_size = H5Iget_name(getId(), NULL, static_cast<size_t>(0)); // If H5Iget_name failed, throw exception - if (name_size < 0) - { + if (name_size < 0) { throw Exception(inMemFunc("getObjName"), "H5Iget_name failed"); } - else if (name_size == 0) - { + else if (name_size == 0) { throw Exception(inMemFunc("getObjName"), "Object must have a name, but name length is 0"); } // Object's name exists, retrieve it - else if (name_size > 0) - { - char* name_C = new char[name_size+1]; // temporary C-string - HDmemset(name_C, 0, name_size+1); // clear buffer + else if (name_size > 0) { + char *name_C = new char[name_size + 1]; // temporary C-string + HDmemset(name_C, 0, name_size + 1); // clear buffer // Use overloaded function - name_size = getObjName(name_C, name_size+1); + name_size = getObjName(name_C, name_size + 1); // Convert the C object name to return obj_name = name_C; // Clean up resource - delete []name_C; + delete[] name_C; } // Return object's name - return(obj_name); + return (obj_name); } //-------------------------------------------------------------------------- @@ -505,35 +524,34 @@ H5std_string H5Object::getObjName() const /// which case the entire name will be retrieved. // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -ssize_t H5Object::getObjName(H5std_string& obj_name, size_t len) const +ssize_t +H5Object::getObjName(H5std_string &obj_name, size_t len) const { ssize_t name_size = 0; // If no length is provided, get the entire object name - if (len == 0) - { - obj_name = getObjName(); + if (len == 0) { + obj_name = getObjName(); name_size = obj_name.length(); } // If length is provided, get that number of characters in name - else - { - char* name_C = new char[len+1]; // temporary C-string - HDmemset(name_C, 0, len+1); // clear buffer + else { + char *name_C = new char[len + 1]; // temporary C-string + HDmemset(name_C, 0, len + 1); // clear buffer // Use overloaded function - name_size = getObjName(name_C, len+1); + name_size = getObjName(name_C, len + 1); // Convert the C object name to return obj_name = name_C; // Clean up resource - delete []name_C; + delete[] name_C; } // Otherwise, keep obj_name intact // Return name size - return(name_size); + return (name_size); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -542,7 +560,9 @@ ssize_t H5Object::getObjName(H5std_string& obj_name, size_t len) const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5Object::~H5Object() {} +H5Object::~H5Object() +{ +} #endif // DOXYGEN_SHOULD_SKIP_THIS -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Object.h b/c++/src/H5Object.h index d7b2b0b..961b9eb 100644 --- a/c++/src/H5Object.h +++ b/c++/src/H5Object.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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 namespace H5 { @@ -40,98 +40,96 @@ namespace H5 { // Inheritance: H5Location -> IdComponent // Define the operator function pointer for H5Aiterate(). -typedef void (*attr_operator_t)(H5Object& loc, - const H5std_string attr_name, - void *operator_data); +typedef void (*attr_operator_t)(H5Object &loc, const H5std_string attr_name, void *operator_data); // Define the operator function pointer for H5Ovisit2(). -typedef int (*visit_operator_t)(H5Object& obj, - const H5std_string attr_name, - const H5O_info_t *oinfo, - void *operator_data); +typedef int (*visit_operator_t)(H5Object &obj, const H5std_string attr_name, const H5O_info_t *oinfo, + void *operator_data); // User data for attribute iteration class UserData4Aiterate { - public: - attr_operator_t op; - void* opData; - H5Object* location; // Consider changing to H5Location + public: + attr_operator_t op; + void * opData; + H5Object * location; // Consider changing to H5Location }; // User data for visit iteration class UserData4Visit { - public: - visit_operator_t op; - void* opData; - H5Object* obj; + public: + visit_operator_t op; + void * opData; + H5Object * obj; }; class H5_DLLCPP H5Object : public H5Location { - public: - // Creates an attribute for the specified object - // PropList is currently not used, so always be default. - Attribute createAttribute(const char* name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const; - Attribute createAttribute(const H5std_string& name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const; + public: + // Creates an attribute for the specified object + // PropList is currently not used, so always be default. + Attribute createAttribute(const char *name, const DataType &type, const DataSpace &space, + const PropList &create_plist = PropList::DEFAULT) const; + Attribute createAttribute(const H5std_string &name, const DataType &type, const DataSpace &space, + const PropList &create_plist = PropList::DEFAULT) const; - // Given its name, opens the attribute that belongs to an object at - // this location. - Attribute openAttribute(const char* name) const; - Attribute openAttribute(const H5std_string& name) const; + // Given its name, opens the attribute that belongs to an object at + // this location. + Attribute openAttribute(const char *name) const; + Attribute openAttribute(const H5std_string &name) const; - // Given its index, opens the attribute that belongs to an object at - // this location. - Attribute openAttribute(const unsigned int idx) const; + // Given its index, opens the attribute that belongs to an object at + // this location. + Attribute openAttribute(const unsigned int idx) const; - // Iterate user's function over the attributes of this object. - int iterateAttrs(attr_operator_t user_op, unsigned* idx = NULL, void* op_data = NULL); + // Iterate user's function over the attributes of this object. + int iterateAttrs(attr_operator_t user_op, unsigned *idx = NULL, void *op_data = NULL); - // Recursively visit elements reachable from this object. - void visit(H5_index_t idx_type, H5_iter_order_t order, visit_operator_t user_op, void *op_data, unsigned int fields); + // Recursively visit elements reachable from this object. + void visit(H5_index_t idx_type, H5_iter_order_t order, visit_operator_t user_op, void *op_data, + unsigned int fields); - // Returns the object header version of an object - unsigned objVersion() const; + // Returns the object header version of an object + unsigned objVersion() const; - // Determines the number of attributes belong to this object. - int getNumAttrs() const; + // Determines the number of attributes belong to this object. + int getNumAttrs() const; - // Checks whether the named attribute exists for this object. - bool attrExists(const char* name) const; - bool attrExists(const H5std_string& name) const; + // Checks whether the named attribute exists for this object. + 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; + // 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 object. - void removeAttr(const char* name) const; - void removeAttr(const H5std_string& name) const; + // Removes the named attribute from this object. + void removeAttr(const char *name) const; + void removeAttr(const H5std_string &name) const; - // Returns an identifier. - virtual hid_t getId() const = 0; - - // Gets the name of this HDF5 object, i.e., Group, DataSet, or - // DataType. - ssize_t getObjName(char *obj_name, size_t buf_size = 0) const; - ssize_t getObjName(H5std_string& obj_name, size_t len = 0) const; - H5std_string getObjName() const; + // Returns an identifier. + virtual hid_t getId() const H5_OVERRIDE = 0; + // Gets the name of this HDF5 object, i.e., Group, DataSet, or + // DataType. + ssize_t getObjName(char *obj_name, size_t buf_size = 0) const; + ssize_t getObjName(H5std_string &obj_name, size_t len = 0) const; + H5std_string getObjName() const; #ifndef DOXYGEN_SHOULD_SKIP_THIS - protected: - // Default constructor - H5Object(); + protected: + // Default constructor + H5Object(); - // Sets the identifier of this object to a new value. - this one - // doesn't increment reference count - virtual void p_setId(const hid_t new_id) = 0; + // Sets the identifier of this object to a new value. - this one + // doesn't increment reference count + virtual void p_setId(const hid_t new_id) H5_OVERRIDE = 0; - // Noop destructor. - virtual ~H5Object(); + // Noop destructor. + virtual ~H5Object() H5_OVERRIDE; #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of H5Object } // namespace H5 -#endif // __H5Object_H +#endif // H5Object_H diff --git a/c++/src/H5OcreatProp.cpp b/c++/src/H5OcreatProp.cpp index 0542d5e..81dae31 100644 --- a/c++/src/H5OcreatProp.cpp +++ b/c++/src/H5OcreatProp.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,7 +27,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -ObjCreatPropList* ObjCreatPropList::DEFAULT_ = 0; +ObjCreatPropList *ObjCreatPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: ObjCreatPropList::getConstant @@ -40,13 +40,13 @@ ObjCreatPropList* ObjCreatPropList::DEFAULT_ = 0; // happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -ObjCreatPropList* ObjCreatPropList::getConstant() +ObjCreatPropList * +ObjCreatPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -55,8 +55,9 @@ ObjCreatPropList* ObjCreatPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new ObjCreatPropList(H5P_OBJECT_CREATE); else - throw PropListIException("ObjCreatPropList::getConstant", "ObjCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("ObjCreatPropList::getConstant", + "ObjCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -66,7 +67,8 @@ ObjCreatPropList* ObjCreatPropList::getConstant() // exception H5::PropListIException // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void ObjCreatPropList::deleteConstants() +void +ObjCreatPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -75,7 +77,7 @@ void ObjCreatPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose: Constant for default property //-------------------------------------------------------------------------- -const ObjCreatPropList& ObjCreatPropList::DEFAULT = *getConstant(); +const ObjCreatPropList &ObjCreatPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -84,7 +86,9 @@ const ObjCreatPropList& ObjCreatPropList::DEFAULT = *getConstant(); ///\brief Creates a file access property list // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -ObjCreatPropList::ObjCreatPropList() : PropList(H5P_OBJECT_CREATE) {} +ObjCreatPropList::ObjCreatPropList() : PropList(H5P_OBJECT_CREATE) +{ +} //-------------------------------------------------------------------------- // Function: ObjCreatPropList copy constructor @@ -92,7 +96,9 @@ ObjCreatPropList::ObjCreatPropList() : PropList(H5P_OBJECT_CREATE) {} ///\param original - IN: ObjCreatPropList instance to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -ObjCreatPropList::ObjCreatPropList(const ObjCreatPropList& original) : PropList(original) {} +ObjCreatPropList::ObjCreatPropList(const ObjCreatPropList &original) : PropList(original) +{ +} //-------------------------------------------------------------------------- // Function: ObjCreatPropList overloaded constructor @@ -100,7 +106,9 @@ ObjCreatPropList::ObjCreatPropList(const ObjCreatPropList& original) : PropList( /// existing one. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -ObjCreatPropList::ObjCreatPropList(const hid_t plist_id) : PropList(plist_id) {} +ObjCreatPropList::ObjCreatPropList(const hid_t plist_id) : PropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: ObjCreatPropList::setAttrPhaseChange @@ -116,11 +124,11 @@ ObjCreatPropList::ObjCreatPropList(const hid_t plist_id) : PropList(plist_id) {} /// H5Pset_attr_phase_change API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -void ObjCreatPropList::setAttrPhaseChange(unsigned max_compact, unsigned min_dense) const +void +ObjCreatPropList::setAttrPhaseChange(unsigned max_compact, unsigned min_dense) const { herr_t ret_value = H5Pset_attr_phase_change(id, max_compact, min_dense); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("ObjCreatPropList::setAttrPhaseChange", "H5Pset_attr_phase_change failed"); } } @@ -139,12 +147,12 @@ void ObjCreatPropList::setAttrPhaseChange(unsigned max_compact, unsigned min_den /// H5Pget_attr_phase_change API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -void ObjCreatPropList::getAttrPhaseChange(unsigned& max_compact, unsigned& min_dense) const +void +ObjCreatPropList::getAttrPhaseChange(unsigned &max_compact, unsigned &min_dense) const { herr_t ret_value; ret_value = H5Pget_attr_phase_change(id, &max_compact, &min_dense); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("ObjCreatPropList::getAttrPhaseChange", "H5Pget_attr_phase_change failed"); } } @@ -168,11 +176,11 @@ void ObjCreatPropList::getAttrPhaseChange(unsigned& max_compact, unsigned& min_d /// in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -void ObjCreatPropList::setAttrCrtOrder(unsigned crt_order_flags) const +void +ObjCreatPropList::setAttrCrtOrder(unsigned crt_order_flags) const { herr_t ret_value = H5Pset_attr_creation_order(id, crt_order_flags); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("ObjCreatPropList::setAttrCrtOrder", "H5Pset_attr_creation_order failed"); } } @@ -190,16 +198,16 @@ void ObjCreatPropList::setAttrCrtOrder(unsigned crt_order_flags) const /// in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -unsigned ObjCreatPropList::getAttrCrtOrder() const +unsigned +ObjCreatPropList::getAttrCrtOrder() const { - herr_t ret_value; + herr_t ret_value; unsigned crt_order_flags = 0; - ret_value = H5Pget_attr_creation_order(id, &crt_order_flags); - if (ret_value < 0) - { + ret_value = H5Pget_attr_creation_order(id, &crt_order_flags); + if (ret_value < 0) { throw PropListIException("ObjCreatPropList::getAttrCrtOrder", "H5Pget_attr_creation_order failed"); } - return(crt_order_flags); + return (crt_order_flags); } //-------------------------------------------------------------------------- @@ -207,6 +215,8 @@ unsigned ObjCreatPropList::getAttrCrtOrder() const ///\brief Noop destructor // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -ObjCreatPropList::~ObjCreatPropList() {} +ObjCreatPropList::~ObjCreatPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5OcreatProp.h b/c++/src/H5OcreatProp.h index 1d5dd55..7f6d411 100644 --- a/c++/src/H5OcreatProp.h +++ b/c++/src/H5OcreatProp.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5ObjCreatPropList_H -#define __H5ObjCreatPropList_H +#ifndef H5ObjCreatPropList_H +#define H5ObjCreatPropList_H namespace H5 { @@ -23,53 +23,56 @@ namespace H5 { */ // Inheritance: PropList -> IdComponent class H5_DLLCPP ObjCreatPropList : public PropList { - public: - ///\brief Default object creation property list. - static const ObjCreatPropList& DEFAULT; + public: + ///\brief Default object creation property list. + static const ObjCreatPropList &DEFAULT; - // Creates a object creation property list. - ObjCreatPropList(); + // Creates a object creation property list. + ObjCreatPropList(); - // Sets attribute storage phase change thresholds. - void setAttrPhaseChange(unsigned max_compact = 8, unsigned min_dense = 6) const; + // Sets attribute storage phase change thresholds. + void setAttrPhaseChange(unsigned max_compact = 8, unsigned min_dense = 6) const; - // Gets attribute storage phase change thresholds. - void getAttrPhaseChange(unsigned& max_compact, unsigned& min_dense) const; + // Gets attribute storage phase change thresholds. + void getAttrPhaseChange(unsigned &max_compact, unsigned &min_dense) const; - // Sets tracking and indexing of attribute creation order. - void setAttrCrtOrder(unsigned crt_order_flags) const; + // Sets tracking and indexing of attribute creation order. + void setAttrCrtOrder(unsigned crt_order_flags) const; - // Gets tracking and indexing settings for attribute creation order. - unsigned getAttrCrtOrder() const; + // Gets tracking and indexing settings for attribute creation order. + unsigned getAttrCrtOrder() const; + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("ObjCreatPropList"); + } - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("ObjCreatPropList"); } + // Copy constructor: same as the original ObjCreatPropList. + ObjCreatPropList(const ObjCreatPropList &original); - // Copy constructor: same as the original ObjCreatPropList. - ObjCreatPropList(const ObjCreatPropList& original); + // Creates a copy of an existing object creation property list + // using the property list id. + ObjCreatPropList(const hid_t plist_id); - // Creates a copy of an existing object creation property list - // using the property list id. - ObjCreatPropList (const hid_t plist_id); - - // Noop destructor - virtual ~ObjCreatPropList(); + // Noop destructor + virtual ~ObjCreatPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static ObjCreatPropList* DEFAULT_; + private: + static ObjCreatPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static ObjCreatPropList* getConstant(); + // Creates the global constant, should only be used by the library + static ObjCreatPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of ObjCreatPropList } // namespace H5 -#endif // __H5ObjCreatPropList_H +#endif // H5ObjCreatPropList_H diff --git a/c++/src/H5PredType.cpp b/c++/src/H5PredType.cpp index 57ba5e5..9e67968 100644 --- a/c++/src/H5PredType.cpp +++ b/c++/src/H5PredType.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,6 +27,7 @@ #include "H5DataType.h" #include "H5AtomType.h" #include "H5PredType.h" +#include "H5private.h" namespace H5 { @@ -51,7 +52,9 @@ PredType::PredType(const hid_t predtype_id) : AtomType(predtype_id) ///\brief Default constructor: Creates a stub predefined datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PredType::PredType() : AtomType() {} +PredType::PredType() : AtomType() +{ +} #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- @@ -60,7 +63,9 @@ PredType::PredType() : AtomType() {} ///\param original - IN: PredType instance to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PredType::PredType(const PredType& original) : AtomType(original) {} +PredType::PredType(const PredType &original) : AtomType(original) +{ +} //-------------------------------------------------------------------------- // Function: PredType::operator= @@ -73,29 +78,35 @@ PredType::PredType(const PredType& original) : AtomType(original) {} // the new id in the left hand side object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PredType& PredType::operator=(const PredType& rhs) +PredType & +PredType::operator=(const PredType &rhs) { if (this != &rhs) copy(rhs); - return(*this); + return (*this); } #ifndef DOXYGEN_SHOULD_SKIP_THIS // These dummy functions do not inherit from DataType - they'll // throw an DataTypeIException if invoked. -void PredType::commit(H5Location& loc, const char* name) +void +PredType::commit(H5_ATTR_UNUSED H5Location &loc, H5_ATTR_UNUSED const char *name) { - throw DataTypeIException("PredType::commit", "Error: Attempted to commit a predefined datatype. Invalid operation!"); + throw DataTypeIException("PredType::commit", + "Error: Attempted to commit a predefined datatype. Invalid operation!"); } -void PredType::commit(H5Location& loc, const H5std_string& name) +void +PredType::commit(H5Location &loc, const H5std_string &name) { commit(loc, name.c_str()); } -bool PredType::committed() +bool +PredType::committed() { - throw DataTypeIException("PredType::committed", "Error: Attempting to check for commit status on a predefined datatype."); + throw DataTypeIException("PredType::committed", + "Error: Attempting to check for commit status on a predefined datatype."); } #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -105,7 +116,9 @@ bool PredType::committed() ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PredType::~PredType() {} +PredType::~PredType() +{ +} /***************************************************************************** The following section is regarding the global constants PredType, @@ -115,180 +128,180 @@ PredType::~PredType() {} #ifndef DOXYGEN_SHOULD_SKIP_THIS // Definition pointers for the constants -PredType* PredType::PREDTYPE_CONST_ = 0; //dummy -PredType* PredType::STD_I8BE_; -PredType* PredType::STD_I8LE_; -PredType* PredType::STD_I16BE_; -PredType* PredType::STD_I16LE_; -PredType* PredType::STD_I32BE_; -PredType* PredType::STD_I32LE_; -PredType* PredType::STD_I64BE_; -PredType* PredType::STD_I64LE_; -PredType* PredType::STD_U8BE_; -PredType* PredType::STD_U8LE_; -PredType* PredType::STD_U16BE_; -PredType* PredType::STD_U16LE_; -PredType* PredType::STD_U32BE_; -PredType* PredType::STD_U32LE_; -PredType* PredType::STD_U64BE_; -PredType* PredType::STD_U64LE_; -PredType* PredType::STD_B8BE_; -PredType* PredType::STD_B8LE_; -PredType* PredType::STD_B16BE_; -PredType* PredType::STD_B16LE_; -PredType* PredType::STD_B32BE_; -PredType* PredType::STD_B32LE_; -PredType* PredType::STD_B64BE_; -PredType* PredType::STD_B64LE_; -PredType* PredType::STD_REF_OBJ_; -PredType* PredType::STD_REF_DSETREG_; - -PredType* PredType::C_S1_; -PredType* PredType::FORTRAN_S1_; - -PredType* PredType::IEEE_F32BE_; -PredType* PredType::IEEE_F32LE_; -PredType* PredType::IEEE_F64BE_; -PredType* PredType::IEEE_F64LE_; - -PredType* PredType::UNIX_D32BE_; -PredType* PredType::UNIX_D32LE_; -PredType* PredType::UNIX_D64BE_; -PredType* PredType::UNIX_D64LE_; - -PredType* PredType::INTEL_I8_; -PredType* PredType::INTEL_I16_; -PredType* PredType::INTEL_I32_; -PredType* PredType::INTEL_I64_; -PredType* PredType::INTEL_U8_; -PredType* PredType::INTEL_U16_; -PredType* PredType::INTEL_U32_; -PredType* PredType::INTEL_U64_; -PredType* PredType::INTEL_B8_; -PredType* PredType::INTEL_B16_; -PredType* PredType::INTEL_B32_; -PredType* PredType::INTEL_B64_; -PredType* PredType::INTEL_F32_; -PredType* PredType::INTEL_F64_; - -PredType* PredType::ALPHA_I8_; -PredType* PredType::ALPHA_I16_; -PredType* PredType::ALPHA_I32_; -PredType* PredType::ALPHA_I64_; -PredType* PredType::ALPHA_U8_; -PredType* PredType::ALPHA_U16_; -PredType* PredType::ALPHA_U32_; -PredType* PredType::ALPHA_U64_; -PredType* PredType::ALPHA_B8_; -PredType* PredType::ALPHA_B16_; -PredType* PredType::ALPHA_B32_; -PredType* PredType::ALPHA_B64_; -PredType* PredType::ALPHA_F32_; -PredType* PredType::ALPHA_F64_; - -PredType* PredType::MIPS_I8_; -PredType* PredType::MIPS_I16_; -PredType* PredType::MIPS_I32_; -PredType* PredType::MIPS_I64_; -PredType* PredType::MIPS_U8_; -PredType* PredType::MIPS_U16_; -PredType* PredType::MIPS_U32_; -PredType* PredType::MIPS_U64_; -PredType* PredType::MIPS_B8_; -PredType* PredType::MIPS_B16_; -PredType* PredType::MIPS_B32_; -PredType* PredType::MIPS_B64_; -PredType* PredType::MIPS_F32_; -PredType* PredType::MIPS_F64_; - -PredType* PredType::NATIVE_CHAR_; -PredType* PredType::NATIVE_SCHAR_; -PredType* PredType::NATIVE_UCHAR_; -PredType* PredType::NATIVE_SHORT_; -PredType* PredType::NATIVE_USHORT_; -PredType* PredType::NATIVE_INT_; -PredType* PredType::NATIVE_UINT_; -PredType* PredType::NATIVE_LONG_; -PredType* PredType::NATIVE_ULONG_; -PredType* PredType::NATIVE_LLONG_; -PredType* PredType::NATIVE_ULLONG_; -PredType* PredType::NATIVE_FLOAT_; -PredType* PredType::NATIVE_DOUBLE_; -PredType* PredType::NATIVE_LDOUBLE_; -PredType* PredType::NATIVE_B8_; -PredType* PredType::NATIVE_B16_; -PredType* PredType::NATIVE_B32_; -PredType* PredType::NATIVE_B64_; -PredType* PredType::NATIVE_OPAQUE_; -PredType* PredType::NATIVE_HSIZE_; -PredType* PredType::NATIVE_HSSIZE_; -PredType* PredType::NATIVE_HERR_; -PredType* PredType::NATIVE_HBOOL_; - -PredType* PredType::NATIVE_INT8_; -PredType* PredType::NATIVE_UINT8_; -PredType* PredType::NATIVE_INT16_; -PredType* PredType::NATIVE_UINT16_; -PredType* PredType::NATIVE_INT32_; -PredType* PredType::NATIVE_UINT32_; -PredType* PredType::NATIVE_INT64_; -PredType* PredType::NATIVE_UINT64_; +PredType *PredType::PREDTYPE_CONST_ = 0; // dummy +PredType *PredType::STD_I8BE_; +PredType *PredType::STD_I8LE_; +PredType *PredType::STD_I16BE_; +PredType *PredType::STD_I16LE_; +PredType *PredType::STD_I32BE_; +PredType *PredType::STD_I32LE_; +PredType *PredType::STD_I64BE_; +PredType *PredType::STD_I64LE_; +PredType *PredType::STD_U8BE_; +PredType *PredType::STD_U8LE_; +PredType *PredType::STD_U16BE_; +PredType *PredType::STD_U16LE_; +PredType *PredType::STD_U32BE_; +PredType *PredType::STD_U32LE_; +PredType *PredType::STD_U64BE_; +PredType *PredType::STD_U64LE_; +PredType *PredType::STD_B8BE_; +PredType *PredType::STD_B8LE_; +PredType *PredType::STD_B16BE_; +PredType *PredType::STD_B16LE_; +PredType *PredType::STD_B32BE_; +PredType *PredType::STD_B32LE_; +PredType *PredType::STD_B64BE_; +PredType *PredType::STD_B64LE_; +PredType *PredType::STD_REF_OBJ_; +PredType *PredType::STD_REF_DSETREG_; + +PredType *PredType::C_S1_; +PredType *PredType::FORTRAN_S1_; + +PredType *PredType::IEEE_F32BE_; +PredType *PredType::IEEE_F32LE_; +PredType *PredType::IEEE_F64BE_; +PredType *PredType::IEEE_F64LE_; + +PredType *PredType::UNIX_D32BE_; +PredType *PredType::UNIX_D32LE_; +PredType *PredType::UNIX_D64BE_; +PredType *PredType::UNIX_D64LE_; + +PredType *PredType::INTEL_I8_; +PredType *PredType::INTEL_I16_; +PredType *PredType::INTEL_I32_; +PredType *PredType::INTEL_I64_; +PredType *PredType::INTEL_U8_; +PredType *PredType::INTEL_U16_; +PredType *PredType::INTEL_U32_; +PredType *PredType::INTEL_U64_; +PredType *PredType::INTEL_B8_; +PredType *PredType::INTEL_B16_; +PredType *PredType::INTEL_B32_; +PredType *PredType::INTEL_B64_; +PredType *PredType::INTEL_F32_; +PredType *PredType::INTEL_F64_; + +PredType *PredType::ALPHA_I8_; +PredType *PredType::ALPHA_I16_; +PredType *PredType::ALPHA_I32_; +PredType *PredType::ALPHA_I64_; +PredType *PredType::ALPHA_U8_; +PredType *PredType::ALPHA_U16_; +PredType *PredType::ALPHA_U32_; +PredType *PredType::ALPHA_U64_; +PredType *PredType::ALPHA_B8_; +PredType *PredType::ALPHA_B16_; +PredType *PredType::ALPHA_B32_; +PredType *PredType::ALPHA_B64_; +PredType *PredType::ALPHA_F32_; +PredType *PredType::ALPHA_F64_; + +PredType *PredType::MIPS_I8_; +PredType *PredType::MIPS_I16_; +PredType *PredType::MIPS_I32_; +PredType *PredType::MIPS_I64_; +PredType *PredType::MIPS_U8_; +PredType *PredType::MIPS_U16_; +PredType *PredType::MIPS_U32_; +PredType *PredType::MIPS_U64_; +PredType *PredType::MIPS_B8_; +PredType *PredType::MIPS_B16_; +PredType *PredType::MIPS_B32_; +PredType *PredType::MIPS_B64_; +PredType *PredType::MIPS_F32_; +PredType *PredType::MIPS_F64_; + +PredType *PredType::NATIVE_CHAR_; +PredType *PredType::NATIVE_SCHAR_; +PredType *PredType::NATIVE_UCHAR_; +PredType *PredType::NATIVE_SHORT_; +PredType *PredType::NATIVE_USHORT_; +PredType *PredType::NATIVE_INT_; +PredType *PredType::NATIVE_UINT_; +PredType *PredType::NATIVE_LONG_; +PredType *PredType::NATIVE_ULONG_; +PredType *PredType::NATIVE_LLONG_; +PredType *PredType::NATIVE_ULLONG_; +PredType *PredType::NATIVE_FLOAT_; +PredType *PredType::NATIVE_DOUBLE_; +PredType *PredType::NATIVE_LDOUBLE_; +PredType *PredType::NATIVE_B8_; +PredType *PredType::NATIVE_B16_; +PredType *PredType::NATIVE_B32_; +PredType *PredType::NATIVE_B64_; +PredType *PredType::NATIVE_OPAQUE_; +PredType *PredType::NATIVE_HSIZE_; +PredType *PredType::NATIVE_HSSIZE_; +PredType *PredType::NATIVE_HERR_; +PredType *PredType::NATIVE_HBOOL_; + +PredType *PredType::NATIVE_INT8_; +PredType *PredType::NATIVE_UINT8_; +PredType *PredType::NATIVE_INT16_; +PredType *PredType::NATIVE_UINT16_; +PredType *PredType::NATIVE_INT32_; +PredType *PredType::NATIVE_UINT32_; +PredType *PredType::NATIVE_INT64_; +PredType *PredType::NATIVE_UINT64_; // LEAST types #if H5_SIZEOF_INT_LEAST8_T != 0 -PredType* PredType::NATIVE_INT_LEAST8_; +PredType *PredType::NATIVE_INT_LEAST8_; #endif /* H5_SIZEOF_INT_LEAST8_T */ #if H5_SIZEOF_UINT_LEAST8_T != 0 -PredType* PredType::NATIVE_UINT_LEAST8_; +PredType *PredType::NATIVE_UINT_LEAST8_; #endif /* H5_SIZEOF_UINT_LEAST8_T */ #if H5_SIZEOF_INT_LEAST16_T != 0 -PredType* PredType::NATIVE_INT_LEAST16_; +PredType *PredType::NATIVE_INT_LEAST16_; #endif /* H5_SIZEOF_INT_LEAST16_T */ #if H5_SIZEOF_UINT_LEAST16_T != 0 -PredType* PredType::NATIVE_UINT_LEAST16_; +PredType *PredType::NATIVE_UINT_LEAST16_; #endif /* H5_SIZEOF_UINT_LEAST16_T */ #if H5_SIZEOF_INT_LEAST32_T != 0 -PredType* PredType::NATIVE_INT_LEAST32_; +PredType *PredType::NATIVE_INT_LEAST32_; #endif /* H5_SIZEOF_INT_LEAST32_T */ #if H5_SIZEOF_UINT_LEAST32_T != 0 -PredType* PredType::NATIVE_UINT_LEAST32_; +PredType *PredType::NATIVE_UINT_LEAST32_; #endif /* H5_SIZEOF_UINT_LEAST32_T */ #if H5_SIZEOF_INT_LEAST64_T != 0 -PredType* PredType::NATIVE_INT_LEAST64_; +PredType *PredType::NATIVE_INT_LEAST64_; #endif /* H5_SIZEOF_INT_LEAST64_T */ #if H5_SIZEOF_UINT_LEAST64_T != 0 -PredType* PredType::NATIVE_UINT_LEAST64_; +PredType *PredType::NATIVE_UINT_LEAST64_; #endif /* H5_SIZEOF_UINT_LEAST64_T */ // FAST types #if H5_SIZEOF_INT_FAST8_T != 0 -PredType* PredType::NATIVE_INT_FAST8_; +PredType *PredType::NATIVE_INT_FAST8_; #endif /* H5_SIZEOF_INT_FAST8_T */ #if H5_SIZEOF_UINT_FAST8_T != 0 -PredType* PredType::NATIVE_UINT_FAST8_; +PredType *PredType::NATIVE_UINT_FAST8_; #endif /* H5_SIZEOF_UINT_FAST8_T */ #if H5_SIZEOF_INT_FAST16_T != 0 -PredType* PredType::NATIVE_INT_FAST16_; +PredType *PredType::NATIVE_INT_FAST16_; #endif /* H5_SIZEOF_INT_FAST16_T */ #if H5_SIZEOF_UINT_FAST16_T != 0 -PredType* PredType::NATIVE_UINT_FAST16_; +PredType *PredType::NATIVE_UINT_FAST16_; #endif /* H5_SIZEOF_UINT_FAST16_T */ #if H5_SIZEOF_INT_FAST32_T != 0 -PredType* PredType::NATIVE_INT_FAST32_; +PredType *PredType::NATIVE_INT_FAST32_; #endif /* H5_SIZEOF_INT_FAST32_T */ #if H5_SIZEOF_UINT_FAST32_T != 0 -PredType* PredType::NATIVE_UINT_FAST32_; +PredType *PredType::NATIVE_UINT_FAST32_; #endif /* H5_SIZEOF_UINT_FAST32_T */ #if H5_SIZEOF_INT_FAST64_T != 0 -PredType* PredType::NATIVE_INT_FAST64_; +PredType *PredType::NATIVE_INT_FAST64_; #endif /* H5_SIZEOF_INT_FAST64_T */ #if H5_SIZEOF_UINT_FAST64_T != 0 -PredType* PredType::NATIVE_UINT_FAST64_; +PredType *PredType::NATIVE_UINT_FAST64_; #endif /* H5_SIZEOF_UINT_FAST64_T */ //-------------------------------------------------------------------------- @@ -305,13 +318,13 @@ PredType* PredType::NATIVE_UINT_FAST64_; // // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -PredType* PredType::getPredTypes() +PredType * +PredType::getPredTypes() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -320,7 +333,9 @@ PredType* PredType::getPredTypes() if (PREDTYPE_CONST_ == 0) makePredTypes(); else - throw H5::DataTypeIException("PredType::getPredTypes", "PredType::getPredTypes is being invoked on an allocated PREDTYPE_CONST_"); + throw H5::DataTypeIException( + "PredType::getPredTypes", + "PredType::getPredTypes is being invoked on an allocated PREDTYPE_CONST_"); return PREDTYPE_CONST_; } @@ -329,38 +344,39 @@ PredType* PredType::getPredTypes() // Purpose Allocate all PredType constants. // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -void PredType::makePredTypes() +void +PredType::makePredTypes() { PREDTYPE_CONST_ = new PredType; - C_S1_ = new PredType(H5T_C_S1); - FORTRAN_S1_ = new PredType(H5T_FORTRAN_S1); + C_S1_ = new PredType(H5T_C_S1); + FORTRAN_S1_ = new PredType(H5T_FORTRAN_S1); - STD_I8BE_ = new PredType(H5T_STD_I8BE); - STD_I8LE_ = new PredType(H5T_STD_I8LE); + STD_I8BE_ = new PredType(H5T_STD_I8BE); + STD_I8LE_ = new PredType(H5T_STD_I8LE); STD_I16BE_ = new PredType(H5T_STD_I16BE); STD_I16LE_ = new PredType(H5T_STD_I16LE); STD_I32BE_ = new PredType(H5T_STD_I32BE); STD_I32LE_ = new PredType(H5T_STD_I32LE); STD_I64BE_ = new PredType(H5T_STD_I64BE); STD_I64LE_ = new PredType(H5T_STD_I64LE); - STD_U8BE_ = new PredType(H5T_STD_U8BE); - STD_U8LE_ = new PredType(H5T_STD_U8LE); + STD_U8BE_ = new PredType(H5T_STD_U8BE); + STD_U8LE_ = new PredType(H5T_STD_U8LE); STD_U16BE_ = new PredType(H5T_STD_U16BE); STD_U16LE_ = new PredType(H5T_STD_U16LE); STD_U32BE_ = new PredType(H5T_STD_U32BE); STD_U32LE_ = new PredType(H5T_STD_U32LE); STD_U64BE_ = new PredType(H5T_STD_U64BE); STD_U64LE_ = new PredType(H5T_STD_U64LE); - STD_B8BE_ = new PredType(H5T_STD_B8BE); - STD_B8LE_ = new PredType(H5T_STD_B8LE); - - STD_B16BE_ = new PredType(H5T_STD_B16BE); - STD_B16LE_ = new PredType(H5T_STD_B16LE); - STD_B32BE_ = new PredType(H5T_STD_B32BE); - STD_B32LE_ = new PredType(H5T_STD_B32LE); - STD_B64BE_ = new PredType(H5T_STD_B64BE); - STD_B64LE_ = new PredType(H5T_STD_B64LE); - STD_REF_OBJ_ = new PredType(H5T_STD_REF_OBJ); + STD_B8BE_ = new PredType(H5T_STD_B8BE); + STD_B8LE_ = new PredType(H5T_STD_B8LE); + + STD_B16BE_ = new PredType(H5T_STD_B16BE); + STD_B16LE_ = new PredType(H5T_STD_B16LE); + STD_B32BE_ = new PredType(H5T_STD_B32BE); + STD_B32LE_ = new PredType(H5T_STD_B32LE); + STD_B64BE_ = new PredType(H5T_STD_B64BE); + STD_B64LE_ = new PredType(H5T_STD_B64LE); + STD_REF_OBJ_ = new PredType(H5T_STD_REF_OBJ); STD_REF_DSETREG_ = new PredType(H5T_STD_REF_DSETREG); IEEE_F32BE_ = new PredType(H5T_IEEE_F32BE); @@ -373,84 +389,84 @@ void PredType::makePredTypes() UNIX_D64BE_ = new PredType(H5T_UNIX_D64BE); UNIX_D64LE_ = new PredType(H5T_UNIX_D64LE); - INTEL_I8_ = new PredType(H5T_INTEL_I8); + INTEL_I8_ = new PredType(H5T_INTEL_I8); INTEL_I16_ = new PredType(H5T_INTEL_I16); INTEL_I32_ = new PredType(H5T_INTEL_I32); INTEL_I64_ = new PredType(H5T_INTEL_I64); - INTEL_U8_ = new PredType(H5T_INTEL_U8); + INTEL_U8_ = new PredType(H5T_INTEL_U8); INTEL_U16_ = new PredType(H5T_INTEL_U16); INTEL_U32_ = new PredType(H5T_INTEL_U32); INTEL_U64_ = new PredType(H5T_INTEL_U64); - INTEL_B8_ = new PredType(H5T_INTEL_B8); + INTEL_B8_ = new PredType(H5T_INTEL_B8); INTEL_B16_ = new PredType(H5T_INTEL_B16); INTEL_B32_ = new PredType(H5T_INTEL_B32); INTEL_B64_ = new PredType(H5T_INTEL_B64); INTEL_F32_ = new PredType(H5T_INTEL_F32); INTEL_F64_ = new PredType(H5T_INTEL_F64); - ALPHA_I8_ = new PredType(H5T_ALPHA_I8); + ALPHA_I8_ = new PredType(H5T_ALPHA_I8); ALPHA_I16_ = new PredType(H5T_ALPHA_I16); ALPHA_I32_ = new PredType(H5T_ALPHA_I32); ALPHA_I64_ = new PredType(H5T_ALPHA_I64); - ALPHA_U8_ = new PredType(H5T_ALPHA_U8); + ALPHA_U8_ = new PredType(H5T_ALPHA_U8); ALPHA_U16_ = new PredType(H5T_ALPHA_U16); ALPHA_U32_ = new PredType(H5T_ALPHA_U32); ALPHA_U64_ = new PredType(H5T_ALPHA_U64); - ALPHA_B8_ = new PredType(H5T_ALPHA_B8); + ALPHA_B8_ = new PredType(H5T_ALPHA_B8); ALPHA_B16_ = new PredType(H5T_ALPHA_B16); ALPHA_B32_ = new PredType(H5T_ALPHA_B32); ALPHA_B64_ = new PredType(H5T_ALPHA_B64); ALPHA_F32_ = new PredType(H5T_ALPHA_F32); ALPHA_F64_ = new PredType(H5T_ALPHA_F64); - MIPS_I8_ = new PredType(H5T_MIPS_I8); + MIPS_I8_ = new PredType(H5T_MIPS_I8); MIPS_I16_ = new PredType(H5T_MIPS_I16); MIPS_I32_ = new PredType(H5T_MIPS_I32); MIPS_I64_ = new PredType(H5T_MIPS_I64); - MIPS_U8_ = new PredType(H5T_MIPS_U8); + MIPS_U8_ = new PredType(H5T_MIPS_U8); MIPS_U16_ = new PredType(H5T_MIPS_U16); MIPS_U32_ = new PredType(H5T_MIPS_U32); MIPS_U64_ = new PredType(H5T_MIPS_U64); - MIPS_B8_ = new PredType(H5T_MIPS_B8); + MIPS_B8_ = new PredType(H5T_MIPS_B8); MIPS_B16_ = new PredType(H5T_MIPS_B16); MIPS_B32_ = new PredType(H5T_MIPS_B32); MIPS_B64_ = new PredType(H5T_MIPS_B64); MIPS_F32_ = new PredType(H5T_MIPS_F32); MIPS_F64_ = new PredType(H5T_MIPS_F64); - NATIVE_CHAR_ = new PredType(H5T_NATIVE_CHAR); - NATIVE_INT_ = new PredType(H5T_NATIVE_INT); - NATIVE_FLOAT_ = new PredType(H5T_NATIVE_FLOAT); - NATIVE_SCHAR_ = new PredType(H5T_NATIVE_SCHAR); - NATIVE_UCHAR_ = new PredType(H5T_NATIVE_UCHAR); - NATIVE_SHORT_ = new PredType(H5T_NATIVE_SHORT); + NATIVE_CHAR_ = new PredType(H5T_NATIVE_CHAR); + NATIVE_INT_ = new PredType(H5T_NATIVE_INT); + NATIVE_FLOAT_ = new PredType(H5T_NATIVE_FLOAT); + NATIVE_SCHAR_ = new PredType(H5T_NATIVE_SCHAR); + NATIVE_UCHAR_ = new PredType(H5T_NATIVE_UCHAR); + NATIVE_SHORT_ = new PredType(H5T_NATIVE_SHORT); NATIVE_USHORT_ = new PredType(H5T_NATIVE_USHORT); - NATIVE_UINT_ = new PredType(H5T_NATIVE_UINT); - NATIVE_LONG_ = new PredType(H5T_NATIVE_LONG); - NATIVE_ULONG_ = new PredType(H5T_NATIVE_ULONG); - NATIVE_LLONG_ = new PredType(H5T_NATIVE_LLONG); + NATIVE_UINT_ = new PredType(H5T_NATIVE_UINT); + NATIVE_LONG_ = new PredType(H5T_NATIVE_LONG); + NATIVE_ULONG_ = new PredType(H5T_NATIVE_ULONG); + NATIVE_LLONG_ = new PredType(H5T_NATIVE_LLONG); NATIVE_ULLONG_ = new PredType(H5T_NATIVE_ULLONG); NATIVE_DOUBLE_ = new PredType(H5T_NATIVE_DOUBLE); -#if H5_SIZEOF_LONG_DOUBLE !=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 NATIVE_LDOUBLE_ = new PredType(H5T_NATIVE_LDOUBLE); #endif - NATIVE_B8_ = new PredType(H5T_NATIVE_B8); - NATIVE_B16_ = new PredType(H5T_NATIVE_B16); - NATIVE_B32_ = new PredType(H5T_NATIVE_B32); - NATIVE_B64_ = new PredType(H5T_NATIVE_B64); + NATIVE_B8_ = new PredType(H5T_NATIVE_B8); + NATIVE_B16_ = new PredType(H5T_NATIVE_B16); + NATIVE_B32_ = new PredType(H5T_NATIVE_B32); + NATIVE_B64_ = new PredType(H5T_NATIVE_B64); NATIVE_OPAQUE_ = new PredType(H5T_NATIVE_OPAQUE); - NATIVE_HSIZE_ = new PredType(H5T_NATIVE_HSIZE); + NATIVE_HSIZE_ = new PredType(H5T_NATIVE_HSIZE); NATIVE_HSSIZE_ = new PredType(H5T_NATIVE_HSSIZE); - NATIVE_HERR_ = new PredType(H5T_NATIVE_HERR); - NATIVE_HBOOL_ = new PredType(H5T_NATIVE_HBOOL); + NATIVE_HERR_ = new PredType(H5T_NATIVE_HERR); + NATIVE_HBOOL_ = new PredType(H5T_NATIVE_HBOOL); - NATIVE_INT8_ = new PredType(H5T_NATIVE_INT8); - NATIVE_UINT8_ = new PredType(H5T_NATIVE_UINT8); - NATIVE_INT16_ = new PredType(H5T_NATIVE_INT16); + NATIVE_INT8_ = new PredType(H5T_NATIVE_INT8); + NATIVE_UINT8_ = new PredType(H5T_NATIVE_UINT8); + NATIVE_INT16_ = new PredType(H5T_NATIVE_INT16); NATIVE_UINT16_ = new PredType(H5T_NATIVE_UINT16); - NATIVE_INT32_ = new PredType(H5T_NATIVE_INT32); + NATIVE_INT32_ = new PredType(H5T_NATIVE_INT32); NATIVE_UINT32_ = new PredType(H5T_NATIVE_UINT32); - NATIVE_INT64_ = new PredType(H5T_NATIVE_INT64); + NATIVE_INT64_ = new PredType(H5T_NATIVE_INT64); NATIVE_UINT64_ = new PredType(H5T_NATIVE_UINT64); // LEAST types @@ -513,13 +529,13 @@ void PredType::makePredTypes() } // makePredTypes - //-------------------------------------------------------------------------- // Function: PredType::deleteConstants // Purpose Deletes all PredType constant pointers. // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -void PredType::deleteConstants() +void +PredType::deleteConstants() { delete STD_I8BE_; delete STD_I8LE_; @@ -709,186 +725,186 @@ void PredType::deleteConstants() // PredType constants. Note that, there is a similar function to getPredTypes() // in other classes, that have global constants, is called getConstant(). -const PredType& PredType::PREDTYPE_CONST = *PredType::getPredTypes(); -const PredType& PredType::STD_I8BE = *STD_I8BE_; -const PredType& PredType::STD_I8LE = *STD_I8LE_; -const PredType& PredType::STD_I16BE = *STD_I16BE_; -const PredType& PredType::STD_I16LE = *STD_I16LE_; -const PredType& PredType::STD_I32BE = *STD_I32BE_; -const PredType& PredType::STD_I32LE = *STD_I32LE_; -const PredType& PredType::STD_I64BE = *STD_I64BE_; -const PredType& PredType::STD_I64LE = *STD_I64LE_; -const PredType& PredType::STD_U8BE = *STD_U8BE_; -const PredType& PredType::STD_U8LE = *STD_U8LE_; -const PredType& PredType::STD_U16BE = *STD_U16BE_; -const PredType& PredType::STD_U16LE = *STD_U16LE_; -const PredType& PredType::STD_U32BE = *STD_U32BE_; -const PredType& PredType::STD_U32LE = *STD_U32LE_; -const PredType& PredType::STD_U64BE = *STD_U64BE_; -const PredType& PredType::STD_U64LE = *STD_U64LE_; -const PredType& PredType::STD_B8BE = *STD_B8BE_; -const PredType& PredType::STD_B8LE = *STD_B8LE_; -const PredType& PredType::STD_B16BE = *STD_B16BE_; -const PredType& PredType::STD_B16LE = *STD_B16LE_; -const PredType& PredType::STD_B32BE = *STD_B32BE_; -const PredType& PredType::STD_B32LE = *STD_B32LE_; -const PredType& PredType::STD_B64BE = *STD_B64BE_; -const PredType& PredType::STD_B64LE = *STD_B64LE_; -const PredType& PredType::STD_REF_OBJ = *STD_REF_OBJ_; -const PredType& PredType::STD_REF_DSETREG = *STD_REF_DSETREG_; - -const PredType& PredType::C_S1 = *C_S1_; -const PredType& PredType::FORTRAN_S1 = *FORTRAN_S1_; - -const PredType& PredType::IEEE_F32BE = *IEEE_F32BE_; -const PredType& PredType::IEEE_F32LE = *IEEE_F32LE_; -const PredType& PredType::IEEE_F64BE = *IEEE_F64BE_; -const PredType& PredType::IEEE_F64LE = *IEEE_F64LE_; - -const PredType& PredType::UNIX_D32BE = *UNIX_D32BE_; -const PredType& PredType::UNIX_D32LE = *UNIX_D32LE_; -const PredType& PredType::UNIX_D64BE = *UNIX_D64BE_; -const PredType& PredType::UNIX_D64LE = *UNIX_D64LE_; - -const PredType& PredType::INTEL_I8 = *INTEL_I8_; -const PredType& PredType::INTEL_I16 = *INTEL_I16_; -const PredType& PredType::INTEL_I32 = *INTEL_I32_; -const PredType& PredType::INTEL_I64 = *INTEL_I64_; -const PredType& PredType::INTEL_U8 = *INTEL_U8_; -const PredType& PredType::INTEL_U16 = *INTEL_U16_; -const PredType& PredType::INTEL_U32 = *INTEL_U32_; -const PredType& PredType::INTEL_U64 = *INTEL_U64_; -const PredType& PredType::INTEL_B8 = *INTEL_B8_; -const PredType& PredType::INTEL_B16 = *INTEL_B16_; -const PredType& PredType::INTEL_B32 = *INTEL_B32_; -const PredType& PredType::INTEL_B64 = *INTEL_B64_; -const PredType& PredType::INTEL_F32 = *INTEL_F32_; -const PredType& PredType::INTEL_F64 = *INTEL_F64_; - -const PredType& PredType::ALPHA_I8 = *ALPHA_I8_; -const PredType& PredType::ALPHA_I16 = *ALPHA_I16_; -const PredType& PredType::ALPHA_I32 = *ALPHA_I32_; -const PredType& PredType::ALPHA_I64 = *ALPHA_I64_; -const PredType& PredType::ALPHA_U8 = *ALPHA_U8_; -const PredType& PredType::ALPHA_U16 = *ALPHA_U16_; -const PredType& PredType::ALPHA_U32 = *ALPHA_U32_; -const PredType& PredType::ALPHA_U64 = *ALPHA_U64_; -const PredType& PredType::ALPHA_B8 = *ALPHA_B8_; -const PredType& PredType::ALPHA_B16 = *ALPHA_B16_; -const PredType& PredType::ALPHA_B32 = *ALPHA_B32_; -const PredType& PredType::ALPHA_B64 = *ALPHA_B64_; -const PredType& PredType::ALPHA_F32 = *ALPHA_F32_; -const PredType& PredType::ALPHA_F64 = *ALPHA_F64_; - -const PredType& PredType::MIPS_I8 = *MIPS_I8_; -const PredType& PredType::MIPS_I16 = *MIPS_I16_; -const PredType& PredType::MIPS_I32 = *MIPS_I32_; -const PredType& PredType::MIPS_I64 = *MIPS_I64_; -const PredType& PredType::MIPS_U8 = *MIPS_U8_; -const PredType& PredType::MIPS_U16 = *MIPS_U16_; -const PredType& PredType::MIPS_U32 = *MIPS_U32_; -const PredType& PredType::MIPS_U64 = *MIPS_U64_; -const PredType& PredType::MIPS_B8 = *MIPS_B8_; -const PredType& PredType::MIPS_B16 = *MIPS_B16_; -const PredType& PredType::MIPS_B32 = *MIPS_B32_; -const PredType& PredType::MIPS_B64 = *MIPS_B64_; -const PredType& PredType::MIPS_F32 = *MIPS_F32_; -const PredType& PredType::MIPS_F64 = *MIPS_F64_; - -const PredType& PredType::NATIVE_CHAR = *NATIVE_CHAR_; -const PredType& PredType::NATIVE_SCHAR = *NATIVE_SCHAR_; -const PredType& PredType::NATIVE_UCHAR = *NATIVE_UCHAR_; -const PredType& PredType::NATIVE_SHORT = *NATIVE_SHORT_; -const PredType& PredType::NATIVE_USHORT = *NATIVE_USHORT_; -const PredType& PredType::NATIVE_INT = *NATIVE_INT_; -const PredType& PredType::NATIVE_UINT = *NATIVE_UINT_; -const PredType& PredType::NATIVE_LONG = *NATIVE_LONG_; -const PredType& PredType::NATIVE_ULONG = *NATIVE_ULONG_; -const PredType& PredType::NATIVE_LLONG = *NATIVE_LLONG_; -const PredType& PredType::NATIVE_ULLONG = *NATIVE_ULLONG_; -const PredType& PredType::NATIVE_FLOAT = *NATIVE_FLOAT_; -const PredType& PredType::NATIVE_DOUBLE = *NATIVE_DOUBLE_; -const PredType& PredType::NATIVE_LDOUBLE = *NATIVE_LDOUBLE_; -const PredType& PredType::NATIVE_B8 = *NATIVE_B8_; -const PredType& PredType::NATIVE_B16 = *NATIVE_B16_; -const PredType& PredType::NATIVE_B32 = *NATIVE_B32_; -const PredType& PredType::NATIVE_B64 = *NATIVE_B64_; -const PredType& PredType::NATIVE_OPAQUE = *NATIVE_OPAQUE_; -const PredType& PredType::NATIVE_HSIZE = *NATIVE_HSIZE_; -const PredType& PredType::NATIVE_HSSIZE = *NATIVE_HSSIZE_; -const PredType& PredType::NATIVE_HERR = *NATIVE_HERR_; -const PredType& PredType::NATIVE_HBOOL = *NATIVE_HBOOL_; - -const PredType& PredType::NATIVE_INT8 = *NATIVE_INT8_; -const PredType& PredType::NATIVE_UINT8 = *NATIVE_UINT8_; -const PredType& PredType::NATIVE_INT16 = *NATIVE_INT16_; -const PredType& PredType::NATIVE_UINT16 = *NATIVE_UINT16_; -const PredType& PredType::NATIVE_INT32 = *NATIVE_INT32_; -const PredType& PredType::NATIVE_UINT32 = *NATIVE_UINT32_; -const PredType& PredType::NATIVE_INT64 = *NATIVE_INT64_; -const PredType& PredType::NATIVE_UINT64 = *NATIVE_UINT64_; +const PredType &PredType::PREDTYPE_CONST = *PredType::getPredTypes(); +const PredType &PredType::STD_I8BE = *STD_I8BE_; +const PredType &PredType::STD_I8LE = *STD_I8LE_; +const PredType &PredType::STD_I16BE = *STD_I16BE_; +const PredType &PredType::STD_I16LE = *STD_I16LE_; +const PredType &PredType::STD_I32BE = *STD_I32BE_; +const PredType &PredType::STD_I32LE = *STD_I32LE_; +const PredType &PredType::STD_I64BE = *STD_I64BE_; +const PredType &PredType::STD_I64LE = *STD_I64LE_; +const PredType &PredType::STD_U8BE = *STD_U8BE_; +const PredType &PredType::STD_U8LE = *STD_U8LE_; +const PredType &PredType::STD_U16BE = *STD_U16BE_; +const PredType &PredType::STD_U16LE = *STD_U16LE_; +const PredType &PredType::STD_U32BE = *STD_U32BE_; +const PredType &PredType::STD_U32LE = *STD_U32LE_; +const PredType &PredType::STD_U64BE = *STD_U64BE_; +const PredType &PredType::STD_U64LE = *STD_U64LE_; +const PredType &PredType::STD_B8BE = *STD_B8BE_; +const PredType &PredType::STD_B8LE = *STD_B8LE_; +const PredType &PredType::STD_B16BE = *STD_B16BE_; +const PredType &PredType::STD_B16LE = *STD_B16LE_; +const PredType &PredType::STD_B32BE = *STD_B32BE_; +const PredType &PredType::STD_B32LE = *STD_B32LE_; +const PredType &PredType::STD_B64BE = *STD_B64BE_; +const PredType &PredType::STD_B64LE = *STD_B64LE_; +const PredType &PredType::STD_REF_OBJ = *STD_REF_OBJ_; +const PredType &PredType::STD_REF_DSETREG = *STD_REF_DSETREG_; + +const PredType &PredType::C_S1 = *C_S1_; +const PredType &PredType::FORTRAN_S1 = *FORTRAN_S1_; + +const PredType &PredType::IEEE_F32BE = *IEEE_F32BE_; +const PredType &PredType::IEEE_F32LE = *IEEE_F32LE_; +const PredType &PredType::IEEE_F64BE = *IEEE_F64BE_; +const PredType &PredType::IEEE_F64LE = *IEEE_F64LE_; + +const PredType &PredType::UNIX_D32BE = *UNIX_D32BE_; +const PredType &PredType::UNIX_D32LE = *UNIX_D32LE_; +const PredType &PredType::UNIX_D64BE = *UNIX_D64BE_; +const PredType &PredType::UNIX_D64LE = *UNIX_D64LE_; + +const PredType &PredType::INTEL_I8 = *INTEL_I8_; +const PredType &PredType::INTEL_I16 = *INTEL_I16_; +const PredType &PredType::INTEL_I32 = *INTEL_I32_; +const PredType &PredType::INTEL_I64 = *INTEL_I64_; +const PredType &PredType::INTEL_U8 = *INTEL_U8_; +const PredType &PredType::INTEL_U16 = *INTEL_U16_; +const PredType &PredType::INTEL_U32 = *INTEL_U32_; +const PredType &PredType::INTEL_U64 = *INTEL_U64_; +const PredType &PredType::INTEL_B8 = *INTEL_B8_; +const PredType &PredType::INTEL_B16 = *INTEL_B16_; +const PredType &PredType::INTEL_B32 = *INTEL_B32_; +const PredType &PredType::INTEL_B64 = *INTEL_B64_; +const PredType &PredType::INTEL_F32 = *INTEL_F32_; +const PredType &PredType::INTEL_F64 = *INTEL_F64_; + +const PredType &PredType::ALPHA_I8 = *ALPHA_I8_; +const PredType &PredType::ALPHA_I16 = *ALPHA_I16_; +const PredType &PredType::ALPHA_I32 = *ALPHA_I32_; +const PredType &PredType::ALPHA_I64 = *ALPHA_I64_; +const PredType &PredType::ALPHA_U8 = *ALPHA_U8_; +const PredType &PredType::ALPHA_U16 = *ALPHA_U16_; +const PredType &PredType::ALPHA_U32 = *ALPHA_U32_; +const PredType &PredType::ALPHA_U64 = *ALPHA_U64_; +const PredType &PredType::ALPHA_B8 = *ALPHA_B8_; +const PredType &PredType::ALPHA_B16 = *ALPHA_B16_; +const PredType &PredType::ALPHA_B32 = *ALPHA_B32_; +const PredType &PredType::ALPHA_B64 = *ALPHA_B64_; +const PredType &PredType::ALPHA_F32 = *ALPHA_F32_; +const PredType &PredType::ALPHA_F64 = *ALPHA_F64_; + +const PredType &PredType::MIPS_I8 = *MIPS_I8_; +const PredType &PredType::MIPS_I16 = *MIPS_I16_; +const PredType &PredType::MIPS_I32 = *MIPS_I32_; +const PredType &PredType::MIPS_I64 = *MIPS_I64_; +const PredType &PredType::MIPS_U8 = *MIPS_U8_; +const PredType &PredType::MIPS_U16 = *MIPS_U16_; +const PredType &PredType::MIPS_U32 = *MIPS_U32_; +const PredType &PredType::MIPS_U64 = *MIPS_U64_; +const PredType &PredType::MIPS_B8 = *MIPS_B8_; +const PredType &PredType::MIPS_B16 = *MIPS_B16_; +const PredType &PredType::MIPS_B32 = *MIPS_B32_; +const PredType &PredType::MIPS_B64 = *MIPS_B64_; +const PredType &PredType::MIPS_F32 = *MIPS_F32_; +const PredType &PredType::MIPS_F64 = *MIPS_F64_; + +const PredType &PredType::NATIVE_CHAR = *NATIVE_CHAR_; +const PredType &PredType::NATIVE_SCHAR = *NATIVE_SCHAR_; +const PredType &PredType::NATIVE_UCHAR = *NATIVE_UCHAR_; +const PredType &PredType::NATIVE_SHORT = *NATIVE_SHORT_; +const PredType &PredType::NATIVE_USHORT = *NATIVE_USHORT_; +const PredType &PredType::NATIVE_INT = *NATIVE_INT_; +const PredType &PredType::NATIVE_UINT = *NATIVE_UINT_; +const PredType &PredType::NATIVE_LONG = *NATIVE_LONG_; +const PredType &PredType::NATIVE_ULONG = *NATIVE_ULONG_; +const PredType &PredType::NATIVE_LLONG = *NATIVE_LLONG_; +const PredType &PredType::NATIVE_ULLONG = *NATIVE_ULLONG_; +const PredType &PredType::NATIVE_FLOAT = *NATIVE_FLOAT_; +const PredType &PredType::NATIVE_DOUBLE = *NATIVE_DOUBLE_; +const PredType &PredType::NATIVE_LDOUBLE = *NATIVE_LDOUBLE_; +const PredType &PredType::NATIVE_B8 = *NATIVE_B8_; +const PredType &PredType::NATIVE_B16 = *NATIVE_B16_; +const PredType &PredType::NATIVE_B32 = *NATIVE_B32_; +const PredType &PredType::NATIVE_B64 = *NATIVE_B64_; +const PredType &PredType::NATIVE_OPAQUE = *NATIVE_OPAQUE_; +const PredType &PredType::NATIVE_HSIZE = *NATIVE_HSIZE_; +const PredType &PredType::NATIVE_HSSIZE = *NATIVE_HSSIZE_; +const PredType &PredType::NATIVE_HERR = *NATIVE_HERR_; +const PredType &PredType::NATIVE_HBOOL = *NATIVE_HBOOL_; + +const PredType &PredType::NATIVE_INT8 = *NATIVE_INT8_; +const PredType &PredType::NATIVE_UINT8 = *NATIVE_UINT8_; +const PredType &PredType::NATIVE_INT16 = *NATIVE_INT16_; +const PredType &PredType::NATIVE_UINT16 = *NATIVE_UINT16_; +const PredType &PredType::NATIVE_INT32 = *NATIVE_INT32_; +const PredType &PredType::NATIVE_UINT32 = *NATIVE_UINT32_; +const PredType &PredType::NATIVE_INT64 = *NATIVE_INT64_; +const PredType &PredType::NATIVE_UINT64 = *NATIVE_UINT64_; // LEAST types #if H5_SIZEOF_INT_LEAST8_T != 0 -const PredType& PredType::NATIVE_INT_LEAST8 = *NATIVE_INT_LEAST8_; +const PredType &PredType::NATIVE_INT_LEAST8 = *NATIVE_INT_LEAST8_; #endif /* H5_SIZEOF_INT_LEAST8_T */ #if H5_SIZEOF_UINT_LEAST8_T != 0 -const PredType& PredType::NATIVE_UINT_LEAST8 = *NATIVE_UINT_LEAST8_; +const PredType &PredType::NATIVE_UINT_LEAST8 = *NATIVE_UINT_LEAST8_; #endif /* H5_SIZEOF_UINT_LEAST8_T */ #if H5_SIZEOF_INT_LEAST16_T != 0 -const PredType& PredType::NATIVE_INT_LEAST16 = *NATIVE_INT_LEAST16_; +const PredType &PredType::NATIVE_INT_LEAST16 = *NATIVE_INT_LEAST16_; #endif /* H5_SIZEOF_INT_LEAST16_T */ #if H5_SIZEOF_UINT_LEAST16_T != 0 -const PredType& PredType::NATIVE_UINT_LEAST16 = *NATIVE_UINT_LEAST16_; +const PredType &PredType::NATIVE_UINT_LEAST16 = *NATIVE_UINT_LEAST16_; #endif /* H5_SIZEOF_UINT_LEAST16_T */ #if H5_SIZEOF_INT_LEAST32_T != 0 -const PredType& PredType::NATIVE_INT_LEAST32 = *NATIVE_INT_LEAST32_; +const PredType &PredType::NATIVE_INT_LEAST32 = *NATIVE_INT_LEAST32_; #endif /* H5_SIZEOF_INT_LEAST32_T */ #if H5_SIZEOF_UINT_LEAST32_T != 0 -const PredType& PredType::NATIVE_UINT_LEAST32 = *NATIVE_UINT_LEAST32_; +const PredType &PredType::NATIVE_UINT_LEAST32 = *NATIVE_UINT_LEAST32_; #endif /* H5_SIZEOF_UINT_LEAST32_T */ #if H5_SIZEOF_INT_LEAST64_T != 0 -const PredType& PredType::NATIVE_INT_LEAST64 = *NATIVE_INT_LEAST64_; +const PredType &PredType::NATIVE_INT_LEAST64 = *NATIVE_INT_LEAST64_; #endif /* H5_SIZEOF_INT_LEAST64_T */ #if H5_SIZEOF_UINT_LEAST64_T != 0 -const PredType& PredType::NATIVE_UINT_LEAST64 = *NATIVE_UINT_LEAST64_; +const PredType &PredType::NATIVE_UINT_LEAST64 = *NATIVE_UINT_LEAST64_; #endif /* H5_SIZEOF_UINT_LEAST64_T */ // FAST types #if H5_SIZEOF_INT_FAST8_T != 0 -const PredType& PredType::NATIVE_INT_FAST8 = *NATIVE_INT_FAST8_; +const PredType &PredType::NATIVE_INT_FAST8 = *NATIVE_INT_FAST8_; #endif /* H5_SIZEOF_INT_FAST8_T */ #if H5_SIZEOF_UINT_FAST8_T != 0 -const PredType& PredType::NATIVE_UINT_FAST8 = *NATIVE_UINT_FAST8_; +const PredType &PredType::NATIVE_UINT_FAST8 = *NATIVE_UINT_FAST8_; #endif /* H5_SIZEOF_UINT_FAST8_T */ #if H5_SIZEOF_INT_FAST16_T != 0 -const PredType& PredType::NATIVE_INT_FAST16 = *NATIVE_INT_FAST16_; +const PredType &PredType::NATIVE_INT_FAST16 = *NATIVE_INT_FAST16_; #endif /* H5_SIZEOF_INT_FAST16_T */ #if H5_SIZEOF_UINT_FAST16_T != 0 -const PredType& PredType::NATIVE_UINT_FAST16 = *NATIVE_UINT_FAST16_; +const PredType &PredType::NATIVE_UINT_FAST16 = *NATIVE_UINT_FAST16_; #endif /* H5_SIZEOF_UINT_FAST16_T */ #if H5_SIZEOF_INT_FAST32_T != 0 -const PredType& PredType::NATIVE_INT_FAST32 = *NATIVE_INT_FAST32_; +const PredType &PredType::NATIVE_INT_FAST32 = *NATIVE_INT_FAST32_; #endif /* H5_SIZEOF_INT_FAST32_T */ #if H5_SIZEOF_UINT_FAST32_T != 0 -const PredType& PredType::NATIVE_UINT_FAST32 = *NATIVE_UINT_FAST32_; +const PredType &PredType::NATIVE_UINT_FAST32 = *NATIVE_UINT_FAST32_; #endif /* H5_SIZEOF_UINT_FAST32_T */ #if H5_SIZEOF_INT_FAST64_T != 0 -const PredType& PredType::NATIVE_INT_FAST64 = *NATIVE_INT_FAST64_; +const PredType &PredType::NATIVE_INT_FAST64 = *NATIVE_INT_FAST64_; #endif /* H5_SIZEOF_INT_FAST64_T */ #if H5_SIZEOF_UINT_FAST64_T != 0 -const PredType& PredType::NATIVE_UINT_FAST64 = *NATIVE_UINT_FAST64_; +const PredType &PredType::NATIVE_UINT_FAST64 = *NATIVE_UINT_FAST64_; #endif /* H5_SIZEOF_UINT_FAST64_T */ #endif // DOXYGEN_SHOULD_SKIP_THIS -} // end namespace +} // namespace H5 /*************************************************************************** Design Note @@ -1102,4 +1118,3 @@ September 2015: using PropList's because of the class types and in favor of clarity. ****************************************************************************/ - diff --git a/c++/src/H5PredType.h b/c++/src/H5PredType.h index 0978384..b40d2b3 100644 --- a/c++/src/H5PredType.h +++ b/c++/src/H5PredType.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5PredType_H -#define __H5PredType_H +#ifndef H5PredType_H +#define H5PredType_H namespace H5 { @@ -26,416 +26,420 @@ namespace H5 { */ // Inheritance: AtomType -> DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP PredType : public AtomType { - public: - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("PredType"); } - - // Makes a copy of the predefined type and stores the new - // id in the left hand side object. - PredType& operator=(const PredType& rhs); - - // Copy constructor: same as the original PredType. - PredType(const PredType& original); - - // Noop destructor - virtual ~PredType(); - - /*! \brief This dummy function do not inherit from DataType - it will - throw a DataTypeIException if invoked. - */ - void commit(H5Location& loc, const H5std_string& name); - /*! \brief This dummy function do not inherit from DataType - it will - throw a DataTypeIException if invoked. - */ - void commit(H5Location& loc, const char* name); - /*! \brief This dummy function do not inherit from DataType - it will - throw a DataTypeIException if invoked. - */ - bool committed(); - - ///\brief PredType constants - static const PredType& STD_I8BE; - static const PredType& STD_I8LE; - static const PredType& STD_I16BE; - static const PredType& STD_I16LE; - static const PredType& STD_I32BE; - static const PredType& STD_I32LE; - static const PredType& STD_I64BE; - static const PredType& STD_I64LE; - static const PredType& STD_U8BE; - static const PredType& STD_U8LE; - static const PredType& STD_U16BE; - static const PredType& STD_U16LE; - static const PredType& STD_U32BE; - static const PredType& STD_U32LE; - static const PredType& STD_U64BE; - static const PredType& STD_U64LE; - static const PredType& STD_B8BE; - static const PredType& STD_B8LE; - static const PredType& STD_B16BE; - static const PredType& STD_B16LE; - static const PredType& STD_B32BE; - static const PredType& STD_B32LE; - static const PredType& STD_B64BE; - static const PredType& STD_B64LE; - static const PredType& STD_REF_OBJ; - static const PredType& STD_REF_DSETREG; - - static const PredType& C_S1; - static const PredType& FORTRAN_S1; - - static const PredType& IEEE_F32BE; - static const PredType& IEEE_F32LE; - static const PredType& IEEE_F64BE; - static const PredType& IEEE_F64LE; - - static const PredType& UNIX_D32BE; - static const PredType& UNIX_D32LE; - static const PredType& UNIX_D64BE; - static const PredType& UNIX_D64LE; - - static const PredType& INTEL_I8; - static const PredType& INTEL_I16; - static const PredType& INTEL_I32; - static const PredType& INTEL_I64; - static const PredType& INTEL_U8; - static const PredType& INTEL_U16; - static const PredType& INTEL_U32; - static const PredType& INTEL_U64; - static const PredType& INTEL_B8; - static const PredType& INTEL_B16; - static const PredType& INTEL_B32; - static const PredType& INTEL_B64; - static const PredType& INTEL_F32; - static const PredType& INTEL_F64; - - static const PredType& ALPHA_I8; - static const PredType& ALPHA_I16; - static const PredType& ALPHA_I32; - static const PredType& ALPHA_I64; - static const PredType& ALPHA_U8; - static const PredType& ALPHA_U16; - static const PredType& ALPHA_U32; - static const PredType& ALPHA_U64; - static const PredType& ALPHA_B8; - static const PredType& ALPHA_B16; - static const PredType& ALPHA_B32; - static const PredType& ALPHA_B64; - static const PredType& ALPHA_F32; - static const PredType& ALPHA_F64; - - static const PredType& MIPS_I8; - static const PredType& MIPS_I16; - static const PredType& MIPS_I32; - static const PredType& MIPS_I64; - static const PredType& MIPS_U8; - static const PredType& MIPS_U16; - static const PredType& MIPS_U32; - static const PredType& MIPS_U64; - static const PredType& MIPS_B8; - static const PredType& MIPS_B16; - static const PredType& MIPS_B32; - static const PredType& MIPS_B64; - static const PredType& MIPS_F32; - static const PredType& MIPS_F64; - - static const PredType& NATIVE_CHAR; - static const PredType& NATIVE_SCHAR; - static const PredType& NATIVE_UCHAR; - static const PredType& NATIVE_SHORT; - static const PredType& NATIVE_USHORT; - static const PredType& NATIVE_INT; - static const PredType& NATIVE_UINT; - static const PredType& NATIVE_LONG; - static const PredType& NATIVE_ULONG; - static const PredType& NATIVE_LLONG; - static const PredType& NATIVE_ULLONG; - static const PredType& NATIVE_FLOAT; - static const PredType& NATIVE_DOUBLE; - static const PredType& NATIVE_LDOUBLE; - static const PredType& NATIVE_B8; - static const PredType& NATIVE_B16; - static const PredType& NATIVE_B32; - static const PredType& NATIVE_B64; - static const PredType& NATIVE_OPAQUE; - static const PredType& NATIVE_HSIZE; - static const PredType& NATIVE_HSSIZE; - static const PredType& NATIVE_HERR; - static const PredType& NATIVE_HBOOL; - - static const PredType& NATIVE_INT8; - static const PredType& NATIVE_UINT8; - static const PredType& NATIVE_INT16; - static const PredType& NATIVE_UINT16; - static const PredType& NATIVE_INT32; - static const PredType& NATIVE_UINT32; - static const PredType& NATIVE_INT64; - static const PredType& NATIVE_UINT64; + public: + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("PredType"); + } + + // Makes a copy of the predefined type and stores the new + // id in the left hand side object. + PredType &operator=(const PredType &rhs); + + // Copy constructor: same as the original PredType. + PredType(const PredType &original); + + // Noop destructor + virtual ~PredType(); + + /*! \brief This dummy function do not inherit from DataType - it will + throw a DataTypeIException if invoked. + */ + void commit(H5Location &loc, const H5std_string &name); + /*! \brief This dummy function do not inherit from DataType - it will + throw a DataTypeIException if invoked. + */ + void commit(H5Location &loc, const char *name); + /*! \brief This dummy function do not inherit from DataType - it will + throw a DataTypeIException if invoked. + */ + bool committed(); + + ///\brief PredType constants + static const PredType &STD_I8BE; + static const PredType &STD_I8LE; + static const PredType &STD_I16BE; + static const PredType &STD_I16LE; + static const PredType &STD_I32BE; + static const PredType &STD_I32LE; + static const PredType &STD_I64BE; + static const PredType &STD_I64LE; + static const PredType &STD_U8BE; + static const PredType &STD_U8LE; + static const PredType &STD_U16BE; + static const PredType &STD_U16LE; + static const PredType &STD_U32BE; + static const PredType &STD_U32LE; + static const PredType &STD_U64BE; + static const PredType &STD_U64LE; + static const PredType &STD_B8BE; + static const PredType &STD_B8LE; + static const PredType &STD_B16BE; + static const PredType &STD_B16LE; + static const PredType &STD_B32BE; + static const PredType &STD_B32LE; + static const PredType &STD_B64BE; + static const PredType &STD_B64LE; + static const PredType &STD_REF_OBJ; + static const PredType &STD_REF_DSETREG; + + static const PredType &C_S1; + static const PredType &FORTRAN_S1; + + static const PredType &IEEE_F32BE; + static const PredType &IEEE_F32LE; + static const PredType &IEEE_F64BE; + static const PredType &IEEE_F64LE; + + static const PredType &UNIX_D32BE; + static const PredType &UNIX_D32LE; + static const PredType &UNIX_D64BE; + static const PredType &UNIX_D64LE; + + static const PredType &INTEL_I8; + static const PredType &INTEL_I16; + static const PredType &INTEL_I32; + static const PredType &INTEL_I64; + static const PredType &INTEL_U8; + static const PredType &INTEL_U16; + static const PredType &INTEL_U32; + static const PredType &INTEL_U64; + static const PredType &INTEL_B8; + static const PredType &INTEL_B16; + static const PredType &INTEL_B32; + static const PredType &INTEL_B64; + static const PredType &INTEL_F32; + static const PredType &INTEL_F64; + + static const PredType &ALPHA_I8; + static const PredType &ALPHA_I16; + static const PredType &ALPHA_I32; + static const PredType &ALPHA_I64; + static const PredType &ALPHA_U8; + static const PredType &ALPHA_U16; + static const PredType &ALPHA_U32; + static const PredType &ALPHA_U64; + static const PredType &ALPHA_B8; + static const PredType &ALPHA_B16; + static const PredType &ALPHA_B32; + static const PredType &ALPHA_B64; + static const PredType &ALPHA_F32; + static const PredType &ALPHA_F64; + + static const PredType &MIPS_I8; + static const PredType &MIPS_I16; + static const PredType &MIPS_I32; + static const PredType &MIPS_I64; + static const PredType &MIPS_U8; + static const PredType &MIPS_U16; + static const PredType &MIPS_U32; + static const PredType &MIPS_U64; + static const PredType &MIPS_B8; + static const PredType &MIPS_B16; + static const PredType &MIPS_B32; + static const PredType &MIPS_B64; + static const PredType &MIPS_F32; + static const PredType &MIPS_F64; + + static const PredType &NATIVE_CHAR; + static const PredType &NATIVE_SCHAR; + static const PredType &NATIVE_UCHAR; + static const PredType &NATIVE_SHORT; + static const PredType &NATIVE_USHORT; + static const PredType &NATIVE_INT; + static const PredType &NATIVE_UINT; + static const PredType &NATIVE_LONG; + static const PredType &NATIVE_ULONG; + static const PredType &NATIVE_LLONG; + static const PredType &NATIVE_ULLONG; + static const PredType &NATIVE_FLOAT; + static const PredType &NATIVE_DOUBLE; + static const PredType &NATIVE_LDOUBLE; + static const PredType &NATIVE_B8; + static const PredType &NATIVE_B16; + static const PredType &NATIVE_B32; + static const PredType &NATIVE_B64; + static const PredType &NATIVE_OPAQUE; + static const PredType &NATIVE_HSIZE; + static const PredType &NATIVE_HSSIZE; + static const PredType &NATIVE_HERR; + static const PredType &NATIVE_HBOOL; + + static const PredType &NATIVE_INT8; + static const PredType &NATIVE_UINT8; + static const PredType &NATIVE_INT16; + static const PredType &NATIVE_UINT16; + static const PredType &NATIVE_INT32; + static const PredType &NATIVE_UINT32; + static const PredType &NATIVE_INT64; + static const PredType &NATIVE_UINT64; // LEAST types #if H5_SIZEOF_INT_LEAST8_T != 0 - static const PredType& NATIVE_INT_LEAST8; + static const PredType &NATIVE_INT_LEAST8; #endif /* H5_SIZEOF_INT_LEAST8_T */ #if H5_SIZEOF_UINT_LEAST8_T != 0 - static const PredType& NATIVE_UINT_LEAST8; + static const PredType &NATIVE_UINT_LEAST8; #endif /* H5_SIZEOF_UINT_LEAST8_T */ #if H5_SIZEOF_INT_LEAST16_T != 0 - static const PredType& NATIVE_INT_LEAST16; + static const PredType &NATIVE_INT_LEAST16; #endif /* H5_SIZEOF_INT_LEAST16_T */ #if H5_SIZEOF_UINT_LEAST16_T != 0 - static const PredType& NATIVE_UINT_LEAST16; + static const PredType &NATIVE_UINT_LEAST16; #endif /* H5_SIZEOF_UINT_LEAST16_T */ #if H5_SIZEOF_INT_LEAST32_T != 0 - static const PredType& NATIVE_INT_LEAST32; + static const PredType &NATIVE_INT_LEAST32; #endif /* H5_SIZEOF_INT_LEAST32_T */ #if H5_SIZEOF_UINT_LEAST32_T != 0 - static const PredType& NATIVE_UINT_LEAST32; + static const PredType &NATIVE_UINT_LEAST32; #endif /* H5_SIZEOF_UINT_LEAST32_T */ #if H5_SIZEOF_INT_LEAST64_T != 0 - static const PredType& NATIVE_INT_LEAST64; + static const PredType &NATIVE_INT_LEAST64; #endif /* H5_SIZEOF_INT_LEAST64_T */ #if H5_SIZEOF_UINT_LEAST64_T != 0 - static const PredType& NATIVE_UINT_LEAST64; + static const PredType &NATIVE_UINT_LEAST64; #endif /* H5_SIZEOF_UINT_LEAST64_T */ // FAST types #if H5_SIZEOF_INT_FAST8_T != 0 - static const PredType& NATIVE_INT_FAST8; + static const PredType &NATIVE_INT_FAST8; #endif /* H5_SIZEOF_INT_FAST8_T */ #if H5_SIZEOF_UINT_FAST8_T != 0 - static const PredType& NATIVE_UINT_FAST8; + static const PredType &NATIVE_UINT_FAST8; #endif /* H5_SIZEOF_UINT_FAST8_T */ #if H5_SIZEOF_INT_FAST16_T != 0 - static const PredType& NATIVE_INT_FAST16; + static const PredType &NATIVE_INT_FAST16; #endif /* H5_SIZEOF_INT_FAST16_T */ #if H5_SIZEOF_UINT_FAST16_T != 0 - static const PredType& NATIVE_UINT_FAST16; + static const PredType &NATIVE_UINT_FAST16; #endif /* H5_SIZEOF_UINT_FAST16_T */ #if H5_SIZEOF_INT_FAST32_T != 0 - static const PredType& NATIVE_INT_FAST32; + static const PredType &NATIVE_INT_FAST32; #endif /* H5_SIZEOF_INT_FAST32_T */ #if H5_SIZEOF_UINT_FAST32_T != 0 - static const PredType& NATIVE_UINT_FAST32; + static const PredType &NATIVE_UINT_FAST32; #endif /* H5_SIZEOF_UINT_FAST32_T */ #if H5_SIZEOF_INT_FAST64_T != 0 - static const PredType& NATIVE_INT_FAST64; + static const PredType &NATIVE_INT_FAST64; #endif /* H5_SIZEOF_INT_FAST64_T */ #if H5_SIZEOF_UINT_FAST64_T != 0 - static const PredType& NATIVE_UINT_FAST64; + static const PredType &NATIVE_UINT_FAST64; #endif /* H5_SIZEOF_UINT_FAST64_T */ #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the PredType global constants - static void deleteConstants(); - - // Dummy constant - static const PredType& PREDTYPE_CONST; // dummy constant - - protected: - // Default constructor - PredType(); - - // Creates a pre-defined type using an HDF5 pre-defined constant - PredType(const hid_t predtype_id); // used by the library only - - private: - // Activates the creation of the PredType global constants - static PredType* getPredTypes(); - - // Dynamically allocates PredType global constants - static void makePredTypes(); - - // Dummy constant - static PredType* PREDTYPE_CONST_; - - // Declaration of pointers to constants - static PredType* STD_I8BE_; - static PredType* STD_I8LE_; - static PredType* STD_I16BE_; - static PredType* STD_I16LE_; - static PredType* STD_I32BE_; - static PredType* STD_I32LE_; - static PredType* STD_I64BE_; - static PredType* STD_I64LE_; - static PredType* STD_U8BE_; - static PredType* STD_U8LE_; - static PredType* STD_U16BE_; - static PredType* STD_U16LE_; - static PredType* STD_U32BE_; - static PredType* STD_U32LE_; - static PredType* STD_U64BE_; - static PredType* STD_U64LE_; - static PredType* STD_B8BE_; - static PredType* STD_B8LE_; - static PredType* STD_B16BE_; - static PredType* STD_B16LE_; - static PredType* STD_B32BE_; - static PredType* STD_B32LE_; - static PredType* STD_B64BE_; - static PredType* STD_B64LE_; - static PredType* STD_REF_OBJ_; - static PredType* STD_REF_DSETREG_; - - static PredType* C_S1_; - static PredType* FORTRAN_S1_; - - static PredType* IEEE_F32BE_; - static PredType* IEEE_F32LE_; - static PredType* IEEE_F64BE_; - static PredType* IEEE_F64LE_; - - static PredType* UNIX_D32BE_; - static PredType* UNIX_D32LE_; - static PredType* UNIX_D64BE_; - static PredType* UNIX_D64LE_; - - static PredType* INTEL_I8_; - static PredType* INTEL_I16_; - static PredType* INTEL_I32_; - static PredType* INTEL_I64_; - static PredType* INTEL_U8_; - static PredType* INTEL_U16_; - static PredType* INTEL_U32_; - static PredType* INTEL_U64_; - static PredType* INTEL_B8_; - static PredType* INTEL_B16_; - static PredType* INTEL_B32_; - static PredType* INTEL_B64_; - static PredType* INTEL_F32_; - static PredType* INTEL_F64_; - - static PredType* ALPHA_I8_; - static PredType* ALPHA_I16_; - static PredType* ALPHA_I32_; - static PredType* ALPHA_I64_; - static PredType* ALPHA_U8_; - static PredType* ALPHA_U16_; - static PredType* ALPHA_U32_; - static PredType* ALPHA_U64_; - static PredType* ALPHA_B8_; - static PredType* ALPHA_B16_; - static PredType* ALPHA_B32_; - static PredType* ALPHA_B64_; - static PredType* ALPHA_F32_; - static PredType* ALPHA_F64_; - - static PredType* MIPS_I8_; - static PredType* MIPS_I16_; - static PredType* MIPS_I32_; - static PredType* MIPS_I64_; - static PredType* MIPS_U8_; - static PredType* MIPS_U16_; - static PredType* MIPS_U32_; - static PredType* MIPS_U64_; - static PredType* MIPS_B8_; - static PredType* MIPS_B16_; - static PredType* MIPS_B32_; - static PredType* MIPS_B64_; - static PredType* MIPS_F32_; - static PredType* MIPS_F64_; - - static PredType* NATIVE_CHAR_; - static PredType* NATIVE_SCHAR_; - static PredType* NATIVE_UCHAR_; - static PredType* NATIVE_SHORT_; - static PredType* NATIVE_USHORT_; - static PredType* NATIVE_INT_; - static PredType* NATIVE_UINT_; - static PredType* NATIVE_LONG_; - static PredType* NATIVE_ULONG_; - static PredType* NATIVE_LLONG_; - static PredType* NATIVE_ULLONG_; - static PredType* NATIVE_FLOAT_; - static PredType* NATIVE_DOUBLE_; - static PredType* NATIVE_LDOUBLE_; - static PredType* NATIVE_B8_; - static PredType* NATIVE_B16_; - static PredType* NATIVE_B32_; - static PredType* NATIVE_B64_; - static PredType* NATIVE_OPAQUE_; - static PredType* NATIVE_HSIZE_; - static PredType* NATIVE_HSSIZE_; - static PredType* NATIVE_HERR_; - static PredType* NATIVE_HBOOL_; - - static PredType* NATIVE_INT8_; - static PredType* NATIVE_UINT8_; - static PredType* NATIVE_INT16_; - static PredType* NATIVE_UINT16_; - static PredType* NATIVE_INT32_; - static PredType* NATIVE_UINT32_; - static PredType* NATIVE_INT64_; - static PredType* NATIVE_UINT64_; + // Deletes the PredType global constants + static void deleteConstants(); + + // Dummy constant + static const PredType &PREDTYPE_CONST; // dummy constant + + protected: + // Default constructor + PredType(); + + // Creates a pre-defined type using an HDF5 pre-defined constant + PredType(const hid_t predtype_id); // used by the library only + + private: + // Activates the creation of the PredType global constants + static PredType *getPredTypes(); + + // Dynamically allocates PredType global constants + static void makePredTypes(); + + // Dummy constant + static PredType *PREDTYPE_CONST_; + + // Declaration of pointers to constants + static PredType *STD_I8BE_; + static PredType *STD_I8LE_; + static PredType *STD_I16BE_; + static PredType *STD_I16LE_; + static PredType *STD_I32BE_; + static PredType *STD_I32LE_; + static PredType *STD_I64BE_; + static PredType *STD_I64LE_; + static PredType *STD_U8BE_; + static PredType *STD_U8LE_; + static PredType *STD_U16BE_; + static PredType *STD_U16LE_; + static PredType *STD_U32BE_; + static PredType *STD_U32LE_; + static PredType *STD_U64BE_; + static PredType *STD_U64LE_; + static PredType *STD_B8BE_; + static PredType *STD_B8LE_; + static PredType *STD_B16BE_; + static PredType *STD_B16LE_; + static PredType *STD_B32BE_; + static PredType *STD_B32LE_; + static PredType *STD_B64BE_; + static PredType *STD_B64LE_; + static PredType *STD_REF_OBJ_; + static PredType *STD_REF_DSETREG_; + + static PredType *C_S1_; + static PredType *FORTRAN_S1_; + + static PredType *IEEE_F32BE_; + static PredType *IEEE_F32LE_; + static PredType *IEEE_F64BE_; + static PredType *IEEE_F64LE_; + + static PredType *UNIX_D32BE_; + static PredType *UNIX_D32LE_; + static PredType *UNIX_D64BE_; + static PredType *UNIX_D64LE_; + + static PredType *INTEL_I8_; + static PredType *INTEL_I16_; + static PredType *INTEL_I32_; + static PredType *INTEL_I64_; + static PredType *INTEL_U8_; + static PredType *INTEL_U16_; + static PredType *INTEL_U32_; + static PredType *INTEL_U64_; + static PredType *INTEL_B8_; + static PredType *INTEL_B16_; + static PredType *INTEL_B32_; + static PredType *INTEL_B64_; + static PredType *INTEL_F32_; + static PredType *INTEL_F64_; + + static PredType *ALPHA_I8_; + static PredType *ALPHA_I16_; + static PredType *ALPHA_I32_; + static PredType *ALPHA_I64_; + static PredType *ALPHA_U8_; + static PredType *ALPHA_U16_; + static PredType *ALPHA_U32_; + static PredType *ALPHA_U64_; + static PredType *ALPHA_B8_; + static PredType *ALPHA_B16_; + static PredType *ALPHA_B32_; + static PredType *ALPHA_B64_; + static PredType *ALPHA_F32_; + static PredType *ALPHA_F64_; + + static PredType *MIPS_I8_; + static PredType *MIPS_I16_; + static PredType *MIPS_I32_; + static PredType *MIPS_I64_; + static PredType *MIPS_U8_; + static PredType *MIPS_U16_; + static PredType *MIPS_U32_; + static PredType *MIPS_U64_; + static PredType *MIPS_B8_; + static PredType *MIPS_B16_; + static PredType *MIPS_B32_; + static PredType *MIPS_B64_; + static PredType *MIPS_F32_; + static PredType *MIPS_F64_; + + static PredType *NATIVE_CHAR_; + static PredType *NATIVE_SCHAR_; + static PredType *NATIVE_UCHAR_; + static PredType *NATIVE_SHORT_; + static PredType *NATIVE_USHORT_; + static PredType *NATIVE_INT_; + static PredType *NATIVE_UINT_; + static PredType *NATIVE_LONG_; + static PredType *NATIVE_ULONG_; + static PredType *NATIVE_LLONG_; + static PredType *NATIVE_ULLONG_; + static PredType *NATIVE_FLOAT_; + static PredType *NATIVE_DOUBLE_; + static PredType *NATIVE_LDOUBLE_; + static PredType *NATIVE_B8_; + static PredType *NATIVE_B16_; + static PredType *NATIVE_B32_; + static PredType *NATIVE_B64_; + static PredType *NATIVE_OPAQUE_; + static PredType *NATIVE_HSIZE_; + static PredType *NATIVE_HSSIZE_; + static PredType *NATIVE_HERR_; + static PredType *NATIVE_HBOOL_; + + static PredType *NATIVE_INT8_; + static PredType *NATIVE_UINT8_; + static PredType *NATIVE_INT16_; + static PredType *NATIVE_UINT16_; + static PredType *NATIVE_INT32_; + static PredType *NATIVE_UINT32_; + static PredType *NATIVE_INT64_; + static PredType *NATIVE_UINT64_; // LEAST types #if H5_SIZEOF_INT_LEAST8_T != 0 - static PredType* NATIVE_INT_LEAST8_; + static PredType *NATIVE_INT_LEAST8_; #endif /* H5_SIZEOF_INT_LEAST8_T */ #if H5_SIZEOF_UINT_LEAST8_T != 0 - static PredType* NATIVE_UINT_LEAST8_; + static PredType *NATIVE_UINT_LEAST8_; #endif /* H5_SIZEOF_UINT_LEAST8_T */ #if H5_SIZEOF_INT_LEAST16_T != 0 - static PredType* NATIVE_INT_LEAST16_; + static PredType *NATIVE_INT_LEAST16_; #endif /* H5_SIZEOF_INT_LEAST16_T */ #if H5_SIZEOF_UINT_LEAST16_T != 0 - static PredType* NATIVE_UINT_LEAST16_; + static PredType *NATIVE_UINT_LEAST16_; #endif /* H5_SIZEOF_UINT_LEAST16_T */ #if H5_SIZEOF_INT_LEAST32_T != 0 - static PredType* NATIVE_INT_LEAST32_; + static PredType *NATIVE_INT_LEAST32_; #endif /* H5_SIZEOF_INT_LEAST32_T */ #if H5_SIZEOF_UINT_LEAST32_T != 0 - static PredType* NATIVE_UINT_LEAST32_; + static PredType *NATIVE_UINT_LEAST32_; #endif /* H5_SIZEOF_UINT_LEAST32_T */ #if H5_SIZEOF_INT_LEAST64_T != 0 - static PredType* NATIVE_INT_LEAST64_; + static PredType *NATIVE_INT_LEAST64_; #endif /* H5_SIZEOF_INT_LEAST64_T */ #if H5_SIZEOF_UINT_LEAST64_T != 0 - static PredType* NATIVE_UINT_LEAST64_; + static PredType *NATIVE_UINT_LEAST64_; #endif /* H5_SIZEOF_UINT_LEAST64_T */ // FAST types #if H5_SIZEOF_INT_FAST8_T != 0 - static PredType* NATIVE_INT_FAST8_; + static PredType *NATIVE_INT_FAST8_; #endif /* H5_SIZEOF_INT_FAST8_T */ #if H5_SIZEOF_UINT_FAST8_T != 0 - static PredType* NATIVE_UINT_FAST8_; + static PredType *NATIVE_UINT_FAST8_; #endif /* H5_SIZEOF_UINT_FAST8_T */ #if H5_SIZEOF_INT_FAST16_T != 0 - static PredType* NATIVE_INT_FAST16_; + static PredType *NATIVE_INT_FAST16_; #endif /* H5_SIZEOF_INT_FAST16_T */ #if H5_SIZEOF_UINT_FAST16_T != 0 - static PredType* NATIVE_UINT_FAST16_; + static PredType *NATIVE_UINT_FAST16_; #endif /* H5_SIZEOF_UINT_FAST16_T */ #if H5_SIZEOF_INT_FAST32_T != 0 - static PredType* NATIVE_INT_FAST32_; + static PredType *NATIVE_INT_FAST32_; #endif /* H5_SIZEOF_INT_FAST32_T */ #if H5_SIZEOF_UINT_FAST32_T != 0 - static PredType* NATIVE_UINT_FAST32_; + static PredType *NATIVE_UINT_FAST32_; #endif /* H5_SIZEOF_UINT_FAST32_T */ #if H5_SIZEOF_INT_FAST64_T != 0 - static PredType* NATIVE_INT_FAST64_; + static PredType *NATIVE_INT_FAST64_; #endif /* H5_SIZEOF_INT_FAST64_T */ #if H5_SIZEOF_UINT_FAST64_T != 0 - static PredType* NATIVE_UINT_FAST64_; + static PredType *NATIVE_UINT_FAST64_; #endif /* H5_SIZEOF_UINT_FAST64_T */ - // End of Declaration of pointers + // End of Declaration of pointers #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of PredType } // namespace H5 -#endif // __H5PredType_H +#endif // H5PredType_H diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index 1918d27..f2c1d70 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -6,29 +6,24 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif #include <string> -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" #include "H5PropList.h" - namespace H5 { - using std::cerr; - using std::endl; +using std::cerr; +using std::endl; #ifndef DOXYGEN_SHOULD_SKIP_THIS // This DOXYGEN_SHOULD_SKIP_THIS block is a work-around approach to control @@ -36,7 +31,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -PropList* PropList::DEFAULT_ = 0; +PropList *PropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: PropList::getConstant @@ -48,13 +43,13 @@ PropList* PropList::DEFAULT_ = 0; // throw a PropListIException. This scenario should not happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -PropList* PropList::getConstant() +PropList * +PropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -63,8 +58,9 @@ PropList* PropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new PropList(H5P_DEFAULT); else - throw PropListIException("PropList::getConstant", "PropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("PropList::getConstant", + "PropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -72,7 +68,8 @@ PropList* PropList::getConstant() // Purpose Deletes the constant object that PropList::DEFAULT_ points to. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void PropList::deleteConstants() +void +PropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -81,7 +78,7 @@ void PropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for default property. //-------------------------------------------------------------------------- -const PropList& PropList::DEFAULT = *getConstant(); +const PropList &PropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -90,7 +87,9 @@ const PropList& PropList::DEFAULT = *getConstant(); ///\brief Default constructor: creates a stub property list object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PropList::PropList() : IdComponent(), id(H5P_DEFAULT) {} +PropList::PropList() : IdComponent(), id(H5P_DEFAULT) +{ +} //-------------------------------------------------------------------------- // Function: PropList copy constructor @@ -98,7 +97,7 @@ PropList::PropList() : IdComponent(), id(H5P_DEFAULT) {} ///\param original - IN: The original property list to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PropList::PropList(const PropList& original) : IdComponent(), id(original.id) +PropList::PropList(const PropList &original) : IdComponent(), id(original.id) { incRefCount(); // increment number of references to this id } @@ -123,21 +122,19 @@ PropList::PropList(const hid_t plist_id) : IdComponent() H5I_type_t id_type = H5Iget_type(plist_id); switch (id_type) { case H5I_GENPROP_CLS: - // call C routine to create a new property from the given prop class - id = H5Pcreate(plist_id); - if (id < 0) - { - throw PropListIException("PropList constructor", "H5Pcreate failed"); - } - break; + // call C routine to create a new property from the given prop class + id = H5Pcreate(plist_id); + if (id < 0) { + throw PropListIException("PropList constructor", "H5Pcreate failed"); + } + break; case H5I_GENPROP_LST: - // call C routine to make a copy of the given property list - id = H5Pcopy(plist_id); - if (id < 0) - { - throw PropListIException("PropList constructor", "H5Pcopy failed"); - } - break; + // call C routine to make a copy of the given property list + id = H5Pcopy(plist_id); + if (id < 0) { + throw PropListIException("PropList constructor", "H5Pcopy failed"); + } + break; /* These should really be error cases, but changing that breaks * the stated behavior and causes test failures. * (DER, July 2017) @@ -157,8 +154,8 @@ PropList::PropList(const hid_t plist_id) : IdComponent() case H5I_NTYPES: case H5I_UNINIT: default: - id = H5P_DEFAULT; - break; + id = H5P_DEFAULT; + break; } } @@ -174,14 +171,15 @@ PropList::PropList(const hid_t plist_id) : IdComponent() // - Replaced decRefCount with close() to let the C library // handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- -void PropList::copy(const PropList& like_plist) +void +PropList::copy(const PropList &like_plist) { // If this object is representing an hdf5 object, close it before // copying like_plist to it try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw PropListIException(inMemFunc("copy"), close_error.getDetailMsg()); } @@ -202,11 +200,12 @@ void PropList::copy(const PropList& like_plist) // and stores the new id in the left hand side object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PropList& PropList::operator=(const PropList& rhs) +PropList & +PropList::operator=(const PropList &rhs) { if (this != &rhs) copy(rhs); - return(*this); + return (*this); } //-------------------------------------------------------------------------- @@ -217,12 +216,12 @@ PropList& PropList::operator=(const PropList& rhs) ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -void PropList::copyProp(PropList& dest, const char *name) const +void +PropList::copyProp(PropList &dest, const char *name) const { - hid_t dst_id = dest.getId(); + hid_t dst_id = dest.getId(); herr_t ret_value = H5Pcopy_prop(dst_id, id, name); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("copyProp"), "H5Pcopy_prop failed"); } } @@ -236,7 +235,8 @@ void PropList::copyProp(PropList& dest, const char *name) const ///\param name - IN: Name of the property to copy - \c H5std_string // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -void PropList::copyProp(PropList& dest, const H5std_string& name) const +void +PropList::copyProp(PropList &dest, const H5std_string &name) const { copyProp(dest, name.c_str()); } @@ -251,16 +251,15 @@ void PropList::copyProp(PropList& dest, const H5std_string& name) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void PropList::copyProp(PropList& dest, PropList& src, const char *name) const +void +PropList::copyProp(PropList &dest, PropList &src, const char *name) const { - hid_t dst_id = dest.getId(); - hid_t src_id = src.getId(); + hid_t dst_id = dest.getId(); + hid_t src_id = src.getId(); herr_t ret_value = H5Pcopy_prop(dst_id, src_id, name); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("copyProp"), "H5Pcopy_prop failed"); } - } //-------------------------------------------------------------------------- @@ -273,7 +272,8 @@ void PropList::copyProp(PropList& dest, PropList& src, const char *name) const ///\param name - IN: Name of the property to copy - \c H5std_string // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void PropList::copyProp(PropList& dest, PropList& src, const H5std_string& name) const +void +PropList::copyProp(PropList &dest, PropList &src, const H5std_string &name) const { copyProp(dest, src, name.c_str()); } @@ -289,9 +289,10 @@ void PropList::copyProp(PropList& dest, PropList& src, const H5std_string& name) // IdComponent::getId now becomes pure virtual function. // Programmer Binh-Minh Ribler - May, 2008 //-------------------------------------------------------------------------- -hid_t PropList::getId() const +hid_t +PropList::getId() const { - return(id); + return (id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -307,17 +308,18 @@ hid_t PropList::getId() const // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void PropList::p_setId(const hid_t new_id) +void +PropList::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw PropListIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } - // reset object's id to the given id - id = new_id; + // reset object's id to the given id + id = new_id; } #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -329,13 +331,12 @@ void PropList::p_setId(const hid_t new_id) ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void PropList::close() +void +PropList::close() { - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Pclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("close"), "H5Pclose failed"); } // reset the id @@ -350,15 +351,14 @@ void PropList::close() ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -hid_t PropList::getClass() const +hid_t +PropList::getClass() const { hid_t plist_class = H5Pget_class(id); - if (plist_class == H5P_ROOT) - { - throw PropListIException(inMemFunc("getClass"), - "H5Pget_class failed - returned H5P_ROOT"); + if (plist_class == H5P_ROOT) { + throw PropListIException(inMemFunc("getClass"), "H5Pget_class failed - returned H5P_ROOT"); } - return(plist_class); + return (plist_class); } //-------------------------------------------------------------------------- @@ -373,7 +373,8 @@ hid_t PropList::getClass() const /// list or class. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -bool PropList::propExist(const char* name) const +bool +PropList::propExist(const char *name) const { // Calls C routine H5Pexist to determine whether a property exists // within a property list or class. It returns a positive value, 0, @@ -396,9 +397,10 @@ bool PropList::propExist(const char* name) const ///\param name - IN: Name of property to check for - \c H5std_string // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -bool PropList::propExist(const H5std_string& name) const +bool +PropList::propExist(const H5std_string &name) const { - return(propExist( name.c_str())); + return (propExist(name.c_str())); } //-------------------------------------------------------------------------- @@ -411,11 +413,11 @@ bool PropList::propExist(const H5std_string& name) const /// list class hierarchy. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::closeClass() const +void +PropList::closeClass() const { herr_t ret_value = H5Pclose_class(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("closeClass"), "H5Pclose_class failed"); } } @@ -432,11 +434,11 @@ void PropList::closeClass() const /// throw an exception. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::getProperty(const char* name, void* value) const +void +PropList::getProperty(const char *name, void *value) const { herr_t ret_value = H5Pget(id, name, value); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("getProperty"), "H5Pget failed"); } } @@ -450,27 +452,27 @@ void PropList::getProperty(const char* name, void* value) const ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5std_string PropList::getProperty(const char* name) const +H5std_string +PropList::getProperty(const char *name) const { // Get property size first size_t size = getPropSize(name); // Allocate buffer then get the property - char* prop_strg_C = new char[size+1]; // temporary C-string for C API - HDmemset(prop_strg_C, 0, size+1); // clear buffer + char *prop_strg_C = new char[size + 1]; // temporary C-string for C API + HDmemset(prop_strg_C, 0, size + 1); // clear buffer herr_t ret_value = H5Pget(id, name, prop_strg_C); // call C API // Throw exception if H5Pget returns failure - if (ret_value < 0) - { - delete []prop_strg_C; + if (ret_value < 0) { + delete[] prop_strg_C; throw PropListIException(inMemFunc("getProperty"), "H5Pget failed"); } // Return property value as a string after deleting temp C-string H5std_string prop_strg(prop_strg_C); - delete []prop_strg_C; + delete[] prop_strg_C; return (prop_strg); } //-------------------------------------------------------------------------- @@ -482,7 +484,8 @@ H5std_string PropList::getProperty(const char* name) const ///\param value - OUT: Pointer to the buffer for the property value // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::getProperty(const H5std_string& name, void* value) const +void +PropList::getProperty(const H5std_string &name, void *value) const { getProperty(name.c_str(), value); } @@ -495,7 +498,8 @@ void PropList::getProperty(const H5std_string& name, void* value) const ///\return The property that is a \c H5std_string. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5std_string PropList::getProperty(const H5std_string& name) const +H5std_string +PropList::getProperty(const H5std_string &name) const { return (getProperty(name.c_str())); } @@ -513,15 +517,15 @@ H5std_string PropList::getProperty(const H5std_string& name) const /// lists and classes. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -size_t PropList::getPropSize(const char *name) const +size_t +PropList::getPropSize(const char *name) const { size_t prop_size; herr_t ret_value = H5Pget_size(id, name, &prop_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("getPropSize"), "H5Pget_size failed"); } - return(prop_size); + return (prop_size); } //-------------------------------------------------------------------------- // Function: PropList::getPropSize @@ -532,7 +536,8 @@ size_t PropList::getPropSize(const char *name) const /// // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -size_t PropList::getPropSize(const H5std_string& name) const +size_t +PropList::getPropSize(const H5std_string &name) const { return (getPropSize(name.c_str())); } @@ -541,22 +546,23 @@ size_t PropList::getPropSize(const H5std_string& name) const // Function: PropList::getClassName ///\brief Return the name of a generic property list class. ///\return A string containing the class name, if success, otherwise, -/// a NULL string. +/// an empty string. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5std_string PropList::getClassName() const +H5std_string +PropList::getClassName() const { - char* temp_str; + char *temp_str; temp_str = H5Pget_class_name(id); - if (temp_str != NULL) - { + if (temp_str != NULL) { H5std_string class_name(temp_str); H5free_memory(temp_str); - return(class_name); + return (class_name); } else - return 0; + return ""; } + //-------------------------------------------------------------------------- // Function: PropList::getNumProps ///\brief Returns the number of properties in this property list or class. @@ -564,12 +570,12 @@ H5std_string PropList::getClassName() const ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -size_t PropList::getNumProps() const +size_t +PropList::getNumProps() const { size_t nprops; - herr_t ret_value = H5Pget_nprops (id, &nprops); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_nprops(id, &nprops); + if (ret_value < 0) { throw PropListIException(inMemFunc("getNumProps"), "H5Pget_nprops failed"); } return (nprops); @@ -586,11 +592,11 @@ size_t PropList::getNumProps() const // the non-const setProperty. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::setProperty(const char* name, const void* value) const +void +PropList::setProperty(const char *name, const void *value) const { herr_t ret_value = H5Pset(id, name, value); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); } } @@ -602,11 +608,11 @@ void PropList::setProperty(const char* name, const void* value) const // Modification // Planned for removal. -BMR, 2017/03/17 1.10.1 //-------------------------------------------------------------------------- -void PropList::setProperty(const char* name, void* value) const +void +PropList::setProperty(const char *name, void *value) const { herr_t ret_value = H5Pset(id, name, value); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); } } @@ -623,11 +629,11 @@ void PropList::setProperty(const char* name, void* value) const // the non-const setProperty. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::setProperty(const char* name, const char* charptr) const +void +PropList::setProperty(const char *name, const char *charptr) const { - herr_t ret_value = H5Pset(id, name, (const void*)charptr); - if (ret_value < 0) - { + herr_t ret_value = H5Pset(id, name, (const void *)charptr); + if (ret_value < 0) { throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); } } @@ -640,7 +646,8 @@ void PropList::setProperty(const char* name, const char* charptr) const ///\param strg - IN: Value for the property is a \c H5std_string // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::setProperty(const char* name, const H5std_string& strg) const +void +PropList::setProperty(const char *name, const H5std_string &strg) const { setProperty(name, strg.c_str()); } @@ -652,7 +659,8 @@ void PropList::setProperty(const char* name, const H5std_string& strg) const // Modification // Planned for removal. -BMR, 2017/03/17 1.10.1 //-------------------------------------------------------------------------- -void PropList::setProperty(const char* name, H5std_string& strg) const +void +PropList::setProperty(const char *name, H5std_string &strg) const { setProperty(name, strg.c_str()); } @@ -666,7 +674,8 @@ void PropList::setProperty(const char* name, H5std_string& strg) const ///\param value - IN: Void pointer to the value for the property // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::setProperty(const H5std_string& name, const void* value) const +void +PropList::setProperty(const H5std_string &name, const void *value) const { setProperty(name.c_str(), value); } @@ -678,7 +687,8 @@ void PropList::setProperty(const H5std_string& name, const void* value) const // Modification // Planned for removal. -BMR, 2017/03/17 1.10.1 //-------------------------------------------------------------------------- -void PropList::setProperty(const H5std_string& name, void* value) const +void +PropList::setProperty(const H5std_string &name, void *value) const { setProperty(name.c_str(), value); } @@ -692,7 +702,8 @@ void PropList::setProperty(const H5std_string& name, void* value) const ///\param strg - IN: Value for the property is a \c H5std_string // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::setProperty(const H5std_string& name, const H5std_string& strg) const +void +PropList::setProperty(const H5std_string &name, const H5std_string &strg) const { setProperty(name.c_str(), strg.c_str()); } @@ -704,7 +715,8 @@ void PropList::setProperty(const H5std_string& name, const H5std_string& strg) c // Modification // Planned for removal. -BMR, 2017/03/17 1.10.1 //-------------------------------------------------------------------------- -void PropList::setProperty(const H5std_string& name, H5std_string& strg) const +void +PropList::setProperty(const H5std_string &name, H5std_string &strg) const { setProperty(name.c_str(), strg.c_str()); } @@ -718,7 +730,8 @@ void PropList::setProperty(const H5std_string& name, H5std_string& strg) const ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -bool PropList::isAClass(const PropList& prop_class) const +bool +PropList::isAClass(const PropList &prop_class) const { htri_t ret_value = H5Pisa_class(id, prop_class.getId()); if (ret_value > 0) @@ -738,11 +751,11 @@ bool PropList::isAClass(const PropList& prop_class) const ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::removeProp(const char *name) const +void +PropList::removeProp(const char *name) const { herr_t ret_value = H5Premove(id, name); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("removeProp"), "H5Premove failed"); } } @@ -755,7 +768,8 @@ void PropList::removeProp(const char *name) const ///\param name - IN: Name of property to remove - \c H5std_string // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::removeProp(const H5std_string& name) const +void +PropList::removeProp(const H5std_string &name) const { removeProp(name.c_str()); } @@ -769,7 +783,8 @@ void PropList::removeProp(const H5std_string& name) const ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -bool PropList::operator==(const PropList& rhs) const +bool +PropList::operator==(const PropList &rhs) const { htri_t ret_value = H5Pequal(id, rhs.getId()); if (ret_value > 0) @@ -789,15 +804,15 @@ bool PropList::operator==(const PropList& rhs) const ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -PropList PropList::getClassParent() const +PropList +PropList::getClassParent() const { hid_t class_id = H5Pget_class_parent(id); - if (class_id < 0) - { + if (class_id < 0) { throw PropListIException(inMemFunc("getClassParent"), "H5Pget_class_parent failed"); } PropList pclass(class_id); - return(pclass); + return (pclass); } //-------------------------------------------------------------------------- @@ -815,9 +830,9 @@ PropList::~PropList() try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { cerr << "PropList::~PropList - " << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5PropList.h b/c++/src/H5PropList.h index d704775..12c8b4b 100644 --- a/c++/src/H5PropList.h +++ b/c++/src/H5PropList.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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 namespace H5 { @@ -23,121 +23,125 @@ namespace H5 { */ // Inheritance: IdComponent class H5_DLLCPP PropList : public IdComponent { - public: - ///\brief Default property list - static const PropList& DEFAULT; + public: + ///\brief Default property list + static const PropList &DEFAULT; - // Creates a property list of a given type or creates a copy of an - // existing property list giving the property list id. - PropList(const hid_t plist_id); + // Creates a property list of a given type or creates a copy of an + // existing property list giving the property list id. + PropList(const hid_t plist_id); - // Make a copy of the given property list using assignment statement - PropList& operator=(const PropList& rhs); + // Make a copy of the given property list using assignment statement + PropList &operator=(const PropList &rhs); - // Compares this property list or class against the given list or class. - bool operator==(const PropList& rhs) const; + // Compares this property list or class against the given list or class. + bool operator==(const PropList &rhs) const; - // Close this property list. - virtual void close(); + // Close this property list. + virtual void close(); - // Close a property list class. - void closeClass() const; + // Close a property list class. + void closeClass() const; - // Makes a copy of the given property list. - void copy(const PropList& like_plist); + // Makes a copy of the given property list. + void copy(const PropList &like_plist); - // Copies a property from this property list or class to another - void copyProp(PropList& dest, const char* name) const; - void copyProp(PropList& dest, const H5std_string& name) const; + // Copies a property from this property list or class to another + void copyProp(PropList &dest, const char *name) const; + void copyProp(PropList &dest, const H5std_string &name) const; - // Copies a property from one property list or property class to another - void copyProp(PropList& dest, PropList& src, const char* name) const; - void copyProp(PropList& dest, PropList& src, const H5std_string& name) const; + // Copies a property from one property list or property class to another + void copyProp(PropList &dest, PropList &src, const char *name) const; + void copyProp(PropList &dest, PropList &src, const H5std_string &name) const; - // Gets the class of this property list, i.e. H5P_FILE_CREATE, - // H5P_FILE_ACCESS, ... - hid_t getClass() const; + // Gets the class of this property list, i.e. H5P_FILE_CREATE, + // H5P_FILE_ACCESS, ... + hid_t getClass() const; - // Return the name of a generic property list class. - H5std_string getClassName() const; + // Return the name of a generic property list class. + H5std_string getClassName() const; - // Returns the parent class of a generic property class. - PropList getClassParent() const; + // Returns the parent class of a generic property class. + PropList getClassParent() const; - // Returns the number of properties in this property list or class. - size_t getNumProps() const; + // Returns the number of properties in this property list or class. + size_t getNumProps() const; - // Query the value of a property in a property list. - void getProperty(const char* name, void* value) const; - void getProperty(const H5std_string& name, void* value) const; - H5std_string getProperty(const char* name) const; - H5std_string getProperty(const H5std_string& name) const; + // Query the value of a property in a property list. + void getProperty(const char *name, void *value) const; + void getProperty(const H5std_string &name, void *value) const; + H5std_string getProperty(const char *name) const; + H5std_string getProperty(const H5std_string &name) const; - // Set a property's value in a property list. - void setProperty(const char* name, const char* charptr) const; - void setProperty(const char* name, const void* value) const; - void setProperty(const char* name, const H5std_string& strg) const; - void setProperty(const H5std_string& name, const void* value) const; - void setProperty(const H5std_string& name, const H5std_string& strg) const; - // Deprecated after 1.10.1, missing const - void setProperty(const char* name, void* value) const; - void setProperty(const char* name, H5std_string& strg) const; - void setProperty(const H5std_string& name, void* value) const; - void setProperty(const H5std_string& name, H5std_string& strg) const; + // Set a property's value in a property list. + void setProperty(const char *name, const char *charptr) const; + void setProperty(const char *name, const void *value) const; + void setProperty(const char *name, const H5std_string &strg) const; + void setProperty(const H5std_string &name, const void *value) const; + void setProperty(const H5std_string &name, const H5std_string &strg) const; + // Deprecated after 1.10.1, missing const + void setProperty(const char *name, void *value) const; + void setProperty(const char *name, H5std_string &strg) const; + void setProperty(const H5std_string &name, void *value) const; + void setProperty(const H5std_string &name, H5std_string &strg) const; - // Query the size of a property in a property list or class. - size_t getPropSize(const char *name) const; - size_t getPropSize(const H5std_string& name) const; + // Query the size of a property in a property list or class. + size_t getPropSize(const char *name) const; + size_t getPropSize(const H5std_string &name) const; - // Determines whether a property list is a certain class. - bool isAClass(const PropList& prop_class) const; + // Determines whether a property list is a certain class. + bool isAClass(const PropList &prop_class) const; - /// Query the existence of a property in a property object. - bool propExist(const char* name) const; - bool propExist(const H5std_string& name) const; + /// Query the existence of a property in a property object. + bool propExist(const char *name) const; + bool propExist(const H5std_string &name) const; - // Removes a property from a property list. - void removeProp(const char *name) const; - void removeProp(const H5std_string& name) const; + // Removes a property from a property list. + void removeProp(const char *name) const; + void removeProp(const H5std_string &name) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("PropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("PropList"); + } - // Default constructor: creates a stub PropList object. - PropList(); + // Default constructor: creates a stub PropList object. + PropList(); - // Copy constructor: same as the original PropList. - PropList(const PropList& original); + // Copy constructor: same as the original PropList. + PropList(const PropList &original); - // Gets the property list id. - virtual hid_t getId() const; + // Gets the property list id. + virtual hid_t getId() const; - // Destructor: properly terminates access to this property list. - virtual ~PropList(); + // Destructor: properly terminates access to this property list. + virtual ~PropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the PropList global constant - static void deleteConstants(); + // Deletes the PropList global constant + static void deleteConstants(); - protected: - hid_t id; // HDF5 property list id + protected: + hid_t id; // HDF5 property list id - // Sets the property list id. - virtual void p_setId(const hid_t new_id); + // Sets the property list id. + virtual void p_setId(const hid_t new_id); - private: - static PropList* DEFAULT_; + private: + static PropList *DEFAULT_; - // Dynamically allocates the PropList global constant - static PropList* getConstant(); + // Dynamically allocates the PropList global constant + static PropList *getConstant(); - // Friend function to set PropList id. For library use only. - friend void f_PropList_setId(PropList* plist, hid_t new_id); + // Friend function to set PropList id. For library use only. + friend void f_PropList_setId(PropList *plist, hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of PropList } // namespace H5 -#endif // __H5PropList_H +#endif // H5PropList_H diff --git a/c++/src/H5StrType.cpp b/c++/src/H5StrType.cpp index f5b65e4..5df48f3 100644 --- a/c++/src/H5StrType.cpp +++ b/c++/src/H5StrType.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -32,6 +32,7 @@ #include "H5StrType.h" #include "H5DataSet.h" #include "H5PredType.h" +#include "H5private.h" namespace H5 { @@ -40,7 +41,9 @@ namespace H5 { ///\brief Default constructor: Creates a stub string datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::StrType() : AtomType() {} +StrType::StrType() : AtomType() +{ +} //-------------------------------------------------------------------------- // Function: StrType overloaded constructor @@ -49,7 +52,7 @@ StrType::StrType() : AtomType() {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::StrType(const PredType& pred_type) : AtomType() +StrType::StrType(const PredType &pred_type) : AtomType() { // use DataType::copy to make a copy of this predefined type copy(pred_type); @@ -78,7 +81,7 @@ StrType::StrType(const PredType& pred_type) : AtomType() // Planned for removal. -BMR, 2005/12/02 // Removed from documentation. -BMR, 2016/03/07 //-------------------------------------------------------------------------- -StrType::StrType(const PredType& pred_type, const size_t& size) : AtomType() +StrType::StrType(const PredType &pred_type, const size_t &size) : AtomType() { // use DataType::copy to make a copy of the string predefined type // then set its length @@ -102,7 +105,7 @@ StrType::StrType(const PredType& pred_type, const size_t& size) : AtomType() // This constructor replaced the previous one. // Programmer Binh-Minh Ribler - Nov 28, 2005 //-------------------------------------------------------------------------- -StrType::StrType(const int dummy, const size_t& size) : AtomType() +StrType::StrType(H5_ATTR_UNUSED const int dummy, const size_t &size) : AtomType() { // use DataType::copy to make a copy of the string predefined type // then set its length @@ -117,14 +120,18 @@ StrType::StrType(const int dummy, const size_t& size) : AtomType() ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::StrType(const hid_t existing_id) : AtomType( existing_id ) {} +StrType::StrType(const hid_t existing_id) : AtomType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: StrType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::StrType(const StrType& original) : AtomType ( original ) {} +StrType::StrType(const StrType &original) : AtomType(original) +{ +} //-------------------------------------------------------------------------- // Function: StrType overloaded constructor @@ -133,13 +140,12 @@ StrType::StrType(const StrType& original) : AtomType ( original ) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::StrType(const DataSet& dataset) : AtomType () +StrType::StrType(const DataSet &dataset) : AtomType() { // Calls C function H5Dget_type to get the id of the datatype id = H5Dget_type(dataset.getId()); - if (id < 0) - { + if (id < 0) { throw DataSetIException("StrType constructor", "H5Dget_type failed"); } } @@ -158,7 +164,7 @@ StrType::StrType(const DataSet& dataset) : AtomType () // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -StrType::StrType(const H5Location& loc, const char *dtype_name) : AtomType() +StrType::StrType(const H5Location &loc, const char *dtype_name) : AtomType() { id = p_opentype(loc, dtype_name); } @@ -177,7 +183,7 @@ StrType::StrType(const H5Location& loc, const char *dtype_name) : AtomType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -StrType::StrType(const H5Location& loc, const H5std_string& dtype_name) : AtomType() +StrType::StrType(const H5Location &loc, const H5std_string &dtype_name) : AtomType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -190,7 +196,8 @@ StrType::StrType(const H5Location& loc, const H5std_string& dtype_name) : AtomTy ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* StrType::decode() const +DataType * +StrType::decode() const { hid_t encoded_strtype_id = H5I_INVALID_HID; try { @@ -201,7 +208,7 @@ DataType* StrType::decode() const } StrType *encoded_strtype = new StrType; encoded_strtype->p_setId(encoded_strtype_id); - return(encoded_strtype); + return (encoded_strtype); } //-------------------------------------------------------------------------- @@ -219,16 +226,16 @@ DataType* StrType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_cset_t StrType::getCset() const +H5T_cset_t +StrType::getCset() const { H5T_cset_t cset = H5Tget_cset(id); // Returns a valid character set type if successful - if (cset == H5T_CSET_ERROR) - { + if (cset == H5T_CSET_ERROR) { throw DataTypeIException("StrType::getCset", "H5Tget_cset failed"); } - return(cset); + return (cset); } //-------------------------------------------------------------------------- @@ -246,11 +253,11 @@ H5T_cset_t StrType::getCset() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void StrType::setCset(H5T_cset_t cset) const +void +StrType::setCset(H5T_cset_t cset) const { herr_t ret_value = H5Tset_cset(id, cset); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("StrType::setCset", "H5Tset_cset failed"); } } @@ -265,17 +272,16 @@ void StrType::setCset(H5T_cset_t cset) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_str_t StrType::getStrpad() const +H5T_str_t +StrType::getStrpad() const { H5T_str_t strpad = H5Tget_strpad(id); // Returns a valid string padding type if successful - if (strpad == H5T_STR_ERROR) - { - throw DataTypeIException("StrType::getStrpad", - "H5Tget_strpad failed - returned H5T_STR_ERROR"); + if (strpad == H5T_STR_ERROR) { + throw DataTypeIException("StrType::getStrpad", "H5Tget_strpad failed - returned H5T_STR_ERROR"); } - return(strpad); + return (strpad); } //-------------------------------------------------------------------------- @@ -288,11 +294,11 @@ H5T_str_t StrType::getStrpad() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void StrType::setStrpad(H5T_str_t strpad) const +void +StrType::setStrpad(H5T_str_t strpad) const { herr_t ret_value = H5Tset_strpad(id, strpad); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("StrType::setStrpad", "H5Tset_strpad failed"); } } @@ -302,6 +308,8 @@ void StrType::setStrpad(H5T_str_t strpad) const ///\brief Properly terminates access to this string datatype. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::~StrType() {} +StrType::~StrType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5StrType.h b/c++/src/H5StrType.h index 38974da..d272c53 100644 --- a/c++/src/H5StrType.h +++ b/c++/src/H5StrType.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have 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 namespace H5 { @@ -23,55 +23,59 @@ namespace H5 { */ // Inheritance: AtomType -> DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP StrType : public AtomType { - public: - // Creates a string type using a predefined type - StrType(const PredType& pred_type); + public: + // Creates a string type using a predefined type + StrType(const PredType &pred_type); - // Creates a string type with specified length - may be obsolete - StrType(const PredType& pred_type, const size_t& size); + // Creates a string type with specified length - may be obsolete + StrType(const PredType &pred_type, const size_t &size); - // Creates a string type with specified length - StrType(const int dummy, const size_t& size); + // Creates a string type with specified length + StrType(const int dummy, const size_t &size); - // Gets the string datatype of the specified dataset - StrType(const DataSet& dataset); + // Gets the string datatype of the specified dataset + StrType(const DataSet &dataset); - // Constructors that open an HDF5 string datatype, given a location. - StrType(const H5Location& loc, const char* name); - StrType(const H5Location& loc, const H5std_string& name); + // Constructors that open an HDF5 string datatype, given a location. + StrType(const H5Location &loc, const char *name); + StrType(const H5Location &loc, const H5std_string &name); - // Returns an StrType object via DataType* by decoding the - // binary object description of this type. - virtual DataType* decode() const; + // Returns an StrType object via DataType* by decoding the + // binary object description of this type. + virtual DataType *decode() const; - // Retrieves the character set type of this string datatype. - H5T_cset_t getCset() const; + // Retrieves the character set type of this string datatype. + H5T_cset_t getCset() const; - // Sets character set to be used. - void setCset(H5T_cset_t cset) const; + // Sets character set to be used. + void setCset(H5T_cset_t cset) const; - // Retrieves the string padding method for this string datatype. - H5T_str_t getStrpad() const; + // Retrieves the string padding method for this string datatype. + H5T_str_t getStrpad() const; - // Defines the storage mechanism for character strings. - void setStrpad(H5T_str_t strpad) const; + // Defines the storage mechanism for character strings. + void setStrpad(H5T_str_t strpad) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("StrType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("StrType"); + } - // default constructor - StrType(); + // default constructor + StrType(); - // Creates a string datatype using an existing id - StrType(const hid_t existing_id); + // Creates a string datatype using an existing id + StrType(const hid_t existing_id); - // Copy constructor: same as the original StrType. - StrType(const StrType& original); + // Copy constructor: same as the original StrType. + StrType(const StrType &original); - // Noop destructor. - virtual ~StrType(); + // Noop destructor. + virtual ~StrType(); }; // end of StrType } // namespace H5 -#endif // __H5StrType_H +#endif // H5StrType_H diff --git a/c++/src/H5VarLenType.cpp b/c++/src/H5VarLenType.cpp index 094af61..0270feb 100644 --- a/c++/src/H5VarLenType.cpp +++ b/c++/src/H5VarLenType.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -33,7 +33,9 @@ namespace H5 { // Function: VarLenType default constructor ///\brief Default constructor: Creates a stub variable-length datatype. //-------------------------------------------------------------------------- -VarLenType::VarLenType() : DataType() {} +VarLenType::VarLenType() : DataType() +{ +} //-------------------------------------------------------------------------- // Function: VarLenType overloaded constructor @@ -42,14 +44,18 @@ VarLenType::VarLenType() : DataType() {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -VarLenType::VarLenType(const hid_t existing_id) : DataType(existing_id) {} +VarLenType::VarLenType(const hid_t existing_id) : DataType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: VarLenType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -VarLenType::VarLenType(const VarLenType& original) : DataType(original) {} +VarLenType::VarLenType(const VarLenType &original) : DataType(original) +{ +} //-------------------------------------------------------------------------- // Function: VarLenType overloaded constructor @@ -63,13 +69,11 @@ VarLenType::VarLenType(const VarLenType& original) : DataType(original) {} // -BMR, Sep, 2017 // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -VarLenType::VarLenType(const DataType* base_type) : DataType() +VarLenType::VarLenType(const DataType *base_type) : DataType() { id = H5Tvlen_create(base_type->getId()); - if (id < 0) - { - throw DataTypeIException("VarLenType constructor", - "H5Tvlen_create returns negative value"); + if (id < 0) { + throw DataTypeIException("VarLenType constructor", "H5Tvlen_create returns negative value"); } } @@ -81,13 +85,11 @@ VarLenType::VarLenType(const DataType* base_type) : DataType() ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -VarLenType::VarLenType(const DataType& base_type) : DataType() +VarLenType::VarLenType(const DataType &base_type) : DataType() { id = H5Tvlen_create(base_type.getId()); - if (id < 0) - { - throw DataTypeIException("VarLenType constructor", - "H5Tvlen_create returns negative value"); + if (id < 0) { + throw DataTypeIException("VarLenType constructor", "H5Tvlen_create returns negative value"); } } @@ -105,7 +107,7 @@ VarLenType::VarLenType(const DataType& base_type) : DataType() // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -VarLenType::VarLenType(const H5Location& loc, const char *dtype_name) : DataType() +VarLenType::VarLenType(const H5Location &loc, const char *dtype_name) : DataType() { id = p_opentype(loc, dtype_name); } @@ -124,7 +126,7 @@ VarLenType::VarLenType(const H5Location& loc, const char *dtype_name) : DataType // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -VarLenType::VarLenType(const H5Location& loc, const H5std_string& dtype_name) : DataType() +VarLenType::VarLenType(const H5Location &loc, const H5std_string &dtype_name) : DataType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -137,7 +139,8 @@ VarLenType::VarLenType(const H5Location& loc, const H5std_string& dtype_name) : ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* VarLenType::decode() const +DataType * +VarLenType::decode() const { hid_t encoded_vltype_id = H5I_INVALID_HID; try { @@ -148,7 +151,7 @@ DataType* VarLenType::decode() const } VarLenType *encoded_vltype = new VarLenType; encoded_vltype->p_setId(encoded_vltype_id); - return(encoded_vltype); + return (encoded_vltype); } //-------------------------------------------------------------------------- @@ -156,6 +159,8 @@ DataType* VarLenType::decode() const ///\brief Properly terminates access to this datatype. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -VarLenType::~VarLenType() {} +VarLenType::~VarLenType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5VarLenType.h b/c++/src/H5VarLenType.h index ab3c14c..f767e0e 100644 --- a/c++/src/H5VarLenType.h +++ b/c++/src/H5VarLenType.h @@ -7,13 +7,13 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5VarLenType_H -#define __H5VarLenType_H +#ifndef H5VarLenType_H +#define H5VarLenType_H namespace H5 { @@ -23,38 +23,42 @@ namespace H5 { */ // Inheritance: DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP VarLenType : public DataType { - public: - // Constructor that creates a variable-length datatype based - // on the specified base type. - VarLenType(const DataType& base_type); + public: + // Constructor that creates a variable-length datatype based + // on the specified base type. + VarLenType(const DataType &base_type); - // Deprecated - will be removed after 1.10.2 - VarLenType(const DataType* base_type); + // Deprecated - will be removed after 1.10.2 + VarLenType(const DataType *base_type); - // Returns an VarLenType object via DataType* by decoding the - // binary object description of this type. - virtual DataType* decode() const; + // Returns an VarLenType object via DataType* by decoding the + // binary object description of this type. + virtual DataType *decode() const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("VarLenType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("VarLenType"); + } - // Copy constructor: same as the original VarLenType. - VarLenType(const VarLenType& original); + // Copy constructor: same as the original VarLenType. + VarLenType(const VarLenType &original); - // Constructor that takes an existing id - VarLenType(const hid_t existing_id); + // Constructor that takes an existing id + VarLenType(const hid_t existing_id); - // Constructors that open a variable-length datatype, given a location. - VarLenType(const H5Location& loc, const char* name); - VarLenType(const H5Location& loc, const H5std_string& name); + // Constructors that open a variable-length datatype, given a location. + VarLenType(const H5Location &loc, const char *name); + VarLenType(const H5Location &loc, const H5std_string &name); - // Noop destructor - virtual ~VarLenType(); + // Noop destructor + virtual ~VarLenType(); - // Default constructor - VarLenType(); + // Default constructor + VarLenType(); }; // end of VarLenType } // namespace H5 -#endif // __H5VarLenType_H +#endif // H5VarLenType_H diff --git a/c++/src/Makefile.am b/c++/src/Makefile.am index eb50209..74ef367 100644 --- a/c++/src/Makefile.am +++ b/c++/src/Makefile.am @@ -6,7 +6,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. ## diff --git a/c++/src/Makefile.in b/c++/src/Makefile.in index 497fce8..69f489f 100644 --- a/c++/src/Makefile.in +++ b/c++/src/Makefile.in @@ -22,7 +22,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # @@ -116,6 +116,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/aclocal_cxx.m4 \ $(top_srcdir)/m4/ax_check_junit.m4 \ $(top_srcdir)/m4/ax_java_options.m4 \ $(top_srcdir)/m4/ax_jni_include_dir.m4 \ + $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/ax_prog_jar.m4 \ $(top_srcdir)/m4/ax_prog_java.m4 \ $(top_srcdir)/m4/ax_prog_java_works.m4 \ @@ -433,11 +434,11 @@ AMTAR = @AMTAR@ # AM_CFLAGS is an automake construct which should be used by Makefiles # instead of CFLAGS, as CFLAGS is reserved solely for the user to define. # This applies to FCFLAGS, CXXFLAGS, CPPFLAGS, and LDFLAGS as well. -AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ @H5_ECFLAGS@ +AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ # Include src directory AM_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@ -I$(top_srcdir)/src -AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ @H5_ECXXFLAGS@ +AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_FCFLAGS = @AM_FCFLAGS@ @H5_FCFLAGS@ AM_JAVACFLAGS = @AM_JAVACFLAGS@ @@ -475,11 +476,56 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DEPRECATED_SYMBOLS = @DEPRECATED_SYMBOLS@ DESIRED_FILE_LOCKING = @DESIRED_FILE_LOCKING@ -DEV_WARNINGS = @DEV_WARNINGS@ +DIAGS = @DIAGS@ DIRECT_VFD = @DIRECT_VFD@ DLLTOOL = @DLLTOOL@ +DOXYGEN_EXAMPLES_DIRECTORY = @DOXYGEN_EXAMPLES_DIRECTORY@ +DOXYGEN_EXTERNAL_SEARCH = @DOXYGEN_EXTERNAL_SEARCH@ +DOXYGEN_HTML_EXTRA_FILES = @DOXYGEN_HTML_EXTRA_FILES@ +DOXYGEN_HTML_EXTRA_STYLESHEET = @DOXYGEN_HTML_EXTRA_STYLESHEET@ +DOXYGEN_HTML_FOOTER = @DOXYGEN_HTML_FOOTER@ +DOXYGEN_HTML_HEADER = @DOXYGEN_HTML_HEADER@ +DOXYGEN_INCLUDE_ALIASES = @DOXYGEN_INCLUDE_ALIASES@ +DOXYGEN_INPUT_DIRECTORY = @DOXYGEN_INPUT_DIRECTORY@ +DOXYGEN_LAYOUT_FILE = @DOXYGEN_LAYOUT_FILE@ +DOXYGEN_MACRO_EXPANSION = @DOXYGEN_MACRO_EXPANSION@ +DOXYGEN_OPTIMIZE_OUTPUT_FOR_C = @DOXYGEN_OPTIMIZE_OUTPUT_FOR_C@ +DOXYGEN_OUTPUT_DIRECTORY = @DOXYGEN_OUTPUT_DIRECTORY@ +DOXYGEN_PACKAGE = @DOXYGEN_PACKAGE@ +DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ +DOXYGEN_PREDEFINED = @DOXYGEN_PREDEFINED@ +DOXYGEN_PROJECT_BRIEF = @DOXYGEN_PROJECT_BRIEF@ +DOXYGEN_PROJECT_LOGO = @DOXYGEN_PROJECT_LOGO@ +DOXYGEN_SEARCHENGINE_URL = @DOXYGEN_SEARCHENGINE_URL@ +DOXYGEN_SERVER_BASED_SEARCH = @DOXYGEN_SERVER_BASED_SEARCH@ +DOXYGEN_STRIP_FROM_PATH = @DOXYGEN_STRIP_FROM_PATH@ +DOXYGEN_TAG_FILE = @DOXYGEN_TAG_FILE@ +DOXYGEN_VERSION_STRING = @DOXYGEN_VERSION_STRING@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ +DX_CONFIG = @DX_CONFIG@ +DX_DOCDIR = @DX_DOCDIR@ +DX_DOT = @DX_DOT@ +DX_DOXYGEN = @DX_DOXYGEN@ +DX_DVIPS = @DX_DVIPS@ +DX_EGREP = @DX_EGREP@ +DX_ENV = @DX_ENV@ +DX_FLAG_chi = @DX_FLAG_chi@ +DX_FLAG_chm = @DX_FLAG_chm@ +DX_FLAG_doc = @DX_FLAG_doc@ +DX_FLAG_dot = @DX_FLAG_dot@ +DX_FLAG_html = @DX_FLAG_html@ +DX_FLAG_man = @DX_FLAG_man@ +DX_FLAG_pdf = @DX_FLAG_pdf@ +DX_FLAG_ps = @DX_FLAG_ps@ +DX_FLAG_rtf = @DX_FLAG_rtf@ +DX_FLAG_xml = @DX_FLAG_xml@ +DX_HHC = @DX_HHC@ +DX_LATEX = @DX_LATEX@ +DX_MAKEINDEX = @DX_MAKEINDEX@ +DX_PDFLATEX = @DX_PDFLATEX@ +DX_PERL = @DX_PERL@ +DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ @@ -511,8 +557,6 @@ H5_CFLAGS = @H5_CFLAGS@ H5_CLASSPATH = @H5_CLASSPATH@ H5_CPPFLAGS = @H5_CPPFLAGS@ H5_CXXFLAGS = @H5_CXXFLAGS@ -H5_ECFLAGS = @H5_ECFLAGS@ -H5_ECXXFLAGS = @H5_ECXXFLAGS@ H5_FCFLAGS = @H5_FCFLAGS@ H5_FORTRAN_SHARED = @H5_FORTRAN_SHARED@ H5_IS_DARWIN = @H5_IS_DARWIN@ @@ -526,7 +570,9 @@ HAVE_DMALLOC = @HAVE_DMALLOC@ HAVE_Fortran_INTEGER_SIZEOF_16 = @HAVE_Fortran_INTEGER_SIZEOF_16@ HAVE_LIBHDFS = @HAVE_LIBHDFS@ HAVE_PTHREAD = @HAVE_PTHREAD@ +HDF5_DOXYGEN = @HDF5_DOXYGEN@ HDF5_HL = @HDF5_HL@ +HDF5_HL_TOOLS = @HDF5_HL_TOOLS@ HDF5_INTERFACES = @HDF5_INTERFACES@ HDF5_TESTS = @HDF5_TESTS@ HDF5_TOOLS = @HDF5_TOOLS@ @@ -536,6 +582,7 @@ HDF_JAVA = @HDF_JAVA@ HID_T = @HID_T@ HL = @HL@ HL_FOR = @HL_FOR@ +HL_TOOLS = @HL_TOOLS@ HSIZE_T = @HSIZE_T@ HSSIZE_T = @HSSIZE_T@ IGNORE_DISABLED_FILE_LOCKS = @IGNORE_DISABLED_FILE_LOCKS@ @@ -729,7 +776,7 @@ LIBH5F_HL = $(top_builddir)/hl/fortran/src/libhdf5hl_fortran.la LIBH5CPP_HL = $(top_builddir)/hl/c++/src/libhdf5_hl_cpp.la # Note that in svn revision 19400 the '/' after DESTDIR in H5* variables below -# has been removed. According to the official description of DESTDIR by Gnu at +# has been removed. According to the official description of DESTDIR by GNU at # http://www.gnu.org/prep/standards/html_node/DESTDIR.html, DESTDIR is # prepended to the normal and complete install path that it precedes for the # purpose of installing in a temporary directory which is useful for building @@ -757,28 +804,28 @@ TRACE = perl $(top_srcdir)/bin/trace # *.clog and *.clog2 are from the MPE option. CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.clog2 LT_VERS_INTERFACE = 106 -LT_VERS_REVISION = 0 +LT_VERS_REVISION = 1 LT_VERS_AGE = 3 -LT_CXX_VERS_INTERFACE = 106 +LT_CXX_VERS_INTERFACE = 107 LT_CXX_VERS_REVISION = 0 -LT_CXX_VERS_AGE = 3 +LT_CXX_VERS_AGE = 4 LT_F_VERS_INTERFACE = 103 -LT_F_VERS_REVISION = 0 +LT_F_VERS_REVISION = 1 LT_F_VERS_AGE = 1 LT_HL_VERS_INTERFACE = 101 -LT_HL_VERS_REVISION = 4 +LT_HL_VERS_REVISION = 5 LT_HL_VERS_AGE = 1 LT_HL_CXX_VERS_INTERFACE = 101 -LT_HL_CXX_VERS_REVISION = 5 +LT_HL_CXX_VERS_REVISION = 6 LT_HL_CXX_VERS_AGE = 1 LT_HL_F_VERS_INTERFACE = 100 -LT_HL_F_VERS_REVISION = 6 +LT_HL_F_VERS_REVISION = 7 LT_HL_F_VERS_AGE = 0 -LT_JAVA_VERS_INTERFACE = 105 +LT_JAVA_VERS_INTERFACE = 106 LT_JAVA_VERS_REVISION = 0 -LT_JAVA_VERS_AGE = 5 +LT_JAVA_VERS_AGE = 6 LT_TOOLS_VERS_INTERFACE = 102 -LT_TOOLS_VERS_REVISION = 0 +LT_TOOLS_VERS_REVISION = 1 LT_TOOLS_VERS_AGE = 0 # This is our main target @@ -1413,8 +1460,9 @@ uninstall-am: uninstall-binSCRIPTS uninstall-includeHEADERS \ # commands that should be executed even if a file with the same name already # exists. .PHONY: build-check-clean build-check-p build-check-s build-lib build-progs \ - build-tests check-clean check-install check-p check-s check-vfd \ - install-doc lib progs tests uninstall-doc _exec_check-s _test help + build-tests check-clean check-install check-p check-s check-vfd \ + install-doc lib progs tests uninstall-doc \ + _exec_check-s _test help trace doxygen help: @$(top_srcdir)/bin/makehelp diff --git a/c++/src/cpp_doc_config b/c++/src/cpp_doc_config index 8397a2f..cf16a62 100644 --- a/c++/src/cpp_doc_config +++ b/c++/src/cpp_doc_config @@ -38,7 +38,7 @@ PROJECT_NAME = # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "1.10.7" +PROJECT_NUMBER = "1.10.8" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/c++/src/h5c++.in b/c++/src/h5c++.in index 5a542f9..573d20d 100644 --- a/c++/src/h5c++.in +++ b/c++/src/h5c++.in @@ -7,7 +7,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # @@ -35,10 +35,10 @@ HL="@HL@" ## (Advanced usage - know what you're doing - you're on your own here.) ## ## The four variables below can be used to insert paths and flags in ## ## CPPFLAGS, CXXFLAGS, LDFLAGS, or LIBS in the h5cc compile line: ## -## $CLINKER $H5BLD_CPPFLAGS $CPPFLAGS $H5BLD_CXXFLAGS $CXXFLAGS ## +## $CXXLINKER $H5BLD_CPPFLAGS $CPPFLAGS $H5BLD_CXXFLAGS $CXXFLAGS ## ## $LDFLAGS $LIBS $clibpath $link_objs $link_args $shared_link ## ## ## -## These settings can be overridden by setting HDF5_CXXFLAGS, ## +## These settings can be overridden by setting HDF5_CXXFLAGS, ## ## HDF5_CPPFLAGS, HDF5_LDFLAGS, or HDF5_LIBS in the environment. ## ## ## ############################################################################ @@ -93,7 +93,7 @@ H5BLD_LDFLAGS="@AM_LDFLAGS@ @LDFLAGS@" H5BLD_LIBS="@LIBS@" CXX="${HDF5_CXX:-$CXXBASE}" -CXXLINKER="${HDF5_CLINKER:-$CXXLINKERBASE}" +CXXLINKER="${HDF5_CXXLINKER:-$CXXLINKERBASE}" CXXFLAGS="${HDF5_CXXFLAGS:-$CXXFLAGSBASE}" CPPFLAGS="${HDF5_CPPFLAGS:-$CPPFLAGSBASE}" LDFLAGS="${HDF5_LDFLAGS:-$LDFLAGSBASE}" diff --git a/c++/src/header.html b/c++/src/header.html index cb42565..5b92416 100644 --- a/c++/src/header.html +++ b/c++/src/header.html @@ -13,7 +13,7 @@ xmlns="http://www.w3.org/TR/REC-html40"> * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * diff --git a/c++/test/CMakeLists.txt b/c++/test/CMakeLists.txt index ca2295e..1255e39 100644 --- a/c++/test/CMakeLists.txt +++ b/c++/test/CMakeLists.txt @@ -37,8 +37,8 @@ set (CPP_TEST_SOURCES set (srcdir ${CMAKE_CURRENT_SOURCE_DIR}) configure_file (${HDF5_CPP_TEST_SOURCE_DIR}/H5srcdir_str.h.in H5srcdir_str.h @ONLY) -add_executable (cpp_testhdf5 ${CPP_TEST_SOURCES} ) -target_include_directories (cpp_testhdf5 PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_TEST_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") +add_executable (cpp_testhdf5 ${CPP_TEST_SOURCES} ${HDF5_CPP_TEST_SOURCE_DIR}/h5cpputil.h) +target_include_directories (cpp_testhdf5 PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};${HDF5_TEST_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") target_compile_options(cpp_testhdf5 PRIVATE "${HDF5_CMAKE_CXX_FLAGS}") target_compile_definitions(cpp_testhdf5 PRIVATE $<$<BOOL:${HDF5_ENABLE_PARALLEL}>:MPICH_SKIP_MPICXX;MPICH_IGNORE_CXX_SEEK># Parallel/MPI, prevent spurious cpp/cxx warnings @@ -49,7 +49,7 @@ if (NOT BUILD_SHARED_LIBS) else () TARGET_C_PROPERTIES (cpp_testhdf5 SHARED) target_link_libraries (cpp_testhdf5 PRIVATE ${HDF5_CPP_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET}) - if (MINGW) + if (MINGW AND HDF5_MINGW_STATIC_GCC_LIBS) target_link_options (${HDF5_CPP_LIBSH_TARGET} PRIVATE -static-libgcc -static-libstdc++ ) @@ -57,6 +57,13 @@ else () endif () set_target_properties (cpp_testhdf5 PROPERTIES FOLDER test/cpp) +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_CPP_TEST_cpp_testhdf5_FORMAT cpp_testhdf5) +endif () + if (HDF5_TEST_CPP AND HDF5_TEST_SERIAL) include (CMakeTests.cmake) endif () diff --git a/c++/test/CMakeTests.cmake b/c++/test/CMakeTests.cmake index a25dc6b..2a0a6be 100644 --- a/c++/test/CMakeTests.cmake +++ b/c++/test/CMakeTests.cmake @@ -5,7 +5,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # diff --git a/c++/test/CMakeVFDTests.cmake b/c++/test/CMakeVFDTests.cmake index 8a44767..f1c6799 100644 --- a/c++/test/CMakeVFDTests.cmake +++ b/c++/test/CMakeVFDTests.cmake @@ -5,7 +5,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # @@ -25,7 +25,7 @@ set (VFD_LIST family ) -if (DIRECT_VFD) +if (H5_HAVE_DIRECT) set (VFD_LIST ${VFD_LIST} direct) endif () diff --git a/c++/test/H5srcdir_str.h.in b/c++/test/H5srcdir_str.h.in index bab1df3..988c065 100644 --- a/c++/test/H5srcdir_str.h.in +++ b/c++/test/H5srcdir_str.h.in @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/c++/test/Makefile.am b/c++/test/Makefile.am index 0fc17fc..0194b0e 100644 --- a/c++/test/Makefile.am +++ b/c++/test/Makefile.am @@ -6,7 +6,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. ## diff --git a/c++/test/Makefile.in b/c++/test/Makefile.in index dced075..954f9df 100644 --- a/c++/test/Makefile.in +++ b/c++/test/Makefile.in @@ -22,7 +22,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # @@ -114,6 +114,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/aclocal_cxx.m4 \ $(top_srcdir)/m4/ax_check_junit.m4 \ $(top_srcdir)/m4/ax_java_options.m4 \ $(top_srcdir)/m4/ax_jni_include_dir.m4 \ + $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/ax_prog_jar.m4 \ $(top_srcdir)/m4/ax_prog_java.m4 \ $(top_srcdir)/m4/ax_prog_java_works.m4 \ @@ -422,12 +423,12 @@ AMTAR = @AMTAR@ # AM_CFLAGS is an automake construct which should be used by Makefiles # instead of CFLAGS, as CFLAGS is reserved solely for the user to define. # This applies to FCFLAGS, CXXFLAGS, CPPFLAGS, and LDFLAGS as well. -AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ @H5_ECFLAGS@ +AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ # Include src, test, and c++/src directories AM_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@ -I$(top_srcdir)/src \ -I$(top_srcdir)/test -I$(top_srcdir)/c++/src -AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ @H5_ECXXFLAGS@ +AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_FCFLAGS = @AM_FCFLAGS@ @H5_FCFLAGS@ AM_JAVACFLAGS = @AM_JAVACFLAGS@ @@ -465,11 +466,56 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DEPRECATED_SYMBOLS = @DEPRECATED_SYMBOLS@ DESIRED_FILE_LOCKING = @DESIRED_FILE_LOCKING@ -DEV_WARNINGS = @DEV_WARNINGS@ +DIAGS = @DIAGS@ DIRECT_VFD = @DIRECT_VFD@ DLLTOOL = @DLLTOOL@ +DOXYGEN_EXAMPLES_DIRECTORY = @DOXYGEN_EXAMPLES_DIRECTORY@ +DOXYGEN_EXTERNAL_SEARCH = @DOXYGEN_EXTERNAL_SEARCH@ +DOXYGEN_HTML_EXTRA_FILES = @DOXYGEN_HTML_EXTRA_FILES@ +DOXYGEN_HTML_EXTRA_STYLESHEET = @DOXYGEN_HTML_EXTRA_STYLESHEET@ +DOXYGEN_HTML_FOOTER = @DOXYGEN_HTML_FOOTER@ +DOXYGEN_HTML_HEADER = @DOXYGEN_HTML_HEADER@ +DOXYGEN_INCLUDE_ALIASES = @DOXYGEN_INCLUDE_ALIASES@ +DOXYGEN_INPUT_DIRECTORY = @DOXYGEN_INPUT_DIRECTORY@ +DOXYGEN_LAYOUT_FILE = @DOXYGEN_LAYOUT_FILE@ +DOXYGEN_MACRO_EXPANSION = @DOXYGEN_MACRO_EXPANSION@ +DOXYGEN_OPTIMIZE_OUTPUT_FOR_C = @DOXYGEN_OPTIMIZE_OUTPUT_FOR_C@ +DOXYGEN_OUTPUT_DIRECTORY = @DOXYGEN_OUTPUT_DIRECTORY@ +DOXYGEN_PACKAGE = @DOXYGEN_PACKAGE@ +DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ +DOXYGEN_PREDEFINED = @DOXYGEN_PREDEFINED@ +DOXYGEN_PROJECT_BRIEF = @DOXYGEN_PROJECT_BRIEF@ +DOXYGEN_PROJECT_LOGO = @DOXYGEN_PROJECT_LOGO@ +DOXYGEN_SEARCHENGINE_URL = @DOXYGEN_SEARCHENGINE_URL@ +DOXYGEN_SERVER_BASED_SEARCH = @DOXYGEN_SERVER_BASED_SEARCH@ +DOXYGEN_STRIP_FROM_PATH = @DOXYGEN_STRIP_FROM_PATH@ +DOXYGEN_TAG_FILE = @DOXYGEN_TAG_FILE@ +DOXYGEN_VERSION_STRING = @DOXYGEN_VERSION_STRING@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ +DX_CONFIG = @DX_CONFIG@ +DX_DOCDIR = @DX_DOCDIR@ +DX_DOT = @DX_DOT@ +DX_DOXYGEN = @DX_DOXYGEN@ +DX_DVIPS = @DX_DVIPS@ +DX_EGREP = @DX_EGREP@ +DX_ENV = @DX_ENV@ +DX_FLAG_chi = @DX_FLAG_chi@ +DX_FLAG_chm = @DX_FLAG_chm@ +DX_FLAG_doc = @DX_FLAG_doc@ +DX_FLAG_dot = @DX_FLAG_dot@ +DX_FLAG_html = @DX_FLAG_html@ +DX_FLAG_man = @DX_FLAG_man@ +DX_FLAG_pdf = @DX_FLAG_pdf@ +DX_FLAG_ps = @DX_FLAG_ps@ +DX_FLAG_rtf = @DX_FLAG_rtf@ +DX_FLAG_xml = @DX_FLAG_xml@ +DX_HHC = @DX_HHC@ +DX_LATEX = @DX_LATEX@ +DX_MAKEINDEX = @DX_MAKEINDEX@ +DX_PDFLATEX = @DX_PDFLATEX@ +DX_PERL = @DX_PERL@ +DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ @@ -501,8 +547,6 @@ H5_CFLAGS = @H5_CFLAGS@ H5_CLASSPATH = @H5_CLASSPATH@ H5_CPPFLAGS = @H5_CPPFLAGS@ H5_CXXFLAGS = @H5_CXXFLAGS@ -H5_ECFLAGS = @H5_ECFLAGS@ -H5_ECXXFLAGS = @H5_ECXXFLAGS@ H5_FCFLAGS = @H5_FCFLAGS@ H5_FORTRAN_SHARED = @H5_FORTRAN_SHARED@ H5_IS_DARWIN = @H5_IS_DARWIN@ @@ -516,7 +560,9 @@ HAVE_DMALLOC = @HAVE_DMALLOC@ HAVE_Fortran_INTEGER_SIZEOF_16 = @HAVE_Fortran_INTEGER_SIZEOF_16@ HAVE_LIBHDFS = @HAVE_LIBHDFS@ HAVE_PTHREAD = @HAVE_PTHREAD@ +HDF5_DOXYGEN = @HDF5_DOXYGEN@ HDF5_HL = @HDF5_HL@ +HDF5_HL_TOOLS = @HDF5_HL_TOOLS@ HDF5_INTERFACES = @HDF5_INTERFACES@ HDF5_TESTS = @HDF5_TESTS@ HDF5_TOOLS = @HDF5_TOOLS@ @@ -526,6 +572,7 @@ HDF_JAVA = @HDF_JAVA@ HID_T = @HID_T@ HL = @HL@ HL_FOR = @HL_FOR@ +HL_TOOLS = @HL_TOOLS@ HSIZE_T = @HSIZE_T@ HSSIZE_T = @HSSIZE_T@ IGNORE_DISABLED_FILE_LOCKS = @IGNORE_DISABLED_FILE_LOCKS@ @@ -719,7 +766,7 @@ LIBH5F_HL = $(top_builddir)/hl/fortran/src/libhdf5hl_fortran.la LIBH5CPP_HL = $(top_builddir)/hl/c++/src/libhdf5_hl_cpp.la # Note that in svn revision 19400 the '/' after DESTDIR in H5* variables below -# has been removed. According to the official description of DESTDIR by Gnu at +# has been removed. According to the official description of DESTDIR by GNU at # http://www.gnu.org/prep/standards/html_node/DESTDIR.html, DESTDIR is # prepended to the normal and complete install path that it precedes for the # purpose of installing in a temporary directory which is useful for building @@ -1256,8 +1303,9 @@ uninstall-am: # commands that should be executed even if a file with the same name already # exists. .PHONY: build-check-clean build-check-p build-check-s build-lib build-progs \ - build-tests check-clean check-install check-p check-s check-vfd \ - install-doc lib progs tests uninstall-doc _exec_check-s _test help + build-tests check-clean check-install check-p check-s check-vfd \ + install-doc lib progs tests uninstall-doc \ + _exec_check-s _test help trace doxygen help: @$(top_srcdir)/bin/makehelp diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index 956aa21..8a97f58 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,38 +23,35 @@ ***************************************************************************/ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file - -const H5std_string FILE1("dataset.h5"); -const H5std_string DSET_DEFAULT_NAME("default"); -const H5std_string DSET_DEFAULT_NAME_PATH("/default"); -const H5std_string DSET_CHUNKED_NAME("chunked"); -const H5std_string DSET_SIMPLE_IO_NAME("simple_io"); -const H5std_string DSET_TCONV_NAME("tconv"); -const H5std_string DSET_COMPRESS_NAME("compressed"); -const H5std_string DSET_BOGUS_NAME("bogus"); +#include "h5cpputil.h" // C++ utilility header file + +const H5std_string FILE1("dataset.h5"); +const H5std_string DSET_DEFAULT_NAME("default"); +const H5std_string DSET_DEFAULT_NAME_PATH("/default"); +const H5std_string DSET_CHUNKED_NAME("chunked"); +const H5std_string DSET_SIMPLE_IO_NAME("simple_io"); +const H5std_string DSET_TCONV_NAME("tconv"); +const H5std_string DSET_COMPRESS_NAME("compressed"); +const H5std_string DSET_BOGUS_NAME("bogus"); +const H5std_string DSET_OPERATOR("testing operator="); +const H5std_string DSET_OPERATOR_PATH("/testing operator="); /* Temporary filter IDs used for testing */ const int H5Z_FILTER_BOGUS = 305; -static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf); // H5_ATTR_UNUSED variables caused warning, but taking them out caused failure. - /*------------------------------------------------------------------------- * Function: test_create * @@ -63,12 +60,10 @@ static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, * Return Success: 0 * * Failure: -1 - * - * Programmer Binh-Minh Ribler (using C version) - * Friday, January 5, 2001 *------------------------------------------------------------------------- */ -static herr_t test_create( H5File& file) +static herr_t +test_create(H5File &file) { SUBTEST("Create, open, close"); @@ -76,19 +71,17 @@ static herr_t test_create( H5File& file) DataSet *dataset = NULL; try { // Create a data space - hsize_t dims[2]; + hsize_t dims[2]; dims[0] = 256; dims[1] = 512; - DataSpace space (2, dims, NULL); + DataSpace space(2, dims, NULL); // Create a dataset using the default dataset creation properties. // We're not sure what they are, so we won't check. - dataset = new DataSet (file.createDataSet - (DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space)); - + dataset = new DataSet(file.createDataSet(DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space)); // Add a comment to the dataset - file.setComment (DSET_DEFAULT_NAME, "This is a dataset"); + file.setComment(DSET_DEFAULT_NAME, "This is a dataset"); // Close the dataset delete dataset; @@ -98,18 +91,19 @@ static herr_t test_create( H5File& file) // dataset can only be created once. If an exception is not thrown for // this action by createDataSet, then throw an invalid action exception. try { - dataset = new DataSet (file.createDataSet - (DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space)); + dataset = new DataSet(file.createDataSet(DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space)); // continuation here, that means no exception has been thrown - throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset"); + throw InvalidActionException("H5File::createDataSet", + "Library allowed overwrite of existing dataset"); } - catch (FileIException& E) // catching invalid creating dataset - {} // do nothing, exception expected + catch (FileIException &E) // catching invalid creating dataset + { + } // do nothing, exception expected // Open the dataset we created above and then close it. This is one // way to open an existing dataset for accessing. - dataset = new DataSet (file.openDataSet (DSET_DEFAULT_NAME)); + dataset = new DataSet(file.openDataSet(DSET_DEFAULT_NAME)); // Get and verify the name of this dataset, using // H5std_string getObjName() @@ -125,30 +119,31 @@ static herr_t test_create( H5File& file) delete dataset; // This is another way to open an existing dataset for accessing. - DataSet another_dataset(file.openDataSet (DSET_DEFAULT_NAME)); + DataSet another_dataset(file.openDataSet(DSET_DEFAULT_NAME)); // Try opening a non-existent dataset. This should fail so if an // exception is not thrown for this action by openDataSet, then // display failure information and throw an exception. try { - dataset = new DataSet (file.openDataSet( "does_not_exist" )); + dataset = new DataSet(file.openDataSet("does_not_exist")); // continuation here, that means no exception has been thrown throw InvalidActionException("H5File::openDataSet", "Attempted to open a non-existent dataset"); } - catch (FileIException& E ) // catching creating non-existent dataset - {} // do nothing, exception expected + catch (FileIException &E) // catching creating non-existent dataset + { + } // do nothing, exception expected // Create a new dataset that uses chunked storage instead of the default // layout. DSetCreatPropList create_parms; - hsize_t csize[2]; + hsize_t csize[2]; csize[0] = 5; csize[1] = 100; - create_parms.setChunk( 2, csize ); + create_parms.setChunk(2, csize); - dataset = new DataSet (file.createDataSet(DSET_CHUNKED_NAME, - PredType::NATIVE_DOUBLE, space, create_parms)); + dataset = + new DataSet(file.createDataSet(DSET_CHUNKED_NAME, PredType::NATIVE_DOUBLE, space, create_parms)); // Note: this one has no error message in C when failure occurs? // clean up and return with success @@ -156,10 +151,9 @@ static herr_t test_create( H5File& file) PASSED(); return 0; - } // outer most try block + } // outer most try block - catch (InvalidActionException& E) - { + catch (InvalidActionException &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -169,8 +163,7 @@ static herr_t test_create( H5File& file) return -1; } // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_create", __LINE__, __FILE__); // clean up and return with failure @@ -178,9 +171,8 @@ static herr_t test_create( H5File& file) delete dataset; return -1; } -} // test_create +} // test_create - /*------------------------------------------------------------------------- * Function: test_simple_io * @@ -191,80 +183,74 @@ static herr_t test_create( H5File& file) * Return Success: 0 * * Failure: -1 - * - * Programmer Binh-Minh Ribler (using C version) - * Friday, January 5, 2001 *------------------------------------------------------------------------- */ -static herr_t test_simple_io( H5File& file) +static herr_t +test_simple_io(H5File &file) { SUBTEST("Simple I/O"); - int points[100][200]; - int check[100][200]; + int points[100][200]; + int check[100][200]; int i, j, n; // Initialize the dataset - for (i = n = 0; i < 100; i++) - { + for (i = n = 0; i < 100; i++) { for (j = 0; j < 200; j++) { points[i][j] = n++; } } - char* tconv_buf = new char [1000]; - try - { + char *tconv_buf = new char[1000]; + try { // Create the data space hsize_t dims[2]; dims[0] = 100; dims[1] = 200; - DataSpace space (2, dims, NULL); + DataSpace space(2, dims, NULL); // Create a small conversion buffer to test strip mining DSetMemXferPropList xfer; - xfer.setBuffer (1000, tconv_buf, NULL); + xfer.setBuffer(1000, tconv_buf, NULL); // Create the dataset - DataSet dataset (file.createDataSet (DSET_SIMPLE_IO_NAME, PredType::NATIVE_INT, space)); + DataSet dataset(file.createDataSet(DSET_SIMPLE_IO_NAME, PredType::NATIVE_INT, space)); // Write the data to the dataset - dataset.write(static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset.write(static_cast<void *>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, + xfer); // Read the dataset back - dataset.read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset.read(static_cast<void *>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < 100; i++) - for (j = 0; j < 200; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); + for (j = 0; j < 200; j++) { + int status = check_values(i, j, points[i][j], check[i][j]); if (status == -1) throw Exception("DataSet::read"); } // clean up and return with success - delete [] tconv_buf; + delete[] tconv_buf; PASSED(); return 0; - } // end try + } // end try // catch all dataset, space, plist exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; // clean up and return with failure if (tconv_buf) - delete [] tconv_buf; + delete[] tconv_buf; return -1; } -} // test_simple_io +} // test_simple_io - /*------------------------------------------------------------------------- * Function: test_datasize * @@ -273,30 +259,26 @@ static herr_t test_simple_io( H5File& file) * Return Success: 0 * * Failure: -1 - * - * Programmer Binh-Minh Ribler - * Thursday, March 22, 2012 *------------------------------------------------------------------------- */ -static herr_t test_datasize(FileAccPropList &fapl) +static herr_t +test_datasize(FileAccPropList &fapl) { SUBTEST("DataSet::getInMemDataSize()"); - try - { + try { // Open FILE1. H5File file(FILE1, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl); // Open dataset DSET_SIMPLE_IO_NAME. - DataSet dset = file.openDataSet (DSET_SIMPLE_IO_NAME); + DataSet dset = file.openDataSet(DSET_SIMPLE_IO_NAME); // Get the dataset's dataspace to calculate the size for verification. DataSpace space(dset.getSpace()); // Get the dimension sizes. hsize_t dims[2]; - int n_dims = space.getSimpleExtentDims(dims); - if (n_dims < 0) - { + int n_dims = space.getSimpleExtentDims(dims); + if (n_dims < 0) { throw Exception("test_compression", "DataSpace::getSimpleExtentDims() failed"); } @@ -308,8 +290,7 @@ static herr_t test_datasize(FileAccPropList &fapl) size_t ds_size = dset.getInMemDataSize(); // Verify the data size. - if (ds_size != expected_size) - { + if (ds_size != expected_size) { H5_FAILED(); cerr << " Expected data size = " << expected_size; cerr << " but dset.getInMemDataSize() returned " << ds_size << endl; @@ -318,19 +299,17 @@ static herr_t test_datasize(FileAccPropList &fapl) PASSED(); return 0; - } // end try + } // end try // catch all dataset, space, plist exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; return -1; } -} // test_datasize +} // test_datasize - /*------------------------------------------------------------------------- * Function: test_tconv * @@ -339,89 +318,81 @@ static herr_t test_datasize(FileAccPropList &fapl) * Return Success: 0 * * Failure: -1 - * - * Programmer Binh-Minh Ribler (using C version) - * Friday, January 5, 2001 *------------------------------------------------------------------------- */ -static herr_t test_tconv(H5File& file) +static herr_t +test_tconv(H5File &file) { // Prepare buffers for input/output - char *out=NULL, *in=NULL; - out = new char [4*1000000]; + char *out = NULL, *in = NULL; + out = new char[4 * 1000000]; // assert (out); - should use exception handler for new - BMR - in = new char [4*1000000]; - //assert (in); + in = new char[4 * 1000000]; + // assert (in); SUBTEST("Data type conversion"); // Initialize the dataset for (int i = 0; i < 1000000; i++) { - out[i*4+0] = 0x11; - out[i*4+1] = 0x22; - out[i*4+2] = 0x33; - out[i*4+3] = 0x44; + out[i * 4 + 0] = 0x11; + out[i * 4 + 1] = 0x22; + out[i * 4 + 2] = 0x33; + out[i * 4 + 3] = 0x44; } - try - { + try { // Create the data space hsize_t dims[1]; dims[0] = 1000000; - DataSpace space (1, dims, NULL); + DataSpace space(1, dims, NULL); // Create the data set - DataSet dataset (file.createDataSet (DSET_TCONV_NAME, PredType::STD_I32LE, space)); + DataSet dataset(file.createDataSet(DSET_TCONV_NAME, PredType::STD_I32LE, space)); // Write the data to the dataset - dataset.write (static_cast<void*>(out), PredType::STD_I32LE); + dataset.write(static_cast<void *>(out), PredType::STD_I32LE); // Read data with byte order conversion - dataset.read (static_cast<void*>(in), PredType::STD_I32BE); + dataset.read(static_cast<void *>(in), PredType::STD_I32BE); // Check for (int i = 0; i < 1000000; i++) { - if (in[4*i+0]!=out[4*i+3] || - in[4*i+1]!=out[4*i+2] || - in[4*i+2]!=out[4*i+1] || - in[4*i+3]!=out[4*i+0]) - { + if (in[4 * i + 0] != out[4 * i + 3] || in[4 * i + 1] != out[4 * i + 2] || + in[4 * i + 2] != out[4 * i + 1] || in[4 * i + 3] != out[4 * i + 0]) { throw Exception("DataSet::read", "Read with byte order conversion failed"); } } // clean up and return with success - delete [] out; - delete [] in; + delete[] out; + delete[] in; PASSED(); return 0; - } // end try + } // end try // catch all dataset and space exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; // clean up and return with failure - delete [] out; - delete [] in; + delete[] out; + delete[] in; return -1; } -} // test_tconv +} // test_tconv /* This message derives from H5Z */ const H5Z_class2_t H5Z_BOGUS[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version number */ - H5Z_FILTER_BOGUS, /* Filter id number */ - 1, 1, /* Encode and decode enabled */ - "bogus", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)filter_bogus, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version number */ + H5Z_FILTER_BOGUS, /* Filter id number */ + 1, 1, /* Encode and decode enabled */ + "bogus", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + filter_bogus, /* The actual filter function */ }}; - /*------------------------------------------------------------------------- * Function: bogus * @@ -435,15 +406,14 @@ const H5Z_class2_t H5Z_BOGUS[1] = {{ * Tuesday, April 21, 1998 *------------------------------------------------------------------------- */ -static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, - const unsigned int cd_values[], size_t nbytes, - size_t *buf_size, void **buf) +static size_t +filter_bogus(unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[], size_t nbytes, + size_t *buf_size, void **buf) // H5_ATTR_UNUSED variables caused warning, but taking them out caused failure. { return nbytes; } - /*------------------------------------------------------------------------- * Function: test_compression * @@ -455,33 +425,29 @@ static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, * Return Success: 0 * * Failure: -1 - * - * Programmer Binh-Minh Ribler (using C version) - * Friday, January 5, 2001 *------------------------------------------------------------------------- */ -static herr_t test_compression(H5File& file) +static herr_t +test_compression(H5File &file) { #ifndef H5_HAVE_FILTER_DEFLATE const char *not_supported; not_supported = " Deflate compression is not enabled."; #endif /* H5_HAVE_FILTER_DEFLATE */ - int points[100][200]; - int check[100][200]; - hsize_t i, j, n; + int points[100][200]; + int check[100][200]; + hsize_t i, j, n; // Initialize the dataset - for (i = n = 0; i < 100; i++) - { + for (i = n = 0; i < 100; i++) { for (j = 0; j < 200; j++) { points[i][j] = static_cast<int>(n++); } } - char* tconv_buf = new char [1000]; - DataSet* dataset = NULL; - try - { + char * tconv_buf = new char[1000]; + DataSet *dataset = NULL; + try { const hsize_t size[2] = {100, 200}; // Create the data space DataSpace space1(2, size, NULL); @@ -489,39 +455,39 @@ static herr_t test_compression(H5File& file) // Create a small conversion buffer to test strip mining DSetMemXferPropList xfer; - xfer.setBuffer (1000, tconv_buf, NULL); + xfer.setBuffer(1000, tconv_buf, NULL); // Use chunked storage with compression DSetCreatPropList dscreatplist; const hsize_t chunk_size[2] = {2, 25}; - dscreatplist.setChunk (2, chunk_size); - dscreatplist.setDeflate (6); + dscreatplist.setChunk(2, chunk_size); + dscreatplist.setDeflate(6); #ifdef H5_HAVE_FILTER_DEFLATE SUBTEST("Compression (setup)"); // Create the dataset - dataset = new DataSet (file.createDataSet - (DSET_COMPRESS_NAME, PredType::NATIVE_INT, space1, dscreatplist)); + dataset = + new DataSet(file.createDataSet(DSET_COMPRESS_NAME, PredType::NATIVE_INT, space1, dscreatplist)); PASSED(); /*---------------------------------------------------------------------- - * STEP 1: Read uninitialized data. It should be zero. - *---------------------------------------------------------------------- - */ + * STEP 1: Read uninitialized data. It should be zero. + *---------------------------------------------------------------------- + */ SUBTEST("Compression (uninitialized read)"); - dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read(static_cast<void *>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - for (i=0; i<size[0]; i++) { - for (j=0; j<size[1]; j++) { - if (0!=check[i][j]) { + for (i = 0; i < size[0]; i++) { + for (j = 0; j < size[1]; j++) { + if (0 != check[i][j]) { H5_FAILED(); cerr << " Read a non-zero value." << endl; - cerr << " At index " << static_cast<unsigned long>(i) - << "," << static_cast<unsigned long>(j) << endl; + cerr << " At index " << static_cast<unsigned long>(i) << "," + << static_cast<unsigned long>(j) << endl; throw Exception("test_compression", "Failed in uninitialized read"); } } @@ -529,38 +495,36 @@ static herr_t test_compression(H5File& file) PASSED(); /*---------------------------------------------------------------------- - * STEP 2: Test compression by setting up a chunked dataset and writing - * to it. - *---------------------------------------------------------------------- - */ + * STEP 2: Test compression by setting up a chunked dataset and writing + * to it. + *---------------------------------------------------------------------- + */ SUBTEST("Compression (write)"); - for (i=n=0; i<size[0]; i++) - { - for (j=0; j<size[1]; j++) - { + for (i = n = 0; i < size[0]; i++) { + for (j = 0; j < size[1]; j++) { points[i][j] = static_cast<int>(n++); } } - dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->write(static_cast<void *>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, + xfer); PASSED(); /*---------------------------------------------------------------------- - * STEP 3: Try to read the data we just wrote. - *---------------------------------------------------------------------- - */ + * STEP 3: Try to read the data we just wrote. + *---------------------------------------------------------------------- + */ SUBTEST("Compression (read)"); // Read the dataset back - dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read(static_cast<void *>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); + for (j = 0; j < size[1]; j++) { + int status = check_values(i, j, points[i][j], check[i][j]); if (status == -1) throw Exception("test_compression", "Failed in read"); } @@ -568,31 +532,29 @@ static herr_t test_compression(H5File& file) PASSED(); /*---------------------------------------------------------------------- - * STEP 4: Write new data over the top of the old data. The new data is - * random thus not very compressible, and will cause the chunks to move - * around as they grow. We only change values for the left half of the - * dataset although we rewrite the whole thing. - *---------------------------------------------------------------------- - */ + * STEP 4: Write new data over the top of the old data. The new data is + * random thus not very compressible, and will cause the chunks to move + * around as they grow. We only change values for the left half of the + * dataset although we rewrite the whole thing. + *---------------------------------------------------------------------- + */ SUBTEST("Compression (modify)"); - for (i=0; i<size[0]; i++) - { - for (j=0; j<size[1]/2; j++) - { - points[i][j] = rand (); + for (i = 0; i < size[0]; i++) { + for (j = 0; j < size[1] / 2; j++) { + points[i][j] = rand(); } } - dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->write(static_cast<void *>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, + xfer); // Read the dataset back and check it - dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read(static_cast<void *>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); + for (j = 0; j < size[1]; j++) { + int status = check_values(i, j, points[i][j], check[i][j]); if (status == -1) throw Exception("test_compression", "Failed in modify"); } @@ -600,66 +562,65 @@ static herr_t test_compression(H5File& file) PASSED(); /*---------------------------------------------------------------------- - * STEP 5: Close the dataset and then open it and read it again. This - * insures that the compression message is picked up properly from the - * object header. - *---------------------------------------------------------------------- - */ + * STEP 5: Close the dataset and then open it and read it again. This + * insures that the compression message is picked up properly from the + * object header. + *---------------------------------------------------------------------- + */ SUBTEST("Compression (re-open)"); // close this dataset to reuse the var delete dataset; - dataset = new DataSet (file.openDataSet (DSET_COMPRESS_NAME)); - dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset = new DataSet(file.openDataSet(DSET_COMPRESS_NAME)); + dataset->read(static_cast<void *>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); + for (j = 0; j < size[1]; j++) { + int status = check_values(i, j, points[i][j], check[i][j]); if (status == -1) throw Exception("test_compression", "Failed in re-open"); } PASSED(); - /*---------------------------------------------------------------------- - * STEP 6: Test partial I/O by writing to and then reading from a - * hyperslab of the dataset. The hyperslab does not line up on chunk - * boundaries (we know that case already works from above tests). - *---------------------------------------------------------------------- - */ + * STEP 6: Test partial I/O by writing to and then reading from a + * hyperslab of the dataset. The hyperslab does not line up on chunk + * boundaries (we know that case already works from above tests). + *---------------------------------------------------------------------- + */ SUBTEST("Compression (partial I/O)"); - const hsize_t hs_size[2] = {4, 50}; + const hsize_t hs_size[2] = {4, 50}; const hsize_t hs_offset[2] = {7, 30}; for (i = 0; i < hs_size[0]; i++) { for (j = 0; j < hs_size[1]; j++) { - points[hs_offset[0]+i][hs_offset[1]+j] = rand (); + points[hs_offset[0] + i][hs_offset[1] + j] = rand(); } } - space1.selectHyperslab( H5S_SELECT_SET, hs_size, hs_offset ); - dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, space1, space1, xfer); - dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, space1, space1, xfer); + space1.selectHyperslab(H5S_SELECT_SET, hs_size, hs_offset); + dataset->write(static_cast<void *>(points), PredType::NATIVE_INT, space1, space1, xfer); + dataset->read(static_cast<void *>(check), PredType::NATIVE_INT, space1, space1, xfer); // Check that the values read are the same as the values written - for (i=0; i<hs_size[0]; i++) { - for (j=0; j<hs_size[1]; j++) { - if (points[hs_offset[0]+i][hs_offset[1]+j] != - check[hs_offset[0]+i][hs_offset[1]+j]) { - H5_FAILED(); - cerr << " Read different values than written.\n" << endl; - cerr << " At index " << static_cast<unsigned long>((hs_offset[0]+i)) << - "," << static_cast<unsigned long>((hs_offset[1]+j)) << endl; - - cerr << " At original: " << static_cast<int>(points[hs_offset[0]+i][hs_offset[1]+j]) << endl; - cerr << " At returned: " << static_cast<int>(check[hs_offset[0]+i][hs_offset[1]+j]) << endl; - throw Exception("test_compression", "Failed in partial I/O"); - } - } // for j - } // for i + for (i = 0; i < hs_size[0]; i++) { + for (j = 0; j < hs_size[1]; j++) { + if (points[hs_offset[0] + i][hs_offset[1] + j] != check[hs_offset[0] + i][hs_offset[1] + j]) { + H5_FAILED(); + cerr << " Read different values than written.\n" << endl; + cerr << " At index " << static_cast<unsigned long>((hs_offset[0] + i)) << "," + << static_cast<unsigned long>((hs_offset[1] + j)) << endl; + + cerr << " At original: " + << static_cast<int>(points[hs_offset[0] + i][hs_offset[1] + j]) << endl; + cerr << " At returned: " << static_cast<int>(check[hs_offset[0] + i][hs_offset[1] + j]) + << endl; + throw Exception("test_compression", "Failed in partial I/O"); + } + } // for j + } // for i delete dataset; dataset = NULL; @@ -673,29 +634,30 @@ static herr_t test_compression(H5File& file) #endif /*---------------------------------------------------------------------- - * STEP 7: Register an application-defined compression method and use it - * to write and then read the dataset. - *---------------------------------------------------------------------- - */ + * STEP 7: Register an application-defined compression method and use it + * to write and then read the dataset. + *---------------------------------------------------------------------- + */ SUBTEST("Compression (app-defined method)"); - if (H5Zregister (H5Z_BOGUS)<0) - throw Exception("test_compression", "Failed in app-defined method"); - if (H5Pset_filter (dscreatplist.getId(), H5Z_FILTER_BOGUS, 0, 0, NULL)<0) + if (H5Zregister(H5Z_BOGUS) < 0) throw Exception("test_compression", "Failed in app-defined method"); - dscreatplist.setFilter (H5Z_FILTER_BOGUS, 0, 0, NULL); + if (H5Pset_filter(dscreatplist.getId(), H5Z_FILTER_BOGUS, 0, 0, NULL) < 0) + throw Exception("test_compression", "Failed in app-defined method"); + dscreatplist.setFilter(H5Z_FILTER_BOGUS, 0, 0, NULL); - DataSpace space2 (2, size, NULL); - dataset = new DataSet (file.createDataSet (DSET_BOGUS_NAME, PredType::NATIVE_INT, space2, dscreatplist)); + DataSpace space2(2, size, NULL); + dataset = + new DataSet(file.createDataSet(DSET_BOGUS_NAME, PredType::NATIVE_INT, space2, dscreatplist)); - dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->write(static_cast<void *>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, + xfer); + dataset->read(static_cast<void *>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); + for (j = 0; j < size[1]; j++) { + int status = check_values(i, j, points[i][j], check[i][j]); if (status == -1) throw Exception("test_compression", "Failed in app-defined method"); } @@ -703,17 +665,16 @@ static herr_t test_compression(H5File& file) PASSED(); /*---------------------------------------------------------------------- - * Cleanup - *---------------------------------------------------------------------- - */ + * Cleanup + *---------------------------------------------------------------------- + */ delete dataset; - delete [] tconv_buf; + delete[] tconv_buf; return 0; } // end try // catch all dataset, file, space, and plist exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -721,12 +682,11 @@ static herr_t test_compression(H5File& file) if (dataset != NULL) delete dataset; if (tconv_buf) - delete [] tconv_buf; + delete[] tconv_buf; return -1; } -} // test_compression +} // test_compression - /*------------------------------------------------------------------------- * Function: test_nbit_methods * @@ -735,25 +695,22 @@ static herr_t test_compression(H5File& file) * Return Success: 0 * * Failure: -1 - * - * Programmer Binh-Minh Ribler - * Friday, April 22, 2016 - * *------------------------------------------------------------------------- */ const H5std_string DSET_NBIT_NAME("nbit_dataset"); -const hsize_t DIM1 = 2; -const hsize_t DIM2 = 5; +const hsize_t DIM1 = 2; +const hsize_t DIM2 = 5; -static herr_t test_nbit_compression(H5File& file) +static herr_t +test_nbit_compression(H5File &file) { typedef struct { - int i; - char c; + int i; + char c; short s; } s1_t; - const hsize_t size[2] = {DIM1, DIM2}; + const hsize_t size[2] = {DIM1, DIM2}; const hsize_t chunk_size[2] = {DIM1, DIM2}; s1_t orig_data[DIM1][DIM2]; s1_t new_data[DIM1][DIM2]; @@ -761,8 +718,7 @@ static herr_t test_nbit_compression(H5File& file) SUBTEST("N-bit compression (setup)"); - try - { + try { // Define datatypes of members of compound datatype IntType i_type(PredType::NATIVE_INT); IntType c_type(PredType::NATIVE_CHAR); @@ -781,7 +737,7 @@ static herr_t test_nbit_compression(H5File& file) mem_cmpd.insertMember("s", HOFFSET(s1_t, s), s_type); // Set order of dataset compound datatype - //cmpd.setOrder(H5T_ORDER_BE); only for atomic type? + // cmpd.setOrder(H5T_ORDER_BE); only for atomic type? // Create the data space DataSpace space(2, size); @@ -796,36 +752,33 @@ static herr_t test_nbit_compression(H5File& file) // Initialize data, assuming size of long long >= size of member datatypes for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { + for (j = 0; j < size[1]; j++) { orig_data[i][j].i = static_cast<int>(i * j); orig_data[i][j].c = static_cast<char>('a' + i); orig_data[i][j].s = static_cast<short>(i + j); // Some even-numbered integer values are negative - if ((i*size[1]+j+1)%2 == 0) { + if ((i * size[1] + j + 1) % 2 == 0) { orig_data[i][j].i = -orig_data[i][j].i; orig_data[i][j].s = static_cast<short>(-orig_data[i][j].s); } } // Write to the dataset - dataset.write(static_cast<void*>(orig_data), mem_cmpd); + dataset.write(static_cast<void *>(orig_data), mem_cmpd); // Read the dataset back */ - dataset.read(static_cast<void*>(new_data), mem_cmpd); + dataset.read(static_cast<void *>(new_data), mem_cmpd); // Check that the values read are the same as the values written. for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - if((new_data[i][j].i != orig_data[i][j].i) || - (new_data[i][j].c != orig_data[i][j].c) || - (new_data[i][j].s != orig_data[i][j].s)) - { + for (j = 0; j < size[1]; j++) { + if ((new_data[i][j].i != orig_data[i][j].i) || (new_data[i][j].c != orig_data[i][j].c) || + (new_data[i][j].s != orig_data[i][j].s)) { H5_FAILED(); printf(" Read different values than written.\n"); - printf(" At index %lu,%lu\n", static_cast<unsigned long>(i), static_cast<unsigned long>(j)); + printf(" At index %lu,%lu\n", static_cast<unsigned long>(i), + static_cast<unsigned long>(j)); } } @@ -834,8 +787,7 @@ static herr_t test_nbit_compression(H5File& file) } // end try block // catch all dataset, file, space, and plist exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -843,7 +795,6 @@ static herr_t test_nbit_compression(H5File& file) } } // test_nbit_compression - /*------------------------------------------------------------------------- * Function: test_multiopen * @@ -855,17 +806,15 @@ static herr_t test_nbit_compression(H5File& file) * Return Success: 0 * * Failure: -1 - * - * Programmer Binh-Minh Ribler (using C version) - * Saturday, February 17, 2001 *------------------------------------------------------------------------- */ -static herr_t test_multiopen (H5File& file) +static herr_t +test_multiopen(H5File &file) { SUBTEST("Multi-open with extending"); - DataSpace* space = NULL; + DataSpace *space = NULL; try { // Create a dataset creation property list @@ -873,17 +822,17 @@ static herr_t test_multiopen (H5File& file) // Set chunk size to given size hsize_t cur_size[1] = {10}; - dcpl.setChunk (1, cur_size); + dcpl.setChunk(1, cur_size); // Create a simple data space with unlimited size hsize_t max_size[1] = {H5S_UNLIMITED}; - space = new DataSpace (1, cur_size, max_size); + space = new DataSpace(1, cur_size, max_size); // Create first dataset - DataSet dset1 = file.createDataSet ("multiopen", PredType::NATIVE_INT, *space, dcpl); + DataSet dset1 = file.createDataSet("multiopen", PredType::NATIVE_INT, *space, dcpl); // Open again the first dataset from the file to another DataSet object. - DataSet dset2 = file.openDataSet ("multiopen"); + DataSet dset2 = file.openDataSet("multiopen"); // Relieve the dataspace delete space; @@ -891,18 +840,16 @@ static herr_t test_multiopen (H5File& file) // Extend the dimensionality of the first dataset cur_size[0] = 20; - dset1.extend (cur_size); + dset1.extend(cur_size); // Get the size from the second handle - space = new DataSpace (dset2.getSpace()); + space = new DataSpace(dset2.getSpace()); hsize_t tmp_size[1]; - space->getSimpleExtentDims (tmp_size); - if (cur_size[0]!=tmp_size[0]) - { - cerr << " Got " << static_cast<int>(tmp_size[0]) - << " instead of " << static_cast<int>(cur_size[0]) - << "!" << endl; + space->getSimpleExtentDims(tmp_size); + if (cur_size[0] != tmp_size[0]) { + cerr << " Got " << static_cast<int>(tmp_size[0]) << " instead of " + << static_cast<int>(cur_size[0]) << "!" << endl; throw Exception("test_multiopen", "Failed in multi-open with extending"); } @@ -913,8 +860,7 @@ static herr_t test_multiopen (H5File& file) } // end try block // catch all dataset, file, space, and plist exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -923,9 +869,8 @@ static herr_t test_multiopen (H5File& file) delete space; return -1; } -} // test_multiopen +} // test_multiopen - /*------------------------------------------------------------------------- * Function: test_types * @@ -934,29 +879,27 @@ static herr_t test_multiopen (H5File& file) * Return Success: 0 * * Failure: -1 - * - * Programmer Binh-Minh Ribler (using C version) - * February 17, 2001 *------------------------------------------------------------------------- */ -static herr_t test_types(H5File& file) +static herr_t +test_types(H5File &file) { SUBTEST("Various datatypes"); - size_t i; - DataSet* dset = NULL; + size_t i; + DataSet *dset = NULL; try { // Create a group in the file that was passed in from the caller - Group grp = file.createGroup ("typetests"); + Group grp = file.createGroup("typetests"); /* bitfield_1 */ unsigned char buf[32]; - hsize_t nelmts = sizeof(buf); - DataType type; + hsize_t nelmts = sizeof(buf); + DataType type; try { // block of bitfield_1 // test copying a predefined type - type.copy (PredType::STD_B8LE); + type.copy(PredType::STD_B8LE); // Test copying a user-defined type using DataType::copy DataType copied_type; @@ -967,7 +910,7 @@ static herr_t test_types(H5File& file) another_copied_type = type; // Test copying a user-defined int type using DataType::operator= - IntType orig_int(PredType::STD_B8LE); + IntType orig_int(PredType::STD_B8LE); DataType generic_type; generic_type = orig_int; @@ -978,45 +921,45 @@ static herr_t test_types(H5File& file) IntType another_int_type; another_int_type = new_int_type; - DataSpace space (1, &nelmts); + DataSpace space(1, &nelmts); dset = new DataSet(grp.createDataSet("bitfield_1", type, space)); // Fill buffer - for (i=0; i<sizeof buf; i++) - buf[i] = static_cast<unsigned char>(0xff) ^ static_cast<unsigned char>(i); + for (i = 0; i < sizeof buf; i++) + buf[i] = static_cast<unsigned char>(0xff) ^ static_cast<unsigned char>(i); // Write data from buf using all default dataspaces and property list - dset->write (buf, type); + dset->write(buf, type); // no failure in bitfield_1, close this dataset delete dset; } // end try block of bitfield_1 // catch exceptions thrown in try block of bitfield_1 - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; - cerr << " <<< " << "bitfield_1: " << E.getFuncName() - << " - " << E.getDetailMsg() << " >>>" << endl << endl; + cerr << " <<< " + << "bitfield_1: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl + << endl; if (dset != NULL) delete dset; return -1; } /* bitfield_2 */ - nelmts = sizeof(buf)/2; + nelmts = sizeof(buf) / 2; try { // bitfield_2 block - type.copy (PredType::STD_B16LE); - DataSpace space (1, &nelmts); + type.copy(PredType::STD_B16LE); + DataSpace space(1, &nelmts); dset = new DataSet(grp.createDataSet("bitfield_2", type, space)); // Fill buffer - for (i=0; i<sizeof(buf); i++) + for (i = 0; i < sizeof(buf); i++) buf[i] = static_cast<unsigned char>(0xff) ^ static_cast<unsigned char>(i); // Write data from buf using all default dataspaces and property // list; if writing fails, deallocate dset and return. - dset->write (buf, type); + dset->write(buf, type); // no failure in bitfield_2, close this dataset and reset for // variable reuse @@ -1025,44 +968,46 @@ static herr_t test_types(H5File& file) } // end try block of bitfield_2 // catch exceptions thrown in try block of bitfield_2 - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; - cerr << " <<< " << "bitfield_2: " << E.getFuncName() - << " - " << E.getDetailMsg() << " >>>" << endl << endl; + cerr << " <<< " + << "bitfield_2: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl + << endl; if (dset != NULL) delete dset; throw E; // propagate the exception } /* opaque_1 */ - DataType* optype = NULL; + DataType *optype = NULL; try { // opaque_1 block optype = new DataType(H5T_OPAQUE, 1); nelmts = sizeof(buf); - DataSpace space (1, &nelmts); - optype->setTag ("testing 1-byte opaque type"); + DataSpace space(1, &nelmts); + optype->setTag("testing 1-byte opaque type"); dset = new DataSet(grp.createDataSet("opaque_1", *optype, space)); // Fill buffer - for (i=0; i<sizeof buf; i++) + for (i = 0; i < sizeof buf; i++) buf[i] = static_cast<unsigned char>(0xff) ^ static_cast<unsigned char>(i); // Write data from buf using all default dataspaces and property // list; if writing fails, deallocate dset and return. - dset->write (buf, *optype); + dset->write(buf, *optype); // no failure in opaque_1 - delete dset; dset = NULL; - delete optype; optype = NULL; + delete dset; + dset = NULL; + delete optype; + optype = NULL; } // end try block of opaque_1 // catch exceptions thrown in try block of opaque_1 - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; - cerr << " <<< " << "opaque_1: " << E.getFuncName() - << " - " << E.getDetailMsg() << " >>>" << endl << endl; + cerr << " <<< " + << "opaque_1: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl + << endl; if (dset != NULL) delete dset; if (optype != NULL) @@ -1072,31 +1017,33 @@ static herr_t test_types(H5File& file) /* opaque_2 */ try { // block opaque_2 - nelmts = sizeof(buf)/4; - DataSpace space (1, &nelmts); + nelmts = sizeof(buf) / 4; + DataSpace space(1, &nelmts); optype = new DataType(H5T_OPAQUE, 4); - optype->setTag ("testing 4-byte opaque type"); + optype->setTag("testing 4-byte opaque type"); dset = new DataSet(grp.createDataSet("opaque_2", *optype, space)); // Fill buffer - for (i=0; i<sizeof(buf); i++) + for (i = 0; i < sizeof(buf); i++) buf[i] = static_cast<unsigned char>(0xff) ^ static_cast<unsigned char>(i); // Write data from buf using all default dataspaces and property // list; if writing fails, deallocate dset and return. - dset->write (buf, *optype); + dset->write(buf, *optype); // no failure in opaque_1 - delete dset; dset = NULL; - delete optype; optype = NULL; - } //end try block of opaque_2 + delete dset; + dset = NULL; + delete optype; + optype = NULL; + } // end try block of opaque_2 // catch exceptions thrown in try block of opaque_2 - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; - cerr << " <<< " << "opaque_2: " << E.getFuncName() - << " - " << E.getDetailMsg() << " >>>" << endl << endl; + cerr << " <<< " + << "opaque_2: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl + << endl; if (dset != NULL) delete dset; if (optype != NULL) @@ -1108,13 +1055,11 @@ static herr_t test_types(H5File& file) return 0; } // end top try block - catch (Exception& E) - { + catch (Exception &E) { return -1; } -} // test_types +} // test_types - /*------------------------------------------------------------------------- * Function: test_getObjinfo * @@ -1126,16 +1071,17 @@ static herr_t test_types(H5File& file) * July, 2018 *------------------------------------------------------------------------- */ -static herr_t test_getinfo(H5File& file) +static herr_t +test_getinfo(H5File &file) { SUBTEST("Getting object information"); try { // Create a data space - hsize_t dims[2]; + hsize_t dims[2]; dims[0] = 256; dims[1] = 512; - DataSpace space (2, dims, NULL); + DataSpace space(2, dims, NULL); // Create a dataset using the default dataset creation properties. // We're not sure what they are, so we won't check. @@ -1158,23 +1104,20 @@ static herr_t test_getinfo(H5File& file) PASSED(); return 0; - } // outer most try block + } // outer most try block - catch (InvalidActionException& E) - { + catch (InvalidActionException &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; return -1; } // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_getinfo", __LINE__, __FILE__); return -1; } -} // test_getinfo +} // test_getinfo - /*------------------------------------------------------------------------- * Function: test_chunk_cache * @@ -1187,10 +1130,11 @@ static herr_t test_getinfo(H5File& file) * July 2018 *------------------------------------------------------------------------- */ -const int RANK1 = 1; +const int RANK1 = 1; const H5std_string FILE_ACCPLIST("test_accplist.h5"); -static herr_t test_chunk_cache(FileAccPropList fapl) +static herr_t +test_chunk_cache(const FileAccPropList &fapl) { SUBTEST("DSetAccPropList::set/getChunkCache"); @@ -1200,14 +1144,14 @@ static herr_t test_chunk_cache(FileAccPropList fapl) DSetAccPropList dapl; // Verify that chunk cache parameters are the same - int mdc_nelmts = 0; + int mdc_nelmts = 0; size_t nslots_1 = 0, nslots_4 = 0, nbytes_1 = 0, nbytes_4 = 0; - double w0_1 = 0.0F, w0_4 = 0.0F; + double w0_1 = 0.0, w0_4 = 0.0; fapl_def.getCache(mdc_nelmts, nslots_1, nbytes_1, w0_1); dapl.getChunkCache(nslots_4, nbytes_4, w0_4); - verify_val(nslots_1, nslots_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); - verify_val(nbytes_1, nbytes_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); - verify_val(w0_1, w0_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); + verify_val(nslots_1, nslots_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); + verify_val(nbytes_1, nbytes_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); + verify_val(w0_1, w0_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); // Set a link access property on dapl to verify property list inheritance dapl.setNumLinks((size_t)134); @@ -1220,7 +1164,7 @@ static herr_t test_chunk_cache(FileAccPropList fapl) // Set new rdcc settings on fapl local size_t nslots_2 = nslots_1 * 2; size_t nbytes_2 = nbytes_1 * 2; - double w0_2 = w0_1 / (double)2.0F; + double w0_2 = w0_1 / 2.0; fapl_local.getCache(mdc_nelmts, nslots_2, nbytes_2, w0_2); // Create a new file using default fcpl and the passed-in fapl @@ -1247,17 +1191,16 @@ static herr_t test_chunk_cache(FileAccPropList fapl) // Retrieve and verify the raw data chunk cache parameters nslots_4 = nbytes_4 = 0; - w0_4 = 0.0F; + w0_4 = 0.0F; dapl2.getChunkCache(nslots_4, nbytes_4, w0_4); verify_val(nslots_2, nslots_4, "DSetCreatPropList::getChunkCache", __LINE__, __FILE__); verify_val(nbytes_2, nbytes_4, "DSetCreatPropList::getChunkCache", __LINE__, __FILE__); verify_val(H5_DBL_ABS_EQUAL(w0_2, w0_4), 1, "DSetCreatPropList::getChunkCache", __LINE__, __FILE__); - // Set new values on original dapl size_t nslots_3 = nslots_1 * 2; size_t nbytes_3 = H5D_CHUNK_CACHE_NBYTES_DEFAULT; - double w0_3 = w0_2 / 2; + double w0_3 = w0_2 / 2; dapl.getChunkCache(nslots_3, nbytes_3, w0_3); // Close dataset @@ -1275,18 +1218,15 @@ static herr_t test_chunk_cache(FileAccPropList fapl) verify_val(nbytes_3, nbytes_4, "DSetCreatPropList::getLayout", __LINE__, __FILE__); verify_val(H5_DBL_ABS_EQUAL(w0_3, w0_4), 1, "DSetCreatPropList::getLayout", __LINE__, __FILE__); - PASSED(); return 0; } // end top try block - catch (Exception& E) - { + catch (Exception &E) { return -1; } } // test_chunk_cache - /*------------------------------------------------------------------------- * Function: test_virtual * @@ -1295,15 +1235,12 @@ static herr_t test_chunk_cache(FileAccPropList fapl) * * Return Success: 0 * Failure: number of errors - * - * Programmer Binh-Minh Ribler - * Friday, March 10, 2017 - * *------------------------------------------------------------------------- */ const int RANK = 2; -static herr_t test_virtual() +static herr_t +test_virtual() { SUBTEST("DSetCreatPropList::setVirtual"); @@ -1338,8 +1275,8 @@ static herr_t test_virtual() dims[1] = 6; DataSpace vspace(RANK, dims, mdims); - hsize_t start[RANK]; // Hyperslab start - hsize_t count[RANK]; // Hyperslab count + hsize_t start[RANK]; // Hyperslab start + hsize_t count[RANK]; // Hyperslab count start[0] = start[1] = 3; count[0] = count[1] = 3; vspace.selectHyperslab(H5S_SELECT_SET, count, start); @@ -1358,13 +1295,65 @@ static herr_t test_virtual() return 0; } // end top try block - catch (Exception& E) - { + catch (Exception &E) { return -1; } } // test_virtual - +/*------------------------------------------------------------------------- + * Function: test_operator + * + * Purpose Tests DataSet::operator= + * + * Return Success: 0 + * + * Failure: -1 + *------------------------------------------------------------------------- + */ +static herr_t +test_operator(H5File &file) +{ + SUBTEST("DataSet::operator="); + + try { + // Create a data space + hsize_t dims[2]; + dims[0] = 256; + dims[1] = 512; + DataSpace space(2, dims, NULL); + + // Create a dataset using the default dataset creation properties. + // We're not sure what they are, so we won't check. + DataSet dataset = file.createDataSet(DSET_OPERATOR, PredType::NATIVE_DOUBLE, space); + + // Add a comment to the dataset + file.setComment(DSET_OPERATOR, "Dataset using operator="); + + // Close the dataset + dataset.close(); + + // Re-open the dataset + DataSet another_dataset(file.openDataSet(DSET_OPERATOR)); + + // Try operator= to make another dataset + DataSet copied_dataset = another_dataset; + + H5std_string copied_dataset_name = copied_dataset.getObjName(); + H5std_string another_dataset_name = another_dataset.getObjName(); + + PASSED(); + return 0; + } // try block + + // catch all other exceptions + catch (Exception &E) { + issue_fail_msg("test_operator", __LINE__, __FILE__); + + // clean up and return with failure + return -1; + } +} // test_operator + /*------------------------------------------------------------------------- * Function: test_dset * @@ -1374,9 +1363,6 @@ static herr_t test_virtual() * * Failure: -1 * - * Programmer Binh-Minh Ribler (using C version) - * Friday, January 5, 2001 - * * Modifications: * Nov 12, 01: * - moved h5_cleanup to outside of try block because @@ -1387,15 +1373,14 @@ static herr_t test_virtual() * *------------------------------------------------------------------------- */ -extern "C" -void test_dset() +extern "C" void +test_dset() { hid_t fapl_id; - fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template - int nerrors=0; // keep track of number of failures occur + fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template + int nerrors = 0; // keep track of number of failures occur - try - { + try { // Use the file access template id to create a file access prop. // list object to pass in H5File::H5File FileAccPropList fapl(fapl_id); @@ -1403,19 +1388,20 @@ void test_dset() H5File file(FILE1, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); // Cause the library to emit initial messages - Group grp = file.createGroup( "emit diagnostics", 0); + Group grp = file.createGroup("emit diagnostics", 0); grp.setComment("Causes diagnostic messages to be emitted"); - nerrors += test_create(file) < 0 ? 1:0; - nerrors += test_simple_io(file) < 0 ? 1:0; - nerrors += test_getinfo(file) < 0 ? 1:0; - nerrors += test_tconv(file) < 0 ? 1:0; - nerrors += test_compression(file) < 0 ? 1:0; - nerrors += test_nbit_compression(file) < 0 ? 1:0; - nerrors += test_multiopen (file) < 0 ? 1:0; - nerrors += test_types(file) < 0 ? 1:0; - nerrors += test_virtual() < 0 ? 1:0; - nerrors += test_chunk_cache(fapl) < 0 ? 1:0; + nerrors += test_create(file) < 0 ? 1 : 0; + nerrors += test_simple_io(file) < 0 ? 1 : 0; + nerrors += test_getinfo(file) < 0 ? 1 : 0; + nerrors += test_tconv(file) < 0 ? 1 : 0; + nerrors += test_compression(file) < 0 ? 1 : 0; + nerrors += test_nbit_compression(file) < 0 ? 1 : 0; + nerrors += test_multiopen(file) < 0 ? 1 : 0; + nerrors += test_types(file) < 0 ? 1 : 0; + nerrors += test_virtual() < 0 ? 1 : 0; + nerrors += test_operator(file) < 0 ? 1 : 0; + nerrors += test_chunk_cache(fapl) < 0 ? 1 : 0; // Close group "emit diagnostics". grp.close(); @@ -1423,18 +1409,16 @@ void test_dset() // Close the file before testing data size. file.close(); - nerrors += test_datasize(fapl) <0 ? 1:0; + nerrors += test_datasize(fapl) < 0 ? 1 : 0; } - catch (Exception& E) - { + catch (Exception &E) { test_report(nerrors, H5std_string(" Dataset")); } // Clean up data file cleanup_dsets(); -} // test_dset +} // test_dset - /*------------------------------------------------------------------------- * Function: cleanup_dsets * @@ -1445,9 +1429,8 @@ void test_dset() * Programmer (use C version) *------------------------------------------------------------------------- */ -extern "C" -void cleanup_dsets() +extern "C" void +cleanup_dsets() { HDremove(FILE1.c_str()); } // cleanup_dsets - diff --git a/c++/test/h5cpputil.cpp b/c++/test/h5cpputil.cpp index f271eed..78169b2 100644 --- a/c++/test/h5cpputil.cpp +++ b/c++/test/h5cpputil.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -19,20 +19,16 @@ ***************************************************************************/ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file /*------------------------------------------------------------------------- * Function: test_report @@ -49,24 +45,21 @@ using namespace H5; * Friday, February 6, 2001 *------------------------------------------------------------------------- */ -int test_report( int nerrors, const H5std_string& testname ) +int +test_report(int nerrors, const H5std_string &testname) { - if (nerrors) - { - nerrors = MAX(1, nerrors); + if (nerrors) { + nerrors = MAX(1, nerrors); if (1 == nerrors) - cerr << "***** " << nerrors << testname - << " TEST FAILED! *****" << endl; + cerr << "***** " << nerrors << testname << " TEST FAILED! *****" << endl; else - cerr << "***** " << nerrors << testname - << " TESTS FAILED! *****" << endl; - return 1; - } - else - { - cerr << "All" << testname << " tests passed." << endl; - return 0; - } + cerr << "***** " << nerrors << testname << " TESTS FAILED! *****" << endl; + return 1; + } + else { + cerr << "All" << testname << " tests passed." << endl; + return 0; + } } /*------------------------------------------------------------------------- @@ -81,14 +74,14 @@ int test_report( int nerrors, const H5std_string& testname ) * *------------------------------------------------------------------------- */ -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 *message) { - if (GetTestVerbosity()>=VERBO_HI) - { + if (GetTestVerbosity() >= VERBO_HI) { cerr << endl; - cerr << ">>> FAILED in " << where << " at line " << line - << " in " << file_name << " - " << message << endl << endl; + cerr << ">>> FAILED in " << where << " at line " << line << " in " << file_name << " - " << message + << endl + << endl; } } @@ -104,15 +97,15 @@ void issue_fail_msg(const char* where, int line, const char* file_name, * *------------------------------------------------------------------------- */ -void issue_fail_msg(const char* where, int line, const char* file_name, - const char* func_name, const char* message) +void +issue_fail_msg(const char *where, int line, const char *file_name, const char *func_name, const char *message) { - if (GetTestVerbosity()>=VERBO_HI) - { + 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; + cerr << ">>> FAILED in " << where << ": " << func_name << endl + << " at line " << line << " in " << file_name << endl + << " C library detail: " << message << endl + << endl; } } @@ -134,13 +127,13 @@ void issue_fail_msg(const char* where, int line, const char* file_name, * Friday, February 6, 2001 *------------------------------------------------------------------------- */ -int check_values (hsize_t i, hsize_t j, int apoint, int acheck) +int +check_values(hsize_t i, hsize_t j, int apoint, int acheck) { - if (apoint != acheck) - { + if (apoint != acheck) { cerr << " Read different values than written.\n" << endl; - cerr << " At index " << static_cast<unsigned long>(i) << "," << - static_cast<unsigned long>(j) << endl; + cerr << " At index " << static_cast<unsigned long>(i) << "," << static_cast<unsigned long>(j) + << endl; return -1; } return 0; @@ -161,10 +154,10 @@ int check_values (hsize_t i, hsize_t j, int apoint, int acheck) * *------------------------------------------------------------------------- */ -void check_values(const char *value, const char* msg, int line, const char* file_name) +void +check_values(const char *value, const char *msg, int line, const char *file_name) { - if (value == NULL) - { + if (value == NULL) { cerr << endl; cerr << "*** ERROR: " << msg << ", at line " << line << endl; IncTestNumErrs(); @@ -187,21 +180,19 @@ void check_values(const char *value, const char* msg, int line, const char* file * May 2, 2010 *------------------------------------------------------------------------- */ -void verify_val(const char* x, const char* value, const char* where, int line, const char* file_name) +void +verify_val(const char *x, const char *value, const char *where, int line, const char *file_name) { - if (GetTestVerbosity()>=VERBO_HI) - { + if (GetTestVerbosity() >= VERBO_HI) { cerr << endl; - cerr << " Call to routine: " << where << " at line " << line - << " in " << file_name << " had value " << x << endl; + cerr << " Call to routine: " << where << " at line " << line << " in " << file_name << " had value " + << x << endl; } - if (strcmp(x, value) != 0) - { + if (strcmp(x, value) != 0) { cerr << endl; - cerr << "*** UNEXPECTED VALUE from " << where << " should be " - << value << ", but is " << x << " at line " << line - << " in " << file_name << endl; - //IncTestNumErrs(); + cerr << "*** UNEXPECTED VALUE from " << where << " should be " << value << ", but is " << x + << " at line " << line << " in " << file_name << endl; + // IncTestNumErrs(); throw TestFailedException(where, ""); } } @@ -209,7 +200,9 @@ void verify_val(const char* x, const char* value, const char* where, int line, c //-------------------------------------------------------------------------- // Function: InvalidActionException default constructor //-------------------------------------------------------------------------- -InvalidActionException::InvalidActionException():Exception(){} +InvalidActionException::InvalidActionException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: InvalidActionException overloaded constructor @@ -221,17 +214,24 @@ InvalidActionException::InvalidActionException():Exception(){} // func - IN: Name of the function where failure should occur // message - IN: Message //-------------------------------------------------------------------------- -InvalidActionException::InvalidActionException(const H5std_string func, const H5std_string message) : Exception(func, message) {} +InvalidActionException::InvalidActionException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: InvalidActionException destructor //-------------------------------------------------------------------------- -InvalidActionException::~InvalidActionException() throw() {} +InvalidActionException::~InvalidActionException() throw() +{ +} //-------------------------------------------------------------------------- // Function: TestFailedException default constructor //-------------------------------------------------------------------------- -TestFailedException::TestFailedException():Exception(){} +TestFailedException::TestFailedException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: TestFailedException overloaded constructor @@ -243,10 +243,14 @@ TestFailedException::TestFailedException():Exception(){} // func - IN: Name of the function where failure should occur // message - IN: Message //-------------------------------------------------------------------------- -TestFailedException::TestFailedException(const H5std_string func, const H5std_string message) : Exception(func, message) {} +TestFailedException::TestFailedException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: TestFailedException destructor //-------------------------------------------------------------------------- -TestFailedException::~TestFailedException() throw() {} - +TestFailedException::~TestFailedException() throw() +{ +} diff --git a/c++/test/h5cpputil.h b/c++/test/h5cpputil.h index 6664d0c..444bc68 100644 --- a/c++/test/h5cpputil.h +++ b/c++/test/h5cpputil.h @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -19,8 +19,8 @@ ***************************************************************************/ -#ifndef _h5cpputil_h -#define _h5cpputil_h +#ifndef H5cpputil_H +#define H5cpputil_H #include "h5test.h" @@ -28,94 +28,97 @@ using namespace H5; using std::cerr; using std::endl; -#define MESSAGE(V,A) {if (HDGetTestVerbosity()>(V)) print_func A;} -#define SUBTEST(TEST) {printf(" Subtest: %-52s",TEST); fflush(stdout);} +#define MESSAGE(V, A) \ + { \ + if (HDGetTestVerbosity() > (V)) \ + print_func A; \ + } +#define SUBTEST(TEST) \ + { \ + printf(" Subtest: %-52s", TEST); \ + fflush(stdout); \ + } -int check_values (hsize_t i, hsize_t j, int apoint, int acheck); -void check_values(const char *value, const char* msg, int line, const char* file_name); -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); +int check_values(hsize_t i, hsize_t j, int apoint, int acheck); +void check_values(const char *value, const char *msg, int line, const char *file_name); +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: - InvalidActionException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG); - InvalidActionException(); - virtual ~InvalidActionException() throw(); + public: + InvalidActionException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + InvalidActionException(); + virtual ~InvalidActionException() throw(); }; class TestFailedException : public Exception { - public: - TestFailedException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG); - TestFailedException(); - virtual ~TestFailedException() throw(); + public: + TestFailedException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + TestFailedException(); + virtual ~TestFailedException() throw(); }; // Overloaded/Template functions to verify values and display proper info // Verifies -void verify_val(const char* x, const char* value, const char* where, int line, const char* file_name); +void verify_val(const char *x, const char *value, const char *where, int line, const char *file_name); template <class Type1, class Type2> - void verify_val(Type1 x, Type2 value, const char* where, int line, const char* file_name) +void +verify_val(Type1 x, Type2 value, const char *where, int line, const char *file_name) { - if (GetTestVerbosity()>=VERBO_HI) - { + if (GetTestVerbosity() >= VERBO_HI) { cerr << endl; - cerr << " Call to routine: " << where << " at line " << line - << " in " << file_name << " had value " << x << endl; + cerr << " Call to routine: " << where << " at line " << line << " in " << file_name << " had value " + << x << endl; } - if (x != value) - { + if (x != value) { cerr << endl; - cerr << "*** UNEXPECTED VALUE from " << where << " should be " - << value << ", but is " << x << " at line " << line - << " in " << file_name << endl; + cerr << "*** UNEXPECTED VALUE from " << where << " should be " << value << ", but is " << x + << " at line " << line << " in " << file_name << endl; IncTestNumErrs(); throw TestFailedException(where, ""); } } template <class Type1, class Type2> - void verify_val(Type1 x, Type2 value, const char* msg, const char* file_name, int line) +void +verify_val(Type1 x, Type2 value, const char *msg, const char *file_name, int line) { - if (x != value) - { + if (x != value) { cerr << endl; - cerr << "*** UNEXPECTED VALUE: " << file_name << ":line " << line - << ": " << msg << " different: " << x << ", should be " << value - << endl; + cerr << "*** UNEXPECTED VALUE: " << file_name << ":line " << line << ": " << msg + << " different: " << x << ", should be " << value << endl; IncTestNumErrs(); throw TestFailedException(file_name, msg); } } template <class Type1, class Type2> - void verify_val_noteq(Type1 x, Type2 value, const char* where, int line, const char* file_name) +void +verify_val_noteq(Type1 x, Type2 value, const char *where, int line, const char *file_name) { - if (GetTestVerbosity()>=VERBO_HI) - { + if (GetTestVerbosity() >= VERBO_HI) { cerr << endl; - cerr << " Call to routine: " << where << " at line " << line - << " in " << file_name << " had value " << x << endl; + cerr << " Call to routine: " << where << " at line " << line << " in " << file_name << " had value " + << x << endl; } - if (x == value) - { + if (x == value) { cerr << endl; - cerr << "*** UNEXPECTED VALUE from " << where << " should not be " - << value << " at line " << line << " in " << file_name << endl; + cerr << "*** UNEXPECTED VALUE from " << where << " should not be " << value << " at line " << line + << " in " << file_name << endl; IncTestNumErrs(); throw TestFailedException(where, ""); } } template <class Type1, class Type2> - void CHECK(Type1 x, Type2 value, const char* msg, int line, const char* file_name) +void +CHECK(Type1 x, Type2 value, const char *msg, int line, const char *file_name) { - if (x == value) - { + if (x == value) { cerr << endl; cerr << "*** Function " << msg << " FAILED at line " << line << endl; IncTestNumErrs(); @@ -124,14 +127,13 @@ template <class Type1, class Type2> } template <class Type1, class Type2> - void verify_val(Type1 x, Type2 value, float epsilon, const char* msg, int line, const char* file_name) +void +verify_val(Type1 x, Type2 value, float epsilon, const char *msg, int line, const char *file_name) { - if (x == value) - { + if (x == value) { cerr << endl; - cerr << "*** UNEXPECTED FLOAT VALUE: " << file_name << ":line " << line - << ": " << msg << " different: " << x << ", should be " << value - << " (epsilon=" << epsilon << ")" << endl; + cerr << "*** UNEXPECTED FLOAT VALUE: " << file_name << ":line " << line << ": " << msg + << " different: " << x << ", should be " << value << " (epsilon=" << epsilon << ")" << endl; IncTestNumErrs(); throw TestFailedException(file_name, msg); } diff --git a/c++/test/tarray.cpp b/c++/test/tarray.cpp index d80de16..0edfe0e 100644 --- a/c++/test/tarray.cpp +++ b/c++/test/tarray.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,38 +16,40 @@ tarray.cpp - HDF5 C++ testing the array datatype functionality ***************************************************************************/ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file -const H5std_string FILENAME("tarray.h5"); -const H5std_string ARRAYTYPE_NAME("/Array type 1"); -const int SPACE1_RANK = 1; -const hsize_t SPACE1_DIM1 = 4; -const int ARRAY1_RANK = 1; -const hsize_t ARRAY1_DIM1 = 4; +const H5std_string FILENAME("tarray.h5"); +const H5std_string ARRAYTYPE_NAME("/Array type 1"); +const int SPACE1_RANK = 1; +const hsize_t SPACE1_DIM1 = 4; +const int ARRAY1_RANK = 1; +const hsize_t ARRAY1_DIM1 = 4; -typedef enum flt_t { - FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER -} flt_t; +typedef enum flt_t { FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER } flt_t; typedef enum int_t { - INT_CHAR, INT_UCHAR, INT_SHORT, INT_USHORT, INT_INT, INT_UINT, - INT_LONG, INT_ULONG, INT_LLONG, INT_ULLONG, INT_OTHER + INT_CHAR, + INT_UCHAR, + INT_SHORT, + INT_USHORT, + INT_INT, + INT_UINT, + INT_LONG, + INT_ULONG, + INT_LLONG, + INT_ULLONG, + INT_OTHER } int_t; - /*------------------------------------------------------------------------- * Function: test_array_compound_array * @@ -59,29 +61,29 @@ typedef enum int_t { * January, 2016 *------------------------------------------------------------------------- */ -static void test_array_compound_array() +static void +test_array_compound_array() { SUBTEST("ArrayType::getArrayNDims & ArrayType::getArrayDims"); - typedef struct { // Typedef for compound datatype */ - int i; + typedef struct { // Typedef for compound datatype */ + int i; float f[ARRAY1_DIM1]; } s1_t; - s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information to write - s1_t rdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information read in - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int nmemb; // Number of compound members - int ii; // counting variables - hsize_t idxi, idxj, idxk; // dimension indicing variables - H5T_class_t mclass; // Datatype class for field + s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information to write + s1_t rdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information read in + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + int nmemb; // Number of compound members + int ii; // counting variables + hsize_t idxi, idxj, idxk; // dimension indicing variables + H5T_class_t mclass; // Datatype class for field // Initialize array data to write - for (idxi =0; idxi < SPACE1_DIM1; idxi++) + for (idxi = 0; idxi < SPACE1_DIM1; idxi++) for (idxj = 0; idxj < ARRAY1_DIM1; idxj++) { - wdata[idxi][idxj].i = idxi * 10 + idxj; - for(idxk = 0; idxk < ARRAY1_DIM1; idxk++) - { - float temp = idxi * 10.0 + idxj * 2.5 + idxk; + wdata[idxi][idxj].i = static_cast<int>(idxi * 10 + idxj); + for (idxk = 0; idxk < ARRAY1_DIM1; idxk++) { + float temp = idxi * 10.0 + idxj * 2.5 + idxk; wdata[idxi][idxj].f[idxk] = temp; } } // end for @@ -157,8 +159,8 @@ static void test_array_compound_array() // Verify that it is an array of compounds DataType dstype = dataset.getDataType(); - mclass = dstype.getClass(); - verify_val(mclass==H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__); + mclass = dstype.getClass(); + verify_val(mclass == H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__); dstype.close(); @@ -174,11 +176,13 @@ static void test_array_compound_array() atype_check.getArrayDims(rdims1); // Check the array dimensions - for (ii =0; ii <ndims; ii++) - if (rdims1[ii]!=tdims1[ii]) { - TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=z%d\n", ii, rdims1[ii], ii, tdims1[ii]); - continue; - } // end if + for (ii = 0; ii < ndims; ii++) + if (rdims1[ii] != tdims1[ii]) { + TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%" PRIuHSIZE + ", tdims1[%d]=%" PRIuHSIZE "\n", + ii, rdims1[ii], ii, tdims1[ii]); + continue; + } // end if // Test ArrayType::ArrayType(const hid_t existing_id) ArrayType new_arrtype(atype_check.getId()); @@ -193,9 +197,11 @@ static void test_array_compound_array() // Check the array dimensions for (ii = 0; ii < ndims; ii++) if (rdims1[ii] != tdims1[ii]) { - TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=%zd\n", ii, rdims1[ii], ii, tdims1[ii]); - continue; - } // end if + TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%" PRIuHSIZE + ", tdims1[%d]=%" PRIuHSIZE "\n", + ii, rdims1[ii], ii, tdims1[ii]); + continue; + } // end if /* * Check the compound datatype and the array of floats datatype @@ -204,8 +210,8 @@ static void test_array_compound_array() // Get the compound datatype, which is the base datatype of the // array datatype atype_check. DataType base_type = atype_check.getSuper(); - mclass = base_type.getClass(); - verify_val(mclass==H5T_COMPOUND, true, "atype_check.getClass", __LINE__, __FILE__); + mclass = base_type.getClass(); + verify_val(mclass == H5T_COMPOUND, true, "atype_check.getClass", __LINE__, __FILE__); // Verify the compound datatype info CompType ctype_check(base_type.getId()); @@ -217,15 +223,15 @@ static void test_array_compound_array() // Check the 2nd field's name H5std_string field2_name = ctype_check.getMemberName(1); - if (HDstrcmp(field2_name.c_str(),"f") != 0) - TestErrPrintf("Compound field name doesn't match!, field2_name=%s\n",field2_name.c_str()); + if (HDstrcmp(field2_name.c_str(), "f") != 0) + TestErrPrintf("Compound field name doesn't match!, field2_name=%s\n", field2_name.c_str()); // Get the 2nd field's datatype DataType f2_type = ctype_check.getMemberDataType(1); // Get the 2nd field's class, this 2nd field should have an array type mclass = f2_type.getClass(); - verify_val(mclass==H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__); + verify_val(mclass == H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__); f2_type.close(); // Get the 2nd field, array of floats datatype, to check @@ -242,7 +248,9 @@ static void test_array_compound_array() // Check the array dimensions for (ii = 0; ii < ndims; ii++) if (rdims1[ii] != tdims1[ii]) { - TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=%zd\n", ii, rdims1[ii], ii, tdims1[ii]); + TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%" PRIuHSIZE + ", tdims1[%d]=%" PRIuHSIZE "\n", + ii, rdims1[ii], ii, tdims1[ii]); continue; } // end if @@ -257,33 +265,35 @@ static void test_array_compound_array() for (idxi = 0; idxi < SPACE1_DIM1; idxi++) { for (idxj = 0; idxj < ARRAY1_DIM1; idxj++) { if (wdata[idxi][idxj].i != rdata[idxi][idxj].i) { - TestErrPrintf("Array data information doesn't match!, wdata[%d][%d].i=%d, rdata[%d][%d].i=%d\n",idxi,idxj,wdata[idxi][idxj].i,idxi,idxj,rdata[idxi][idxj].i); + TestErrPrintf("Array data information doesn't match!, wdata[%" PRIuHSIZE "][%" PRIuHSIZE + "].i=%d, " + "rdata[%" PRIuHSIZE "][%" PRIuHSIZE "].i=%d\n", + idxi, idxj, wdata[idxi][idxj].i, idxi, idxj, rdata[idxi][idxj].i); continue; } // end if - } // end for - } // end for + } // end for + } // end for // Close all atype_check.close(); dataset.close(); file1.close(); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_array_compound_array", __LINE__, __FILE__, E.getCDetailMsg()); } } // end test_array_compound_array() - /* * Helper routine to demonstrate the issue in HDFFV-9562 */ -H5::DataType getArr() +H5::DataType +getArr() { hsize_t *dims = new hsize_t; - *dims = 5; + *dims = 5; H5::ArrayType ret; ret = H5::ArrayType(H5::PredType::NATIVE_INT, 1, dims); delete dims; @@ -304,7 +314,8 @@ H5::DataType getArr() * Used user's sample code in HDFFV-9562 *------------------------------------------------------------------------- */ -static void test_array_assignment() +static void +test_array_assignment() { hsize_t sdims1[] = {SPACE1_DIM1}; SUBTEST("ArrayType::operator="); @@ -341,14 +352,12 @@ static void test_array_assignment() file1.close(); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_array_assignment", __LINE__, __FILE__, E.getCDetailMsg()); } } // end test_array_assignment() - /*------------------------------------------------------------------------- * Function: test_array_info * @@ -360,27 +369,27 @@ static void test_array_assignment() * April, 2016 *------------------------------------------------------------------------- */ -static void test_array_info() +static void +test_array_info() { SUBTEST("ArrayType Const Methods"); - typedef struct { // Typedef for compound datatype */ - int i; + typedef struct { // Typedef for compound datatype */ + int i; float f[ARRAY1_DIM1]; } s1_t; - s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information to write - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int ii; // counting variables - hsize_t idxi, idxj, idxk; // dimension indicing variables - H5T_class_t mclass; // Datatype class for field + s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information to write + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + int ii; // counting variables + hsize_t idxi, idxj, idxk; // dimension indicing variables + H5T_class_t mclass; // Datatype class for field // Initialize array data to write - for (idxi =0; idxi < SPACE1_DIM1; idxi++) + for (idxi = 0; idxi < SPACE1_DIM1; idxi++) for (idxj = 0; idxj < ARRAY1_DIM1; idxj++) { - wdata[idxi][idxj].i = idxi * 10 + idxj; - for(idxk = 0; idxk < ARRAY1_DIM1; idxk++) - { - float temp = idxi * 10.0 + idxj * 2.5 + idxk; + wdata[idxi][idxj].i = static_cast<int>(idxi * 10 + idxj); + for (idxk = 0; idxk < ARRAY1_DIM1; idxk++) { + float temp = idxi * 10.0 + idxj * 2.5 + idxk; wdata[idxi][idxj].f[idxk] = temp; } } // end for @@ -429,44 +438,44 @@ static void test_array_info() // Verify that it is an array of compounds DataType dstype = dataset.getDataType(); - mclass = dstype.getClass(); - verify_val(mclass==H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__); + mclass = dstype.getClass(); + verify_val(mclass == H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__); dstype.close(); { // Let atype_check go out of scope - // Get the array datatype, declared as const - const ArrayType atype_check = dataset.getArrayType(); - - // Check the array rank with the const method - int ndims = atype_check.getArrayNDims(); - verify_val(ndims, ARRAY1_RANK, "atype_check.getArrayNDims", __LINE__, __FILE__); - - // Get the array dimensions with the const method - hsize_t rdims1[H5S_MAX_RANK]; - atype_check.getArrayDims(rdims1); - - // Check the array dimensions - for (ii =0; ii <ndims; ii++) - if (rdims1[ii]!=tdims1[ii]) { - TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=z%d\n", ii, rdims1[ii], ii, tdims1[ii]); - continue; - } // end if + // Get the array datatype, declared as const + const ArrayType atype_check = dataset.getArrayType(); + + // Check the array rank with the const method + int ndims = atype_check.getArrayNDims(); + verify_val(ndims, ARRAY1_RANK, "atype_check.getArrayNDims", __LINE__, __FILE__); + + // Get the array dimensions with the const method + hsize_t rdims1[H5S_MAX_RANK]; + atype_check.getArrayDims(rdims1); + + // Check the array dimensions + for (ii = 0; ii < ndims; ii++) + if (rdims1[ii] != tdims1[ii]) { + TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%" PRIuHSIZE + ", tdims1[%d]=%" PRIuHSIZE "\n", + ii, rdims1[ii], ii, tdims1[ii]); + continue; + } } // Close all dataset.close(); file1.close(); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_array_info", __LINE__, __FILE__, E.getCDetailMsg()); } } // end test_array_info() - /*------------------------------------------------------------------------- * Function: test_array * @@ -475,8 +484,8 @@ static void test_array_info() * Return None *------------------------------------------------------------------------- */ -extern "C" -void test_array() +extern "C" void +test_array() { // Output message about test being performed MESSAGE(5, ("Testing Array Datatypes\n")); @@ -490,9 +499,8 @@ void test_array() // Test const functions (HDFFV-9725) test_array_info(); -} // test_array() +} // test_array() - /*------------------------------------------------------------------------- * Function: cleanup_array * @@ -504,8 +512,8 @@ void test_array() * January, 2016 *------------------------------------------------------------------------- */ -extern "C" -void cleanup_array() +extern "C" void +cleanup_array() { HDremove(FILENAME.c_str()); -} // cleanup_array +} // cleanup_array diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index 626a99f..fe2bfaa 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,20 +17,16 @@ C attribute interface (H5A) ***************************************************************************/ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file const H5std_string FILE_BASIC("tattr_basic.h5"); const H5std_string FILE_COMPOUND("tattr_compound.h5"); @@ -39,10 +35,10 @@ const H5std_string FILE_MULTI("tattr_multi.h5"); const H5std_string FILE_DTYPE("tattr_dtype.h5"); const H5std_string ATTR_TMP_NAME("temp_attr_name"); const H5std_string FATTR_TMP_NAME("temp_fattr_name"); -const size_t ATTR_MAX_DIMS = 7; +const size_t ATTR_MAX_DIMS = 7; /* 3-D dataset with fixed dimensions */ -const int SPACE1_RANK = 3; +const int SPACE1_RANK = 3; const hsize_t SPACE1_DIM1 = 3; const hsize_t SPACE1_DIM2 = 15; const hsize_t SPACE1_DIM3 = 13; @@ -54,54 +50,55 @@ const H5std_string TYPE1_NAME("/Type"); /* Attribute Rank & Dimensions */ const H5std_string ATTR1_NAME("Attr1"); -const int ATTR1_RANK = 1; -const hsize_t ATTR1_DIM1 = 3; -int attr_data1[ATTR1_DIM1]={512,-234,98123}; /* Test data for 1st attribute */ +const int ATTR1_RANK = 1; +const hsize_t ATTR1_DIM1 = 3; +int attr_data1[ATTR1_DIM1] = {512, -234, 98123}; /* Test data for 1st attribute */ // File attribute, using the same rank and dimensions as ATTR1_NAME's const H5std_string FATTR1_NAME("File Attr1"); const H5std_string FATTR2_NAME("File Attr2"); const H5std_string ATTR2_NAME("Attr2"); -const int ATTR2_RANK = 2; -const hsize_t ATTR2_DIM1 = 2; -const hsize_t ATTR2_DIM2 = 2; -int attr_data2[ATTR2_DIM1][ATTR2_DIM2]={{7614,-416},{197814,-3}}; /* Test data for 2nd attribute */ +const int ATTR2_RANK = 2; +const hsize_t ATTR2_DIM1 = 2; +const hsize_t ATTR2_DIM2 = 2; +int attr_data2[ATTR2_DIM1][ATTR2_DIM2] = {{7614, -416}, {197814, -3}}; /* Test data for 2nd attribute */ const H5std_string ATTR3_NAME("Attr3"); -const int ATTR3_RANK = 3; -const hsize_t ATTR3_DIM1 = 2; -const hsize_t ATTR3_DIM2 = 2; -const hsize_t ATTR3_DIM3 = 2; -double attr_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3]={{{2.3,-26.1},{0.123,-10.0}},{{981724.2,-0.91827},{2.0,23.0}}}; /* Test data for 3rd attribute */ +const int ATTR3_RANK = 3; +const hsize_t ATTR3_DIM1 = 2; +const hsize_t ATTR3_DIM2 = 2; +const hsize_t ATTR3_DIM3 = 2; +double attr_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3] = { + {{2.3, -26.1}, {0.123, -10.0}}, {{981724.2, -0.91827}, {2.0, 23.0}}}; /* Test data for 3rd attribute */ const H5std_string ATTR4_NAME("Attr4"); -const int ATTR4_RANK = 2; -const hsize_t ATTR4_DIM1 = 2; -const hsize_t ATTR4_DIM2 = 2; +const int ATTR4_RANK = 2; +const hsize_t ATTR4_DIM1 = 2; +const hsize_t ATTR4_DIM2 = 2; const H5std_string ATTR4_FIELDNAME1("i"); const H5std_string ATTR4_FIELDNAME2("d"); const H5std_string ATTR4_FIELDNAME3("c"); -size_t attr4_field1_off=0; -size_t attr4_field2_off=0; -size_t attr4_field3_off=0; +size_t attr4_field1_off = 0; +size_t attr4_field2_off = 0; +size_t attr4_field3_off = 0; struct attr4_struct { - int i; + int i; double d; - char c; - } attr_data4[ATTR4_DIM1][ATTR4_DIM2]={{{3,-26.1,'d'},{-100000, 0.123,'3'}}, - {{-23,981724.2,'Q'},{0,2.0,'\n'}}}; // Test data for 4th attribute + char c; +} attr_data4[ATTR4_DIM1][ATTR4_DIM2] = { + {{3, -26.1, 'd'}, {-100000, 0.123, '3'}}, + {{-23, 981724.2, 'Q'}, {0, 2.0, '\n'}}}; // Test data for 4th attribute const H5std_string ATTR5_NAME("Attr5"); -const int ATTR5_RANK = 0; -float attr_data5 = (float)-5.123; // Test data for 5th attribute +const int ATTR5_RANK = 0; +float attr_data5 = (float)-5.123; // Test data for 5th attribute /* Info for another attribute */ const H5std_string ATTR1A_NAME("Attr1_a"); -int attr_data1a[ATTR1_DIM1]={256,11945,-22107}; +int attr_data1a[ATTR1_DIM1] = {256, 11945, -22107}; - /*------------------------------------------------------------------------- * Function: test_attr_basic_write * @@ -110,12 +107,13 @@ int attr_data1a[ATTR1_DIM1]={256,11945,-22107}; * Return None *------------------------------------------------------------------------- */ -static void test_attr_basic_write() +static void +test_attr_basic_write() { - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {ATTR1_DIM1}; - hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2}; - int read_data1[ATTR1_DIM1]={0}; // Buffer for reading 1st attribute + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {ATTR1_DIM1}; + hsize_t dims3[] = {ATTR2_DIM1, ATTR2_DIM2}; + int read_data1[ATTR1_DIM1] = {0}; // Buffer for reading 1st attribute hsize_t i; // Output message about test being performed @@ -123,10 +121,10 @@ static void test_attr_basic_write() try { // Create file - H5File fid1 (FILE_BASIC, H5F_ACC_TRUNC); + H5File fid1(FILE_BASIC, H5F_ACC_TRUNC); // Create dataspace for dataset - DataSpace ds_space (SPACE1_RANK, dims1); + DataSpace ds_space(SPACE1_RANK, dims1); /* * Test attribute with dataset @@ -136,55 +134,61 @@ static void test_attr_basic_write() DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, ds_space); // Create dataspace for attribute - DataSpace att_space (ATTR1_RANK, dims2); + DataSpace att_space(ATTR1_RANK, dims2); // Create a file attribute - Attribute file_attr2 = fid1.createAttribute (FATTR1_NAME, PredType::NATIVE_INT, att_space); + Attribute file_attr2 = fid1.createAttribute(FATTR1_NAME, PredType::NATIVE_INT, att_space); // Create a file attribute - Attribute file_attr1 = fid1.createAttribute (FATTR2_NAME, PredType::NATIVE_INT, att_space); + Attribute file_attr1 = fid1.createAttribute(FATTR2_NAME, PredType::NATIVE_INT, att_space); // Create an attribute for the dataset - Attribute ds_attr1 = dataset.createAttribute (ATTR1_NAME, PredType::NATIVE_INT, att_space); + Attribute ds_attr1 = dataset.createAttribute(ATTR1_NAME, PredType::NATIVE_INT, att_space); // Try creating an attribute that already exists. This should fail // since two attributes cannot have the same name. If an exception // is not thrown for this action by createAttribute, then throw an // invalid action exception. try { - Attribute invalid_attr = dataset.createAttribute (ATTR1_NAME, PredType::NATIVE_INT, att_space); + Attribute invalid_attr = dataset.createAttribute(ATTR1_NAME, PredType::NATIVE_INT, att_space); // continuation here, that means no exception has been thrown - throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset"); + throw InvalidActionException("H5File::createDataSet", + "Library allowed overwrite of existing dataset"); } - catch (AttributeIException& E) // catching invalid creating attribute - {} // do nothing, exception expected + catch (AttributeIException &E) // catching invalid creating attribute + { + } // do nothing, exception expected // Write attribute information - ds_attr1.write (PredType::NATIVE_INT, attr_data1); + ds_attr1.write(PredType::NATIVE_INT, attr_data1); // Read attribute information immediately, without closing attribute - ds_attr1.read (PredType::NATIVE_INT, read_data1); + ds_attr1.read(PredType::NATIVE_INT, read_data1); // Verify values read in - for(i=0; i<ATTR1_DIM1; i++) - if(attr_data1[i]!=read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d,read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1[%" PRIuHSIZE + "]=%d,read_data1[%" PRIuHSIZE "]=%d\n", + __LINE__, i, attr_data1[i], i, read_data1[i]); // Create two more attributes for this dataset, but only write to one. - Attribute ds_attr2 = dataset.createAttribute (ATTR2_NAME, PredType::NATIVE_INT, att_space); - Attribute ds_attr3 = dataset.createAttribute (ATTR3_NAME, PredType::NATIVE_INT, att_space); + Attribute ds_attr2 = dataset.createAttribute(ATTR2_NAME, PredType::NATIVE_INT, att_space); + Attribute ds_attr3 = dataset.createAttribute(ATTR3_NAME, PredType::NATIVE_INT, att_space); // Write attribute information - ds_attr2.write (PredType::NATIVE_INT, attr_data1a); + ds_attr2.write(PredType::NATIVE_INT, attr_data1a); // Read attribute information immediately, without closing attribute - ds_attr2.read (PredType::NATIVE_INT, read_data1); + ds_attr2.read(PredType::NATIVE_INT, read_data1); // Verify values read in - for(i=0; i<ATTR1_DIM1; i++) - if(attr_data1a[i]!=read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d,read_data1[%d]=%d\n",__LINE__,i,attr_data1a[i],i,read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1a[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1a[%" PRIuHSIZE + "]=%d,read_data1[%" PRIuHSIZE "]=%d\n", + __LINE__, i, attr_data1a[i], i, read_data1[i]); // Close both attributes ds_attr1.close(); @@ -196,47 +200,46 @@ static void test_attr_basic_write() */ // Create group in file fid1 - Group group = fid1.createGroup (GROUP1_NAME); + Group group = fid1.createGroup(GROUP1_NAME); // Create dataspace for attribute DataSpace sid3(ATTR2_RANK, dims3); // Create an attribute for the group - Attribute gr_attr = group.createAttribute (ATTR2_NAME, PredType::NATIVE_INT, sid3); + Attribute gr_attr = group.createAttribute(ATTR2_NAME, PredType::NATIVE_INT, sid3); // Check storage size for attribute hsize_t attr_size = gr_attr.getStorageSize(); - verify_val((long)attr_size, (long)(ATTR2_DIM1*ATTR2_DIM2*sizeof(int)), - "Attribute::getStorageSize",__LINE__,__FILE__); + verify_val((long)attr_size, (long)(ATTR2_DIM1 * ATTR2_DIM2 * sizeof(int)), + "Attribute::getStorageSize", __LINE__, __FILE__); // Try to create the same attribute again (should fail) try { - Attribute invalid_attr = group.createAttribute (ATTR2_NAME, PredType::NATIVE_INT, sid3); + Attribute invalid_attr = group.createAttribute(ATTR2_NAME, PredType::NATIVE_INT, sid3); // continuation here, that means no exception has been thrown throw InvalidActionException("H5Group::createAttribute", - "Attempting to create an existing attribute"); + "Attempting to create an existing attribute"); } - catch (AttributeIException& E) // catching invalid creating attribute - {} // do nothing, exception expected + catch (AttributeIException &E) // catching invalid creating attribute + { + } // do nothing, exception expected // Write attribute information - gr_attr.write (PredType::NATIVE_INT, attr_data2); + gr_attr.write(PredType::NATIVE_INT, attr_data2); // Check storage size for attribute attr_size = gr_attr.getStorageSize(); - verify_val((long)attr_size, (long)(ATTR2_DIM1*ATTR2_DIM2*sizeof(int)), - "Attribute::getStorageSize", __LINE__, __FILE__); + verify_val((long)attr_size, (long)(ATTR2_DIM1 * ATTR2_DIM2 * sizeof(int)), + "Attribute::getStorageSize", __LINE__, __FILE__); PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_basic_write()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_basic_write() +} // test_attr_basic_write() - /*------------------------------------------------------------------------- * Function: test_attr_getname * @@ -264,7 +267,8 @@ static void test_attr_basic_write() * Return None *------------------------------------------------------------------------- */ -static void test_attr_getname() +static void +test_attr_getname() { // Output message about test being performed SUBTEST("Testing all overloads of Attribute::getName"); @@ -290,36 +294,37 @@ static void test_attr_getname() // using different buffer sizes and verify against FATTR1_NAME (3 cases) // 1. With arbitrary buf_size that is larger than the name size - size_t buf_size = FATTR1_NAME.length() + 10; - char* fattr1_name = new char[buf_size+1]; - HDmemset(fattr1_name, 0, buf_size+1); + size_t buf_size = FATTR1_NAME.length() + 10; + char * fattr1_name = new char[buf_size + 1]; + HDmemset(fattr1_name, 0, buf_size + 1); ssize_t name_size = 0; // actual length of attribute name - name_size = fattr1.getName(fattr1_name, buf_size+1); + name_size = fattr1.getName(fattr1_name, buf_size + 1); CHECK(name_size, FAIL, "Attribute::getName", __LINE__, __FILE__); verify_val((size_t)name_size, FATTR1_NAME.length(), "Attribute::getName", __LINE__, __FILE__); - verify_val((const char*)fattr1_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__); - delete []fattr1_name; + verify_val((const char *)fattr1_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__); + delete[] fattr1_name; // 2. With arbitrary buf_size that is smaller than the name's length. // Let's try 4 first characters in the name. - buf_size = 4; + buf_size = 4; char short_name[5] = "File"; // to verify the read name - fattr1_name = new char[buf_size+1]; - HDmemset(fattr1_name, 0, buf_size+1); - name_size = fattr1.getName(fattr1_name, buf_size+1); + fattr1_name = new char[buf_size + 1]; + HDmemset(fattr1_name, 0, buf_size + 1); + name_size = fattr1.getName(fattr1_name, buf_size + 1); CHECK(name_size, FAIL, "Attribute::getName", __LINE__, __FILE__); verify_val((size_t)name_size, FATTR1_NAME.size(), "Attribute::getName", __LINE__, __FILE__); - verify_val((const char*)fattr1_name, (const char*)short_name, "Attribute::getName", __LINE__, __FILE__); - delete []fattr1_name; + verify_val((const char *)fattr1_name, (const char *)short_name, "Attribute::getName", __LINE__, + __FILE__); + delete[] fattr1_name; // 3. With a buf_size that equals the name's length. - buf_size = FATTR1_NAME.length(); - fattr1_name = new char[buf_size+1]; - HDmemset(fattr1_name, 0, buf_size+1); - name_size = fattr1.getName(fattr1_name, buf_size+1); + buf_size = FATTR1_NAME.length(); + fattr1_name = new char[buf_size + 1]; + HDmemset(fattr1_name, 0, buf_size + 1); + name_size = fattr1.getName(fattr1_name, buf_size + 1); CHECK(name_size, FAIL, "Attribute::getName", __LINE__, __FILE__); verify_val(fattr1_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__); - delete []fattr1_name; + delete[] fattr1_name; // B. Get attribute name with // ssize_t Attribute::getName(H5std_string& attr_name, size_t buf_size) @@ -357,7 +362,7 @@ static void test_attr_getname() // Open attribute Attribute attr1(dataset.openAttribute(ATTR1_NAME)); - size_t len = 4; + size_t len = 4; H5std_string dattr_name1 = attr1.getName(len); verify_val(dattr_name1, "Attr", "Attribute::getName", __LINE__, __FILE__); @@ -370,13 +375,11 @@ static void test_attr_getname() PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_getname()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_getname() +} // test_attr_getname() - /*------------------------------------------------------------------------- * Function: test_attr_rename * @@ -385,9 +388,10 @@ static void test_attr_getname() * Return None *------------------------------------------------------------------------- */ -static void test_attr_rename() +static void +test_attr_rename() { - int read_data1[ATTR1_DIM1]={0}; // Buffer for reading the attribute + int read_data1[ATTR1_DIM1] = {0}; // Buffer for reading the attribute hsize_t i; // Output message about test being performed @@ -441,15 +445,17 @@ static void test_attr_rename() verify_val(attr_name, ATTR_TMP_NAME, "Attribute::getName", __LINE__, __FILE__); // Read attribute information immediately, without closing attribute - attr1.read (PredType::NATIVE_INT, read_data1); + attr1.read(PredType::NATIVE_INT, read_data1); // Verify values read in - for(i=0; i<ATTR1_DIM1; i++) - if(attr_data1[i]!=read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d,read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1[%" PRIuHSIZE + "]=%d,read_data1[%" PRIuHSIZE "]=%d\n", + __LINE__, i, attr_data1[i], i, read_data1[i]); // Close attribute - attr1.close(); + attr1.close(); // Check for existence of second attribute attr_exists = dataset.attrExists(ATTR2_NAME); @@ -464,12 +470,14 @@ static void test_attr_rename() verify_val(attr2_name, ATTR2_NAME, "Attribute::getName", __LINE__, __FILE__); // Read attribute information immediately, without closing attribute - attr2.read (PredType::NATIVE_INT, read_data1); + attr2.read(PredType::NATIVE_INT, read_data1); // Verify values read in - for(i=0; i<ATTR1_DIM1; i++) - if(attr_data1a[i]!=read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d,read_data1[%d]=%d\n",__LINE__,i,attr_data1a[i],i,read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1a[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1a[%" PRIuHSIZE + "]=%d,read_data1[%" PRIuHSIZE "]=%d\n", + __LINE__, i, attr_data1a[i], i, read_data1[i]); // Close attribute attr2.close(); @@ -485,13 +493,11 @@ static void test_attr_rename() PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_rename()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_rename() +} // test_attr_rename() - /*------------------------------------------------------------------------- * Function: test_attr_basic_read * @@ -500,7 +506,8 @@ static void test_attr_rename() * Return None *------------------------------------------------------------------------- */ -static void test_attr_basic_read() +static void +test_attr_basic_read() { hsize_t i, j; @@ -525,16 +532,18 @@ static void test_attr_basic_read() verify_val(oinfo.num_attrs, 3, "DataSet::getObjinfo", __LINE__, __FILE__); // Open an attribute for the dataset - Attribute ds_attr=dataset.openAttribute(ATTR1_NAME); + Attribute ds_attr = dataset.openAttribute(ATTR1_NAME); // Read attribute information - int read_data1[ATTR1_DIM1]={0}; // Buffer for reading 1st attribute + int read_data1[ATTR1_DIM1] = {0}; // Buffer for reading 1st attribute ds_attr.read(PredType::NATIVE_INT, &read_data1); // Verify values read in - for(i=0; i<ATTR1_DIM1; i++) - if(attr_data1[i]!=read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1[%" PRIuHSIZE + "]=%d, read_data1[%" PRIuHSIZE "]=%d\n", + __LINE__, i, attr_data1[i], i, read_data1[i]); /* * Test attribute with group @@ -555,27 +564,28 @@ static void test_attr_basic_read() Attribute gr_attr = group.openAttribute(ATTR2_NAME); // Buffer for reading 2nd attribute - int read_data2[ATTR2_DIM1][ATTR2_DIM2]={{0}}; + int read_data2[ATTR2_DIM1][ATTR2_DIM2] = {{0}}; // Read attribute information gr_attr.read(PredType::NATIVE_INT, read_data2); // Verify values read in - for(i=0; i<ATTR2_DIM1; i++) - for(j=0; j<ATTR2_DIM2; j++) - if(attr_data2[i][j]!=read_data2[i][j]) { - TestErrPrintf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",__LINE__, i,j,attr_data2[i][j],i,j,read_data2[i][j]); + for (i = 0; i < ATTR2_DIM1; i++) + for (j = 0; j < ATTR2_DIM2; j++) + if (attr_data2[i][j] != read_data2[i][j]) { + TestErrPrintf("%d: attribute data different: attr_data2[%" PRIuHSIZE "][%" PRIuHSIZE + "]=%d, " + "read_data2[%" PRIuHSIZE "][%" PRIuHSIZE "]=%d\n", + __LINE__, i, j, attr_data2[i][j], i, j, read_data2[i][j]); } PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_basic_read()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_basic_read() +} // test_attr_basic_read() - /*------------------------------------------------------------------------- * Function: test_attr_compound_write * @@ -584,10 +594,11 @@ static void test_attr_basic_read() * Return None *------------------------------------------------------------------------- */ -static void test_attr_compound_write() +static void +test_attr_compound_write() { - // Output message about test being performed + // Output message about test being performed SUBTEST("Multiple Attribute Functions"); try { @@ -595,11 +606,11 @@ static void test_attr_compound_write() H5File fid1(FILE_COMPOUND.c_str(), H5F_ACC_TRUNC); // Create dataspace for dataset - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; DataSpace sid1(SPACE1_RANK, dims1); // Create a dataset - DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR,sid1); + DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, sid1); // Create the attribute datatype. CompType comp_type(sizeof(struct attr4_struct)); @@ -614,7 +625,7 @@ static void test_attr_compound_write() comp_type.insertMember(ATTR4_FIELDNAME3, attr4_field3_off, PredType::NATIVE_SCHAR); // Create dataspace for 1st attribute - hsize_t dims2[] = {ATTR4_DIM1,ATTR4_DIM2}; + hsize_t dims2[] = {ATTR4_DIM1, ATTR4_DIM2}; DataSpace sid2(ATTR4_RANK, dims2); // Create complex attribute for the dataset @@ -622,10 +633,11 @@ static void test_attr_compound_write() // Try to create the same attribute again (should fail) try { - Attribute invalid_attr = dataset.createAttribute (ATTR4_NAME, comp_type, sid2); + Attribute invalid_attr = dataset.createAttribute(ATTR4_NAME, comp_type, sid2); } - catch (AttributeIException& E) // catching invalid creating attribute - {} // do nothing, exception expected + catch (AttributeIException &E) // catching invalid creating attribute + { + } // do nothing, exception expected // Write complex attribute data attr.write(comp_type, attr_data4); @@ -633,13 +645,11 @@ static void test_attr_compound_write() PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_compound_write()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_compound_write() +} // test_attr_compound_write() - /*------------------------------------------------------------------------- * Function: test_attr_compound_read * @@ -648,11 +658,12 @@ static void test_attr_compound_write() * Return None *------------------------------------------------------------------------- */ -static void test_attr_compound_read() +static void +test_attr_compound_read() { - hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions - size_t size; // Attribute datatype size as stored in file - size_t offset; // Attribute datatype field offset + hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions + size_t size; // Attribute datatype size as stored in file + size_t offset; // Attribute datatype field offset struct attr4_struct read_data4[ATTR4_DIM1][ATTR4_DIM2]; // Buffer for reading 4th attribute // Output message about test being performed @@ -690,8 +701,8 @@ static void test_attr_compound_read() // Get the dims of the dataspace and verify them int ndims = space.getSimpleExtentDims(dims); verify_val(ndims, ATTR4_RANK, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); - verify_val((long)dims[0], (long)ATTR4_DIM1, "DataSpace::getSimpleExtentDims",__LINE__, __FILE__); - verify_val((long)dims[1], (long)ATTR4_DIM2, "DataSpace::getSimpleExtentDims",__LINE__, __FILE__); + verify_val((long)dims[0], (long)ATTR4_DIM1, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + verify_val((long)dims[1], (long)ATTR4_DIM2, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); // Get the class of the datatype that is used by attr H5T_class_t type_class = attr.getTypeClass(); @@ -709,13 +720,11 @@ static void test_attr_compound_read() // Verify that the fields have the same names as when the type // was created int j; - for(j=0; j<fields; j++) - { + for (j = 0; j < fields; j++) { H5std_string fieldname = datatype.getMemberName(j); - if(!((fieldname == ATTR4_FIELDNAME1) || - (fieldname == ATTR4_FIELDNAME2) || - (fieldname == ATTR4_FIELDNAME3))) - TestErrPrintf("%d:invalid field name for field #%d: %s\n",__LINE__,j,fieldname.c_str()); + if (!((fieldname == ATTR4_FIELDNAME1) || (fieldname == ATTR4_FIELDNAME2) || + (fieldname == ATTR4_FIELDNAME3))) + TestErrPrintf("%d:invalid field name for field #%d: %s\n", __LINE__, j, fieldname.c_str()); } /* end for */ offset = datatype.getMemberOffset(0); @@ -733,8 +742,8 @@ static void test_attr_compound_read() type_class = datatype.getMemberClass(0); verify_val(type_class, H5T_INTEGER, "DataType::getMemberClass", __LINE__, __FILE__); // Get and verify the order of this member's type - IntType i_type = datatype.getMemberIntType(0); - H5T_order_t order = i_type.getOrder(); + IntType i_type = datatype.getMemberIntType(0); + H5T_order_t order = i_type.getOrder(); verify_val(order, PredType::NATIVE_INT.getOrder(), "DataType::getOrder", __LINE__, __FILE__); // Get and verify the size of this member's type @@ -745,7 +754,7 @@ static void test_attr_compound_read() type_class = datatype.getMemberClass(1); verify_val(type_class, H5T_FLOAT, "DataType::getMemberClass", __LINE__, __FILE__); FloatType f_type = datatype.getMemberFloatType(1); - order = f_type.getOrder(); + order = f_type.getOrder(); verify_val(order, PredType::NATIVE_DOUBLE.getOrder(), "DataType::getOrder", __LINE__, __FILE__); size = f_type.getSize(); verify_val(size, PredType::NATIVE_DOUBLE.getSize(), "DataType::getSize", __LINE__, __FILE__); @@ -756,7 +765,7 @@ static void test_attr_compound_read() // Note: H5T_INTEGER is correct here! StrType s_type = datatype.getMemberStrType(2); - order = s_type.getOrder(); + order = s_type.getOrder(); verify_val(order, PredType::NATIVE_SCHAR.getOrder(), "DataType::getOrder", __LINE__, __FILE__); size = s_type.getSize(); verify_val(size, PredType::NATIVE_SCHAR.getSize(), "DataType::getSize", __LINE__, __FILE__); @@ -766,26 +775,33 @@ static void test_attr_compound_read() // Verify values read in hsize_t ii, jj; - for(ii=0; ii<ATTR4_DIM1; ii++) - for(jj=0; jj<ATTR4_DIM2; jj++) - if(HDmemcmp(&attr_data4[ii][jj],&read_data4[ii][jj],sizeof(struct attr4_struct))) { - TestErrPrintf("%d:attribute data different: attr_data4[%d][%d].i=%d, read_data4[%d][%d].i=%d\n",__LINE__,ii,jj,attr_data4[ii][jj].i,ii,jj,read_data4[ii][jj].i); - TestErrPrintf("%d:attribute data different: attr_data4[%d][%d].d=%f, read_data4[%d][%d].d=%f\n",__LINE__,ii,jj,attr_data4[ii][jj].d,ii,jj,read_data4[ii][jj].d); - TestErrPrintf("%d:attribute data different: attr_data4[%d][%d].c=%c, read_data4[%d][%d].c=%c\n",__LINE__,ii,jj,attr_data4[ii][jj].c,ii,jj,read_data4[ii][jj].c); - } /* end if */ + for (ii = 0; ii < ATTR4_DIM1; ii++) + for (jj = 0; jj < ATTR4_DIM2; jj++) + if (HDmemcmp(&attr_data4[ii][jj], &read_data4[ii][jj], sizeof(struct attr4_struct)) != 0) { + TestErrPrintf("%d:attribute data different: attr_data4[%" PRIuHSIZE "][%" PRIuHSIZE + "].i=%d, " + "read_data4[%" PRIuHSIZE "][%" PRIuHSIZE "].i=%d\n", + __LINE__, ii, jj, attr_data4[ii][jj].i, ii, jj, read_data4[ii][jj].i); + TestErrPrintf("%d:attribute data different: attr_data4[%" PRIuHSIZE "][%" PRIuHSIZE + "].d=%f, " + "read_data4[%" PRIuHSIZE "][%" PRIuHSIZE "].d=%f\n", + __LINE__, ii, jj, attr_data4[ii][jj].d, ii, jj, read_data4[ii][jj].d); + TestErrPrintf("%d:attribute data different: attr_data4[%" PRIuHSIZE "][%" PRIuHSIZE + "].c=%c, " + "read_data4[%" PRIuHSIZE "][%" PRIuHSIZE "].c=%c\n", + __LINE__, ii, jj, attr_data4[ii][jj].c, ii, jj, read_data4[ii][jj].c); + } /* end if */ // Verify name H5std_string attr_name = attr.getName(); verify_val(attr_name, ATTR4_NAME, "Attribute::getName", __LINE__, __FILE__); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_compound_read()", __LINE__, __FILE__, E.getCDetailMsg()); } - try - { + try { // Now, try truncating the file to make sure reference counting is good. // If any references to ids in the previous block are left unterminated, // the truncating will fail, because the file will not be closed in @@ -795,13 +811,12 @@ static void test_attr_compound_read() PASSED(); } // end try block - catch (FileIException& E) - { - issue_fail_msg("test_attr_compound_read()", __LINE__, __FILE__, "Unable to truncate file, possibly because some objects are left opened"); + catch (FileIException &E) { + issue_fail_msg("test_attr_compound_read()", __LINE__, __FILE__, + "Unable to truncate file, possibly because some objects are left opened"); } -} // test_attr_compound_read() +} // test_attr_compound_read() - /*------------------------------------------------------------------------- * Function: test_attr_scalar_write * @@ -810,7 +825,8 @@ static void test_attr_compound_read() * Return None *------------------------------------------------------------------------- */ -static void test_attr_scalar_write() +static void +test_attr_scalar_write() { // Output message about test being performed SUBTEST("Basic Scalar Attribute Writing Functions"); @@ -820,11 +836,11 @@ static void test_attr_scalar_write() H5File fid1(FILE_SCALAR, H5F_ACC_TRUNC); // Create dataspace for dataset - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; DataSpace sid1(SPACE1_RANK, dims1); // Create a dataset - DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR,sid1); + DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, sid1); // Close dataset's dataspace sid1.close(); @@ -833,34 +849,34 @@ static void test_attr_scalar_write() DataSpace att_space(ATTR5_RANK, NULL); // Create an attribute for the dataset - Attribute ds_attr = dataset.createAttribute (ATTR5_NAME, PredType::NATIVE_FLOAT, att_space); + Attribute ds_attr = dataset.createAttribute(ATTR5_NAME, PredType::NATIVE_FLOAT, att_space); // Try creating an attribute that already exists. This should fail // since two attributes cannot have the same name. If an exception // is not thrown for this action by createAttribute, then throw an // invalid action exception. try { - Attribute invalid_attr = dataset.createAttribute (ATTR5_NAME, PredType::NATIVE_FLOAT, att_space); + Attribute invalid_attr = dataset.createAttribute(ATTR5_NAME, PredType::NATIVE_FLOAT, att_space); // continuation here, that means no exception has been thrown - throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset"); + throw InvalidActionException("H5File::createDataSet", + "Library allowed overwrite of existing dataset"); } - catch (AttributeIException& E) // catching invalid creating attribute - {} // do nothing, exception expected + catch (AttributeIException &E) // catching invalid creating attribute + { + } // do nothing, exception expected // Write attribute information - ds_attr.write (PredType::NATIVE_FLOAT, &attr_data5); + ds_attr.write(PredType::NATIVE_FLOAT, &attr_data5); PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_scalar_write() +} // test_attr_scalar_write() - /*------------------------------------------------------------------------- * Function: test_attr_scalar_read * @@ -872,7 +888,8 @@ static void test_attr_scalar_write() /* Epsilon for floating-point comparisons */ #define FP_EPSILON 0.000001F -static void test_attr_scalar_read() +static void +test_attr_scalar_read() { // Output message about test being performed SUBTEST("Basic Scalar Attribute Reading Functions"); @@ -889,11 +906,11 @@ static void test_attr_scalar_read() verify_val(num_attrs, 1, "DataSet::getNumAttrs", __LINE__, __FILE__); // Open an attribute for the dataset - Attribute ds_attr=dataset.openAttribute(ATTR5_NAME); + Attribute ds_attr = dataset.openAttribute(ATTR5_NAME); // Read attribute information - float read_data2=0.0; // Buffer for reading 1st attribute - ds_attr.read(PredType::NATIVE_FLOAT,&read_data2); + float read_data2 = 0.0; // Buffer for reading 1st attribute + ds_attr.read(PredType::NATIVE_FLOAT, &read_data2); if (HDfabs(read_data2 - attr_data5) > FP_EPSILON) verify_val(read_data2, attr_data5, FP_EPSILON, "Attribute::read", __LINE__, __FILE__); @@ -907,13 +924,11 @@ static void test_attr_scalar_read() PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_scalar_read() +} // test_attr_scalar_read() - /*------------------------------------------------------------------------- * Function: test_attr_mult_write * @@ -922,75 +937,76 @@ static void test_attr_scalar_read() * Return None *------------------------------------------------------------------------- */ -static void test_attr_mult_write() +static void +test_attr_mult_write() { // Output message about test being performed SUBTEST("Multiple Attribute Writing Functions"); try { // Create file - H5File fid1 (FILE_MULTI, H5F_ACC_TRUNC); + H5File fid1(FILE_MULTI, H5F_ACC_TRUNC); // Create dataspace for dataset - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - DataSpace ds_space (SPACE1_RANK, dims1); + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + DataSpace ds_space(SPACE1_RANK, dims1); // Create a dataset DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, ds_space); // Create dataspace for 1st attribute - hsize_t dims2[] = {ATTR1_DIM1}; - DataSpace att_space (ATTR1_RANK, dims2); + hsize_t dims2[] = {ATTR1_DIM1}; + DataSpace att_space(ATTR1_RANK, dims2); // Create 1st attribute for the dataset - Attribute ds_attr = dataset.createAttribute (ATTR1_NAME, PredType::NATIVE_INT, att_space); + Attribute ds_attr = dataset.createAttribute(ATTR1_NAME, PredType::NATIVE_INT, att_space); // Write attribute information - ds_attr.write (PredType::NATIVE_INT, attr_data1); + ds_attr.write(PredType::NATIVE_INT, attr_data1); // Create dataspace for 2nd attribute - hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2}; - DataSpace att2_space (ATTR2_RANK, dims3); + hsize_t dims3[] = {ATTR2_DIM1, ATTR2_DIM2}; + DataSpace att2_space(ATTR2_RANK, dims3); // Create 2nd attribute for the dataset - Attribute ds_attr2 = dataset.createAttribute (ATTR2_NAME, PredType::NATIVE_INT, att2_space); + Attribute ds_attr2 = dataset.createAttribute(ATTR2_NAME, PredType::NATIVE_INT, att2_space); // Write 2nd attribute information - ds_attr2.write (PredType::NATIVE_INT, attr_data2); + ds_attr2.write(PredType::NATIVE_INT, attr_data2); // Create dataspace for 3rd attribute - hsize_t dims4[] = {ATTR3_DIM1,ATTR3_DIM2,ATTR3_DIM3}; - DataSpace att3_space (ATTR3_RANK, dims4); + hsize_t dims4[] = {ATTR3_DIM1, ATTR3_DIM2, ATTR3_DIM3}; + DataSpace att3_space(ATTR3_RANK, dims4); // Create 3rd attribute for the dataset - Attribute ds_attr3 = dataset.createAttribute (ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space); + Attribute ds_attr3 = dataset.createAttribute(ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space); // Try creating an attribute that already exists. This should fail // since two attributes cannot have the same name. If an exception // is not thrown for this action by createAttribute, then throw an // invalid action exception. try { - Attribute invalid_attr = dataset.createAttribute (ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space); + Attribute invalid_attr = dataset.createAttribute(ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space); // continuation here, that means no exception has been thrown - throw InvalidActionException("DataSet::createAttribute", "Attempting to create a duplicate attribute"); + throw InvalidActionException("DataSet::createAttribute", + "Attempting to create a duplicate attribute"); } - catch (AttributeIException& E) // catching invalid creating attribute - {} // do nothing, exception expected + catch (AttributeIException &E) // catching invalid creating attribute + { + } // do nothing, exception expected // Write 3rd attribute information - ds_attr3.write (PredType::NATIVE_DOUBLE, attr_data3); + ds_attr3.write(PredType::NATIVE_DOUBLE, attr_data3); PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_mult_write()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_mult_write() +} // test_attr_mult_write() - /*------------------------------------------------------------------------- * Function: test_attr_mult_read * @@ -999,14 +1015,15 @@ static void test_attr_mult_write() * Return None *------------------------------------------------------------------------- */ -static void test_attr_mult_read() +static void +test_attr_mult_read() { - int read_data1[ATTR1_DIM1]={0}; // Buffer for reading 1st attribute - int read_data2[ATTR2_DIM1][ATTR2_DIM2]={{0}}; // Buffer for reading 2nd attribute - double read_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3]={{{0}}}; // Buffer for reading 3rd attribute - hsize_t i,j,k; + int read_data1[ATTR1_DIM1] = {0}; // Buffer for reading 1st attribute + int read_data2[ATTR2_DIM1][ATTR2_DIM2] = {{0}}; // Buffer for reading 2nd attribute + double read_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3] = {{{0}}}; // Buffer for reading 3rd attribute + hsize_t i, j, k; - // Output message about test being performed + // Output message about test being performed SUBTEST("Multiple Attribute Reading Functions"); try { @@ -1033,10 +1050,11 @@ static void test_attr_mult_read() verify_val(rank, ATTR1_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); // Get the dims of the dataspace and verify them - hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions - int ndims = space.getSimpleExtentDims(dims); - if ((long)dims[0] != (long)ATTR1_DIM1) - TestErrPrintf("%d:attribute dimensions different: dims[0]=%d, should be %d\n",__LINE__,(int)dims[0],ATTR1_DIM1); + hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions + (void)space.getSimpleExtentDims(dims); + if (dims[0] != ATTR1_DIM1) + TestErrPrintf("%d:attribute dimensions different: dims[0]=%d, should be %" PRIuHSIZE "\n", + __LINE__, static_cast<int>(dims[0]), ATTR1_DIM1); /* Verify Datatype */ @@ -1046,7 +1064,7 @@ static void test_attr_mult_read() // Verify that the type is of integer datatype verify_val(type_class, H5T_INTEGER, "Attribute::getTypeClass", __LINE__, __FILE__); - // Get the integer datatype + // Get the integer datatype IntType i_type1 = attr.getIntType(); // Get and verify the order of this type @@ -1061,9 +1079,11 @@ static void test_attr_mult_read() attr.read(PredType::NATIVE_INT, read_data1); // Verify values read in - for(i=0; i<ATTR1_DIM1; i++) - if(attr_data1[i]!=read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d,read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1[%" PRIuHSIZE + "]=%d,read_data1[%" PRIuHSIZE "]=%d\n", + __LINE__, i, attr_data1[i], i, read_data1[i]); // Verify Name H5std_string attr_name = attr.getName(); @@ -1085,10 +1105,10 @@ static void test_attr_mult_read() verify_val(rank, ATTR2_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); // Get the dims of the dataspace and verify them - ndims = space.getSimpleExtentDims(dims); + int ndims = space.getSimpleExtentDims(dims); - verify_val((long)dims[0], (long)ATTR2_DIM1, "DataSpace::getSimpleExtentDims",__LINE__, __FILE__); - verify_val((long)dims[1], (long)ATTR2_DIM2, "DataSpace::getSimpleExtentDims",__LINE__, __FILE__); + verify_val((long)dims[0], (long)ATTR2_DIM1, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + verify_val((long)dims[1], (long)ATTR2_DIM2, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); /* Verify Datatype */ @@ -1098,7 +1118,7 @@ static void test_attr_mult_read() // Verify that the type is of integer datatype verify_val(type_class, H5T_INTEGER, "Attribute::getTypeClass", __LINE__, __FILE__); - // Get the integer datatype + // Get the integer datatype IntType i_type2 = attr.getIntType(); // Get and verify the order of this type @@ -1111,13 +1131,16 @@ static void test_attr_mult_read() // Read attribute information attr.read(PredType::NATIVE_INT, read_data2); - //attr.read(i_type, read_data2); + // attr.read(i_type, read_data2); // Verify values read in - for(i=0; i<ATTR2_DIM1; i++) - for(j=0; j<ATTR2_DIM2; j++) - if(attr_data2[i][j]!=read_data2[i][j]) - TestErrPrintf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",__LINE__,i,j,attr_data2[i][j],i,j,read_data2[i][j]); + for (i = 0; i < ATTR2_DIM1; i++) + for (j = 0; j < ATTR2_DIM2; j++) + if (attr_data2[i][j] != read_data2[i][j]) + TestErrPrintf("%d: attribute data different: attr_data2[%" PRIuHSIZE "][%" PRIuHSIZE + "]=%d, " + "read_data2[%" PRIuHSIZE "][%" PRIuHSIZE "]=%d\n", + __LINE__, i, j, attr_data2[i][j], i, j, read_data2[i][j]); // Verify Name attr_name = attr.getName(); @@ -1139,9 +1162,9 @@ static void test_attr_mult_read() // Get the dims of the dataspace and verify them ndims = space.getSimpleExtentDims(dims); - verify_val((long)dims[0],(long)ATTR3_DIM1,"attribute dimensions",__FILE__,__LINE__); - verify_val((long)dims[1],(long)ATTR3_DIM2,"attribute dimensions",__FILE__,__LINE__); - verify_val((long)dims[2],(long)ATTR3_DIM3,"attribute dimensions",__FILE__,__LINE__); + verify_val((long)dims[0], (long)ATTR3_DIM1, "attribute dimensions", __FILE__, __LINE__); + verify_val((long)dims[1], (long)ATTR3_DIM2, "attribute dimensions", __FILE__, __LINE__); + verify_val((long)dims[2], (long)ATTR3_DIM3, "attribute dimensions", __FILE__, __LINE__); /* Verify Datatype */ @@ -1151,7 +1174,7 @@ static void test_attr_mult_read() // Verify that the type is of compound datatype verify_val(type_class, H5T_FLOAT, "Attribute::getTypeClass", __LINE__, __FILE__); - // Get the double datatype + // Get the double datatype FloatType f_type = attr.getFloatType(); // Get and verify the order of this type @@ -1166,11 +1189,14 @@ static void test_attr_mult_read() attr.read(PredType::NATIVE_DOUBLE, read_data3); // Verify values read in - for(i=0; i<ATTR3_DIM1; i++) - for(j=0; j<ATTR3_DIM2; j++) - for(k=0; k<ATTR3_DIM3; k++) - if(attr_data3[i][j][k]!=read_data3[i][j][k]) - TestErrPrintf("%d: attribute data different: attr_data3[%d][%d][%d]=%f, read_data3[%d][%d][%d]=%f\n",__LINE__,i,j,k,attr_data3[i][j][k],i,j,k,read_data3[i][j][k]); + for (i = 0; i < ATTR3_DIM1; i++) + for (j = 0; j < ATTR3_DIM2; j++) + for (k = 0; k < ATTR3_DIM3; k++) + if (abs(attr_data3[i][j][k] - read_data3[i][j][k]) > DBL_EPSILON) + TestErrPrintf("%d: attribute data different: attr_data3[%" PRIuHSIZE "][%" PRIuHSIZE + "][%" PRIuHSIZE "]=%f, " + "read_data3[%" PRIuHSIZE "][%" PRIuHSIZE "][%" PRIuHSIZE "]=%f\n", + __LINE__, i, j, k, attr_data3[i][j][k], i, j, k, read_data3[i][j][k]); // Verify Name attr_name = attr.getName(); @@ -1179,13 +1205,11 @@ static void test_attr_mult_read() PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_mult_read()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_mult_read() +} // test_attr_mult_read() - /*------------------------------------------------------------------------- * Function: test_attr_delete * @@ -1194,9 +1218,10 @@ static void test_attr_mult_read() * Return None *------------------------------------------------------------------------- */ -static void test_attr_delete() +static void +test_attr_delete() { - H5std_string attr_name; // Buffer for attribute names + H5std_string attr_name; // Buffer for attribute names // Output message about test being performed SUBTEST("Removing Attribute Function"); @@ -1218,7 +1243,7 @@ static void test_attr_delete() // Verify the name of the only file attribute left Attribute fattr = fid1.openAttribute((unsigned)0); - attr_name = fattr.getName(); + attr_name = fattr.getName(); verify_val(attr_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__); fattr.close(); @@ -1236,10 +1261,12 @@ static void test_attr_delete() dataset.removeAttr("Bogus"); // continuation here, that means no exception has been thrown - throw InvalidActionException("DataSet::removeAttr", "Attempting to remove non-existing attribute"); + throw InvalidActionException("DataSet::removeAttr", + "Attempting to remove non-existing attribute"); } - catch (AttributeIException& E) // catching invalid removing attribute - {} // do nothing, exception expected + catch (AttributeIException &E) // catching invalid removing attribute + { + } // do nothing, exception expected // Test deleting dataset's attributes @@ -1299,13 +1326,11 @@ static void test_attr_delete() PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_delete()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_delete() +} // test_attr_delete() - /*------------------------------------------------------------------------- * Function: test_attr_dtype_shared * @@ -1314,14 +1339,15 @@ static void test_attr_delete() * Return None *------------------------------------------------------------------------- */ -static void test_attr_dtype_shared() +static void +test_attr_dtype_shared() { - int data=8; // Data to write - int rdata=0; // Data read in + int data = 8; // Data to write + int rdata = 0; // Data read in #ifndef H5_NO_DEPRECATED_SYMBOLS - H5G_stat_t statbuf; // Object's information + H5G_stat_t statbuf; // Object's information #endif - h5_stat_size_t filesize; // Size of file after modifications + h5_stat_size_t filesize; // Size of file after modifications // Output message about test being performed SUBTEST("Shared Datatypes with Attributes"); @@ -1334,7 +1360,7 @@ static void test_attr_dtype_shared() fid1.close(); // Get size of file - h5_stat_size_t empty_filesize; // Size of empty file + h5_stat_size_t empty_filesize; // Size of empty file empty_filesize = h5_get_file_size(FILE_DTYPE.c_str(), H5P_DEFAULT); if (empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); @@ -1347,67 +1373,68 @@ static void test_attr_dtype_shared() // scope, causing incorrect number of ref counts. { // First enclosed block - // Create a datatype to commit and use - IntType dtype(PredType::NATIVE_INT); + // Create a datatype to commit and use + IntType dtype(PredType::NATIVE_INT); - // Commit datatype to file - dtype.commit(fid1, TYPE1_NAME); + // Commit datatype to file + dtype.commit(fid1, TYPE1_NAME); #ifndef H5_NO_DEPRECATED_SYMBOLS - // Check reference count on named datatype - fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 1, "DataType::getObjinfo", __LINE__, __FILE__); + // Check reference count on named datatype + fid1.getObjinfo(TYPE1_NAME, statbuf); + verify_val((int)statbuf.nlink, 1, "DataType::getObjinfo", __LINE__, __FILE__); #endif - // Create dataspace for dataset - DataSpace dspace; + // Create dataspace for dataset + DataSpace dspace; - DataSet dset = fid1.createDataSet(DSET1_NAME, dtype, dspace); + DataSet dset = fid1.createDataSet(DSET1_NAME, dtype, dspace); #ifndef H5_NO_DEPRECATED_SYMBOLS - // Check reference count on named datatype - fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 2, "H5File::getObjinfo", __LINE__, __FILE__); + // Check reference count on named datatype + fid1.getObjinfo(TYPE1_NAME, statbuf); + verify_val((int)statbuf.nlink, 2, "H5File::getObjinfo", __LINE__, __FILE__); #endif - // Create attribute on dataset - Attribute attr = dset.createAttribute(ATTR1_NAME,dtype,dspace); + // Create attribute on dataset + Attribute attr = dset.createAttribute(ATTR1_NAME, dtype, dspace); #ifndef H5_NO_DEPRECATED_SYMBOLS - // Check reference count on named datatype - fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 3, "DataSet::getObjinfo", __LINE__, __FILE__); + // Check reference count on named datatype + fid1.getObjinfo(TYPE1_NAME, statbuf); + verify_val((int)statbuf.nlink, 3, "DataSet::getObjinfo", __LINE__, __FILE__); #endif - // Close attribute - attr.close(); + // Close attribute + attr.close(); - // Delete attribute - dset.removeAttr(ATTR1_NAME); + // Delete attribute + dset.removeAttr(ATTR1_NAME); #ifndef H5_NO_DEPRECATED_SYMBOLS - // Check reference count on named datatype - fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 2, "DataSet::getObjinfo after DataSet::removeAttr", __LINE__, __FILE__); + // Check reference count on named datatype + fid1.getObjinfo(TYPE1_NAME, statbuf); + verify_val((int)statbuf.nlink, 2, "DataSet::getObjinfo after DataSet::removeAttr", __LINE__, + __FILE__); #endif - // Create attribute on dataset - attr = dset.createAttribute(ATTR1_NAME,dtype,dspace); + // Create attribute on dataset + attr = dset.createAttribute(ATTR1_NAME, dtype, dspace); #ifndef H5_NO_DEPRECATED_SYMBOLS - // Check reference count on named datatype - fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 3, "DataSet::createAttribute", __LINE__, __FILE__); + // Check reference count on named datatype + fid1.getObjinfo(TYPE1_NAME, statbuf); + verify_val((int)statbuf.nlink, 3, "DataSet::createAttribute", __LINE__, __FILE__); #endif - // Write data into the attribute - attr.write(PredType::NATIVE_INT,&data); + // Write data into the attribute + attr.write(PredType::NATIVE_INT, &data); - // Close attribute, dataset, dataspace, datatype, and file - attr.close(); - dset.close(); - dspace.close(); - dtype.close(); + // Close attribute, dataset, dataspace, datatype, and file + attr.close(); + dset.close(); + dspace.close(); + dtype.close(); } // end of first enclosing fid1.close(); @@ -1417,24 +1444,24 @@ static void test_attr_dtype_shared() { // Second enclosed block... - // Open dataset - DataSet *dset2 = new DataSet (fid1.openDataSet(DSET1_NAME)); + // Open dataset + DataSet *dset2 = new DataSet(fid1.openDataSet(DSET1_NAME)); - // Open attribute - Attribute *attr2 = new Attribute (dset2->openAttribute(ATTR1_NAME)); + // Open attribute + Attribute *attr2 = new Attribute(dset2->openAttribute(ATTR1_NAME)); - // Read data from the attribute - attr2->read(PredType::NATIVE_INT, &rdata); - verify_val(data, rdata, "Attribute::read", __LINE__, __FILE__); + // Read data from the attribute + attr2->read(PredType::NATIVE_INT, &rdata); + verify_val(data, rdata, "Attribute::read", __LINE__, __FILE__); - // Close attribute and dataset - delete attr2; - delete dset2; + // Close attribute and dataset + delete attr2; + delete dset2; #ifndef H5_NO_DEPRECATED_SYMBOLS - // Check reference count on named datatype - fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 3, "DataSet::openAttribute", __LINE__, __FILE__); + // Check reference count on named datatype + fid1.getObjinfo(TYPE1_NAME, statbuf); + verify_val((int)statbuf.nlink, 3, "DataSet::openAttribute", __LINE__, __FILE__); #endif } // end of second enclosing @@ -1458,15 +1485,13 @@ static void test_attr_dtype_shared() verify_val((long)filesize, (long)empty_filesize, "Checking file size", __LINE__, __FILE__); PASSED(); - } // end try block + } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_dtype_shared()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_dtype_shared() +} // test_attr_dtype_shared() - /*------------------------------------------------------------------------- * Function: test_string_attr * @@ -1480,9 +1505,10 @@ const H5std_string ATTR1_FL_STR_NAME("String_attr 1"); const H5std_string ATTR2_FL_STR_NAME("String_attr 2"); const H5std_string ATTR_VL_STR_NAME("String_attr"); const H5std_string ATTRSTR_DATA("String Attribute"); -const int ATTR_LEN = 17; +const int ATTR_LEN = 17; -static void test_string_attr() +static void +test_string_attr() { // Output message about test being performed SUBTEST("I/O on FL and VL String Attributes"); @@ -1501,7 +1527,7 @@ static void test_string_attr() Group root = fid1.openGroup("/"); // Create dataspace for the attribute. - DataSpace att_space (H5S_SCALAR); + DataSpace att_space(H5S_SCALAR); /* Test Attribute::write(...,const void *buf) with Fixed len string */ @@ -1524,18 +1550,20 @@ static void test_string_attr() // Read and verify the attribute string as a string of chars. char flstring_att_check[ATTR_LEN]; gr_flattr1.read(fls_type, flstring_att_check); - if(HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), flstring_att_check); + if (HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str()) != 0) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n", + __LINE__, ATTRSTR_DATA.c_str(), flstring_att_check); // Read and verify the attribute string as a string of chars; buffer // is dynamically allocated. size_t attr_size = gr_flattr1.getInMemDataSize(); - char *fl_dyn_string_att_check; - fl_dyn_string_att_check = new char[attr_size+1]; + char * fl_dyn_string_att_check; + fl_dyn_string_att_check = new char[attr_size + 1]; gr_flattr1.read(fls_type, fl_dyn_string_att_check); - if(HDstrcmp(fl_dyn_string_att_check, ATTRSTR_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), fl_dyn_string_att_check); - delete []fl_dyn_string_att_check; + if (HDstrcmp(fl_dyn_string_att_check, ATTRSTR_DATA.c_str()) != 0) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n", + __LINE__, ATTRSTR_DATA.c_str(), fl_dyn_string_att_check); + delete[] fl_dyn_string_att_check; /* Test Attribute::read(...,H5std_string& strg) with FL string */ @@ -1543,13 +1571,15 @@ static void test_string_attr() H5std_string read_flstr1; gr_flattr1.read(fls_type, read_flstr1); if (read_flstr1 != ATTRSTR_DATA) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr1=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_flstr1.c_str()); + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr1=%s\n", __LINE__, + ATTRSTR_DATA.c_str(), read_flstr1.c_str()); // Read and verify the attribute string as a string of chars. HDstrcpy(flstring_att_check, ""); gr_flattr2.read(fls_type, flstring_att_check); - if(HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), flstring_att_check); + if (HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str()) != 0) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n", + __LINE__, ATTRSTR_DATA.c_str(), flstring_att_check); /* Test Attribute::read(...,H5std_string& strg) with FL string */ @@ -1557,7 +1587,8 @@ static void test_string_attr() H5std_string read_flstr2; gr_flattr2.read(fls_type, read_flstr2); if (read_flstr2 != ATTRSTR_DATA) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr2=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_flstr2.c_str()); + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr2=%s\n", __LINE__, + ATTRSTR_DATA.c_str(), read_flstr2.c_str()); // // Variable-lenth string attributes @@ -1575,8 +1606,9 @@ static void test_string_attr() // Read and verify the attribute string as a string of chars. char *string_att_check; gr_vlattr.read(vls_type, &string_att_check); - if(HDstrcmp(string_att_check, ATTRSTR_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,string_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), string_att_check); + if (HDstrcmp(string_att_check, ATTRSTR_DATA.c_str()) != 0) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,string_att_check=%s\n", + __LINE__, ATTRSTR_DATA.c_str(), string_att_check); HDfree(string_att_check); /* Test Attribute::read(...,H5std_string& strg) with VL string */ @@ -1584,17 +1616,16 @@ static void test_string_attr() H5std_string read_str; gr_vlattr.read(vls_type, read_str); if (read_str != ATTRSTR_DATA) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_str=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_str.c_str()); + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_str=%s\n", __LINE__, + ATTRSTR_DATA.c_str(), read_str.c_str()); PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_string_attr()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_string_attr() +} // test_string_attr() - /*------------------------------------------------------------------------- * Function: test_attr_exists * @@ -1606,7 +1637,8 @@ static void test_string_attr() * Additional attrExists tests are in test_attr_rename(). *------------------------------------------------------------------------- */ -static void test_attr_exists() +static void +test_attr_exists() { // Output message about test being performed SUBTEST("Check Attribute Existence"); @@ -1621,12 +1653,14 @@ static void test_attr_exists() // Check for existence of attribute bool attr_exists = fid1.attrExists(ATTR1_FL_STR_NAME); if (attr_exists == false) - throw InvalidActionException("H5File::attrExists", "fid1, ATTR1_FL_STR_NAMEAttribute should exist but does not"); + throw InvalidActionException("H5File::attrExists", + "fid1, ATTR1_FL_STR_NAMEAttribute should exist but does not"); // Check for existence of attribute attr_exists = fid1.attrExists(FATTR1_NAME); if (attr_exists == false) - throw InvalidActionException("H5File::attrExists", "fid1,FATTR2_NAMEAttribute should exist but does not"); + throw InvalidActionException("H5File::attrExists", + "fid1,FATTR2_NAMEAttribute should exist but does not"); // Open a group. Group group = fid1.openGroup(GROUP1_NAME); @@ -1634,22 +1668,20 @@ static void test_attr_exists() // Check for existence of attribute attr_exists = group.attrExists(ATTR2_NAME); if (attr_exists == false) - throw InvalidActionException("H5File::attrExists", "group, ATTR2_NAMEAttribute should exist but does not"); + throw InvalidActionException("H5File::attrExists", + "group, ATTR2_NAMEAttribute should exist but does not"); PASSED(); } // end try block - catch (InvalidActionException& E) - { + catch (InvalidActionException &E) { issue_fail_msg("test_attr_exists()", __LINE__, __FILE__, E.getCDetailMsg()); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_exists()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_exists() +} // test_attr_exists() - /*------------------------------------------------------------------------- * Function: test_attr_dense_create * @@ -1659,25 +1691,25 @@ static void test_attr_exists() *------------------------------------------------------------------------- */ const H5std_string FILE_CRTPROPS("tattr_crt_properties.h5"); -const int NAME_BUF_SIZE = 1024; -const unsigned MAX_COMPACT_DEF = 8; -const unsigned MIN_DENSE_DEF = 6; +const int NAME_BUF_SIZE = 1024; +const unsigned MAX_COMPACT_DEF = 8; +const unsigned MIN_DENSE_DEF = 6; -static void test_attr_dense_create(FileCreatPropList& fcpl, - FileAccPropList& fapl) +static void +test_attr_dense_create(FileCreatPropList &fcpl, FileAccPropList &fapl) { // Output message about test being performed SUBTEST("Dense Attribute Storage Creation"); try { // Create file - H5File fid1 (FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl); + H5File fid1(FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl); // Close file fid1.close(); // Get size of file - h5_stat_size_t empty_filesize; // Size of empty file + h5_stat_size_t empty_filesize; // Size of empty file empty_filesize = h5_get_file_size(FILE_CRTPROPS.c_str(), fapl.getId()); if (empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); @@ -1698,16 +1730,18 @@ static void test_attr_dense_create(FileCreatPropList& fcpl, // Retrieve limits for compact/dense attribute storage dcpl.getAttrPhaseChange(max_compact, min_dense); - verify_val(max_compact, MAX_COMPACT_DEF, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); - verify_val(min_dense, MIN_DENSE_DEF, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); + verify_val(max_compact, MAX_COMPACT_DEF, "DSetCreatPropList::getAttrPhaseChange", __LINE__, __FILE__); + verify_val(min_dense, MIN_DENSE_DEF, "DSetCreatPropList::getAttrPhaseChange", __LINE__, __FILE__); // Set new compact/dense attribute storage limits to some random numbers dcpl.setAttrPhaseChange(7, 5); // Retrieve limits for compact/dense attribute storage and verify them dcpl.getAttrPhaseChange(max_compact, min_dense); - verify_val(max_compact, static_cast<unsigned>(7), "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); - verify_val(min_dense, static_cast<unsigned>(5), "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); + verify_val(max_compact, static_cast<unsigned>(7), "DSetCreatPropList::getAttrPhaseChange", __LINE__, + __FILE__); + verify_val(min_dense, static_cast<unsigned>(5), "DSetCreatPropList::getAttrPhaseChange", __LINE__, + __FILE__); // Close property list dcpl.close(); @@ -1715,10 +1749,9 @@ static void test_attr_dense_create(FileCreatPropList& fcpl, // H5O_is_attr_dense_test - un-usable // Add attributes, until just before converting to dense storage - char attr_name[NAME_BUF_SIZE]; + char attr_name[NAME_BUF_SIZE]; unsigned attr_num; - for (attr_num = 0; attr_num < max_compact; attr_num++) - { + for (attr_num = 0; attr_num < max_compact; attr_num++) { // Create attribute sprintf(attr_name, "attr %02u", attr_num); Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space); @@ -1740,28 +1773,27 @@ static void test_attr_dense_create(FileCreatPropList& fcpl, } // Attempt to add attribute again, which should fail - try - { + try { // Create another attribute sprintf(attr_name, "attr %02u", attr_num); Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space); // continuation here, that means no exception has been thrown - throw InvalidActionException("DataSet::createAttribute", "Maximum number of attributes has been reached"); + throw InvalidActionException("DataSet::createAttribute", + "Maximum number of attributes has been reached"); } - catch (AttributeIException& E) // catching invalid action - {} // do nothing, exception expected + catch (AttributeIException &E) // catching invalid action + { + } // do nothing, exception expected PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_dense_create()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_dense_create() +} // test_attr_dense_create() - /*------------------------------------------------------------------------- * Function: test_attr_corder_create_basic * @@ -1770,23 +1802,23 @@ static void test_attr_dense_create(FileCreatPropList& fcpl, * Return None *------------------------------------------------------------------------- */ -static void test_attr_corder_create_basic(FileCreatPropList& fcpl, - FileAccPropList& fapl) +static void +test_attr_corder_create_basic(FileCreatPropList &fcpl, FileAccPropList &fapl) { // Output message about test being performed SUBTEST("Basic Code for Attributes with Creation Order Info"); try { // Create file - H5File fid1 (FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl); + H5File fid1(FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl); // Create dataset creation property list. DSetCreatPropList dcpl; // Get creation order indexing on object unsigned crt_order_flags = 0; - crt_order_flags = dcpl.getAttrCrtOrder(); - verify_val(crt_order_flags, (unsigned)0, "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__); + crt_order_flags = dcpl.getAttrCrtOrder(); + verify_val(crt_order_flags, (unsigned)0, "DSetCreatPropList::getAttrCrtOrder", __LINE__, __FILE__); // Setting invalid combination of a attribute order creation order // indexing on should fail @@ -1794,16 +1826,19 @@ static void test_attr_corder_create_basic(FileCreatPropList& fcpl, dcpl.setAttrCrtOrder(H5P_CRT_ORDER_INDEXED); // continuation here, that means no exception has been thrown - throw InvalidActionException("DSetCreatPropList::getAttrCrtOrder", "Indexing cannot be set alone, order tracking is required"); + throw InvalidActionException("DSetCreatPropList::getAttrCrtOrder", + "Indexing cannot be set alone, order tracking is required"); } - catch (PropListIException& E) // catching invalid action - {} // do nothing, exception expected + catch (PropListIException &E) // catching invalid action + { + } // do nothing, exception expected // Set attribute creation order tracking & indexing for object then // verify them dcpl.setAttrCrtOrder(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED); crt_order_flags = dcpl.getAttrCrtOrder(); - verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__); + verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), + "DSetCreatPropList::getAttrCrtOrder", __LINE__, __FILE__); // Create dataspace for dataset DataSpace ds_space(H5S_SCALAR); @@ -1838,18 +1873,17 @@ static void test_attr_corder_create_basic(FileCreatPropList& fcpl, // Query the attribute creation properties crt_order_flags = dcpl.getAttrCrtOrder(); - verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__); + verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), + "DSetCreatPropList::getAttrCrtOrder", __LINE__, __FILE__); PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_corder_create_basic()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_corder_create_basic() +} // test_attr_corder_create_basic() - /*------------------------------------------------------------------------- * Function: test_attr * @@ -1858,14 +1892,13 @@ static void test_attr_corder_create_basic(FileCreatPropList& fcpl, * Return None *------------------------------------------------------------------------- */ -extern "C" -void test_attr() +extern "C" void +test_attr() { // Output message about test being performed MESSAGE(5, ("Testing Attributes\n")); - try - { + try { // Create a default file access property list FileAccPropList fapl; @@ -1887,45 +1920,41 @@ void test_attr() // Loop over using new group format unsigned new_format; - for (new_format = FALSE; new_format <= TRUE; new_format++) - { + for (new_format = FALSE; new_format <= TRUE; new_format++) { FileAccPropList curr_fapl; // Set the file access proplist for the type of format - if (new_format) - { + if (new_format) { MESSAGE(7, ("testing with new file format\n")); curr_fapl = fapl_new; } - else - { + else { MESSAGE(7, ("testing with old file format\n")); curr_fapl = fapl; } - test_attr_basic_write(); // Test basic H5A writing code - test_attr_getname(); // Test overloads of Attribute::getName - test_attr_rename(); // Test renaming attribute - test_attr_basic_read(); // Test basic H5A reading code + test_attr_basic_write(); // Test basic H5A writing code + test_attr_getname(); // Test overloads of Attribute::getName + test_attr_rename(); // Test renaming attribute + test_attr_basic_read(); // Test basic H5A reading code test_attr_compound_write(); // Test complex datatype H5A writing code test_attr_compound_read(); // Test complex datatype H5A reading code - test_attr_scalar_write(); // Test scalar dataspace H5A writing code - test_attr_scalar_read(); // Test scalar dataspace H5A reading code + test_attr_scalar_write(); // Test scalar dataspace H5A writing code + test_attr_scalar_read(); // Test scalar dataspace H5A reading code - test_attr_mult_write(); // Test writing multiple attributes - test_attr_mult_read(); // Test reading multiple attributes - test_attr_delete(); // Test deleting attributes + test_attr_mult_write(); // Test writing multiple attributes + test_attr_mult_read(); // Test reading multiple attributes + test_attr_delete(); // Test deleting attributes - test_attr_dtype_shared(); // Test using shared datatypes in attributes + test_attr_dtype_shared(); // Test using shared datatypes in attributes - test_string_attr(); // Test read/write string attribute - test_attr_exists(); // Test H5Location::attrExists + test_string_attr(); // Test read/write string attribute + test_attr_exists(); // Test H5Location::attrExists // Test with new format - if (new_format) - { + if (new_format) { // Test dense attribute storage creation test_attr_dense_create(fcpl, curr_fapl); @@ -1933,15 +1962,13 @@ void test_attr() test_attr_corder_create_basic(fcpl, curr_fapl); } } // end for - } // end try block + } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr() +} // test_attr() - /*------------------------------------------------------------------------- * Function: cleanup_attr * @@ -1950,8 +1977,8 @@ void test_attr() * Return None *------------------------------------------------------------------------- */ -extern "C" -void cleanup_attr() +extern "C" void +cleanup_attr() { HDremove(FILE_BASIC.c_str()); HDremove(FILE_COMPOUND.c_str()); @@ -1960,4 +1987,3 @@ void cleanup_attr() HDremove(FILE_DTYPE.c_str()); HDremove(FILE_CRTPROPS.c_str()); } - diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp index ec8adf0..82c21e8 100644 --- a/c++/test/tcompound.cpp +++ b/c++/test/tcompound.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,30 +16,25 @@ tcompound.cpp - HDF5 C++ testing the compound data type functionality ***************************************************************************/ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file /* Number of elements in each test */ #define NTESTELEM 100000 typedef struct complex_t { - double re; - double im; + double re; + double im; } complex_t; - /*------------------------------------------------------------------------- * Function: test_compound_1 * @@ -51,7 +46,8 @@ typedef struct complex_t { * January, 2007 *------------------------------------------------------------------------- */ -static void test_compound_1() +static void +test_compound_1() { // Output message about test being performed SUBTEST("Compound Data Types"); @@ -63,15 +59,13 @@ static void test_compound_1() complex_type.insertMember("real", HOFFSET(complex_t, re), PredType::NATIVE_DOUBLE); complex_type.insertMember("imaginary", HOFFSET(complex_t, im), PredType::NATIVE_DOUBLE); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_compound_1() +} // test_compound_1() - /*------------------------------------------------------------------------- * Function: test_compound_2 * @@ -85,7 +79,8 @@ static void test_compound_1() * January, 2007 *------------------------------------------------------------------------- */ -static void test_compound_2() +static void +test_compound_2() { typedef struct { int a, b, c[4], d, e; @@ -94,33 +89,33 @@ static void test_compound_2() int e, d, c[4], b, a; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - const int nelmts = NTESTELEM; - const hsize_t four = 4; - int i; + src_typ_t * s_ptr; + dst_typ_t * d_ptr; + const int nelmts = NTESTELEM; + const hsize_t four = 4; + int i; unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; - ArrayType *array_dt = NULL; + ArrayType * array_dt = NULL; // Output message about test being performed SUBTEST("Compound Element Reordering"); try { // Sizes should be the same, but be careful just in case - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); - for (i=0; i<nelmts; i++) { - s_ptr = ((src_typ_t*)orig) + i; - s_ptr->a = i*8+0; - s_ptr->b = i*8+1; - s_ptr->c[0] = i*8+2; - s_ptr->c[1] = i*8+3; - s_ptr->c[2] = i*8+4; - s_ptr->c[3] = i*8+5; - s_ptr->d = i*8+6; - s_ptr->e = i*8+7; + buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t)); + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + s_ptr->a = i * 8 + 0; + s_ptr->b = i * 8 + 1; + s_ptr->c[0] = i * 8 + 2; + s_ptr->c[1] = i * 8 + 3; + s_ptr->c[2] = i * 8 + 4; + s_ptr->c[3] = i * 8 + 5; + s_ptr->d = i * 8 + 6; + s_ptr->e = i * 8 + 7; } - memcpy(buf, orig, nelmts*sizeof(src_typ_t)); + memcpy(buf, orig, nelmts * sizeof(src_typ_t)); // Build hdf5 datatypes array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); @@ -150,29 +145,22 @@ static void test_compound_2() st.convert(dt, (size_t)nelmts, buf, bkg); // Compare results - for (i=0; i<nelmts; i++) { - s_ptr = ((src_typ_t*)orig) + i; - d_ptr = ((dst_typ_t*)buf) + i; - if (s_ptr->a != d_ptr->a || - s_ptr->b != d_ptr->b || - s_ptr->c[0] != d_ptr->c[0] || - s_ptr->c[1] != d_ptr->c[1] || - s_ptr->c[2] != d_ptr->c[2] || - s_ptr->c[3] != d_ptr->c[3] || - s_ptr->d != d_ptr->d || - s_ptr->e != d_ptr->e) { + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + d_ptr = ((dst_typ_t *)buf) + i; + if (s_ptr->a != d_ptr->a || s_ptr->b != d_ptr->b || s_ptr->c[0] != d_ptr->c[0] || + s_ptr->c[1] != d_ptr->c[1] || s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] || + s_ptr->d != d_ptr->d || s_ptr->e != d_ptr->e) { H5_FAILED(); cerr << " i=" << i << endl; - cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b - << "c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," - << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" - << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; - cerr << " dst={a=" << s_ptr->a << ", b=" << s_ptr->b - << "c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," - << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" - << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; - } + cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b << "c=[" << s_ptr->c[0] << "," + << s_ptr->c[1] << "," << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" << s_ptr->d + << ", e=" << s_ptr->e << "}" << endl; + cerr << " dst={a=" << s_ptr->a << ", b=" << s_ptr->b << "c=[" << s_ptr->c[0] << "," + << s_ptr->c[1] << "," << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" << s_ptr->d + << ", e=" << s_ptr->e << "}" << endl; } + } // Release resources HDfree(buf); HDfree(bkg); @@ -182,18 +170,16 @@ static void test_compound_2() st.close(); dt.close(); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } - if(array_dt) + if (array_dt) delete array_dt; -} // test_compound_2() +} // test_compound_2() - /*------------------------------------------------------------------------- * Function: test_compound_3 * @@ -207,42 +193,43 @@ static void test_compound_2() * January, 2007 *------------------------------------------------------------------------- */ -static void test_compound_3() +static void +test_compound_3() { typedef struct { int a, b, c[4], d, e; } src_typ_t; typedef struct { - int a, c[4], e; + int a, c[4], e; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - int i; - const int nelmts = NTESTELEM; - const hsize_t four = 4; + src_typ_t * s_ptr; + dst_typ_t * d_ptr; + int i; + const int nelmts = NTESTELEM; + const hsize_t four = 4; unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; - ArrayType* array_dt = NULL; + ArrayType * array_dt = NULL; // Output message about test being performed SUBTEST("Compound Datatype Subset Conversions"); try { /* Initialize */ - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); - for (i=0; i<nelmts; i++) { - s_ptr = ((src_typ_t*)orig) + i; - s_ptr->a = i*8+0; - s_ptr->b = i*8+1; - s_ptr->c[0] = i*8+2; - s_ptr->c[1] = i*8+3; - s_ptr->c[2] = i*8+4; - s_ptr->c[3] = i*8+5; - s_ptr->d = i*8+6; - s_ptr->e = i*8+7; + buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t)); + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + s_ptr->a = i * 8 + 0; + s_ptr->b = i * 8 + 1; + s_ptr->c[0] = i * 8 + 2; + s_ptr->c[1] = i * 8 + 3; + s_ptr->c[2] = i * 8 + 4; + s_ptr->c[3] = i * 8 + 5; + s_ptr->d = i * 8 + 6; + s_ptr->e = i * 8 + 7; } - memcpy(buf, orig, nelmts*sizeof(src_typ_t)); + memcpy(buf, orig, nelmts * sizeof(src_typ_t)); /* Build hdf5 datatypes */ array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); @@ -270,27 +257,20 @@ static void test_compound_3() st.convert(dt, (size_t)nelmts, buf, bkg); /* Compare results */ - for (i=0; i<nelmts; i++) { - s_ptr = ((src_typ_t*)orig) + i; - d_ptr = ((dst_typ_t*)buf) + i; - if (s_ptr->a != d_ptr->a || - s_ptr->c[0] != d_ptr->c[0] || - s_ptr->c[1] != d_ptr->c[1] || - s_ptr->c[2] != d_ptr->c[2] || - s_ptr->c[3] != d_ptr->c[3] || - s_ptr->e != d_ptr->e) { + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + d_ptr = ((dst_typ_t *)buf) + i; + if (s_ptr->a != d_ptr->a || s_ptr->c[0] != d_ptr->c[0] || s_ptr->c[1] != d_ptr->c[1] || + s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] || s_ptr->e != d_ptr->e) { H5_FAILED(); cerr << " i=" << i << endl; - cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b - << ", c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," - << s_ptr->c[2] << "," << s_ptr->c[3] << "], d=" - << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; - cerr << " dst={a=" << d_ptr->a - << ", c=[" << d_ptr->c[0] << "," << d_ptr->c[1] << "," - << d_ptr->c[2] << "," << d_ptr->c[3] << "], e=" - << d_ptr->e << "}" << endl; + cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b << ", c=[" << s_ptr->c[0] << "," + << s_ptr->c[1] << "," << s_ptr->c[2] << "," << s_ptr->c[3] << "], d=" << s_ptr->d + << ", e=" << s_ptr->e << "}" << endl; + cerr << " dst={a=" << d_ptr->a << ", c=[" << d_ptr->c[0] << "," << d_ptr->c[1] << "," + << d_ptr->c[2] << "," << d_ptr->c[3] << "], e=" << d_ptr->e << "}" << endl; } // if - } // for + } // for /* Release resources */ HDfree(buf); @@ -301,18 +281,16 @@ static void test_compound_3() st.close(); dt.close(); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } - if(array_dt) + if (array_dt) delete array_dt; -} // test_compound_3() +} // test_compound_3() - /*------------------------------------------------------------------------- * Function: test_compound_4 * @@ -326,7 +304,8 @@ static void test_compound_3() * January, 2007 *------------------------------------------------------------------------- */ -static void test_compound_4() +static void +test_compound_4() { typedef struct { @@ -335,38 +314,38 @@ static void test_compound_4() typedef struct { short b; - int a, c[4]; + int a, c[4]; short d; - int e; + int e; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - int i; - const int nelmts = NTESTELEM; - const hsize_t four = 4; + src_typ_t * s_ptr; + dst_typ_t * d_ptr; + int i; + const int nelmts = NTESTELEM; + const hsize_t four = 4; unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; - ArrayType* array_dt = NULL; + ArrayType * array_dt = NULL; // Output message about test being performed SUBTEST("Compound Element Shrinking & Reordering"); try { /* Sizes should be the same, but be careful just in case */ - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); - for (i=0; i<nelmts; i++) { - s_ptr = ((src_typ_t*)orig) + i; - s_ptr->a = i*8+0; - s_ptr->b = (i*8+1) & 0x7fff; - s_ptr->c[0] = i*8+2; - s_ptr->c[1] = i*8+3; - s_ptr->c[2] = i*8+4; - s_ptr->c[3] = i*8+5; - s_ptr->d = (i*8+6) & 0x7fff; - s_ptr->e = i*8+7; + buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t)); + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + s_ptr->a = i * 8 + 0; + s_ptr->b = (i * 8 + 1) & 0x7fff; + s_ptr->c[0] = i * 8 + 2; + s_ptr->c[1] = i * 8 + 3; + s_ptr->c[2] = i * 8 + 4; + s_ptr->c[3] = i * 8 + 5; + s_ptr->d = (i * 8 + 6) & 0x7fff; + s_ptr->e = i * 8 + 7; } - memcpy(buf, orig, nelmts*sizeof(src_typ_t)); + memcpy(buf, orig, nelmts * sizeof(src_typ_t)); /* Build hdf5 datatypes */ array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); @@ -396,30 +375,22 @@ static void test_compound_4() st.convert(dt, (size_t)nelmts, buf, bkg); /* Compare results */ - for (i=0; i<nelmts; i++) { - s_ptr = ((src_typ_t*)orig) + i; - d_ptr = ((dst_typ_t*)buf) + i; - if (s_ptr->a != d_ptr->a || - s_ptr->b != d_ptr->b || - s_ptr->c[0] != d_ptr->c[0] || - s_ptr->c[1] != d_ptr->c[1] || - s_ptr->c[2] != d_ptr->c[2] || - s_ptr->c[3] != d_ptr->c[3] || - s_ptr->d != d_ptr->d || - s_ptr->e != d_ptr->e) - { + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + d_ptr = ((dst_typ_t *)buf) + i; + if (s_ptr->a != d_ptr->a || s_ptr->b != d_ptr->b || s_ptr->c[0] != d_ptr->c[0] || + s_ptr->c[1] != d_ptr->c[1] || s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] || + s_ptr->d != d_ptr->d || s_ptr->e != d_ptr->e) { H5_FAILED(); cerr << " i=" << i << endl; - cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b - << "c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," - << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" - << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; - cerr << " dst={a=" << d_ptr->a << ", b=" << d_ptr->b - << "c=[" << d_ptr->c[0] << "," << d_ptr->c[1] << "," - << d_ptr->c[2] << "," << d_ptr->c[3] << ", d=" - << d_ptr->d << ", e=" << d_ptr->e << "}" << endl; + cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b << "c=[" << s_ptr->c[0] << "," + << s_ptr->c[1] << "," << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" << s_ptr->d + << ", e=" << s_ptr->e << "}" << endl; + cerr << " dst={a=" << d_ptr->a << ", b=" << d_ptr->b << "c=[" << d_ptr->c[0] << "," + << d_ptr->c[1] << "," << d_ptr->c[2] << "," << d_ptr->c[3] << ", d=" << d_ptr->d + << ", e=" << d_ptr->e << "}" << endl; } // if - } // for + } // for /* Release resources */ HDfree(buf); @@ -430,18 +401,16 @@ static void test_compound_4() st.close(); dt.close(); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } - if(array_dt) + if (array_dt) delete array_dt; -} // test_compound_4() +} // test_compound_4() - /*------------------------------------------------------------------------- * Function: test_compound_5 * @@ -456,27 +425,27 @@ static void test_compound_4() * January, 2007 *------------------------------------------------------------------------- */ -static void test_compound_5() +static void +test_compound_5() { typedef struct { - char name[16]; - short tdim; - short coll_ids[4]; + char name[16]; + short tdim; + short coll_ids[4]; } src_typ_t; typedef struct { - char name[16]; - short tdim; - int coll_ids[4]; + char name[16]; + short tdim; + int coll_ids[4]; } dst_typ_t; - hsize_t dims[1] = {4}; - src_typ_t src[2] = {{"one", 102, {104, 105, 106, 107}}, - {"two", 202, {204, 205, 206, 207}}}; - dst_typ_t *dst; - void *buf = HDcalloc(2, sizeof(dst_typ_t)); - void *bkg = HDcalloc(2, sizeof(dst_typ_t)); - ArrayType* array_dt = NULL; + hsize_t dims[1] = {4}; + src_typ_t src[2] = {{"one", 102, {104, 105, 106, 107}}, {"two", 202, {204, 205, 206, 207}}}; + dst_typ_t *dst; + void * buf = HDcalloc(2, sizeof(dst_typ_t)); + void * bkg = HDcalloc(2, sizeof(dst_typ_t)); + ArrayType *array_dt = NULL; // Output message about test being performed SUBTEST("Optimized Struct Converter"); @@ -484,17 +453,17 @@ static void test_compound_5() /* Build datatypes */ array_dt = new ArrayType(PredType::NATIVE_SHORT, 1, dims); - CompType short_array(4*sizeof(short)); + CompType short_array(4 * sizeof(short)); short_array.insertMember("_", 0, *array_dt); array_dt->close(); delete array_dt; - CompType int_array(4*sizeof(int)); + CompType int_array(4 * sizeof(int)); array_dt = new ArrayType(PredType::NATIVE_INT, 1, dims); int_array.insertMember("_", 0, *array_dt); array_dt->close(); - StrType strg(PredType::C_S1, 16); + StrType strg(PredType::C_S1, 16); CompType src_type(sizeof(src_typ_t)); src_type.insertMember("name", HOFFSET(src_typ_t, name), strg); src_type.insertMember("tdim", HOFFSET(src_typ_t, tdim), PredType::NATIVE_SHORT); @@ -508,7 +477,7 @@ static void test_compound_5() /* Convert data */ memcpy(buf, src, sizeof(src)); src_type.convert(dst_type, (size_t)2, buf, bkg); - dst = (dst_typ_t*)buf; + dst = (dst_typ_t *)buf; /* Cleanup */ src_type.close(); @@ -518,31 +487,27 @@ static void test_compound_5() int_array.close(); /* Check results */ - if (memcmp(src[1].name, dst[1].name, sizeof(src[1].name)) || - src[1].tdim!=dst[1].tdim || - src[1].coll_ids[0]!=dst[1].coll_ids[0] || - src[1].coll_ids[1]!=dst[1].coll_ids[1] || - src[1].coll_ids[2]!=dst[1].coll_ids[2] || - src[1].coll_ids[3]!=dst[1].coll_ids[3]) - { H5_FAILED(); } + if (memcmp(src[1].name, dst[1].name, sizeof(src[1].name)) != 0 || src[1].tdim != dst[1].tdim || + src[1].coll_ids[0] != dst[1].coll_ids[0] || src[1].coll_ids[1] != dst[1].coll_ids[1] || + src[1].coll_ids[2] != dst[1].coll_ids[2] || src[1].coll_ids[3] != dst[1].coll_ids[3]) { + H5_FAILED(); + } /* Free memory buffers */ HDfree(buf); HDfree(bkg); dst = NULL; PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } - if(array_dt) + if (array_dt) delete array_dt; -} // test_compound_5() +} // test_compound_5() - /*------------------------------------------------------------------------- * Function: test_compound_6 * @@ -556,7 +521,8 @@ static void test_compound_5() * January, 2007 *------------------------------------------------------------------------- */ -static void test_compound_6() +static void +test_compound_6() { typedef struct { short b; @@ -568,25 +534,25 @@ static void test_compound_6() long d; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - int i; - const int nelmts = NTESTELEM; - unsigned char *buf=NULL, *orig=NULL, *bkg=NULL; + src_typ_t * s_ptr; + dst_typ_t * d_ptr; + int i; + const int nelmts = NTESTELEM; + unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; // Output message about test being performed SUBTEST("Compound Element Growing"); try { /* Sizes should be the same, but be careful just in case */ - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); - for (i=0; i<nelmts; i++) { - s_ptr = ((src_typ_t*)orig) + i; - s_ptr->b = (i*8+1) & 0x7fff; - s_ptr->d = (i*8+6) & 0x7fff; + buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t)); + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + s_ptr->b = (i * 8 + 1) & 0x7fff; + s_ptr->d = (i * 8 + 6) & 0x7fff; } - memcpy(buf, orig, nelmts*sizeof(src_typ_t)); + memcpy(buf, orig, nelmts * sizeof(src_typ_t)); /* Build hdf5 datatypes */ CompType st(sizeof(src_typ_t)); @@ -601,20 +567,16 @@ static void test_compound_6() st.convert(dt, (size_t)nelmts, buf, bkg); /* Compare results */ - for (i=0; i<nelmts; i++) { - s_ptr = ((src_typ_t*)orig) + i; - d_ptr = ((dst_typ_t*)buf) + i; - if (s_ptr->b != d_ptr->b || - s_ptr->d != d_ptr->d) - { + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + d_ptr = ((dst_typ_t *)buf) + i; + if (s_ptr->b != d_ptr->b || s_ptr->d != d_ptr->d) { H5_FAILED(); cerr << " i=" << i << endl; - cerr << " src={b=" << s_ptr->b << ", d=" << s_ptr->d - << "}" << endl; - cerr << " dst={b=" << d_ptr->b << ", d=" << d_ptr->d - << "}" << endl; + cerr << " src={b=" << s_ptr->b << ", d=" << s_ptr->d << "}" << endl; + cerr << " dst={b=" << d_ptr->b << ", d=" << d_ptr->d << "}" << endl; } // if - } // for + } // for /* Release resources */ HDfree(buf); @@ -625,15 +587,13 @@ static void test_compound_6() st.close(); dt.close(); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_compound_6() +} // test_compound_6() - /*------------------------------------------------------------------------- * Function: test_compound_7 * @@ -646,18 +606,19 @@ static void test_compound_6() * January, 2007 *------------------------------------------------------------------------- */ -static void test_compound_7() +static void +test_compound_7() { typedef struct { - int a; + int a; float b; - long c; + long c; } s1_typ_t; typedef struct { - int a; - float b; - long c; + int a; + float b; + long c; double d; } s2_typ_t; @@ -666,9 +627,9 @@ static void test_compound_7() try { CompType tid1(sizeof(s1_typ_t)); - tid1.insertMember("a", HOFFSET(s1_typ_t,a),PredType::NATIVE_INT); - tid1.insertMember("b", HOFFSET(s1_typ_t,b),PredType::NATIVE_FLOAT); - tid1.insertMember("c", HOFFSET(s1_typ_t,c),PredType::NATIVE_LONG); + tid1.insertMember("a", HOFFSET(s1_typ_t, a), PredType::NATIVE_INT); + tid1.insertMember("b", HOFFSET(s1_typ_t, b), PredType::NATIVE_FLOAT); + tid1.insertMember("c", HOFFSET(s1_typ_t, c), PredType::NATIVE_LONG); size_t type_size = tid1.getSize(); verify_val(type_size, sizeof(s1_typ_t), "DataType::getSize", __LINE__, __FILE__); @@ -683,22 +644,23 @@ static void test_compound_7() try { tid2.insertMember("d", HOFFSET(s2_typ_t, d), PredType::NATIVE_DOUBLE); // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("CompType::insertMember", "Attempted to insert field past end of compound data type."); - } catch (DataTypeIException& err) {} + throw InvalidActionException("CompType::insertMember", + "Attempted to insert field past end of compound data type."); + } + catch (DataTypeIException &err) { + } /* Release resources */ tid1.close(); tid2.close(); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_compound_7() +} // test_compound_7() - /*------------------------------------------------------------------------- * Function: test_compound_set_size * @@ -712,7 +674,8 @@ static void test_compound_7() */ const H5std_string COMPFILE("tcompound_types.h5"); -static void test_compound_set_size() +static void +test_compound_set_size() { typedef struct { int a, b, c[4], d, e; @@ -779,15 +742,13 @@ static void test_compound_set_size() file.close(); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_compound_set_size() +} // test_compound_set_size() - /*------------------------------------------------------------------------- * Function: test_compound * @@ -799,23 +760,22 @@ static void test_compound_set_size() * January 2007 *------------------------------------------------------------------------- */ -extern "C" -void test_compound() +extern "C" void +test_compound() { // Output message about test being performed MESSAGE(5, ("Testing Compound Data Type operations\n")); - test_compound_1(); // various things about compound data types - test_compound_2(); // compound element reordering - test_compound_3(); // compound datatype subset conversions - test_compound_4(); // compound element shrinking & reordering - test_compound_5(); // optimized struct converter - test_compound_6(); // compound element growing - test_compound_7(); // compound element insertion - test_compound_set_size(); // set size on compound data types -} // test_compound() - - + test_compound_1(); // various things about compound data types + test_compound_2(); // compound element reordering + test_compound_3(); // compound datatype subset conversions + test_compound_4(); // compound element shrinking & reordering + test_compound_5(); // optimized struct converter + test_compound_6(); // compound element growing + test_compound_7(); // compound element insertion + test_compound_set_size(); // set size on compound data types +} // test_compound() + /*------------------------------------------------------------------------- * Function: cleanup_compound * @@ -824,8 +784,8 @@ void test_compound() * Return None *------------------------------------------------------------------------- */ -extern "C" -void cleanup_compound() +extern "C" void +cleanup_compound() { HDremove(COMPFILE.c_str()); -} // cleanup_file +} // cleanup_file diff --git a/c++/test/tdspl.cpp b/c++/test/tdspl.cpp index 438f385..257233e 100644 --- a/c++/test/tdspl.cpp +++ b/c++/test/tdspl.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,29 +17,26 @@ list functionality ***************************************************************************/ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file const H5std_string FILENAME("tdatatransform.h5"); -static void test_transfplist() +static void +test_transfplist() { - const char* c_to_f = "(9/5.0)*x + 32"; - const char* simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */ + const char *c_to_f = "(9/5.0)*x + 32"; + const char *simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */ /* inverses the utrans transform in init_test to get back original array */ - const char* utrans_inv = "(x/3)*4 - 100"; + const char *utrans_inv = "(x/3)*4 - 100"; SUBTEST("DSetMemXferPropList::set/getDataTransform()"); try { @@ -63,12 +60,12 @@ static void test_transfplist() // Find out the length of the transform expression, allocate the buffer // for it, then read and verify the expression from the copied plist - ssize_t tran_len = dxpl_c_to_f_copy.getDataTransform(NULL); - char *c_to_f_read = (char *)HDmalloc(tran_len+1); - HDmemset(c_to_f_read, 0, tran_len+1); - dxpl_c_to_f_copy.getDataTransform(c_to_f_read, tran_len+1); - verify_val((const char*)c_to_f_read, (const char*)c_to_f, - "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + ssize_t tran_len = dxpl_c_to_f_copy.getDataTransform(NULL); + char * c_to_f_read = (char *)HDmalloc(tran_len + 1); + HDmemset(c_to_f_read, 0, tran_len + 1); + dxpl_c_to_f_copy.getDataTransform(c_to_f_read, tran_len + 1); + verify_val((const char *)c_to_f_read, (const char *)c_to_f, "DSetMemXferPropList::getDataTransform", + __LINE__, __FILE__); HDfree(c_to_f_read); // @@ -78,39 +75,37 @@ static void test_transfplist() // Get and verify the expression with: // ssize_t getDataTransform(char* exp, const size_t buf_size [default=0]) - tran_len = dxpl_c_to_f.getDataTransform(NULL); - c_to_f_read = (char *)HDmalloc(tran_len+1); - HDmemset(c_to_f_read, 0, tran_len+1); - dxpl_c_to_f.getDataTransform(c_to_f_read, tran_len+1); - verify_val((const char*)c_to_f_read, (const char*)c_to_f, - "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + tran_len = dxpl_c_to_f.getDataTransform(NULL); + c_to_f_read = (char *)HDmalloc(tran_len + 1); + HDmemset(c_to_f_read, 0, tran_len + 1); + dxpl_c_to_f.getDataTransform(c_to_f_read, tran_len + 1); + verify_val((const char *)c_to_f_read, (const char *)c_to_f, "DSetMemXferPropList::getDataTransform", + __LINE__, __FILE__); HDfree(c_to_f_read); // Get and verify the expression with: // H5std_string DSetMemXferPropList::getDataTransform() H5std_string simple_read = dxpl_simple.getDataTransform(); - verify_val((const char*)simple_read.c_str(), (const char*)simple, - "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + verify_val((const char *)simple_read.c_str(), (const char *)simple, + "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); // Get and verify the expression with: // ssize_t getDataTransform(char* exp, const size_t buf_size) - tran_len = dxpl_utrans_inv.getDataTransform(NULL, 0); - char *utrans_inv_read = (char *)HDmalloc(tran_len+1); - HDmemset(utrans_inv_read, 0, tran_len+1); - dxpl_utrans_inv.getDataTransform(utrans_inv_read, tran_len+1); - verify_val((const char*)utrans_inv_read, (const char*)utrans_inv, - "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + tran_len = dxpl_utrans_inv.getDataTransform(NULL, 0); + char *utrans_inv_read = (char *)HDmalloc(tran_len + 1); + HDmemset(utrans_inv_read, 0, tran_len + 1); + dxpl_utrans_inv.getDataTransform(utrans_inv_read, tran_len + 1); + verify_val((const char *)utrans_inv_read, (const char *)utrans_inv, + "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); HDfree(utrans_inv_read); PASSED(); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_transfplist", __LINE__, __FILE__, E.getCDetailMsg()); } } - /*------------------------------------------------------------------------- * Function: test_dsproplist * @@ -119,17 +114,16 @@ static void test_transfplist() * Return None *------------------------------------------------------------------------- */ -extern "C" -void test_dsproplist() +extern "C" void +test_dsproplist() { // Output message about test being performed MESSAGE(5, ("Testing Generic Dataset Property Lists\n")); test_transfplist(); // test set/getDataTransform() -} // test_dsproplist() +} // test_dsproplist() - /*------------------------------------------------------------------------- * Function: cleanup_dsproplist * @@ -138,8 +132,8 @@ void test_dsproplist() * Return none *------------------------------------------------------------------------- */ -extern "C" -void cleanup_dsproplist() +extern "C" void +cleanup_dsproplist() { HDremove(FILENAME.c_str()); } diff --git a/c++/test/testhdf5.cpp b/c++/test/testhdf5.cpp index a2a0867..71428ce 100644 --- a/c++/test/testhdf5.cpp +++ b/c++/test/testhdf5.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -38,26 +38,21 @@ GetTestNumErrs() -- Retrieve the number of testing errors ***************************************************************************/ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file int main(int argc, char *argv[]) { - try - { + try { // Turn of the auto-printing when failure occurs so that we can // handle the errors appropriately since sometime failures are // caused deliberately and expected. @@ -70,39 +65,38 @@ main(int argc, char *argv[]) // testing dataset functionalities in dset.cpp AddTest("dsets", test_dset, cleanup_dsets, "Dataset I/O Operations", NULL); // testing dataspace functionalities in th5s.cpp - AddTest("th5s", test_h5s, cleanup_h5s, "Dataspaces", NULL); + AddTest("th5s", test_h5s, cleanup_h5s, "Dataspaces", NULL); // testing attribute functionalities in tattr.cpp - AddTest("tattr", test_attr, cleanup_attr, "Attributes", NULL); + AddTest("tattr", test_attr, cleanup_attr, "Attributes", NULL); // testing object functionalities in tobject.cpp - AddTest("tobject", test_object, cleanup_object, "Objects", NULL); + AddTest("tobject", test_object, cleanup_object, "Objects", NULL); // testing reference functionalities in trefer.cpp - AddTest("trefer", test_reference, cleanup_reference, "References", NULL); + AddTest("trefer", test_reference, cleanup_reference, "References", NULL); // testing variable-length strings in tvlstr.cpp - AddTest("tvlstr", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings", NULL); - AddTest("ttypes", test_types, cleanup_types, "Generic Data Types", NULL); - AddTest("tarray", test_array, cleanup_array, "Array Datatypes", NULL); - AddTest("tcompound", test_compound, cleanup_compound, "Compound Data Types", NULL); - AddTest("tdspl", test_dsproplist, cleanup_dsproplist, "Dataset Property List", NULL); - AddTest("tfilter", test_filters, cleanup_filters, "Various Filters", NULL); - AddTest("tlinks", test_links, cleanup_links, "Various Links", NULL); -/* Comment out tests that are not done yet. - BMR, Feb 2001 - AddTest("select", test_select, cleanup_select, "Selections", NULL); - AddTest("time", test_time, cleanup_time, "Time Datatypes", NULL); - AddTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes", NULL); -*/ - AddTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration", NULL); -/* - AddTest("genprop", test_genprop, cleanup_genprop, "Generic Properties", NULL); - AddTest("id", test_ids, NULL, "User-Created Identifiers", NULL); - -Comment out tests that are not done yet */ - -/* Tentative - BMR 2007/1/12 - AddTest("enum", test_enum, cleanup_enum, "Enum Data Types", NULL); -*/ + AddTest("tvlstr", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings", NULL); + AddTest("ttypes", test_types, cleanup_types, "Generic Data Types", NULL); + AddTest("tarray", test_array, cleanup_array, "Array Datatypes", NULL); + AddTest("tcompound", test_compound, cleanup_compound, "Compound Data Types", NULL); + AddTest("tdspl", test_dsproplist, cleanup_dsproplist, "Dataset Property List", NULL); + AddTest("tfilter", test_filters, cleanup_filters, "Various Filters", NULL); + AddTest("tlinks", test_links, cleanup_links, "Various Links", NULL); + /* Comment out tests that are not done yet. - BMR, Feb 2001 + AddTest("select", test_select, cleanup_select, "Selections", NULL); + AddTest("time", test_time, cleanup_time, "Time Datatypes", NULL); + AddTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes", NULL); + */ + AddTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration", NULL); + /* + AddTest("genprop", test_genprop, cleanup_genprop, "Generic Properties", NULL); + AddTest("id", test_ids, NULL, "User-Created Identifiers", NULL); + + Comment out tests that are not done yet */ + + /* Tentative - BMR 2007/1/12 + AddTest("enum", test_enum, cleanup_enum, "Enum Data Types", NULL); + */ } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("Tests failed", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -110,7 +104,7 @@ Comment out tests that are not done yet */ TestInfo(argv[0]); /* Parse command line arguments */ - TestParseCmdLine(argc,argv); + TestParseCmdLine(argc, argv); /* Perform requested testing */ PerformTests(); @@ -128,4 +122,3 @@ Comment out tests that are not done yet */ return (GetTestNumErrs()); } - diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp index 8b874cb..421a734 100644 --- a/c++/test/tfile.cpp +++ b/c++/test/tfile.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,47 +20,42 @@ h5_fileaccess() -- in h5test.c, returns a file access template ***************************************************************************/ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file - -const hsize_t F1_USERBLOCK_SIZE = (hsize_t)0; -const size_t F1_OFFSET_SIZE = sizeof(haddr_t); -const size_t F1_LENGTH_SIZE = sizeof(hsize_t); -const unsigned F1_SYM_LEAF_K = 4; -const unsigned F1_SYM_INTERN_K = 16; -const H5std_string FILE1("tfile1.h5"); - -const hsize_t F2_USERBLOCK_SIZE = (hsize_t)512; -const size_t F2_OFFSET_SIZE = 8; -const size_t F2_LENGTH_SIZE = 8; -const unsigned F2_SYM_LEAF_K = 8; -const unsigned F2_SYM_INTERN_K = 32; -const unsigned F2_ISTORE = 64; -const H5std_string FILE2("tfile2.h5"); - -const hsize_t F3_USERBLOCK_SIZE = (hsize_t)0; -const size_t F3_OFFSET_SIZE = F2_OFFSET_SIZE; -const size_t F3_LENGTH_SIZE = F2_LENGTH_SIZE; -const unsigned F3_SYM_LEAF_K = F2_SYM_LEAF_K; -const unsigned F3_SYM_INTERN_K = F2_SYM_INTERN_K; -const H5std_string FILE3("tfile3.h5"); - -const int KB = 1024; -const H5std_string FILE4("tfile4.h5"); - - +#include "h5cpputil.h" // C++ utilility header file + +const hsize_t F1_USERBLOCK_SIZE = (hsize_t)0; +const size_t F1_OFFSET_SIZE = sizeof(haddr_t); +const size_t F1_LENGTH_SIZE = sizeof(hsize_t); +const unsigned F1_SYM_LEAF_K = 4; +const unsigned F1_SYM_INTERN_K = 16; +const H5std_string FILE1("tfile1.h5"); + +const hsize_t F2_USERBLOCK_SIZE = (hsize_t)512; +const size_t F2_OFFSET_SIZE = 8; +const size_t F2_LENGTH_SIZE = 8; +const unsigned F2_SYM_LEAF_K = 8; +const unsigned F2_SYM_INTERN_K = 32; +const unsigned F2_ISTORE = 64; +const H5std_string FILE2("tfile2.h5"); + +const hsize_t F3_USERBLOCK_SIZE = (hsize_t)0; +const size_t F3_OFFSET_SIZE = F2_OFFSET_SIZE; +const size_t F3_LENGTH_SIZE = F2_LENGTH_SIZE; +const unsigned F3_SYM_LEAF_K = F2_SYM_LEAF_K; +const unsigned F3_SYM_INTERN_K = F2_SYM_INTERN_K; +const H5std_string FILE3("tfile3.h5"); + +const int KB = 1024; +const H5std_string FILE4("tfile4.h5"); + /*------------------------------------------------------------------------- * Function: test_file_create * @@ -80,7 +75,8 @@ const H5std_string FILE4("tfile4.h5"); * with a special routine. *------------------------------------------------------------------------- */ -static void test_file_create() +static void +test_file_create() { // Output message about test being performed SUBTEST("File Creation I/O"); @@ -93,21 +89,22 @@ static void test_file_create() remove(FILE1.c_str()); // Setting this to NULL for cleaning up in failure situations - H5File* file1 = NULL; + H5File *file1 = NULL; try { // Create file FILE1 - file1 = new H5File (FILE1, H5F_ACC_EXCL); + file1 = new H5File(FILE1, H5F_ACC_EXCL); // Try to create the same file with H5F_ACC_TRUNC. This should fail // because file1 is the same file and is currently open. try { - H5File file2 (FILE1, H5F_ACC_TRUNC); // should throw E + H5File file2(FILE1, H5F_ACC_TRUNC); // should throw E // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "Attempted to create an existing file."); } - catch (FileIException& E) // catch truncating existing file - {} // do nothing, FAIL expected + catch (FileIException &E) // catch truncating existing file + { + } // do nothing, FAIL expected // Close file1 delete file1; @@ -116,52 +113,56 @@ static void test_file_create() // Try again with H5F_ACC_EXCL. This should fail because the file // already exists from the previous steps. try { - H5File file2(FILE1, H5F_ACC_EXCL); // should throw E + H5File file2(FILE1, H5F_ACC_EXCL); // should throw E // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "File already exists."); } - catch (FileIException& E) // catching creating existing file - {} // do nothing, FAIL expected + catch (FileIException &E) // catching creating existing file + { + } // do nothing, FAIL expected - // Test create with H5F_ACC_TRUNC. This will truncate the existing file. - file1 = new H5File (FILE1, H5F_ACC_TRUNC); + // Test create with H5F_ACC_TRUNC. This will truncate the existing file. + file1 = new H5File(FILE1, H5F_ACC_TRUNC); // Try to create first file again. This should fail because file1 // is the same file and is currently open. - try { - H5File file2 (FILE1, H5F_ACC_TRUNC); // should throw E + try { + H5File file2(FILE1, H5F_ACC_TRUNC); // should throw E // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "H5F_ACC_TRUNC attempt on an opened file."); } - catch (FileIException& E) // catching truncating opened file - {} // do nothing, FAIL expected + catch (FileIException &E) // catching truncating opened file + { + } // do nothing, FAIL expected - // Try with H5F_ACC_EXCL. This should fail too because the file already - // exists. - try { - H5File file3 (FILE1, H5F_ACC_EXCL); // should throw E + // Try with H5F_ACC_EXCL. This should fail too because the file already + // exists. + try { + H5File file3(FILE1, H5F_ACC_EXCL); // should throw E // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "H5F_ACC_EXCL attempt on an existing file."); - } - catch (FileIException& E) // catching H5F_ACC_EXCL on existing file - {} // do nothing, FAIL expected + } + catch (FileIException &E) // catching H5F_ACC_EXCL on existing file + { + } // do nothing, FAIL expected - // Get the file-creation template + // Get the file-creation template FileCreatPropList tmpl1 = file1->getCreatePlist(); hsize_t ublock = tmpl1.getUserblock(); - verify_val((long)ublock, (long)F1_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); + verify_val((long)ublock, (long)F1_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, + __FILE__); - size_t parm1, parm2; // file-creation parameters - tmpl1.getSizes( parm1, parm2); + size_t parm1, parm2; // file-creation parameters + tmpl1.getSizes(parm1, parm2); verify_val(parm1, F1_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); verify_val(parm2, F1_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - unsigned iparm1,iparm2; // file-creation parameters - tmpl1.getSymk( iparm1, iparm2); + unsigned iparm1, iparm2; // file-creation parameters + tmpl1.getSymk(iparm1, iparm2); verify_val(iparm1, F1_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F1_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); @@ -171,85 +172,84 @@ static void test_file_create() // Close first file delete file1; } - catch (InvalidActionException& E) - { + catch (InvalidActionException &E) { cerr << " *FAILED*" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; if (file1 != NULL) // clean up delete file1; } // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg()); if (file1 != NULL) // clean up delete file1; } // Setting this to NULL for cleaning up in failure situations - FileCreatPropList* tmpl1 = NULL; - try - { - // Create a new file with a non-standard file-creation template + FileCreatPropList *tmpl1 = NULL; + try { + // Create a new file with a non-standard file-creation template tmpl1 = new FileCreatPropList; - // Set the new file-creation parameters - tmpl1->setUserblock (F2_USERBLOCK_SIZE); - tmpl1->setSizes( F2_OFFSET_SIZE, F2_LENGTH_SIZE ); - tmpl1->setSymk( F2_SYM_INTERN_K, F2_SYM_LEAF_K ); + // Set the new file-creation parameters + tmpl1->setUserblock(F2_USERBLOCK_SIZE); + tmpl1->setSizes(F2_OFFSET_SIZE, F2_LENGTH_SIZE); + tmpl1->setSymk(F2_SYM_INTERN_K, F2_SYM_LEAF_K); - // Try to create second file, with non-standard file-creation template - // params. - H5File file2( FILE2, H5F_ACC_TRUNC, *tmpl1 ); + // Try to create second file, with non-standard file-creation template + // params. + H5File file2(FILE2, H5F_ACC_TRUNC, *tmpl1); - // Release file-creation template + // Release file-creation template delete tmpl1; tmpl1 = NULL; // Get the file-creation template - tmpl1 = new FileCreatPropList (file2.getCreatePlist()); + tmpl1 = new FileCreatPropList(file2.getCreatePlist()); // Get the file-creation parameters hsize_t ublock = tmpl1->getUserblock(); - verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); + verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, + __FILE__); size_t parm1, parm2; // file-creation parameters - tmpl1->getSizes( parm1, parm2); + tmpl1->getSizes(parm1, parm2); verify_val(parm1, F2_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); verify_val(parm2, F2_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - unsigned iparm1,iparm2; // file-creation parameters - tmpl1->getSymk( iparm1, iparm2); + unsigned iparm1, iparm2; // file-creation parameters + tmpl1->getSymk(iparm1, iparm2); verify_val(iparm1, F2_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F2_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); // Clone the file-creation template FileCreatPropList tmpl2; - tmpl2.copy (*tmpl1); + tmpl2.copy(*tmpl1); // Release file-creation template delete tmpl1; tmpl1 = NULL; // Set the new file-creation parameter - tmpl2.setUserblock( F3_USERBLOCK_SIZE ); + tmpl2.setUserblock(F3_USERBLOCK_SIZE); // Try to create second file, with non-standard file-creation template // params - H5File file3( FILE3, H5F_ACC_TRUNC, tmpl2 ); + H5File file3(FILE3, H5F_ACC_TRUNC, tmpl2); // Get the file-creation template - tmpl1 = new FileCreatPropList (file3.getCreatePlist()); + tmpl1 = new FileCreatPropList(file3.getCreatePlist()); // Get the file-creation parameters ublock = tmpl1->getUserblock(); - verify_val((long)ublock, (long)F3_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); + verify_val((long)ublock, (long)F3_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, + __FILE__); - tmpl1->getSizes( parm1, parm2); + tmpl1->getSizes(parm1, parm2); verify_val(parm1, F3_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); verify_val(parm2, F3_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - tmpl1->getSymk( iparm1, iparm2); + tmpl1->getSymk(iparm1, iparm2); verify_val(iparm1, F3_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F3_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); @@ -258,15 +258,13 @@ static void test_file_create() PASSED(); } // catch all exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg()); - if (tmpl1 != NULL) // clean up + if (tmpl1 != NULL) // clean up delete tmpl1; } -} // test_file_create() +} // test_file_create() - /*------------------------------------------------------------------------- * Function: test_file_open * @@ -286,7 +284,8 @@ static void test_file_create() * with a special routine. *------------------------------------------------------------------------- */ -static void test_file_open() +static void +test_file_open() { // Output message about test being performed SUBTEST("File Opening I/O"); @@ -294,22 +293,23 @@ static void test_file_open() try { // Open first file - H5File file1 (FILE2, H5F_ACC_RDWR ); + H5File file1(FILE2, H5F_ACC_RDWR); // Get the file-creation template FileCreatPropList tmpl1 = file1.getCreatePlist(); // Get the file-creation parameters hsize_t ublock = tmpl1.getUserblock(); - verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); + verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, + __FILE__); - size_t parm1, parm2; // file-creation parameters - tmpl1.getSizes( parm1, parm2); + size_t parm1, parm2; // file-creation parameters + tmpl1.getSizes(parm1, parm2); verify_val(parm1, F2_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); verify_val(parm2, F2_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - unsigned iparm1,iparm2; // file-creation parameters - tmpl1.getSymk( iparm1, iparm2); + unsigned iparm1, iparm2; // file-creation parameters + tmpl1.getSymk(iparm1, iparm2); verify_val(iparm1, F2_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F2_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); @@ -319,14 +319,15 @@ static void test_file_open() // Try truncating the file, and it should fail because the file is // still opened with file2. - try { - H5File file3 (FILE2, H5F_ACC_TRUNC); // should throw E + try { + H5File file3(FILE2, H5F_ACC_TRUNC); // should throw E // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "Attempt truncating an opened file."); - } - catch (FileIException& E) // catching H5F_ACC_TRUNC on opened file - {} // do nothing, FAIL expected + } + catch (FileIException &E) // catching H5F_ACC_TRUNC on opened file + { + } // do nothing, FAIL expected // Now, really close the file. file2.close(); @@ -340,15 +341,13 @@ static void test_file_open() H5File file4(FILE2, H5F_ACC_TRUNC); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_open()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_file_open() +} // test_file_open() - /*------------------------------------------------------------------------- * Function: test_file_size * @@ -360,12 +359,13 @@ static void test_file_open() * June, 2004 *------------------------------------------------------------------------- */ -static void test_file_size() +static void +test_file_size() { // Output message about test being performed SUBTEST("File Size"); - hid_t fapl_id; + hid_t fapl_id; fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template try { @@ -373,33 +373,34 @@ static void test_file_size() // list object to pass in H5File::H5File FileAccPropList fapl(fapl_id); - // Set to sec2 driver. Do we want to test other file drivers? + // Set to sec2 driver. Do we want to test other file drivers? // They're not tested in C++. // File drivers seem not implemented. // fapl.setSec2(); // Create a file - H5File file4( FILE4, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); + H5File file4(FILE4, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); // Get file size hsize_t file_size = file4.getFileSize(); // Check if file size is reasonable. It's supposed to be 2KB now. - if (file_size < 1*KB || file_size > 4*KB) - issue_fail_msg("test_file_size()", __LINE__, __FILE__, "getFileSize() returned unreasonable value"); + if (file_size < 1 * KB || file_size > 4 * KB) + issue_fail_msg("test_file_size()", __LINE__, __FILE__, + "getFileSize() returned unreasonable value"); // Get the amount of free space in the file hssize_t free_space = file4.getFreeSpace(); // Check if it's reasonable. It's 0 now. - if (free_space < 0 || free_space > 4*KB) - issue_fail_msg("test_file_size()", __LINE__, __FILE__, "getFreeSpace returned unreasonable value"); + if (free_space < 0 || free_space > 4 * KB) + issue_fail_msg("test_file_size()", __LINE__, __FILE__, + "getFreeSpace returned unreasonable value"); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_size()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -408,9 +409,8 @@ static void test_file_size() if (ret < 0) issue_fail_msg("test_file_size()", __LINE__, __FILE__, "H5Pclose failed"); -} // test_file_size() +} // test_file_size() - /*------------------------------------------------------------------------- * Function: test_file_name * @@ -422,14 +422,14 @@ static void test_file_size() * July, 2004 *------------------------------------------------------------------------- */ -const int RANK = 2; -const int NX = 4; -const int NY = 5; -const H5std_string GROUPNAME ("group"); -const H5std_string DSETNAME ("dataset"); -const H5std_string DATTRNAME ("dataset attribute"); -const H5std_string FATTRNAME ("file attribute"); -const H5std_string DTYPENAME ("compound"); +const int RANK = 2; +const int NX = 4; +const int NY = 5; +const H5std_string GROUPNAME("group"); +const H5std_string DSETNAME("dataset"); +const H5std_string DATTRNAME("dataset attribute"); +const H5std_string FATTRNAME("file attribute"); +const H5std_string DTYPENAME("compound"); // Compound datatype typedef struct s1_t { @@ -437,7 +437,8 @@ typedef struct s1_t { float b; } s1_t; -static void test_file_name() +static void +test_file_name() { // Output message about test being performed. SUBTEST("File Name"); @@ -459,11 +460,11 @@ static void test_file_name() verify_val(file_name, FILE4, "Group::getFileName", __LINE__, __FILE__); // Create the data space. - hsize_t dims[RANK] = {NX, NY}; + hsize_t dims[RANK] = {NX, NY}; DataSpace space(RANK, dims); // Create a new dataset. - DataSet dataset(file4.createDataSet (DSETNAME, PredType::NATIVE_INT, space)); + DataSet dataset(file4.createDataSet(DSETNAME, PredType::NATIVE_INT, space)); // Get and verify file name via a dataset. file_name = dataset.getFileName(); @@ -477,7 +478,7 @@ static void test_file_name() verify_val(file_name, FILE4, "Attribute::getFileName", __LINE__, __FILE__); // Create a compound datatype. - CompType comp_type (sizeof(s1_t)); + CompType comp_type(sizeof(s1_t)); // Insert fields. comp_type.insertMember("a", HOFFSET(s1_t, a), PredType::NATIVE_INT); @@ -490,15 +491,13 @@ static void test_file_name() comp_type.getFileName(); verify_val(file_name, FILE4, "CompType::getFileName", __LINE__, __FILE__); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_name()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_file_name() +} // test_file_name() - /*------------------------------------------------------------------------- * * Function: test_file_attribute @@ -508,15 +507,16 @@ static void test_file_name() * Return None *------------------------------------------------------------------------- */ -const int RANK1 = 1; -const int ATTR1_DIM1 = 3; -const H5std_string FILE5("tfattrs.h5"); -const H5std_string FATTR1_NAME ("file attribute 1"); -const H5std_string FATTR2_NAME ("file attribute 2"); -int fattr_data[ATTR1_DIM1]={512,-234,98123}; // Test data for file attribute -int dattr_data[ATTR1_DIM1]={256,-123,1000}; // Test data for dataset attribute - -static void test_file_attribute() +const int RANK1 = 1; +const int ATTR1_DIM1 = 3; +const H5std_string FILE5("tfattrs.h5"); +const H5std_string FATTR1_NAME("file attribute 1"); +const H5std_string FATTR2_NAME("file attribute 2"); +int fattr_data[ATTR1_DIM1] = {512, -234, 98123}; // Test data for file attribute +int dattr_data[ATTR1_DIM1] = {256, -123, 1000}; // Test data for dataset attribute + +static void +test_file_attribute() { int rdata[ATTR1_DIM1]; int i; @@ -530,7 +530,7 @@ static void test_file_attribute() H5File file5(FILE5, H5F_ACC_TRUNC); // Create the data space - hsize_t dims[RANK1] = {ATTR1_DIM1}; + hsize_t dims[RANK1] = {ATTR1_DIM1}; DataSpace space(RANK1, dims); // Create two attributes for the file @@ -543,13 +543,15 @@ static void test_file_attribute() // Try to create the same attribute again (should fail) Attribute fattr_dup(file5.createAttribute(FATTR2_NAME, PredType::NATIVE_INT, space)); // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("H5File createAttribute", "Attempted to create an existing attribute."); + throw InvalidActionException("H5File createAttribute", + "Attempted to create an existing attribute."); } - catch (AttributeIException& E) // catch creating existing attribute - {} // do nothing, FAIL expected + catch (AttributeIException &E) // catch creating existing attribute + { + } // do nothing, FAIL expected // Create a new dataset - DataSet dataset(file5.createDataSet (DSETNAME, PredType::NATIVE_INT, space)); + DataSet dataset(file5.createDataSet(DSETNAME, PredType::NATIVE_INT, space)); // Create an attribute for the dataset Attribute dattr(dataset.createAttribute(DATTRNAME, PredType::NATIVE_INT, space)); @@ -605,20 +607,18 @@ static void test_file_attribute() if (rdata[i] != dattr_data[i]) { H5_FAILED(); cerr << endl; - cerr << "element [" << i << "] is " << rdata[i] << - "but should have been " << dattr_data[i] << endl; - } + cerr << "element [" << i << "] is " << rdata[i] << "but should have been " << dattr_data[i] + << endl; } + } PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_file_attribute() +} // test_file_attribute() - /*------------------------------------------------------------------------- * Function: test_libver_bounds_real * @@ -632,94 +632,92 @@ static void test_file_attribute() * March, 2015 *------------------------------------------------------------------------- */ -const H5std_string FILE6("tfile5.h5"); -const H5std_string ROOTGROUP("/"); -const H5std_string GROUP1("/G1"); -const H5std_string SUBGROUP3("/G1/G3"); - -static void test_libver_bounds_real( - H5F_libver_t libver_create, unsigned oh_vers_create, - H5F_libver_t libver_mod, unsigned oh_vers_mod) +const H5std_string FILE6("tfile5.h5"); +const H5std_string ROOTGROUP("/"); +const H5std_string GROUP1("/G1"); +const H5std_string SUBGROUP3("/G1/G3"); + +static void +test_libver_bounds_real(H5F_libver_t libver_create, unsigned oh_vers_create, H5F_libver_t libver_mod, + unsigned oh_vers_mod) { try { - /* - * Create a new file using the default creation property and access property - * with latest library version. - */ - FileAccPropList fapl; - fapl.setLibverBounds(libver_create, H5F_LIBVER_LATEST); - H5File file(FILE6, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); + /* + * Create a new file using the default creation property and access property + * with latest library version. + */ + FileAccPropList fapl; + fapl.setLibverBounds(libver_create, H5F_LIBVER_LATEST); + H5File file(FILE6, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); - /* - * Make sure the root group has the correct object header version - */ - unsigned obj_version = file.childObjVersion(ROOTGROUP); - verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); - - // Verify object header version another way - H5O_info_t oinfo; - HDmemset(&oinfo, 0, sizeof(oinfo)); - file.getObjinfo(oinfo, H5O_INFO_HDR); - verify_val(oinfo.hdr.version, oh_vers_create, "H5File::getObjinfo", __LINE__, __FILE__); - - /* - * Reopen the file and make sure the root group still has the correct - * version - */ - file.close(); + /* + * Make sure the root group has the correct object header version + */ + unsigned obj_version = file.childObjVersion(ROOTGROUP); + verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); - fapl.setLibverBounds(libver_mod, H5F_LIBVER_LATEST); + // Verify object header version another way + H5O_info_t oinfo; + HDmemset(&oinfo, 0, sizeof(oinfo)); + file.getObjinfo(oinfo, H5O_INFO_HDR); + verify_val(oinfo.hdr.version, oh_vers_create, "H5File::getObjinfo", __LINE__, __FILE__); - file.openFile(FILE6, H5F_ACC_RDWR, fapl); + /* + * Reopen the file and make sure the root group still has the correct + * version + */ + file.close(); - obj_version = file.childObjVersion(ROOTGROUP); - verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); + fapl.setLibverBounds(libver_mod, H5F_LIBVER_LATEST); - /* - * Create a group named "/G1" in the file, and make sure it has the correct - * object header version - */ - Group group = file.createGroup(GROUP1); + file.openFile(FILE6, H5F_ACC_RDWR, fapl); - obj_version = group.objVersion(); - verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__); + obj_version = file.childObjVersion(ROOTGROUP); + verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); - // Verify object header version another way - HDmemset(&oinfo, 0, sizeof(oinfo)); - group.getObjinfo(oinfo, H5O_INFO_HDR); - verify_val(oinfo.hdr.version, oh_vers_mod, "Group::getObjinfo", __LINE__, __FILE__); + /* + * Create a group named "/G1" in the file, and make sure it has the correct + * object header version + */ + Group group = file.createGroup(GROUP1); - group.close(); // close "/G1" + obj_version = group.objVersion(); + verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__); - /* - * Create a group named "/G1/G3" in the file, and make sure it has the - * correct object header version - */ - group = file.createGroup(SUBGROUP3); + // Verify object header version another way + HDmemset(&oinfo, 0, sizeof(oinfo)); + group.getObjinfo(oinfo, H5O_INFO_HDR); + verify_val(oinfo.hdr.version, oh_vers_mod, "Group::getObjinfo", __LINE__, __FILE__); - obj_version = group.objVersion(); - verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__); + group.close(); // close "/G1" - group.close(); // close "/G1/G3" + /* + * Create a group named "/G1/G3" in the file, and make sure it has the + * correct object header version + */ + group = file.createGroup(SUBGROUP3); - /* - * Make sure the root group still has the correct object header version - */ - obj_version = file.childObjVersion(ROOTGROUP); - verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); + obj_version = group.objVersion(); + verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__); + + group.close(); // close "/G1/G3" - // Everything should be closed as they go out of scope - } // end of try block + /* + * Make sure the root group still has the correct object header version + */ + obj_version = file.childObjVersion(ROOTGROUP); + verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); - catch (Exception& E) - { + // Everything should be closed as they go out of scope + } // end of try block + + catch (Exception &E) { issue_fail_msg("test_libver_bounds_real()", __LINE__, __FILE__, E.getCDetailMsg()); } } /* end test_libver_bounds_real() */ - /*------------------------------------------------------------------------- * * Function: test_libver_bounds @@ -733,7 +731,8 @@ static void test_libver_bounds_real( * March 2015 *------------------------------------------------------------------------- */ -static void test_libver_bounds() +static void +test_libver_bounds() { // Output message about test being performed SUBTEST("Setting library version bounds"); @@ -744,7 +743,6 @@ static void test_libver_bounds() PASSED(); } /* end test_libver_bounds() */ - /*------------------------------------------------------------------------- * Function: test_commonfg * @@ -756,7 +754,8 @@ static void test_libver_bounds() * March, 2015 *------------------------------------------------------------------------- */ -static void test_commonfg() +static void +test_commonfg() { // Output message about test being performed SUBTEST("Root group"); @@ -772,11 +771,11 @@ static void test_commonfg() Group group(rootgroup.createGroup(GROUPNAME, 0)); // Create the data space. - hsize_t dims[RANK] = {NX, NY}; + hsize_t dims[RANK] = {NX, NY}; DataSpace space(RANK, dims); // Create a new dataset. - DataSet dataset(group.createDataSet (DSETNAME, PredType::NATIVE_INT, space)); + DataSet dataset(group.createDataSet(DSETNAME, PredType::NATIVE_INT, space)); // Get and verify file name via a dataset. H5std_string file_name = dataset.getFileName(); @@ -797,16 +796,14 @@ static void test_commonfg() verify_val(file_name, FILE4, "Attribute::getFileName", __LINE__, __FILE__); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_commonfg()", __LINE__, __FILE__, E.getCDetailMsg()); } } /* end test_commonfg() */ - /*------------------------------------------------------------------------- * Function: test_file_info * @@ -821,16 +818,17 @@ static void test_commonfg() *------------------------------------------------------------------------- */ const H5std_string FILE7("tfile7.h5"); -const hsize_t FSP_SIZE_DEF = 4096; -const hsize_t FSP_SIZE512 = 512; +const hsize_t FSP_SIZE_DEF = 4096; +const hsize_t FSP_SIZE512 = 512; -static void test_file_info() +static void +test_file_info() { // Output message about test being performed SUBTEST("File general information"); - hsize_t out_threshold = 0; // Free space section threshold to get - hbool_t out_persist = FALSE;// Persist free-space read + hsize_t out_threshold = 0; // Free space section threshold to get + hbool_t out_persist = FALSE; // Persist free-space read // File space handling strategy H5F_fspace_strategy_t out_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; @@ -861,7 +859,8 @@ static void test_file_info() /* Retrieve file space page size */ hsize_t out_fsp_psize = fcpl.getFileSpacePagesize(); - verify_val(out_fsp_psize, FSP_SIZE_DEF, "FileCreatPropList::getFileSpacePagesize", __LINE__, __FILE__); + verify_val(out_fsp_psize, FSP_SIZE_DEF, "FileCreatPropList::getFileSpacePagesize", __LINE__, + __FILE__); // Set various file information. fcpl.setUserblock(F2_USERBLOCK_SIZE); @@ -869,9 +868,9 @@ static void test_file_info() fcpl.setSymk(F2_SYM_INTERN_K, F2_SYM_LEAF_K); fcpl.setIstorek(F2_ISTORE); - hsize_t threshold = 5; // Free space section threshold to set - hbool_t persist = TRUE; // Persist free-space to set - H5F_fspace_strategy_t strategy = H5F_FSPACE_STRATEGY_PAGE; + hsize_t threshold = 5; // Free space section threshold to set + hbool_t persist = TRUE; // Persist free-space to set + H5F_fspace_strategy_t strategy = H5F_FSPACE_STRATEGY_PAGE; fcpl.setFileSpaceStrategy(strategy, persist, threshold); fcpl.setFileSpacePagesize(FSP_SIZE512); @@ -923,10 +922,10 @@ static void test_file_info() unsigned istore_ik = fcpl2.getIstorek(); verify_val(istore_ik, F2_ISTORE, "FileCreatPropList::getIstorek", __LINE__, __FILE__); - /* ret=H5Pget_shared_mesg_nindexes(fcpl2,&nindexes); - CHECK(ret, FAIL, "H5Pget_shared_mesg_nindexes"); - VERIFY(nindexes, MISC11_NINDEXES, "H5Pget_shared_mesg_nindexes"); - */ + /* ret=H5Pget_shared_mesg_nindexes(fcpl2,&nindexes); + CHECK(ret, FAIL, "H5Pget_shared_mesg_nindexes"); + VERIFY(nindexes, MISC11_NINDEXES, "H5Pget_shared_mesg_nindexes"); + */ // Get and verify the file space info from the creation property list */ fcpl2.getFileSpaceStrategy(out_strategy, out_persist, out_threshold); @@ -938,14 +937,12 @@ static void test_file_info() verify_val(out_fsp_psize, FSP_SIZE512, "FileCreatPropList::getFileSpacePagesize", __LINE__, __FILE__); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_filespace_info()", __LINE__, __FILE__, E.getCDetailMsg()); } -} /* test_file_info() */ +} /* test_file_info() */ - /*------------------------------------------------------------------------- * Function: test_file * @@ -957,23 +954,22 @@ static void test_file_info() * January 2001 *------------------------------------------------------------------------- */ -extern "C" -void test_file() +extern "C" void +test_file() { // Output message about test being performed MESSAGE(5, ("Testing File I/O Operations\n")); - test_file_create(); // Test file creation (also creation templates) - test_file_open(); // Test file opening - test_file_size(); // Test file size - test_file_name(); // Test getting file's name - test_file_attribute(); // Test file attribute feature - test_libver_bounds(); // Test format version - test_commonfg(); // Test H5File as a root group - test_file_info(); // Test various file info -} // test_file() - - + test_file_create(); // Test file creation (also creation templates) + test_file_open(); // Test file opening + test_file_size(); // Test file size + test_file_name(); // Test getting file's name + test_file_attribute(); // Test file attribute feature + test_libver_bounds(); // Test format version + test_commonfg(); // Test H5File as a root group + test_file_info(); // Test various file info +} // test_file() + /*------------------------------------------------------------------------- * Function: cleanup_file * @@ -985,7 +981,8 @@ void test_file() #ifdef __cplusplus extern "C" #endif -void cleanup_file() + void + cleanup_file() { HDremove(FILE1.c_str()); HDremove(FILE2.c_str()); @@ -994,4 +991,4 @@ void cleanup_file() HDremove(FILE5.c_str()); HDremove(FILE6.c_str()); HDremove(FILE7.c_str()); -} // cleanup_file +} // cleanup_file diff --git a/c++/test/tfilter.cpp b/c++/test/tfilter.cpp index 5a493ac..e89838c 100644 --- a/c++/test/tfilter.cpp +++ b/c++/test/tfilter.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,23 +16,19 @@ tfilter.cpp - HDF5 C++ testing various filters and their combination. ***************************************************************************/ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file -#define DSET_DIM1 100 -#define DSET_DIM2 200 +#define DSET_DIM1 100 +#define DSET_DIM2 200 #define FILTER_CHUNK_DIM1 2 #define FILTER_CHUNK_DIM2 25 @@ -49,23 +45,20 @@ static herr_t test_filter_internal(hid_t fid, const char *name, hid_t dcpl, /* Temporary filter IDs used for testing */ const int H5Z_FILTER_BOGUS = 305; -#if 0 // H5_ATTR_UNUSED variables caused warning, so duplicated below with NULL instead -static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); -#endif -static size_t filter_bogus(size_t nbytes); +static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf); + /* This message derives from H5Z */ const H5Z_class2_t H5Z_BOGUS[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_BOGUS, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "bogus", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)filter_bogus, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_BOGUS, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "bogus", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + filter_bogus, /* The actual filter function */ }}; - /*------------------------------------------------------------------------- * Function: filter_bogus * @@ -80,17 +73,18 @@ const H5Z_class2_t H5Z_BOGUS[1] = {{ *------------------------------------------------------------------------- */ static size_t -#if 0 // H5_ATTR_UNUSED variables caused warning, so duplicated below with NULL instead -filter_bogus(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) -#endif -filter_bogus(size_t nbytes) +filter_bogus(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) { + (void)flags; + (void)cd_nelmts; + (void)cd_values; + (void)buf_size; + (void)buf; + return nbytes; } - /*------------------------------------------------------------------------- * Function: test_null_filter * @@ -107,25 +101,26 @@ filter_bogus(size_t nbytes) */ const hsize_t chunk_size[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; -static void test_null_filter() +static void +test_null_filter() { // Output message about test being performed SUBTEST("'Null' filter"); try { - //hsize_t null_size; // Size of dataset with null filter + // hsize_t null_size; // Size of dataset with null filter // Prepare dataset create property list DSetCreatPropList dsplist; dsplist.setChunk(2, chunk_size); - if (H5Zregister (H5Z_BOGUS)<0) + if (H5Zregister(H5Z_BOGUS) < 0) throw Exception("test_null_filter", "H5Zregister failed"); // Set some pretent filter dsplist.setFilter(H5Z_FILTER_BOGUS); // this function is just a stub right now; will work on it later - BMR - //if(test_filter_internal(file,DSET_BOGUS_NAME,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&null_size)<0) + // if(test_filter_internal(file,DSET_BOGUS_NAME,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&null_size)<0) // throw Exception("test_null_filter", "test_filter_internal failed"); // Close objects. @@ -134,13 +129,11 @@ static void test_null_filter() } // end of try // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_null_filter()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_null_filter +} // test_null_filter - /*------------------------------------------------------------------------- * Function: test_szip_filter * @@ -157,28 +150,29 @@ static void test_null_filter() */ const H5std_string DSET_SZIP_NAME("szipped dataset"); -static void test_szip_filter(H5File& file1) +static void +test_szip_filter(H5File &file1) { #ifdef H5_HAVE_FILTER_SZIP int points[DSET_DIM1][DSET_DIM2], check[DSET_DIM1][DSET_DIM2]; - unsigned szip_options_mask=H5_SZIP_NN_OPTION_MASK; - unsigned szip_pixels_per_block=4; + unsigned szip_options_mask = H5_SZIP_NN_OPTION_MASK; + unsigned szip_pixels_per_block = 4; // Output message about test being performed SUBTEST("szip filter (with encoder)"); - if ( h5_szip_can_encode() == 1) { - char* tconv_buf = new char [1000]; + if (h5_szip_can_encode() == 1) { + char *tconv_buf = new char[1000]; try { - const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; + const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; // Create the data space DataSpace space1(2, size, NULL); // Create a small conversion buffer to test strip mining (?) DSetMemXferPropList xfer; - xfer.setBuffer (1000, tconv_buf, NULL); + xfer.setBuffer(1000, tconv_buf, NULL); // Prepare dataset create property list DSetCreatPropList dsplist; @@ -188,27 +182,24 @@ static void test_szip_filter(H5File& file1) dsplist.setSzip(szip_options_mask, szip_pixels_per_block); // Create a dataset with szip compression - DataSpace space2 (2, size, NULL); - DataSet dataset(file1.createDataSet (DSET_SZIP_NAME, PredType::NATIVE_INT, space2, dsplist)); + DataSpace space2(2, size, NULL); + DataSet dataset(file1.createDataSet(DSET_SZIP_NAME, PredType::NATIVE_INT, space2, dsplist)); hsize_t i, j, n; - for (i=n=0; i<size[0]; i++) - { - for (j=0; j<size[1]; j++) - { + for (i = n = 0; i < size[0]; i++) { + for (j = 0; j < size[1]; j++) { points[i][j] = (int)n++; } } // Write to the dataset then read back the values - dataset.write ((void*)points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - dataset.read ((void*)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset.write((void *)points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset.read((void *)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); + for (j = 0; j < size[1]; j++) { + int status = check_values(i, j, points[i][j], check[i][j]); if (status == -1) throw Exception("test_szip_filter", "Failed in testing szip method"); } @@ -217,8 +208,7 @@ static void test_szip_filter(H5File& file1) } // end of try // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_szip_filter()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -228,15 +218,14 @@ static void test_szip_filter(H5File& file1) SKIPPED(); } -#else /* H5_HAVE_FILTER_SZIP */ +#else /* H5_HAVE_FILTER_SZIP */ SUBTEST("szip filter"); SKIPPED(); H5std_string fname = file1.getFileName(); cerr << " Szip filter not enabled for file '" << fname << "'" << endl; #endif /* H5_HAVE_FILTER_SZIP */ -} // test_szip_filter +} // test_szip_filter - /*------------------------------------------------------------------------- * Function: test_filters * @@ -245,18 +234,17 @@ static void test_szip_filter(H5File& file1) * Return None *------------------------------------------------------------------------- */ -const H5std_string FILE1("tfilters.h5"); -extern "C" -void test_filters() +const H5std_string FILE1("tfilters.h5"); +extern "C" void +test_filters() { // Output message about test being performed MESSAGE(5, ("Testing Various Filters\n")); - hid_t fapl_id; + hid_t fapl_id; fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template - try - { + try { // Use the file access template id to create a file access prop. list FileAccPropList fapl(fapl_id); @@ -266,13 +254,11 @@ void test_filters() test_null_filter(); test_szip_filter(file1); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_filters()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_filters() +} // test_filters() - /*------------------------------------------------------------------------- * Function: cleanup_filters * @@ -281,8 +267,8 @@ void test_filters() * Return none *------------------------------------------------------------------------- */ -extern "C" -void cleanup_filters() +extern "C" void +cleanup_filters() { HDremove(FILE1.c_str()); } diff --git a/c++/test/th5s.cpp b/c++/test/th5s.cpp index d4853da..9952e68 100644 --- a/c++/test/th5s.cpp +++ b/c++/test/th5s.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -19,48 +19,44 @@ EXTERNAL ROUTINES/VARIABLES: ***************************************************************************/ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file -#include "H5srcdir.h" // srcdir querying header file +#include "h5cpputil.h" // C++ utilility header file +#include "H5srcdir.h" // srcdir querying header file -const H5std_string TESTFILE("th5s.h5"); -const H5std_string DATAFILE("th5s1.h5"); +const H5std_string TESTFILE("th5s.h5"); +const H5std_string DATAFILE("th5s1.h5"); /* 3-D dataset with fixed dimensions */ const H5std_string SPACE1_NAME("Space1"); -const int SPACE1_RANK = 3; -const int SPACE1_DIM1 = 3; -const int SPACE1_DIM2 = 15; -const int SPACE1_DIM3 = 13; +const int SPACE1_RANK = 3; +const int SPACE1_DIM1 = 3; +const int SPACE1_DIM2 = 15; +const int SPACE1_DIM3 = 13; /* 4-D dataset with one unlimited dimension */ const H5std_string SPACE2_NAME("Space2"); -const int SPACE2_RANK = 4; -const int SPACE2_DIM1 = 0; -const int SPACE2_DIM2 = 15; -const int SPACE2_DIM3 = 13; -const int SPACE2_DIM4 = 23; -const hsize_t SPACE2_MAX1 = H5S_UNLIMITED; -const hsize_t SPACE2_MAX2 = 15; -const hsize_t SPACE2_MAX3 = 13; -const hsize_t SPACE2_MAX4 = 23; +const int SPACE2_RANK = 4; +const int SPACE2_DIM1 = 0; +const int SPACE2_DIM2 = 15; +const int SPACE2_DIM3 = 13; +const int SPACE2_DIM4 = 23; +const hsize_t SPACE2_MAX1 = H5S_UNLIMITED; +const hsize_t SPACE2_MAX2 = 15; +const hsize_t SPACE2_MAX3 = 13; +const hsize_t SPACE2_MAX4 = 23; /* Scalar dataset with simple datatype */ const H5std_string SPACE3_NAME("Scalar1"); -const int SPACE3_RANK = 0; -unsigned space3_data=65; +const int SPACE3_RANK = 0; +unsigned space3_data = 65; /* Scalar dataset with compound datatype */ const H5std_string SPACE4_NAME("Scalar2"); @@ -68,21 +64,20 @@ const H5std_string SPACE4_FIELDNAME1("c1"); const H5std_string SPACE4_FIELDNAME2("u"); const H5std_string SPACE4_FIELDNAME3("f"); const H5std_string SPACE4_FIELDNAME4("c2"); -size_t space4_field1_off=0; -size_t space4_field2_off=0; -size_t space4_field3_off=0; -size_t space4_field4_off=0; +size_t space4_field1_off = 0; +size_t space4_field2_off = 0; +size_t space4_field3_off = 0; +size_t space4_field4_off = 0; struct space4_struct { - char c1; + char c1; unsigned u; - float f; - char c2; - } space4_data={'v',987123,(float)-3.14,'g'}; /* Test data for 4th dataspace */ + float f; + char c2; +} space4_data = {'v', 987123, (float)-3.14, 'g'}; /* Test data for 4th dataspace */ /* Null dataspace */ int space5_data = 7; - /*------------------------------------------------------------------------- * Function: test_h5s_basic * @@ -105,11 +100,12 @@ int space5_data = 7; * size to be zero. So I took out the test against it. *------------------------------------------------------------------------- */ -static void test_h5s_basic() +static void +test_h5s_basic() { hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2, SPACE2_DIM3, SPACE2_DIM4}; - hsize_t dims3[H5S_MAX_RANK+1]; + hsize_t dims3[H5S_MAX_RANK + 1]; hsize_t tmax[4]; // Output message about test being performed @@ -117,13 +113,13 @@ static void test_h5s_basic() try { // Create simple dataspace sid1 - DataSpace sid1 (SPACE1_RANK, dims1 ); + DataSpace sid1(SPACE1_RANK, dims1); // Get simple extent npoints of the dataspace sid1 and verify it hssize_t n; // Number of dataspace elements n = sid1.getSimpleExtentNpoints(); verify_val((long)n, (long)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3), - "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Get the logical rank of dataspace sid1 and verify it int rank; // Logical rank of dataspace @@ -131,21 +127,21 @@ static void test_h5s_basic() verify_val(rank, SPACE1_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); // Retrieves dimension size of dataspace sid1 and verify it - int ndims; // Number of dimensions + int ndims; // Number of dimensions hsize_t tdims[4]; // Dimension array to test with - ndims = sid1.getSimpleExtentDims( tdims ); + ndims = sid1.getSimpleExtentDims(tdims); verify_val(ndims, SPACE1_RANK, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); verify_val(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(unsigned)), 0, - "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); // Create simple dataspace sid2 - hsize_t max2[] = {SPACE2_MAX1, SPACE2_MAX2, SPACE2_MAX3, SPACE2_MAX4}; - DataSpace sid2 (SPACE2_RANK, dims2, max2); + hsize_t max2[] = {SPACE2_MAX1, SPACE2_MAX2, SPACE2_MAX3, SPACE2_MAX4}; + DataSpace sid2(SPACE2_RANK, dims2, max2); // Get simple extent npoints of dataspace sid2 and verify it n = sid2.getSimpleExtentNpoints(); verify_val((long)n, (long)(SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4), - "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Get the logical rank of dataspace sid2 and verify it rank = sid2.getSimpleExtentNdims(); @@ -153,34 +149,36 @@ static void test_h5s_basic() // Retrieves dimension size and max size of dataspace sid2 and // verify them - ndims = sid2.getSimpleExtentDims( tdims, tmax ); + ndims = sid2.getSimpleExtentDims(tdims, tmax); verify_val(HDmemcmp(tdims, dims2, SPACE2_RANK * sizeof(unsigned)), 0, - "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); - verify_val(HDmemcmp(tmax, max2, SPACE2_RANK * sizeof(unsigned)), 0, - "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + verify_val(HDmemcmp(tmax, max2, SPACE2_RANK * sizeof(unsigned)), 0, "DataSpace::getSimpleExtentDims", + __LINE__, __FILE__); // Check to be sure we can't create a simple data space that has too // many dimensions. try { - DataSpace manydims_ds(H5S_MAX_RANK+1, dims3, NULL); + DataSpace manydims_ds(H5S_MAX_RANK + 1, dims3, NULL); // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("DataSpace constructor", "Library allowed overwrite of existing dataset"); + throw InvalidActionException("DataSpace constructor", + "Library allowed overwrite of existing dataset"); } - catch (DataSpaceIException& E) // Simple data space with too many dims - {} // do nothing, exception expected - - /* - * Try reading a file that has been prepared that has a dataset with a - * higher dimensionality than what the library can handle. - * - * 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. - */ - char *tmp_str = new char[TESTFILE.length()+1]; + catch (DataSpaceIException &E) // Simple data space with too many dims + { + } // do nothing, exception expected + + /* + * Try reading a file that has been prepared that has a dataset with a + * higher dimensionality than what the library can handle. + * + * 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. + */ + 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; + delete[] tmp_str; // Create file H5File fid1(testfile, H5F_ACC_RDONLY); @@ -188,33 +186,33 @@ static void test_h5s_basic() // Try to open the dataset that has higher dimensionality than // what the library can handle and this operation should fail. try { - DataSet dset1 = fid1.openDataSet( "dset" ); + DataSet dset1 = fid1.openDataSet("dset"); // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("H5File::openDataSet", "Opening a dataset with higher dimensionality than what the library can handle"); + throw InvalidActionException( + "H5File::openDataSet", + "Opening a dataset with higher dimensionality than what the library can handle"); } - catch (FileIException& E) // catching higher dimensionality dataset - {} // do nothing, exception expected + catch (FileIException &E) // catching higher dimensionality dataset + { + } // do nothing, exception expected - // CHECK_I(ret, "H5Fclose"); // leave this here, later, fake a failure - // in the p_close see how this will handle it. - BMR + // CHECK_I(ret, "H5Fclose"); // leave this here, later, fake a failure + // in the p_close see how this will handle it. - BMR PASSED(); - } // end of try block + } // end of try block - catch (InvalidActionException& E) - { + catch (InvalidActionException &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; } // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_h5s_basic()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_h5s_basic() +} // test_h5s_basic() - /*------------------------------------------------------------------------- * Function: test_h5s_scalar_write * @@ -234,7 +232,8 @@ static void test_h5s_basic() * with a special routine. *------------------------------------------------------------------------- */ -static void test_h5s_scalar_write() +static void +test_h5s_scalar_write() { // Output message about test being performed SUBTEST("Scalar Dataspace Writing"); @@ -246,7 +245,7 @@ static void test_h5s_scalar_write() // Create scalar dataspace DataSpace sid1(SPACE3_RANK, NULL); - //n = H5Sget_simple_extent_npoints(sid1); + // n = H5Sget_simple_extent_npoints(sid1); hssize_t n; // Number of dataspace elements n = sid1.getSimpleExtentNpoints(); verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); @@ -256,9 +255,9 @@ static void test_h5s_scalar_write() verify_val(rank, SPACE3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); // Retrieves dimension size of dataspace sid1 and verify it - int ndims; // Number of dimensions + int ndims; // Number of dimensions hsize_t tdims[4]; // Dimension array to test with - ndims = sid1.getSimpleExtentDims( tdims ); + ndims = sid1.getSimpleExtentDims(tdims); verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); // Verify extent type @@ -267,18 +266,16 @@ static void test_h5s_scalar_write() verify_val(ext_type, H5S_SCALAR, "DataSpace::getSimpleExtentType", __LINE__, __FILE__); // Create and write a dataset - DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT,sid1); + DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT, sid1); dataset.write(&space3_data, PredType::NATIVE_UINT); PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_h5s_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_h5s_scalar_write() +} // test_h5s_scalar_write() - /*------------------------------------------------------------------------- * Function: test_h5s_scalar_read * @@ -298,7 +295,8 @@ static void test_h5s_scalar_write() * with a special routine. *------------------------------------------------------------------------- */ -static void test_h5s_scalar_read() +static void +test_h5s_scalar_read() { hsize_t tdims[4]; // Dimension array to test with @@ -331,16 +329,14 @@ static void test_h5s_scalar_read() verify_val(rdata, space3_data, "DataSet::read", __LINE__, __FILE__); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { // all the exceptions caused by negative returned values by C APIs issue_fail_msg("test_h5s_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_h5s_scalar_read() +} // test_h5s_scalar_read() - /*------------------------------------------------------------------------- * Function: test_h5s_null * @@ -360,7 +356,8 @@ static void test_h5s_scalar_read() * with a special routine. *------------------------------------------------------------------------- */ -static void test_h5s_null() +static void +test_h5s_null() { // Output message about test being performed SUBTEST("Null Dataspace Writing"); @@ -377,7 +374,7 @@ static void test_h5s_null() verify_val((long)n, 0, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Create a dataset - DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT,sid1); + DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT, sid1); // Try to write nothing to the dataset dataset.write(&space5_data, PredType::NATIVE_INT); @@ -388,13 +385,11 @@ static void test_h5s_null() PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_h5s_null()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_h5s_null() +} // test_h5s_null() - /*------------------------------------------------------------------------- * Function: test_h5s_compound_scalar_write * @@ -415,7 +410,8 @@ static void test_h5s_null() * with a special routine. *------------------------------------------------------------------------- */ -static void test_h5s_compound_scalar_write() +static void +test_h5s_compound_scalar_write() { // Output message about test being performed SUBTEST("Compound Dataspace Writing"); @@ -426,18 +422,14 @@ static void test_h5s_compound_scalar_write() // Create the compound datatype. CompType tid1(sizeof(struct space4_struct)); - space4_field1_off=HOFFSET(struct space4_struct, c1); - tid1.insertMember(SPACE4_FIELDNAME1, space4_field1_off, - PredType::NATIVE_SCHAR); - space4_field2_off=HOFFSET(struct space4_struct, u); - tid1.insertMember(SPACE4_FIELDNAME2, space4_field2_off, - PredType::NATIVE_UINT); - space4_field3_off=HOFFSET(struct space4_struct, f); - tid1.insertMember(SPACE4_FIELDNAME3, space4_field3_off, - PredType::NATIVE_FLOAT); - space4_field4_off=HOFFSET(struct space4_struct, c2); - tid1.insertMember(SPACE4_FIELDNAME4, space4_field4_off, - PredType::NATIVE_SCHAR); + space4_field1_off = HOFFSET(struct space4_struct, c1); + tid1.insertMember(SPACE4_FIELDNAME1, space4_field1_off, PredType::NATIVE_SCHAR); + space4_field2_off = HOFFSET(struct space4_struct, u); + tid1.insertMember(SPACE4_FIELDNAME2, space4_field2_off, PredType::NATIVE_UINT); + space4_field3_off = HOFFSET(struct space4_struct, f); + tid1.insertMember(SPACE4_FIELDNAME3, space4_field3_off, PredType::NATIVE_FLOAT); + space4_field4_off = HOFFSET(struct space4_struct, c2); + tid1.insertMember(SPACE4_FIELDNAME4, space4_field4_off, PredType::NATIVE_SCHAR); // Create scalar dataspace DataSpace sid1(SPACE3_RANK, NULL); @@ -459,15 +451,13 @@ static void test_h5s_compound_scalar_write() dataset.write(&space4_data, tid1); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { // all the exceptions caused by negative returned values by C APIs issue_fail_msg("test_h5s_compound_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_h5s_compound_scalar_write() +} // test_h5s_compound_scalar_write() - /*------------------------------------------------------------------------- * Function: test_h5s_compound_scalar_read * @@ -488,7 +478,8 @@ static void test_h5s_compound_scalar_write() * with a special routine. *------------------------------------------------------------------------- */ -static void test_h5s_compound_scalar_read() +static void +test_h5s_compound_scalar_read() { hsize_t tdims[4]; // Dimension array to test with @@ -521,27 +512,24 @@ static void test_h5s_compound_scalar_read() dataset.read(&rdata, type); // Verify read data - if(HDmemcmp(&space4_data,&rdata,sizeof(struct space4_struct))) - { - cerr << "scalar data different: space4_data.c1=" - << space4_data.c1 << ", read_data4.c1=" << rdata.c1 << endl; - cerr << "scalar data different: space4_data.u=" - << space4_data.u << ", read_data4.u=" << rdata.u << endl; - cerr << "scalar data different: space4_data.f=" - << space4_data.f << ", read_data4.f=" << rdata.f << endl; - TestErrPrintf("scalar data different: space4_data.c1=%c, read_data4.c1=%c\n", - space4_data.c1, rdata.c2); + if (HDmemcmp(&space4_data, &rdata, sizeof(struct space4_struct)) != 0) { + cerr << "scalar data different: space4_data.c1=" << space4_data.c1 + << ", read_data4.c1=" << rdata.c1 << endl; + cerr << "scalar data different: space4_data.u=" << space4_data.u << ", read_data4.u=" << rdata.u + << endl; + cerr << "scalar data different: space4_data.f=" << space4_data.f << ", read_data4.f=" << rdata.f + << endl; + TestErrPrintf("scalar data different: space4_data.c1=%c, read_data4.c1=%c\n", space4_data.c1, + rdata.c2); } // end if PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { // all the exceptions caused by negative returned values by C APIs issue_fail_msg("test_h5s_compound_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_h5s_compound_scalar_read() +} // test_h5s_compound_scalar_read() - /*------------------------------------------------------------------------- * Function: test_h5s * @@ -553,21 +541,20 @@ static void test_h5s_compound_scalar_read() * Mar 2001 *------------------------------------------------------------------------- */ -extern "C" -void test_h5s() +extern "C" void +test_h5s() { // Output message about test being performed MESSAGE(5, ("Testing Dataspaces\n")); - test_h5s_basic(); // Test basic H5S code - test_h5s_scalar_write(); // Test scalar H5S writing code - test_h5s_scalar_read(); // Test scalar H5S reading code - test_h5s_null(); // Test null H5S code - test_h5s_compound_scalar_write(); // Test compound datatype scalar H5S writing code - test_h5s_compound_scalar_read(); // Test compound datatype scalar H5S reading code -} // test_h5s() + test_h5s_basic(); // Test basic H5S code + test_h5s_scalar_write(); // Test scalar H5S writing code + test_h5s_scalar_read(); // Test scalar H5S reading code + test_h5s_null(); // Test null H5S code + test_h5s_compound_scalar_write(); // Test compound datatype scalar H5S writing code + test_h5s_compound_scalar_read(); // Test compound datatype scalar H5S reading code +} // test_h5s() - /*------------------------------------------------------------------------- * Function: cleanup_h5s * @@ -576,9 +563,8 @@ void test_h5s() * Return None *------------------------------------------------------------------------- */ -extern "C" -void cleanup_h5s() +extern "C" void +cleanup_h5s() { HDremove(DATAFILE.c_str()); -} // cleanup_h5s - +} // cleanup_h5s diff --git a/c++/test/titerate.cpp b/c++/test/titerate.cpp index 616dc00..97de3a8 100644 --- a/c++/test/titerate.cpp +++ b/c++/test/titerate.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,20 +16,16 @@ titerate.cpp - HDF5 C++ testing iterate related functionality ***************************************************************************/ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file /* Number of datasets for group iteration test */ #define NDATASETS 50 @@ -41,53 +37,48 @@ using namespace H5; //#define ITER_NGROUPS 150 /* General maximum length of names used */ -#define NAMELEN 80 +#define NAMELEN 80 /* 1-D dataset with fixed dimensions */ //#define SPACE1_RANK 1 //#define SPACE1_DIM1 4 -const H5std_string FILE_ITERATE("titerate.h5"); -const H5std_string GROUP1("Top Group"); -const H5std_string GROUP1_PATH("/Top Group"); -const H5std_string GROUP1_1("Sub-Group 1.1"); -const H5std_string GROUP1_1_PATH("/Top Group/Sub-Group 1.1"); -const H5std_string GROUP1_2("Sub-Group 1.2"); -const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2"); -const H5std_string DSET_DEFAULT_NAME("default"); -const H5std_string DSET_IN_FILE("Dataset in File"); -const H5std_string DSET_IN_FILE_PATH("/Dataset in File"); -const H5std_string DSET_IN_GRP1("Dataset in Group 1"); -const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset in Group 1"); -const H5std_string DSET_IN_GRP1_2("Dataset in Group 1.2"); -const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset in Group 1.2"); - -typedef enum { - RET_ZERO, - RET_TWO, - RET_CHANGE, - RET_CHANGE2 -} iter_enum; +const H5std_string FILE_ITERATE("titerate.h5"); +const H5std_string GROUP1("Top Group"); +const H5std_string GROUP1_PATH("/Top Group"); +const H5std_string GROUP1_1("Sub-Group 1.1"); +const H5std_string GROUP1_1_PATH("/Top Group/Sub-Group 1.1"); +const H5std_string GROUP1_2("Sub-Group 1.2"); +const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2"); +const H5std_string DSET_DEFAULT_NAME("default"); +const H5std_string DSET_IN_FILE("Dataset in File"); +const H5std_string DSET_IN_FILE_PATH("/Dataset in File"); +const H5std_string DSET_IN_GRP1("Dataset in Group 1"); +const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset in Group 1"); +const H5std_string DSET_IN_GRP1_2("Dataset in Group 1.2"); +const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset in Group 1.2"); + +typedef enum { RET_ZERO, RET_TWO, RET_CHANGE, RET_CHANGE2 } iter_enum; /* Custom group iteration callback data */ typedef struct { - char name[NAMELEN]; /* The name of the object */ - H5O_type_t type; /* The type of the object */ - iter_enum command; /* The type of return value */ + char name[NAMELEN]; /* The name of the object */ + H5O_type_t type; /* The type of the object */ + iter_enum command; /* The type of return value */ } iter_info; int iter_strcmp(const void *s1, const void *s2); - /*------------------------------------------------------------------------- * Function: iter_strcmp * * Purpose String comparison routine for qsort *------------------------------------------------------------------------- */ -int iter_strcmp(const void *s1, const void *s2) +int +iter_strcmp(const void *s1, const void *s2) { - return(HDstrcmp(*(const char * const *)s1,*(const char * const *)s2)); + return (HDstrcmp(*(const char *const *)s1, *(const char *const *)s2)); } /*------------------------------------------------------------------------- @@ -96,36 +87,37 @@ int iter_strcmp(const void *s1, const void *s2) * Purpose Custom link iteration callback routine *------------------------------------------------------------------------- */ -static herr_t liter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t H5_ATTR_UNUSED *link_info, void *op_data) +static herr_t +liter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t H5_ATTR_UNUSED *link_info, + void *op_data) { - iter_info *info = (iter_info *)op_data; - static int count = 0; + iter_info *info = (iter_info *)op_data; + static int count = 0; static int count2 = 0; HDstrcpy(info->name, name); - switch(info->command) { + switch (info->command) { case RET_ZERO: - return(0); + return (0); case RET_TWO: - return(2); + return (2); case RET_CHANGE: count++; - return(count > 10 ? 1 : 0); + return (count > 10 ? 1 : 0); case RET_CHANGE2: count2++; - return(count2 > 10 ? 1 : 0); + return (count2 > 10 ? 1 : 0); default: printf("invalid iteration command"); - return(-1); + return (-1); } /* end switch */ } /* end liter_cb() */ - /*------------------------------------------------------------------------- * Function: test_iter_group * @@ -138,14 +130,15 @@ static herr_t liter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_i * Friday, September 9, 2016 *------------------------------------------------------------------------- */ -static void test_iter_group(FileAccPropList& fapl) +static void +test_iter_group(FileAccPropList &fapl) { - int i; /* counting variable */ - hsize_t idx; /* Index in the group */ - char name[NAMELEN]; /* temporary name buffer */ - char *lnames[NDATASETS + 2];/* Names of the links created */ - iter_info info; /* Custom iteration information */ - herr_t ret; /* Generic return value */ + int i; /* counting variable */ + hsize_t idx; /* Index in the group */ + char name[NAMELEN]; /* temporary name buffer */ + char * lnames[NDATASETS + 2]; /* Names of the links created */ + iter_info info; /* Custom iteration information */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ SUBTEST("Group Iteration"); @@ -157,8 +150,8 @@ static void test_iter_group(FileAccPropList& fapl) /* Test iterating over empty group */ info.command = RET_ZERO; - idx = 0; - ret = H5Literate(file.getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info); + idx = 0; + ret = H5Literate(file.getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info); verify_val(ret, SUCCEED, "H5Literate", __LINE__, __FILE__); DataType datatype(PredType::NATIVE_INT); @@ -166,16 +159,15 @@ static void test_iter_group(FileAccPropList& fapl) // Create a scalar file space DataSpace filespace; - for (i=0; i< NDATASETS; i++) - { - sprintf(name, "Dataset %d", i); + for (i = 0; i < NDATASETS; i++) { + sprintf(name, "Dataset %d", i); - // Create a dataset in the file - DataSet dataset = file.createDataSet(name, datatype, filespace); + // Create a dataset in the file + DataSet dataset = file.createDataSet(name, datatype, filespace); - /* Keep a copy of the dataset names */ - lnames[i] = HDstrdup(name); - check_values(lnames[i], "HDstrdup returns NULL", __LINE__, __FILE__); + /* Keep a copy of the dataset names */ + lnames[i] = HDstrdup(name); + check_values(lnames[i], "HDstrdup returns NULL", __LINE__, __FILE__); } /* end for */ @@ -191,7 +183,6 @@ static void test_iter_group(FileAccPropList& fapl) /* Sort the dataset names */ HDqsort(lnames, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp); - /* Iterate through the datasets in the root group in various ways */ // Open data file to read @@ -205,15 +196,16 @@ static void test_iter_group(FileAccPropList& fapl) verify_val(nobjs, (hsize_t)(NDATASETS + 2), "H5Gget_info", __LINE__, __FILE__); H5std_string obj_name; - for (i = 0; i < nobjs; i++) - { - //H5O_info_t oinfo; /* Object info */ + for (i = 0; i < nobjs; i++) { + // H5O_info_t oinfo; /* Object info */ obj_name = root_group.getObjnameByIdx(i); - //ret = (herr_t)H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, dataset_name, (size_t)NAMELEN, H5P_DEFAULT); + // ret = (herr_t)H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, + // dataset_name, (size_t)NAMELEN, H5P_DEFAULT); - //oinfo = root_group.childObjType((hsize_t)i, H5_INDEX_NAME, H5_ITER_INC, "."); - //ret = H5Oget_info_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5P_DEFAULT); + // oinfo = root_group.childObjType((hsize_t)i, H5_INDEX_NAME, H5_ITER_INC, "."); + // ret = H5Oget_info_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, + // H5P_DEFAULT); } /* end for */ // Attempted to iterate with invalid index, should fail @@ -223,63 +215,69 @@ static void test_iter_group(FileAccPropList& fapl) // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with invalid index"); } - catch (GroupIException& invalid_action) // invalid index - {} // do nothing, exception expected + catch (GroupIException &invalid_action) // invalid index + { + } // do nothing, exception expected // Attempted to iterate with negative index, should fail try { info.command = RET_ZERO; - idx = (hsize_t)-1; - obj_name = root_group.getObjnameByIdx(idx); + idx = (hsize_t)-1; + obj_name = root_group.getObjnameByIdx(idx); // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with negative index"); } - catch (FileIException& invalid_action) // invalid index - {} // do nothing, exception expected - catch (GroupIException& invalid_action) // invalid index - {} // do nothing, exception expected + catch (FileIException &invalid_action) // invalid index + { + } // do nothing, exception expected + catch (GroupIException &invalid_action) // invalid index + { + } // do nothing, exception expected /* Test skipping exactly as many entries as in the group */ try { info.command = RET_ZERO; - idx = NDATASETS + 2; - obj_name = root_group.getObjnameByIdx(idx); + idx = NDATASETS + 2; + obj_name = root_group.getObjnameByIdx(idx); // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with negative index"); } - catch (FileIException& invalid_action) // invalid index - {} // do nothing, exception expected - catch (GroupIException& invalid_action) // invalid index - {} // do nothing, exception expected + catch (FileIException &invalid_action) // invalid index + { + } // do nothing, exception expected + catch (GroupIException &invalid_action) // invalid index + { + } // do nothing, exception expected /* Test skipping more entries than are in the group */ try { info.command = RET_ZERO; - idx = NDATASETS + 3; - obj_name = root_group.getObjnameByIdx(idx); + idx = NDATASETS + 3; + obj_name = root_group.getObjnameByIdx(idx); // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("Group::getObjnameByIdx", "Attempt to iterate with negative index"); } - catch (FileIException& invalid_action) // invalid index - {} // do nothing, exception expected - catch (GroupIException& invalid_action) // invalid index - {} // do nothing, exception expected + catch (FileIException &invalid_action) // invalid index + { + } // do nothing, exception expected + catch (GroupIException &invalid_action) // invalid index + { + } // do nothing, exception expected /* Free the dataset names */ - for(i = 0; i< (NDATASETS + 2); i++) + for (i = 0; i < (NDATASETS + 2); i++) HDfree(lnames[i]); // Everything will be closed as they go out of scope PASSED(); - } // try block + } // try block // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_iter_group", __LINE__, __FILE__); } @@ -348,7 +346,6 @@ static void test_iter_group(FileAccPropList& fapl) #endif } /* test_iter_group() */ - /*------------------------------------------------------------------------- * Function: printelems * @@ -362,31 +359,29 @@ const H5std_string GDATASET_NAME("group dset"); const H5std_string ATTR_NAME("Units"); const H5std_string FATTR_NAME("F attr"); const H5std_string GATTR_NAME("G attr"); -const int DIM1 = 2; -void printelems(const Group& group, const H5std_string& dsname, const H5std_string& atname) +const int DIM1 = 2; +void +printelems(const Group &group, const H5std_string &dsname, const H5std_string &atname) { - try - { - DataSet d1(group.openDataSet(dsname)); + try { + DataSet d1(group.openDataSet(dsname)); DataSpace s1 = d1.getSpace(); s1.close(); d1.close(); - unsigned idx = 0; - Attribute a1(group.openAttribute(idx)); + unsigned idx = 0; + Attribute a1(group.openAttribute(idx)); H5std_string aname = a1.getName(); verify_val(aname, atname, "printelems", __LINE__, __FILE__); a1.close(); - } + } // Catch all exceptions and rethrow so caller can handle - catch (Exception& E) - { + catch (Exception &E) { throw; } } - /*------------------------------------------------------------------------- * Function: test_HDFFV_9920 * @@ -396,33 +391,31 @@ void printelems(const Group& group, const H5std_string& dsname, const H5std_stri * Friday, September 9, 2016 *------------------------------------------------------------------------- */ -static void test_HDFFV_9920() +static void +test_HDFFV_9920() { - int attr_data[2] = { 100, 200}; - hsize_t dims[1] = { DIM1 }; + int attr_data[2] = {100, 200}; + hsize_t dims[1] = {DIM1}; - try - { + try { // Create a new file and a group in it - H5File file( FILE_NAME, H5F_ACC_TRUNC ); + H5File file(FILE_NAME, H5F_ACC_TRUNC); Group gr1(file.createGroup(GRP_NAME)); // Create the data space for the attribute. - DataSpace dspace = DataSpace (1, dims ); + DataSpace dspace = DataSpace(1, dims); DataSet fds = file.createDataSet(FDATASET_NAME, PredType::STD_I32BE, dspace); DataSet gds = gr1.createDataSet(GDATASET_NAME, PredType::STD_I32BE, dspace); // Create a file attribute and a group attribute. - Attribute fa1 = file.createAttribute(FATTR_NAME, PredType::STD_I32BE, - dspace); - Attribute ga1 = gr1.createAttribute(GATTR_NAME, PredType::STD_I32BE, - dspace); + Attribute fa1 = file.createAttribute(FATTR_NAME, PredType::STD_I32BE, dspace); + Attribute ga1 = gr1.createAttribute(GATTR_NAME, PredType::STD_I32BE, dspace); // Write the attribute data. - fa1.write( PredType::NATIVE_INT, attr_data); - ga1.write( PredType::NATIVE_INT, attr_data); + fa1.write(PredType::NATIVE_INT, attr_data); + ga1.write(PredType::NATIVE_INT, attr_data); fa1.close(); ga1.close(); @@ -433,16 +426,14 @@ static void test_HDFFV_9920() printelems(file, FDATASET_NAME, FATTR_NAME); printelems(gr1, GDATASET_NAME, GATTR_NAME); - } // end of try block + } // end of try block // Catch all failures for handling in the same way - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_HDFFV_9920()", __LINE__, __FILE__, E.getCDetailMsg()); } } - /*------------------------------------------------------------------------- * Function: test_iterate * @@ -455,8 +446,8 @@ static void test_HDFFV_9920() * Tuesday, September 6, 2016 *------------------------------------------------------------------------- */ -extern "C" -void test_iterate() +extern "C" void +test_iterate() { // Output message about test being performed MESSAGE(5, ("Testing Iterate Feature\n")); @@ -465,13 +456,12 @@ void test_iterate() FileAccPropList fapl; fapl.setLibverBounds(H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); - test_iter_group(fapl); // Test iterating groups - test_HDFFV_9920(); // Test the fix of HDFFV-9920 - //test_iter_attr(fapl); // Test iterating attributes + test_iter_group(fapl); // Test iterating groups + test_HDFFV_9920(); // Test the fix of HDFFV-9920 + // test_iter_attr(fapl); // Test iterating attributes -} // test_iterate +} // test_iterate - /*------------------------------------------------------------------------- * Function: cleanup_iterate * @@ -480,8 +470,8 @@ void test_iterate() * Return none *------------------------------------------------------------------------- */ -extern "C" -void cleanup_iterate() +extern "C" void +cleanup_iterate() { HDremove(FILE_ITERATE.c_str()); } // cleanup_iterate diff --git a/c++/test/tlinks.cpp b/c++/test/tlinks.cpp index 491cd6a..a66741c 100644 --- a/c++/test/tlinks.cpp +++ b/c++/test/tlinks.cpp @@ -5,7 +5,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,46 +16,35 @@ C link interface (H5L) ***************************************************************************/ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file -#define NAME_BUF_SIZE 1024 -#define H5L_DIM1 100 -#define H5L_DIM2 100 +#define NAME_BUF_SIZE 1024 +#define H5L_DIM1 100 +#define H5L_DIM2 100 // Object visit structs typedef struct { - const char *path; /* Path to object */ - H5O_type_t type; /* Type of object */ + const char *path; /* Path to object */ + H5O_type_t type; /* Type of object */ } obj_visit_t; // User data for callback function typedef struct { - unsigned idx; /* Index in object visit structure */ - const obj_visit_t *info; /* Pointer to the object visit structure to use */ + unsigned idx; /* Index in object visit structure */ + const obj_visit_t *info; /* Pointer to the object visit structure to use */ } ovisit_ud_t; -static const char *FILENAME[] = { - "link0", - "link1.h5", - "link2.h5", - "visit", - NULL -}; +static const char *FILENAME[] = {"link0", "link1.h5", "link2.h5", "visit", NULL}; - /*------------------------------------------------------------------------- * Function: test_basic_links * @@ -67,17 +56,17 @@ static const char *FILENAME[] = { * October 16, 2009 *------------------------------------------------------------------------- */ -static void test_basic_links(hid_t fapl_id, hbool_t new_format) +static void +test_basic_links(hid_t fapl_id, hbool_t new_format) { hsize_t size[1] = {1}; - char filename[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; // Use the file access template id to create a file access prop. list. FileAccPropList fapl(fapl_id); - try - { - if(new_format) + try { + if (new_format) SUBTEST("Link creation (w/new group format)") else SUBTEST("Link creation") @@ -86,7 +75,7 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) H5File file(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); // Create simple dataspace - DataSpace scalar (1, size, size); + DataSpace scalar(1, size, size); // Create a group then close it by letting the object go out of scope { @@ -103,25 +92,19 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) // Because these are not implemented in the C++ API yet, they are // used so CommonFG::getLinkval can be tested. // Create a hard link - if(H5Lcreate_hard( - file_id, "dset1", H5L_SAME_LOC, "grp1/hard1", - H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_hard(file_id, "dset1", H5L_SAME_LOC, "grp1/hard1", H5P_DEFAULT, H5P_DEFAULT) < 0) throw Exception("test_basic_links", "H5Lcreate_hard failed"); // Create a symbolic link - if(H5Lcreate_soft( - "/dset1", file_id, "grp1/soft", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_soft("/dset1", file_id, "grp1/soft", H5P_DEFAULT, H5P_DEFAULT) < 0) throw Exception("test_basic_links", "H5Lcreate_soft failed"); // Create a symbolic link to something that doesn't exist - if(H5Lcreate_soft( - "foobar", file_id, "grp1/dangle", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_soft("foobar", file_id, "grp1/dangle", H5P_DEFAULT, H5P_DEFAULT) < 0) throw Exception("test_basic_links", "H5Lcreate_soft failed"); // Create a recursive symbolic link - if(H5Lcreate_soft( - "/grp1/recursive", file_id, "/grp1/recursive", - H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_soft("/grp1/recursive", file_id, "/grp1/recursive", H5P_DEFAULT, H5P_DEFAULT) < 0) throw Exception("test_basic_links", "H5Lcreate_soft failed"); // Verify link values before closing the file @@ -136,26 +119,24 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) verify_val(reclink_val, "/grp1/recursive", "H5File::getLinkval grp1/recursive", __LINE__, __FILE__); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg()); } // Open the file and check on the links in it - try - { + try { // Open the file above H5File file(filename, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl); // Verify link existence - if(file.nameExists("dset1", LinkAccPropList::DEFAULT) != TRUE) + if (file.nameExists("dset1", LinkAccPropList::DEFAULT) != TRUE) throw InvalidActionException("H5File::nameExists", "dset1 doesn't exist"); - if(file.nameExists("grp1/soft", LinkAccPropList::DEFAULT) != TRUE) + if (file.nameExists("grp1/soft", LinkAccPropList::DEFAULT) != TRUE) throw InvalidActionException("H5File::nameExists", "grp1/soft doesn't exist"); // Deprecated - if(file.exists("dset1", LinkAccPropList::DEFAULT) != TRUE) + if (file.exists("dset1", LinkAccPropList::DEFAULT) != TRUE) throw InvalidActionException("H5File::exists", "dset1 doesn't exist"); - if(file.exists("grp1/soft", LinkAccPropList::DEFAULT) != TRUE) + if (file.exists("grp1/soft", LinkAccPropList::DEFAULT) != TRUE) throw InvalidActionException("H5File::exists", "grp1/soft doesn't exist"); // Verify link values @@ -167,13 +148,11 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_basic_links - /*------------------------------------------------------------------------- * Function: test_lcpl * @@ -191,16 +170,15 @@ static void test_lcpl(hid_t fapl_id, hbool_t new_format) { H5L_info_t linfo; - char filename[1024]; - hsize_t dims[2]; + char filename[1024]; + hsize_t dims[2]; - if(new_format) + if (new_format) SUBTEST("Link creation property lists (w/new group format)") else SUBTEST("Link creation property lists") - try - { + try { FileAccPropList fapl(fapl_id); // Create a new file. @@ -213,7 +191,7 @@ test_lcpl(hid_t fapl_id, hbool_t new_format) // Check that its character encoding is the default. linfo = file.getLinkInfo(GROUP1NAME); - if(linfo.cset != H5T_CSET_ASCII) + if (linfo.cset != H5T_CSET_ASCII) throw InvalidActionException("H5Lget_info", "Character encoding is not default"); // Create and commit a datatype with the default LCPL. @@ -228,7 +206,7 @@ test_lcpl(hid_t fapl_id, hbool_t new_format) // Create a simple dataspace. dims[0] = H5L_DIM1; dims[1] = H5L_DIM2; - DataSpace dspace(2 ,dims); + DataSpace dspace(2, dims); // Create a dataset using the default LCPL. DataSet dset(file.createDataSet("/dataset", PredType::NATIVE_INT, dspace)); @@ -252,13 +230,11 @@ test_lcpl(hid_t fapl_id, hbool_t new_format) PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_lcpl()", __LINE__, __FILE__, E.getCDetailMsg()); } } // end test_lcpl() - /*------------------------------------------------------------------------- * Function: test_move * @@ -272,15 +248,14 @@ test_lcpl(hid_t fapl_id, hbool_t new_format) static void test_move(hid_t fapl_id, hbool_t new_format) { - char filename[1024]; + char filename[1024]; - if(new_format) + if (new_format) SUBTEST("Group::moveLink (w/new group format)") else SUBTEST("Group::moveLink") - try - { + try { FileAccPropList fapl(fapl_id); // Create two new files @@ -303,15 +278,16 @@ test_move(hid_t fapl_id, hbool_t new_format) grp_1.moveLink("group_move", file_b, "group_new_name"); // Should throw an exception but didn't - H5_FAILED(); - cerr << " Group group_move should not be moved across files" << endl; - } catch (Exception& E) { + H5_FAILED(); + cerr << " Group group_move should not be moved across files" << endl; + } + catch (Exception &E) { // expected } // Move a soft link across files, should succeed grp_2.moveLink("soft", file_b, "soft_new_name"); - if(file_b.exists("soft_new_name") != TRUE) + if (file_b.exists("soft_new_name") != TRUE) throw InvalidActionException("H5File::exists", "grp1/soft doesn't exist"); // Move a group across groups in the same file while renaming it @@ -326,9 +302,10 @@ test_move(hid_t fapl_id, hbool_t new_format) moved_grp = grp_1.openGroup("group_move"); // Should throw an exception but didn't - H5_FAILED(); - cerr << " Group group_move should not be in original location" << endl; - } catch (Exception& E) { + H5_FAILED(); + cerr << " Group group_move should not be in original location" << endl; + } + catch (Exception &E) { // expected } @@ -360,46 +337,49 @@ test_move(hid_t fapl_id, hbool_t new_format) moved_grp = grp_1.openGroup("group_newer_name"); moved_grp.close(); - H5_FAILED(); // Should throw an exception but didn't - cerr << " Group group_newer_name should not be in GROUP1NAME" << endl; - } catch (Exception& E) { + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_newer_name should not be in GROUP1NAME" << endl; + } + catch (Exception &E) { // expected } try { moved_grp = grp_2.openGroup("group_newer_name"); moved_grp.close(); - H5_FAILED(); // Should throw an exception but didn't - cerr << " Group group_newer_name should not be in GROUP2NAME" << endl; - } catch (Exception& E) { + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_newer_name should not be in GROUP2NAME" << endl; + } + catch (Exception &E) { // expected } try { moved_grp = grp_2.openGroup("group_new_name"); moved_grp.close(); - H5_FAILED(); // Should throw an exception but didn't - cerr << " Group group_new_name should not be in GROUP2NAME" << endl; - } catch (Exception& E) { + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_new_name should not be in GROUP2NAME" << endl; + } + catch (Exception &E) { // expected } try { moved_grp = grp_1.openGroup("group_copy"); moved_grp.close(); - H5_FAILED(); // Should throw an exception but didn't - cerr << " Group group_copy should not be in GROUP1NAME" << endl; - } catch (Exception& E) { + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_copy should not be in GROUP1NAME" << endl; + } + catch (Exception &E) { // expected } PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_move()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_move - + /*------------------------------------------------------------------------- * Function: test_copy * @@ -410,17 +390,17 @@ test_move(hid_t fapl_id, hbool_t new_format) * March, 2018 *------------------------------------------------------------------------- */ -static void test_copy(hid_t fapl_id, hbool_t new_format) +static void +test_copy(hid_t fapl_id, hbool_t new_format) { char filename[1024]; - if(new_format) + if (new_format) SUBTEST("Group::copyLink (w/new group format)") else SUBTEST("Group::copyLink") - try - { + try { // Create two new files h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename); H5File file_a(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl_id); @@ -439,7 +419,8 @@ static void test_copy(hid_t fapl_id, hbool_t new_format) // Copy a group across files, should fail try { grp_1.copyLink("group_copy", file_b, "group_new_name"); - } catch (Exception& E) { + } + catch (Exception &E) { // expected } @@ -509,9 +490,10 @@ static void test_copy(hid_t fapl_id, hbool_t new_format) moved_grp = grp_2.openGroup("group_newer_name"); moved_grp.close(); - H5_FAILED(); // Should throw an exception but didn't - cerr << " Group group_newer_name should not be in GROUP2NAME" << endl; - } catch (Exception& E) { + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_newer_name should not be in GROUP2NAME" << endl; + } + catch (Exception &E) { // expected } @@ -521,21 +503,20 @@ static void test_copy(hid_t fapl_id, hbool_t new_format) moved_grp = grp_1.openGroup("group_copy"); moved_grp.close(); - H5_FAILED(); // Should throw an exception but didn't - cerr << " Group group_copy should not be in GROUP1NAME" << endl; - } catch (Exception& E) { + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_copy should not be in GROUP1NAME" << endl; + } + catch (Exception &E) { // expected } PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_copy()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_copy - /*------------------------------------------------------------------------- * Function: test_num_links * @@ -547,17 +528,17 @@ static void test_copy(hid_t fapl_id, hbool_t new_format) * October 16, 2009 *------------------------------------------------------------------------- */ -static void test_num_links(hid_t fapl_id, hbool_t new_format) +static void +test_num_links(hid_t fapl_id, hbool_t new_format) { char filename[NAME_BUF_SIZE]; - if(new_format) + if (new_format) SUBTEST("Setting number of links (w/new group format)") else SUBTEST("Setting number of links") - try - { + try { // Use the file access template id to create a file access prop. list. FileAccPropList fapl(fapl_id); @@ -565,7 +546,7 @@ static void test_num_links(hid_t fapl_id, hbool_t new_format) H5File file(filename, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl); LinkAccPropList lapl; - size_t nlinks = 5; + size_t nlinks = 5; lapl.setNumLinks(nlinks); // Read it back and verify @@ -574,13 +555,11 @@ static void test_num_links(hid_t fapl_id, hbool_t new_format) PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_num_links()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_num_links - // Data for visit on the file static const obj_visit_t file_visit[] = { {".", H5O_TYPE_GROUP}, @@ -600,22 +579,25 @@ const H5std_string FILE_NAME("tvisit.h5"); const H5std_string GROUP_NAME("/Data"); const H5std_string DSET1_NAME("/Data/Compressed_Data"); const H5std_string DSET2_NAME("/Data/Float_Data"); -const int RANK = 2; -const int DIM1 = 2; +const int RANK = 2; +const int DIM1 = 2; // Operator function -static int visit_obj_cb(H5Object& obj, const H5std_string name, const H5O_info_t *oinfo, void *_op_data) +static int +visit_obj_cb(H5Object &obj, const H5std_string name, const H5O_info_t *oinfo, void *_op_data) { - ovisit_ud_t *op_data = static_cast <ovisit_ud_t *>(_op_data); + ovisit_ud_t *op_data = static_cast<ovisit_ud_t *>(_op_data); // Check for correct object information - if(strcmp(op_data->info[op_data->idx].path, name.c_str())) return(H5_ITER_ERROR); - if(op_data->info[op_data->idx].type != oinfo->type) return(H5_ITER_ERROR); + if (strcmp(op_data->info[op_data->idx].path, name.c_str()) != 0) + return (H5_ITER_ERROR); + if (op_data->info[op_data->idx].type != oinfo->type) + return (H5_ITER_ERROR); // Advance to next location op_data->idx++; - return(H5_ITER_CONT); + return (H5_ITER_CONT); } /*------------------------------------------------------------------------- @@ -628,93 +610,90 @@ static int visit_obj_cb(H5Object& obj, const H5std_string name, const H5O_info_t * February 8, 2019 *------------------------------------------------------------------------- */ -static void test_visit(hid_t fapl_id, hbool_t new_format) +static void +test_visit(hid_t fapl_id, hbool_t new_format) { - hsize_t dims[2]; - hsize_t cdims[2]; - char filename[NAME_BUF_SIZE]; + hsize_t dims[2]; + hsize_t cdims[2]; + char filename[NAME_BUF_SIZE]; - if(new_format) + if (new_format) SUBTEST("H5Object::visit (w/new group format)") else SUBTEST("H5Object::visit") - try - { + try { // Use the file access template id to create a file access prop. list FileAccPropList fapl(fapl_id); // Build the hdf5 file name and create the file h5_fixname(FILENAME[3], fapl_id, filename, sizeof filename); - H5File *file = new H5File(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); + H5File *file = new H5File(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); // Create a group - Group* group = new Group(file->createGroup(GROUP_NAME)); + Group *group = new Group(file->createGroup(GROUP_NAME)); // Create a chunked/compressed dataset within this group specified by path - dims[0] = 20; - dims[1] = 2; - cdims[0] = 2; - cdims[1] = 2; - DataSpace *dataspace = new DataSpace(RANK, dims); // create new dspace - DSetCreatPropList ds_creatplist; // create dataset creation prop list - ds_creatplist.setChunk(2, cdims); // then modify it for compression - ds_creatplist.setDeflate(6); - - DataSet* dataset = new DataSet(file->createDataSet(DSET1_NAME, - PredType::NATIVE_INT, *dataspace, ds_creatplist)); - - delete dataset; - delete dataspace; - - // Create another dataset - dims[0] = 5; - dims[1] = 2; - dataspace = new DataSpace(RANK, dims); // create second dspace - dataset = new DataSet(file->createDataSet(DSET2_NAME, - PredType::NATIVE_FLOAT, *dataspace)); + dims[0] = 20; + dims[1] = 2; + cdims[0] = 2; + cdims[1] = 2; + DataSpace * dataspace = new DataSpace(RANK, dims); // create new dspace + DSetCreatPropList ds_creatplist; // create dataset creation prop list + ds_creatplist.setChunk(2, cdims); // then modify it for compression + ds_creatplist.setDeflate(6); + + DataSet *dataset = + new DataSet(file->createDataSet(DSET1_NAME, PredType::NATIVE_INT, *dataspace, ds_creatplist)); + + delete dataset; + delete dataspace; + + // Create another dataset + dims[0] = 5; + dims[1] = 2; + dataspace = new DataSpace(RANK, dims); // create second dspace + dataset = new DataSet(file->createDataSet(DSET2_NAME, PredType::NATIVE_FLOAT, *dataspace)); // Close everything - delete dataset; - delete dataspace; - delete group; - delete file; + delete dataset; + delete dataspace; + delete group; + delete file; - // Reopen the file and group in the file. - file = new H5File(filename, H5F_ACC_RDWR); - group = new Group(file->openGroup("Data")); + // Reopen the file and group in the file. + file = new H5File(filename, H5F_ACC_RDWR); + group = new Group(file->openGroup("Data")); // Open the group - dataset = new DataSet(group->openDataSet(DSET2_NAME)); + dataset = new DataSet(group->openDataSet(DSET2_NAME)); delete dataset; // Visit objects in the file - ovisit_ud_t udata; /* User-data for visiting */ - udata.idx = 0; + ovisit_ud_t udata; /* User-data for visiting */ + udata.idx = 0; udata.info = file_visit; file->visit(H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC); // Visit objects in the group - udata.idx = 0; + udata.idx = 0; udata.info = group_visit; group->visit(H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC); - // Close the group and file. - delete group; - delete file; + // Close the group and file. + delete group; + delete file; PASSED(); } // end of try block - catch (Exception& E) - { - cerr << "in catch" << endl; + catch (Exception &E) { + cerr << "in catch" << endl; issue_fail_msg("test_visit()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_visit() - /*------------------------------------------------------------------------- * Function: test_links * @@ -725,35 +704,33 @@ static void test_visit(hid_t fapl_id, hbool_t new_format) * October 16, 2009 *------------------------------------------------------------------------- */ -extern "C" -void test_links() +extern "C" void +test_links() { - hid_t fapl_id, fapl2_id; /* File access property lists */ - unsigned new_format; /* Whether to use the new format or not */ + hid_t fapl_id, fapl2_id; /* File access property lists */ + unsigned new_format; /* Whether to use the new format or not */ - if((fapl_id = h5_fileaccess()) < 0) + if ((fapl_id = h5_fileaccess()) < 0) throw Exception("test_links", "Unable to get file access property list"); // Output message about test being performed MESSAGE(5, ("Testing Various Links\n")); - try - { + try { /* Copy the file access property list */ - if((fapl2_id = H5Pcopy(fapl_id)) < 0) + if ((fapl2_id = H5Pcopy(fapl_id)) < 0) throw Exception("test_links", "H5Pcopy failed"); /* Set the "use the latest version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl2_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl2_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) throw Exception("test_links", "H5Pset_libver_bounds failed"); /* Loop over using new group format */ - for(new_format = FALSE; new_format <= TRUE; new_format++) - { + for (new_format = FALSE; new_format <= TRUE; new_format++) { hid_t my_fapl_id; /* Check for FAPL to use */ - if(new_format) + if (new_format) my_fapl_id = fapl2_id; else my_fapl_id = fapl_id; @@ -773,13 +750,11 @@ void test_links() h5_clean_files(FILENAME, fapl_id); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_links()", __LINE__, __FILE__, E.getCDetailMsg()); } } - /*------------------------------------------------------------------------- * Function: cleanup_links * @@ -788,8 +763,8 @@ void test_links() * Return none *------------------------------------------------------------------------- */ -extern "C" -void cleanup_links() +extern "C" void +cleanup_links() { HDremove(FILENAME[0]); HDremove(FILENAME[1]); diff --git a/c++/test/tobject.cpp b/c++/test/tobject.cpp index 138c4ca..cb12573 100644 --- a/c++/test/tobject.cpp +++ b/c++/test/tobject.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,36 +16,31 @@ tobject.cpp - HDF5 C++ testing object related functionality ***************************************************************************/ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file - -const H5std_string FILE_OBJECTS("tobjects.h5"); -const H5std_string FILE_OBJHDR("tobject_header.h5"); -const H5std_string GROUP1("Top Group"); -const H5std_string GROUP1_PATH("/Top Group"); -const H5std_string GROUP1_1("Sub-Group 1.1"); -const H5std_string GROUP1_1_PATH("/Top Group/Sub-Group 1.1"); -const H5std_string GROUP1_2("Sub-Group 1.2"); -const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2"); -const H5std_string DSET_DEFAULT_NAME("default"); -const H5std_string DSET_IN_FILE("Dataset in File"); -const H5std_string DSET_IN_FILE_PATH("/Dataset in File"); -const H5std_string DSET_IN_GRP1("Dataset_in_Group_1"); -const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset_in_Group_1"); -const H5std_string DSET_IN_GRP1_2("Dataset_in_Group_1.2"); -const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset_in_Group_1.2"); - - +#include "h5cpputil.h" // C++ utilility header file + +const H5std_string FILE_OBJECTS("tobjects.h5"); +const H5std_string FILE_OBJHDR("tobject_header.h5"); +const H5std_string GROUP1("Top Group"); +const H5std_string GROUP1_PATH("/Top Group"); +const H5std_string GROUP1_1("Sub-Group 1.1"); +const H5std_string GROUP1_1_PATH("/Top Group/Sub-Group 1.1"); +const H5std_string GROUP1_2("Sub-Group 1.2"); +const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2"); +const H5std_string DSET_DEFAULT_NAME("default"); +const H5std_string DSET_IN_FILE("Dataset in File"); +const H5std_string DSET_IN_FILE_PATH("/Dataset in File"); +const H5std_string DSET_IN_GRP1("Dataset_in_Group_1"); +const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset_in_Group_1"); +const H5std_string DSET_IN_GRP1_2("Dataset_in_Group_1.2"); +const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset_in_Group_1.2"); + /*------------------------------------------------------------------------- * Function: test_get_objname * @@ -68,7 +63,8 @@ const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset_ * Friday, March 4, 2014 *------------------------------------------------------------------------- */ -static void test_get_objname() +static void +test_get_objname() { SUBTEST("H5Object::getObjName on Groups and Datasets"); @@ -77,7 +73,7 @@ static void test_get_objname() H5File file(FILE_OBJECTS, H5F_ACC_TRUNC); // Create a top group and 2 subgroups - Group grp1 = file.createGroup(GROUP1, 0); + Group grp1 = file.createGroup(GROUP1, 0); Group grp1_1 = grp1.createGroup(GROUP1_1, 0); Group grp1_2 = grp1.createGroup(GROUP1_2, 0); @@ -88,27 +84,24 @@ static void test_get_objname() ssize_t name_len = grp1.getObjName(NULL); // Random length is 4 - if (name_len > 4) - { - char* grp1_name = new char[5]; - name_len = grp1.getObjName(grp1_name, 5); - verify_val((const char*)grp1_name, "/Top", "Group::getObjName", __LINE__, __FILE__); - delete []grp1_name; + if (name_len > 4) { + char *grp1_name = new char[5]; + name_len = grp1.getObjName(grp1_name, 5); + verify_val((const char *)grp1_name, "/Top", "Group::getObjName", __LINE__, __FILE__); + delete[] grp1_name; } // Create a data space - hsize_t dims[2]; + hsize_t dims[2]; dims[0] = 2; dims[1] = 5; - DataSpace space (2, dims, NULL); + DataSpace space(2, dims, NULL); // Create a dataset in the file - DataSet dsinfile = file.createDataSet(DSET_IN_FILE, - PredType::NATIVE_DOUBLE, space); + DataSet dsinfile = file.createDataSet(DSET_IN_FILE, PredType::NATIVE_DOUBLE, space); // Create a dataset in the group - DataSet dsingrp = grp1.createDataSet(DSET_IN_GRP1, - PredType::NATIVE_INT, space); + DataSet dsingrp = grp1.createDataSet(DSET_IN_GRP1, PredType::NATIVE_INT, space); // Get and verify the name of each dataset, using // H5std_string getObjName() and @@ -135,23 +128,21 @@ static void test_get_objname() // Reopen that same dataset then check the name again with another // overload: ssize_t getObjName(H5std_string& obj_name, size_t len = 0) - dsingrp = grp1_2.openDataSet(DSET_IN_GRP1_2); + dsingrp = grp1_2.openDataSet(DSET_IN_GRP1_2); name_len = dsingrp.getObjName(ds_name); verify_val(ds_name, DSET_IN_GRP1_2_PATH, "DataSet::getObjName", __LINE__, __FILE__); // Everything will be closed as they go out of scope PASSED(); - } // try block + } // try block // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_get_objname", __LINE__, __FILE__); } -} // test_get_objname +} // test_get_objname - /*------------------------------------------------------------------------- * Function: test_existance * @@ -174,7 +165,8 @@ static void test_get_objname() * Friday, March 4, 2014 *------------------------------------------------------------------------- */ -static void test_existance() +static void +test_existance() { SUBTEST("H5File::exists and Group::exists"); @@ -222,7 +214,7 @@ static void test_existance() // Check if a dataset exists given dataset as location with full path name DataSet dset1 = file.openDataSet(DSET_IN_FILE); - exists = dset1.nameExists("/Top Group/Dataset_in_Group_1"); + exists = dset1.nameExists("/Top Group/Dataset_in_Group_1"); verify_val(exists, TRUE, "Group::nameExists given dataset with full path name", __LINE__, __FILE__); exists = grp1_2.nameExists(DSET_IN_GRP1); @@ -236,16 +228,14 @@ static void test_existance() // Everything will be closed as they go out of scope PASSED(); - } // try block + } // try block // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_existance", __LINE__, __FILE__); } -} // test_existance +} // test_existance - /*------------------------------------------------------------------------- * Function: test_get_objname_ontypes * @@ -258,7 +248,8 @@ static void test_existance() * March 4, 2014 *------------------------------------------------------------------------- */ -static void test_get_objname_ontypes() +static void +test_get_objname_ontypes() { SUBTEST("H5Object::getObjName on Committed Datatypes"); @@ -267,7 +258,7 @@ static void test_get_objname_ontypes() H5File file(FILE_OBJECTS, H5F_ACC_RDWR); // Create a group - Group grp = file.createGroup ("typetests"); + Group grp = file.createGroup("typetests"); // Create a datatype and save it IntType inttype(PredType::STD_B8LE); @@ -326,7 +317,8 @@ static void test_get_objname_ontypes() // Name this datatype new_int_type.commit(grp, "IntType NATIVE_INT"); ssize_t name_len = new_int_type.getObjName(type_name); // default len - verify_val(name_len, (ssize_t)HDstrlen("/typetests/IntType NATIVE_INT"), "DataType::getObjName", __LINE__, __FILE__); + verify_val(name_len, (ssize_t)HDstrlen("/typetests/IntType NATIVE_INT"), "DataType::getObjName", + __LINE__, __FILE__); verify_val(type_name, "/typetests/IntType NATIVE_INT", "DataType::getObjName", __LINE__, __FILE__); // Close everything or they can be closed when objects go out of scope @@ -338,13 +330,11 @@ static void test_get_objname_ontypes() PASSED(); } // end top try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_get_objname_ontypes", __LINE__, __FILE__); } -} // test_get_objname_ontypes +} // test_get_objname_ontypes - /*------------------------------------------------------------------------- * Function: test_get_objtype * @@ -357,7 +347,8 @@ static void test_get_objname_ontypes() * Friday, March 4, 2014 *------------------------------------------------------------------------- */ -static void test_get_objtype() +static void +test_get_objtype() { SUBTEST("H5File::childObjType and H5Group::childObjType"); @@ -398,16 +389,14 @@ static void test_get_objtype() // Everything will be closed as they go out of scope PASSED(); - } // try block + } // try block // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_get_objtype", __LINE__, __FILE__); } -} // test_get_objtype +} // test_get_objtype - /*------------------------------------------------------------------------- * Function: test_open_object_header * @@ -427,9 +416,10 @@ const H5std_string DSETNAME("dataset"); #define DIM0 5 #define DIM1 10 -static void test_open_object_header() +static void +test_open_object_header() { - hsize_t dims[2]; + hsize_t dims[2]; // Output message about test being performed SUBTEST("Group::getObjId"); @@ -452,16 +442,16 @@ static void test_open_object_header() dims[0] = DIM0; dims[1] = DIM1; DataSpace dspace(RANK, dims); - DataSet dset(file1.createDataSet(DSETNAME, PredType::NATIVE_INT, dspace)); + DataSet dset(file1.createDataSet(DSETNAME, PredType::NATIVE_INT, dspace)); // Close dataset and dataspace dset.close(); dspace.close(); // Now make sure that getObjId can open all three types of objects - hid_t obj_grp = file1.getObjId(GROUPNAME); + hid_t obj_grp = file1.getObjId(GROUPNAME); hid_t obj_dtype = file1.getObjId(DTYPENAME); - hid_t obj_dset = file1.getObjId(DSETNAME); + hid_t obj_dset = file1.getObjId(DSETNAME); // Make sure that each is the right kind of ID H5I_type_t id_type = IdComponent::getHDFObjType(obj_grp); @@ -473,7 +463,7 @@ static void test_open_object_header() /* Do something more complex with each of the IDs to make sure */ - Group grp2(obj_grp); + Group grp2(obj_grp); hsize_t num_objs = grp2.getNumObjs(); verify_val(num_objs, 1, "H5Gget_info", __LINE__, __FILE__); // There should be one object, the datatype @@ -482,7 +472,7 @@ static void test_open_object_header() file1.closeObjId(obj_dtype); dset.setId(obj_dset); - dspace = dset.getSpace(); + dspace = dset.getSpace(); bool is_simple = dspace.isSimple(); verify_val(is_simple, true, "isSimple", __LINE__, __FILE__); dspace.close(); @@ -509,23 +499,20 @@ static void test_open_object_header() grp2.close(); PASSED(); - } // end of try block + } // end of try block // catch invalid action exception - catch (InvalidActionException& E) - { + catch (InvalidActionException &E) { cerr << " in InvalidActionException" << endl; cerr << " *FAILED*" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; } // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " in Exception" << endl; issue_fail_msg("test_file_name()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_open_object_header +} // test_open_object_header - /*------------------------------------------------------------------------- * Function: test_getobjectinfo_same_file * @@ -540,9 +527,10 @@ static void test_open_object_header() const H5std_string FILE_OBJINFO("tobject_getinfo.h5"); const H5std_string GROUP1NAME("group1"); const H5std_string GROUP2NAME("group2"); -static void test_getobjectinfo_same_file() +static void +test_getobjectinfo_same_file() { - H5O_info_t oinfo1, oinfo2; /* Object info structs */ + H5O_info_t oinfo1, oinfo2; /* Object info structs */ // Output message about test being performed SUBTEST("Group::getObjinfo"); @@ -588,7 +576,6 @@ static void test_getobjectinfo_same_file() grp2.getObjinfo(oinfo2); verify_val(oinfo1.fileno, oinfo2.fileno, "file number from getObjinfo", __LINE__, __FILE__); - // Reset object info HDmemset(&oinfo1, 0, sizeof(oinfo1)); HDmemset(&oinfo2, 0, sizeof(oinfo2)); @@ -604,16 +591,15 @@ static void test_getobjectinfo_same_file() file2.close(); PASSED(); - } // end of try block + } // end of try block // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " in Exception " << E.getCFuncName() << "detail: " << E.getCDetailMsg() << endl; issue_fail_msg("test_getobjectinfo_same_file()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_getobjectinfo_same_file - +} // test_getobjectinfo_same_file + /*------------------------------------------------------------------------- * Function: test_intermediate_groups * @@ -636,7 +622,8 @@ const H5std_string GROUP20NAME("/group20"); const H5std_string GROUP21NAME("/group20/group21"); const H5std_string GROUP22NAME("group21/group22"); const H5std_string GROUP22FULLNAME("/group20/group21/group22"); -static void test_intermediate_groups() +static void +test_intermediate_groups() { // Output message about test being performed SUBTEST("Group::set/getCreateIntermediateGroup"); @@ -663,7 +650,9 @@ static void test_intermediate_groups() // fail because group GROUP13NAME is missing try { Group grp14_nopl(file.createGroup(GROUP14NAME)); - } catch (FileIException& expected1) {} // Failure is ignored + } + catch (FileIException &expected1) { + } // Failure is ignored // Create GROUP14NAME with the flag to create missing groups set // to FALSE, should fail because group GROUP13NAME is missing @@ -677,14 +666,15 @@ static void test_intermediate_groups() try { Group grp14_false(file.createGroup(GROUP14NAME, lcpl)); - } catch (FileIException& expected2) {} // Failure is ignored + } + catch (FileIException &expected2) { + } // Failure is ignored // Set the flag to create missing groups set to TRUE lcpl.setCreateIntermediateGroup(true); crt_int_grps = lcpl.getCreateIntermediateGroup(); verify_val(crt_int_grps, true, "LinkCreatPropList::getCreateIntermediateGroup", __LINE__, __FILE__); - // Create GROUP14NAME with the use of link create plist Group grp14(file.createGroup(GROUP14NAME, lcpl)); @@ -715,16 +705,15 @@ static void test_intermediate_groups() Group grp22fromfile(file.openGroup(GROUP22FULLNAME)); PASSED(); - } // end of try block + } // end of try block // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " in Exception " << E.getCFuncName() << "detail: " << E.getCDetailMsg() << endl; issue_fail_msg("test_intermediate_groups()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_intermediate_groups - +} // test_intermediate_groups + /*------------------------------------------------------------------------- * Function: test_object * @@ -736,8 +725,8 @@ static void test_intermediate_groups() * March 4, 2014 *------------------------------------------------------------------------- */ -extern "C" -void test_object() +extern "C" void +test_object() { // Output message about test being performed MESSAGE(5, ("Testing Object Functions\n")); @@ -750,9 +739,8 @@ void test_object() test_getobjectinfo_same_file(); // Test object info in same file test_intermediate_groups(); // Test intermediate group property -} // test_object +} // test_object - /*------------------------------------------------------------------------- * Function: cleanup_objects * @@ -761,8 +749,8 @@ void test_object() * Return None *------------------------------------------------------------------------- */ -extern "C" -void cleanup_object() +extern "C" void +cleanup_object() { HDremove(FILE_OBJECTS.c_str()); } // cleanup_objects diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp index b2b65ce..f4eab6f 100644 --- a/c++/test/trefer.cpp +++ b/c++/test/trefer.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,31 +17,27 @@ Reference interface (H5R) ***************************************************************************/ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file -const H5std_string FILE1("trefer1.h5"); -const H5std_string FILE2("trefer2.h5"); +const H5std_string FILE1("trefer1.h5"); +const H5std_string FILE2("trefer2.h5"); // Dataset 1 -const H5std_string DSET1_NAME("Dataset1"); -const H5std_string DSET2_NAME("Dataset2"); +const H5std_string DSET1_NAME("Dataset1"); +const H5std_string DSET2_NAME("Dataset2"); -const H5std_string MEMBER1( "a_name" ); -const H5std_string MEMBER2( "b_name" ); -const H5std_string MEMBER3( "c_name" ); +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 int SPACE1_RANK = 1; @@ -58,10 +54,9 @@ const int POINT1_NPOINTS = 10; typedef struct s1_t { unsigned int a; unsigned int b; - float c; + float c; } s1_t; - /*------------------------------------------------------------------------- * Function: test_reference_params * @@ -70,30 +65,31 @@ typedef struct s1_t { * Return None *------------------------------------------------------------------------- */ -static void test_reference_params() +static void +test_reference_params() { const char *write_comment = "Foo!"; /* Comments for group */ // Output message about test being performed SUBTEST("Object Reference Parameters"); - H5File* file1 = NULL; + H5File *file1 = NULL; try { - hobj_ref_t *wbuf, // buffer to write to disk - *rbuf, // buffer read from disk - *tbuf; // temp. buffer read from disk + 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); + 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); + file1 = new H5File(FILE1, H5F_ACC_TRUNC); // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create a group @@ -105,10 +101,10 @@ static void test_reference_params() // 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 + 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); @@ -143,19 +139,29 @@ static void test_reference_params() /* Test parameters to H5Location::reference */ try { file1->reference(NULL, "/Group1/Dataset1"); - } catch (ReferenceException& E) {} // We expect this to fail + } + catch (ReferenceException &E) { + } // We expect this to fail try { file1->reference(&wbuf[0], NULL); - } catch (ReferenceException& E) {} // We expect this to fail + } + catch (ReferenceException &E) { + } // We expect this to fail try { file1->reference(&wbuf[0], ""); - } catch (ReferenceException& E) {} // We expect this to fail + } + 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 + } + 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 + } + catch (ReferenceException &E) { + } // We expect this to fail // Close resources dataset.close(); @@ -169,17 +175,14 @@ static void test_reference_params() PASSED(); } // end try - catch (Exception& E) - { - issue_fail_msg("test_reference_param()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + catch (Exception &E) { + issue_fail_msg("test_reference_param()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg()); } - if(file1) + if (file1) delete file1; -} /* test_reference_param() */ +} /* test_reference_param() */ - /*------------------------------------------------------------------------- * Function: test_reference_obj * @@ -189,31 +192,32 @@ static void test_reference_params() * Return None *------------------------------------------------------------------------- */ -static void test_reference_obj() +static void +test_reference_obj() { - int i; // counting variables - const H5std_string write_comment="Foo!"; // Comments for group + int i; // counting variables + const H5std_string write_comment = "Foo!"; // Comments for group // Output message about test being performed SUBTEST("Object Reference Functions"); - H5File* file1 = NULL; + H5File *file1 = NULL; try { - hobj_ref_t *wbuf, // buffer to write to disk - *rbuf, // buffer read from disk - *tbuf; // temp. buffer read from disk + 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); + 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); + file1 = new H5File(FILE1, H5F_ACC_TRUNC); // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create dataset access property list @@ -228,9 +232,9 @@ static void test_reference_obj() // Create a dataset (inside /Group1) DataSet dataset = group.createDataSet(DSET1_NAME, PredType::NATIVE_UINT, sid1); - unsigned *tu32; // Temporary pointer to uint32 data + unsigned *tu32; // Temporary pointer to uint32 data for (tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) - *tu32++=i*3; // from C test + *tu32++ = i * 3; // from C test // Write selection to disk dataset.write(wbuf, PredType::NATIVE_UINT); @@ -265,22 +269,22 @@ static void test_reference_obj() // 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); @@ -304,15 +308,15 @@ static void test_reference_obj() DataSet dset2(dataset, &rbuf[0], H5R_OBJECT, dapl); // Check information in the referenced dataset - sid1 = dset2.getSpace(); + 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(); @@ -323,18 +327,19 @@ static void test_reference_obj() // Get group's comment using // H5std_string getComment(const char* name, <buf_size=0 by default>) H5std_string read_comment1 = group.getComment(".", 10); - verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__); + verify_val(read_comment1.c_str(), write_comment, "Group::getComment", __LINE__, __FILE__); // Test with the old default value read_comment1 = group.getComment(".", 256); - verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__); + verify_val(read_comment1.c_str(), write_comment, "Group::getComment", __LINE__, __FILE__); // Test that getComment handles failures gracefully, using // H5std_string getComment(const char* name, <buf_size=0 by default>) try { H5std_string read_comment_tmp = group.getComment(NULL); } - catch (Exception& E) {} // We expect this to fail + catch (Exception &E) { + } // We expect this to fail // Close group group.close(); @@ -349,9 +354,9 @@ static void test_reference_obj() H5T_class_t tclass; tclass = dtype1.getClass(); - verify_val(tclass, H5T_COMPOUND, "DataType::getClass",__LINE__,__FILE__); + verify_val(tclass, H5T_COMPOUND, "DataType::getClass", __LINE__, __FILE__); int n_members = dtype1.getNmembers(); - verify_val(n_members, 3, "CompType::getNmembers",__LINE__,__FILE__); + verify_val(n_members, 3, "CompType::getNmembers", __LINE__, __FILE__); // Close all objects and file dtype1.close(); @@ -365,17 +370,14 @@ static void test_reference_obj() PASSED(); } // end try - catch (Exception& E) - { - issue_fail_msg("test_reference_obj()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + catch (Exception &E) { + issue_fail_msg("test_reference_obj()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg()); } - if(file1) + if (file1) delete file1; -} // test_reference_obj() +} // test_reference_obj() - /*------------------------------------------------------------------------- * Function: test_reference_group * @@ -384,23 +386,24 @@ static void test_reference_obj() * Return None *------------------------------------------------------------------------- */ -#define GROUPNAME "/group" -#define GROUPNAME2 "group2" -#define GROUPNAME3 "group3" -#define DSETNAME "/dset" -#define DSETNAME2 "dset2" -#define NAME_SIZE 16 - -static void test_reference_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() { - hobj_ref_t wref; /* Reference to write */ - hobj_ref_t rref; /* Reference to read */ - const H5std_string write_comment="Foo!"; // Comments for group + 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; + H5File *file1 = NULL; try { /* * Create file with a group and a dataset containing an object @@ -408,7 +411,7 @@ static void test_reference_group() */ // Create file FILE1 - file1 = new H5File (FILE1, H5F_ACC_TRUNC); + file1 = new H5File(FILE1, H5F_ACC_TRUNC); // Create scalar dataspace DataSpace sid1; @@ -467,25 +470,25 @@ static void test_reference_group() // Check number of objects in the group dereferenced by constructor hsize_t nobjs = refgroup.getNumObjs(); - verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs",__LINE__,__FILE__); + verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs", __LINE__, __FILE__); // Check number of objects in the group dereferenced by ::reference nobjs = group.getNumObjs(); - verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs",__LINE__,__FILE__); + verify_val(nobjs, (hsize_t)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__); + 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__); + verify_val(fname, FILE1, "H5Group::getFileName", __LINE__, __FILE__); // Check object type using Group::getObjinfo() H5O_info_t oinfo; HDmemset(&oinfo, 0, sizeof(oinfo)); group.getObjinfo(".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, oinfo); - verify_val(oinfo.type, H5O_TYPE_DATASET, "Group::getObjinfo",__LINE__,__FILE__); + verify_val(oinfo.type, H5O_TYPE_DATASET, "Group::getObjinfo", __LINE__, __FILE__); // Check for out of bound query by index try { @@ -494,12 +497,14 @@ static void test_reference_group() // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("Group::getObjinfo", "Out of bound index."); - } catch (Exception& err) {} // do nothing, failure expected + } + catch (Exception &err) { + } // do nothing, failure expected // Unlink one of the objects in the dereferenced group, and re-check refgroup.unlink(GROUPNAME2); nobjs = refgroup.getNumObjs(); - verify_val(nobjs, (hsize_t)2, "H5Group::getNumObjs",__LINE__,__FILE__); + verify_val(nobjs, (hsize_t)2, "H5Group::getNumObjs", __LINE__, __FILE__); // Close resources group.close(); @@ -509,17 +514,14 @@ static void test_reference_group() PASSED(); } // end try - catch (Exception& E) - { - issue_fail_msg("test_reference_group()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + catch (Exception &E) { + issue_fail_msg("test_reference_group()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg()); } - if(file1) + if (file1) delete file1; -} /* test_reference_group() */ +} /* test_reference_group() */ - /*------------------------------------------------------------------------- * Function: test_reference_region_1D * @@ -528,30 +530,31 @@ static void test_reference_group() * Return None *------------------------------------------------------------------------- */ -static void test_reference_region_1D() +static void +test_reference_region_1D() { - 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 */ + 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 + 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); + 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); @@ -559,7 +562,7 @@ static void test_reference_region_1D() H5File file1(FILE2, H5F_ACC_TRUNC); // Create dataspace for datasets - hsize_t dims3[] = {SPACE3_DIM1}; + hsize_t dims3[] = {SPACE3_DIM1}; DataSpace sid3(SPACE3_RANK, dims3); // Create dataset access property list @@ -568,7 +571,7 @@ static void test_reference_region_1D() // Create a dataset DataSet dset3 = file1.createDataSet(DSET2_NAME, PredType::STD_U8LE, sid3); - uint8_t *tu8; // Temporary pointer to uint8 data + uint8_t *tu8; // Temporary pointer to uint8 data for (tu8 = dwbuf, i = 0; i < SPACE3_DIM1; i++) *tu8++ = i * 3; // from C test @@ -579,7 +582,7 @@ static void test_reference_region_1D() dset3.close(); // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create a dataset @@ -590,24 +593,24 @@ static void test_reference_region_1D() */ /* Select 15 2x1 hyperslabs for first reference */ - start[0] = 2; + start[0] = 2; stride[0] = 5; - count[0] = 15; - block[0] = 2; + 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__); + 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__); + verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__); /* Select sequence of ten points for second reference */ coord1[0][0] = 16; @@ -626,7 +629,7 @@ static void test_reference_region_1D() // Get and verify the number of elements in a dataspace selection nelms = sid3.getSelectNpoints(); - verify_val(nelms, 10, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(nelms, 10, "DataSet::getRefObjType", __LINE__, __FILE__); // Store first dataset region file1.reference(&wbuf[1], "/Dataset2", sid3); @@ -658,12 +661,12 @@ static void test_reference_region_1D() // 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__); + verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__); // Get dataspace of dset3 the verify number of elements - sid1 = dset3.getSpace(); + sid1 = dset3.getSpace(); nelms = sid1.getSimpleExtentNpoints(); - verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); } // End of test DataSet::dereference { // Test DataSet constructor -by dereference @@ -672,9 +675,9 @@ static void test_reference_region_1D() DataSet newds(dset1, &rbuf[0], H5R_DATASET_REGION, dapl); // Get dataspace of newds then verify number of elements - sid1 = newds.getSpace(); + sid1 = newds.getSpace(); nelms = sid1.getSimpleExtentNpoints(); - verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Close objects for this mini test newds.close(); @@ -684,8 +687,8 @@ static void test_reference_region_1D() // 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__); + 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 @@ -696,11 +699,11 @@ static void test_reference_region_1D() // Get and verify number of elements in a dataspace selection nelms = reg_sp.getSelectNpoints(); - verify_val((long)nelms, 30, "DataSpace::getSelectNpoints",__LINE__,__FILE__); + 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__); + 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); @@ -709,43 +712,43 @@ static void test_reference_region_1D() reg_sp.getSelectHyperBlocklist((hsize_t)0, (hsize_t)nelms, coords); // Verify values in the list - verify_val(coords[0], (hsize_t)2, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[1], (hsize_t)3, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[2], (hsize_t)7, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[3], (hsize_t)8, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[4],(hsize_t)12, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[5],(hsize_t)13, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[6],(hsize_t)17, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[7],(hsize_t)18, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[8],(hsize_t)22, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[9],(hsize_t)23, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[10],(hsize_t)27, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[11],(hsize_t)28, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[12],(hsize_t)32, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[13],(hsize_t)33, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[14],(hsize_t)37, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[15],(hsize_t)38, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[16],(hsize_t)42, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[17],(hsize_t)43, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[18],(hsize_t)47, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[19],(hsize_t)48, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[20],(hsize_t)52, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[21],(hsize_t)53, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[22],(hsize_t)57, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[23],(hsize_t)58, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[24],(hsize_t)62, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[25],(hsize_t)63, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[26],(hsize_t)67, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[27],(hsize_t)68, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[28],(hsize_t)72, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[29],(hsize_t)73, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[0], (hsize_t)2, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[1], (hsize_t)3, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[2], (hsize_t)7, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[3], (hsize_t)8, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[4], (hsize_t)12, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[5], (hsize_t)13, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[6], (hsize_t)17, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[7], (hsize_t)18, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[8], (hsize_t)22, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[9], (hsize_t)23, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[10], (hsize_t)27, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[11], (hsize_t)28, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[12], (hsize_t)32, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[13], (hsize_t)33, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[14], (hsize_t)37, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[15], (hsize_t)38, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[16], (hsize_t)42, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[17], (hsize_t)43, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[18], (hsize_t)47, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[19], (hsize_t)48, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[20], (hsize_t)52, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[21], (hsize_t)53, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[22], (hsize_t)57, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[23], (hsize_t)58, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[24], (hsize_t)62, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[25], (hsize_t)63, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[26], (hsize_t)67, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[27], (hsize_t)68, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[28], (hsize_t)72, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[29], (hsize_t)73, "Hyperslab Coordinates", __LINE__, __FILE__); HDfree(coords); // Check boundaries reg_sp.getSelectBounds(low, high); - verify_val(low[0],(hsize_t)2, "DataSpace::getSelectBounds",__LINE__,__FILE__); - verify_val(high[0],(hsize_t)73, "DataSpace::getSelectBounds",__LINE__,__FILE__); + verify_val(low[0], (hsize_t)2, "DataSpace::getSelectBounds", __LINE__, __FILE__); + verify_val(high[0], (hsize_t)73, "DataSpace::getSelectBounds", __LINE__, __FILE__); /* Close region space */ reg_sp.close(); @@ -759,7 +762,7 @@ static void test_reference_region_1D() // 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__); + 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)); @@ -768,23 +771,23 @@ static void test_reference_region_1D() 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__); + 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],(hsize_t)3, "DataSpace::getSelectBounds",__LINE__,__FILE__); - verify_val(high[0],(hsize_t)97, "DataSpace::getSelectBounds",__LINE__,__FILE__); + verify_val(low[0], (hsize_t)3, "DataSpace::getSelectBounds", __LINE__, __FILE__); + verify_val(high[0], (hsize_t)97, "DataSpace::getSelectBounds", __LINE__, __FILE__); // Close element space elm_sp.close(); @@ -803,12 +806,10 @@ static void test_reference_region_1D() PASSED(); } // end try - catch (Exception& E) - { - issue_fail_msg("test_reference_region_1D()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + catch (Exception &E) { + issue_fail_msg("test_reference_region_1D()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg()); } -} /* test_reference_region_1D() */ +} /* test_reference_region_1D() */ /*------------------------------------------------------------------------- * @@ -816,8 +817,8 @@ static void test_reference_region_1D() * *------------------------------------------------------------------------- */ -extern "C" -void test_reference() +extern "C" void +test_reference() { // Output message about test being performed MESSAGE(5, ("Testing References\n")); @@ -827,9 +828,8 @@ void test_reference() test_reference_group(); // Test group reference functionality test_reference_region_1D(); // Test 1-D reference functionality -} // test_reference() +} // test_reference() - /*------------------------------------------------------------------------- * Function: cleanup_reference * @@ -838,10 +838,9 @@ void test_reference() * Return None *------------------------------------------------------------------------- */ -extern "C" -void cleanup_reference() +extern "C" void +cleanup_reference() { HDremove(FILE1.c_str()); HDremove(FILE2.c_str()); } - diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp index b8846f4..50f9282 100644 --- a/c++/test/ttypes.cpp +++ b/c++/test/ttypes.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,26 +16,22 @@ ttypes.cpp - HDF5 C++ testing the general datatype functionality ***************************************************************************/ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file /* * Offset from alinged memory returned by malloc(). This can be used to test * that type conversions handle non-aligned buffers correctly. */ -#define ALIGNMENT 1 +#define ALIGNMENT 1 /* * Define if you want to test alignment code on a machine that doesn't @@ -50,35 +46,34 @@ using namespace H5; #define H5T_FRIEND #include "H5Tpkg.h" #endif -#define SET_ALIGNMENT(TYPE,VAL) \ - H5T_NATIVE_##TYPE##_ALIGN_g=MAX(H5T_NATIVE_##TYPE##_ALIGN_g, VAL) +#define SET_ALIGNMENT(TYPE, VAL) H5T_NATIVE_##TYPE##_ALIGN_g = MAX(H5T_NATIVE_##TYPE##_ALIGN_g, VAL) #endif - /* #include "H5Tpkg.h" +/* #include "H5Tpkg.h" */ -const char *FILENAME[] = { - "dtypes1.h5", - "dtypes2.h5", - "dtypes3.h5", - "dtypes4.h5", - NULL -}; +const char *FILENAME[] = {"dtypes1.h5", "dtypes2.h5", "dtypes3.h5", "dtypes4.h5", NULL}; /* * Count up or down depending on whether the machine is big endian or little * endian. If local variable `endian' is H5T_ORDER_BE then the result will * be I, otherwise the result will be Z-(I+1). */ -#define ENDIAN(Z,I) (H5T_ORDER_BE==endian?(I):(Z)-((I)+1)) - +#define ENDIAN(Z, I) (H5T_ORDER_BE == endian ? (I) : (Z) - ((I) + 1)) -typedef enum flt_t { - FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER -} flt_t; +typedef enum flt_t { FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER } flt_t; typedef enum int_t { - INT_CHAR, INT_UCHAR, INT_SHORT, INT_USHORT, INT_INT, INT_UINT, - INT_LONG, INT_ULONG, INT_LLONG, INT_ULLONG, INT_OTHER + INT_CHAR, + INT_UCHAR, + INT_SHORT, + INT_USHORT, + INT_INT, + INT_UINT, + INT_LONG, + INT_ULONG, + INT_LLONG, + INT_ULLONG, + INT_OTHER } int_t; typedef struct { @@ -88,7 +83,6 @@ typedef struct { double d; } src_typ_t; - /*------------------------------------------------------------------------- * Function: test_classes * @@ -100,7 +94,8 @@ typedef struct { * January, 2007 *------------------------------------------------------------------------- */ -static void test_classes() +static void +test_classes() { SUBTEST("PredType::getClass()"); try { @@ -108,24 +103,23 @@ static void test_classes() // PredType::NATIVE_INT should be in H5T_INTEGER class H5T_class_t tcls = PredType::NATIVE_INT.getClass(); - if (H5T_INTEGER!=tcls) { + if (H5T_INTEGER != tcls) { puts(" Invalid type class for H5T_NATIVE_INT"); } // PredType::NATIVE_DOUBLE should be in H5T_FLOAT class tcls = PredType::NATIVE_DOUBLE.getClass(); - if (H5T_FLOAT!=tcls) { - verify_val(tcls, H5T_FLOAT, "test_class: invalid type class for NATIVE_DOUBLE -", __LINE__, __FILE__); + if (H5T_FLOAT != tcls) { + verify_val(tcls, H5T_FLOAT, "test_class: invalid type class for NATIVE_DOUBLE -", __LINE__, + __FILE__); } PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_classes", __LINE__, __FILE__, E.getCDetailMsg()); } } - /*------------------------------------------------------------------------- * Function: test_copy * @@ -137,7 +131,8 @@ static void test_classes() * January, 2007 *------------------------------------------------------------------------- */ -static void test_copy() +static void +test_copy() { SUBTEST("DataType::copy() and DataType::operator="); @@ -148,7 +143,7 @@ static void test_copy() // Test copying a predefined type using DataType::copy DataType copied_type; - copied_type.copy (PredType::STD_B8LE); + copied_type.copy(PredType::STD_B8LE); // Test copying a user-defined type using DataType::operator= DataType assigned_usertype; @@ -159,7 +154,7 @@ static void test_copy() copied_usertype.copy(copied_type); // Test copying a user-defined int type using DataType::operator= - IntType orig_int(PredType::STD_B8LE); + IntType orig_int(PredType::STD_B8LE); DataType generic_type; generic_type = orig_int; @@ -172,13 +167,11 @@ static void test_copy() PASSED(); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_copy", __LINE__, __FILE__, E.getCDetailMsg()); } } - /*------------------------------------------------------------------------- * Function: test_detect_type_class * @@ -190,29 +183,30 @@ static void test_copy() * August, 2017 *------------------------------------------------------------------------- */ -typedef struct { /* Struct with atomic fields */ - int i; - float f; - char c; - double d; - short s; +typedef struct { /* Struct with atomic fields */ + int i; + float f; + char c; + double d; + short s; } atomic_typ_t; -typedef struct { /* Struct with complex fields */ - hobj_ref_t arr_r[3][3]; - int i; - hvl_t vl_f; - hvl_t vl_s; - char c; - short s; +typedef struct { /* Struct with complex fields */ + hobj_ref_t arr_r[3][3]; + int i; + hvl_t vl_f; + hvl_t vl_s; + char c; + short s; } complex_typ_t; -static void test_detect_type_class() +static void +test_detect_type_class() { SUBTEST("DataType::detectClass()"); try { - bool in_class = false; // indicates whether a datatype is in a class + bool in_class = false; // indicates whether a datatype is in a class /* * Test class of some atomic types. @@ -260,8 +254,8 @@ static void test_detect_type_class() */ // Create an array datatype with an atomic base type - unsigned rank = 2; // Rank for array datatype - hsize_t dims[2] = {3,3}; // Dimensions for array datatype + unsigned rank = 2; // Rank for array datatype + hsize_t dims[2] = {3, 3}; // Dimensions for array datatype ArrayType atom_arr(PredType::STD_REF_OBJ, rank, dims); // Make certain that the correct classes can be detected @@ -367,13 +361,11 @@ static void test_detect_type_class() PASSED(); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_detect_type_class", __LINE__, __FILE__, E.getCDetailMsg()); } } - /*------------------------------------------------------------------------- * Function: test_vltype * @@ -385,12 +377,12 @@ static void test_detect_type_class() * August, 2017 *------------------------------------------------------------------------- */ -static void test_vltype() +static void +test_vltype() { // Output message about test being performed SUBTEST("VarLenType functions"); - try - { + try { VarLenType vltype(PredType::NATIVE_INT); bool in_class = vltype.detectClass(H5T_VLEN); @@ -408,9 +400,11 @@ static void test_vltype() in_class = vltype2.detectClass(H5T_VLEN); verify_val(in_class, true, "VarLenType::detectClass() with H5T_VLEN for vltype2", __LINE__, __FILE__); in_class = vltype2.detectClass(H5T_INTEGER); - verify_val(in_class, true, "VarLenType::detectClass() with H5T_INTEGER for vltype2", __LINE__, __FILE__); + verify_val(in_class, true, "VarLenType::detectClass() with H5T_INTEGER for vltype2", __LINE__, + __FILE__); in_class = vltype2.detectClass(H5T_FLOAT); - verify_val(in_class, false, "VarLenType::detectClass() with H5T_FLOAT for vltype2", __LINE__, __FILE__); + verify_val(in_class, false, "VarLenType::detectClass() with H5T_FLOAT for vltype2", __LINE__, + __FILE__); // Create a new file to use in this test H5File file(FILENAME[3], H5F_ACC_TRUNC); @@ -435,17 +429,16 @@ static void test_vltype() in_class = vltype2.detectClass(H5T_VLEN); verify_val(in_class, true, "VarLenType::detectClass() with H5T_VLEN for vltype2", __LINE__, __FILE__); in_class = first_vlt_again.detectClass(H5T_FLOAT); - verify_val(in_class, true, "VarLenType::detectClass() with H5T_FLOAT for first_vlt_again", __LINE__, __FILE__); + verify_val(in_class, true, "VarLenType::detectClass() with H5T_FLOAT for first_vlt_again", __LINE__, + __FILE__); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_vltype", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_vltype +} // test_vltype - /*------------------------------------------------------------------------- * Function: test_query * @@ -460,14 +453,14 @@ static void test_vltype() const H5std_string CompT_NAME("Compound_type"); const H5std_string EnumT_NAME("Enum_type"); -static void test_query() +static void +test_query() { - short enum_val; + short enum_val; // Output message about test being performed SUBTEST("Query functions of compound and enumeration types"); - try - { + try { // Create File H5File file(FILENAME[2], H5F_ACC_TRUNC); @@ -482,11 +475,11 @@ static void test_query() // Create a enumerate datatype EnumType tid2(sizeof(short)); - tid2.insert("RED", (enum_val=0,&enum_val)); - tid2.insert("GREEN", (enum_val=1,&enum_val)); - tid2.insert("BLUE", (enum_val=2,&enum_val)); - tid2.insert("ORANGE", (enum_val=3,&enum_val)); - tid2.insert("YELLOW", (enum_val=4,&enum_val)); + tid2.insert("RED", (enum_val = 0, &enum_val)); + tid2.insert("GREEN", (enum_val = 1, &enum_val)); + tid2.insert("BLUE", (enum_val = 2, &enum_val)); + tid2.insert("ORANGE", (enum_val = 3, &enum_val)); + tid2.insert("YELLOW", (enum_val = 4, &enum_val)); // Query member number and member index by name, for compound type int nmembs = tid1.getNmembers(); @@ -506,10 +499,10 @@ static void test_query() // prop list, then close it tid1.commit(file, CompT_NAME); PropList tcpl = tid1.getCreatePlist(); - if (!IdComponent::isValid(tcpl.getId())) - { + if (!IdComponent::isValid(tcpl.getId())) { // Throw an invalid action exception - throw InvalidActionException("H5Object::createAttribute", "Datatype creation property list is not valid"); + throw InvalidActionException("H5Object::createAttribute", + "Datatype creation property list is not valid"); } tcpl.close(); tid1.close(); @@ -518,10 +511,10 @@ static void test_query() // prop list, then close it tid2.commit(file, EnumT_NAME); tcpl = tid2.getCreatePlist(); - if (!IdComponent::isValid(tcpl.getId())) - { + if (!IdComponent::isValid(tcpl.getId())) { // Throw an invalid action exception - throw InvalidActionException("H5Object::createAttribute", "Datatype creation property list is not valid"); + throw InvalidActionException("H5Object::createAttribute", + "Datatype creation property list is not valid"); } tcpl.close(); tid2.close(); @@ -560,14 +553,12 @@ static void test_query() H5File file1(FILENAME[2], H5F_ACC_TRUNC); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_query", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_query +} // test_query - /*------------------------------------------------------------------------- * Function: test_transient * @@ -579,17 +570,18 @@ static void test_query() * January, 2007 *------------------------------------------------------------------------- */ -const char* filename1 = "dtypes1.h5"; +const char *filename1 = "dtypes1.h5"; -static void test_transient () +static void +test_transient() { - static hsize_t ds_size[2] = {10, 20}; + static hsize_t ds_size[2] = {10, 20}; SUBTEST("Transient datatypes"); try { // Create the file and the dataspace. - H5File file(filename1, H5F_ACC_TRUNC); + H5File file(filename1, H5F_ACC_TRUNC); DataSpace space(2, ds_size, ds_size); // Copying a predefined type results in a modifiable copy @@ -600,8 +592,11 @@ static void test_transient () try { Attribute attr(type.createAttribute("attr1", PredType::NATIVE_INT, space)); // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("H5Object::createAttribute", "Attempted to commit a predefined datatype."); - } catch (AttributeIException& err) {} // do nothing, failure expected + throw InvalidActionException("H5Object::createAttribute", + "Attempted to commit a predefined datatype."); + } + catch (AttributeIException &err) { + } // do nothing, failure expected // Create a dataset from a transient datatype // type.close(); - put trace in H5Tclose to make sure it's closed @@ -614,8 +609,11 @@ static void test_transient () itype.setPrecision(256); // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("PredType::setPrecision", "Dataset datatypes should not be modifiable!"); - } catch (DataTypeIException& err) {} + throw InvalidActionException("PredType::setPrecision", + "Dataset datatypes should not be modifiable!"); + } + catch (DataTypeIException &err) { + } itype.close(); // Get a copy of the dataset's datatype by applying DataType::copy() @@ -635,14 +633,12 @@ static void test_transient () type.close(); space.close(); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_transient", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_transient +} // test_transient - /*------------------------------------------------------------------------- * Function: test_named * @@ -656,12 +652,12 @@ static void test_transient () */ const H5std_string filename2("dtypes2.h5"); -static void test_named () +static void +test_named() { static hsize_t ds_size[2] = {10, 20}; - hsize_t i; - unsigned attr_data[10][20]; - DataType *ds_type = NULL; + unsigned attr_data[10][20]; + DataType * ds_type = NULL; SUBTEST("Named datatypes"); try { @@ -678,15 +674,16 @@ static void test_named () // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("PredType::commit", "Attempted to commit a predefined datatype."); - } catch (DataTypeIException& err) {} + } + catch (DataTypeIException &err) { + } // Copy a predefined datatype and commit the copy. IntType itype(PredType::NATIVE_INT); itype.commit(file, "native-int"); // Test commit passing in const H5File& for prototype with const - try - { + try { // Create random char type IntType atype(PredType::NATIVE_UCHAR); @@ -696,9 +693,8 @@ static void test_named () // Commit type passing in const group; compilation would fail if // no matching prototype atype.commit(const_grp, "random uchar"); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_named", __LINE__, __FILE__, "Commit at const group"); } @@ -708,11 +704,14 @@ static void test_named () // We should not be able to modify a type after it has been committed. try { - itype.setPrecision(256); // attempt an invalid action... + itype.setPrecision(256); // attempt an invalid action... // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("IntType::setPrecision", "Attempted to modify a committed datatype."); - } catch (DataTypeIException& err) {} + throw InvalidActionException("IntType::setPrecision", + "Attempted to modify a committed datatype."); + } + catch (DataTypeIException &err) { + } // We should not be able to re-commit a committed type try { @@ -720,12 +719,17 @@ static void test_named () // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("IntType::commit", "Attempted to re-commit a committed datatype."); - } catch (DataTypeIException& err) {} // do nothing, failure expected + } + catch (DataTypeIException &err) { + } // do nothing, failure expected // It should be possible to define an attribute for the named type Attribute attr1 = itype.createAttribute("attr1", PredType::NATIVE_UCHAR, space); - for (i=0; i<ds_size[0]*ds_size[1]; i++) - attr_data[0][i] = (int)i;/*tricky*/ + for (hsize_t i = 0; i < ds_size[0]; i++) { + for (hsize_t j = 0; j < ds_size[1]; j++) { + attr_data[i][j] = static_cast<unsigned>(i * ds_size[1] + j); + } + } attr1.write(PredType::NATIVE_UINT, attr_data); attr1.close(); @@ -734,13 +738,15 @@ static void test_named () IntType trans_type; trans_type.copy(itype); bool iscommitted = trans_type.committed(); - verify_val(iscommitted, 0, "DataType::committed() - Copying a named type should result in a transient type!", __LINE__, __FILE__); + verify_val(iscommitted, 0, + "DataType::committed() - Copying a named type should result in a transient type!", + __LINE__, __FILE__); trans_type.setPrecision(256); trans_type.close(); // Close the committed type and reopen it. It should be a named type. itype.close(); - itype = file.openIntType("native-int"); + itype = file.openIntType("native-int"); iscommitted = itype.committed(); if (!iscommitted) throw InvalidActionException("IntType::committed()", "Opened named types should be named types!"); @@ -748,8 +754,8 @@ static void test_named () // Create a dataset that uses the named type, then get the dataset's // datatype and make sure it's a named type. DataSet dset = file.createDataSet("dset1", itype, space); - ds_type = new DataType(dset.getDataType()); - iscommitted = ds_type->committed(); + ds_type = new DataType(dset.getDataType()); + iscommitted = ds_type->committed(); if (!iscommitted) throw InvalidActionException("IntType::committed()", "Dataset type should be named type!"); dset.close(); @@ -758,8 +764,8 @@ static void test_named () // Reopen the dataset and its type, then make sure the type is // a named type. - dset = file.openDataSet("dset1"); - ds_type = new DataType(dset.getDataType()); + dset = file.openDataSet("dset1"); + ds_type = new DataType(dset.getDataType()); iscommitted = ds_type->committed(); if (!iscommitted) throw InvalidActionException("IntType::committed()", "Dataset type should be named type!"); @@ -773,8 +779,8 @@ static void test_named () delete ds_type; // Reopen the second dataset and make sure the type is shared - dset = file.openDataSet("dset2"); - ds_type = new DataType(dset.getDataType()); + dset = file.openDataSet("dset2"); + ds_type = new DataType(dset.getDataType()); iscommitted = ds_type->committed(); if (!iscommitted) throw InvalidActionException("DataType::iscommitted()", "Dataset type should be named type!"); @@ -793,17 +799,15 @@ static void test_named () space.close(); file.close(); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_named", __LINE__, __FILE__, E.getCDetailMsg()); } - if(ds_type) + if (ds_type) delete ds_type; -} // test_named +} // test_named - /*------------------------------------------------------------------------- * Function: test_encode_decode * @@ -816,12 +820,13 @@ static void test_named () *------------------------------------------------------------------------- */ const H5std_string filename3("encode_decode.h5"); -const int ARRAY1_RANK = 1; -const int ARRAY1_DIM = 10; +const int ARRAY1_RANK = 1; +const int ARRAY1_DIM = 10; -static void test_encode_decode() +static void +test_encode_decode() { - short enum_val; + short enum_val; SUBTEST("DataType::encode() and DataType::decode()"); try { @@ -847,7 +852,7 @@ static void test_encode_decode() verify_val(cmptyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__); // Decode compound type's buffer to a new CompType - CompType* decoded_cmp_ptr(static_cast<CompType *>(cmptyp.decode())); + CompType *decoded_cmp_ptr(static_cast<CompType *>(cmptyp.decode())); // Verify that the datatype was copied exactly via encoding/decoding verify_val(cmptyp == *decoded_cmp_ptr, true, "DataType::decode", __LINE__, __FILE__); @@ -871,11 +876,11 @@ static void test_encode_decode() // Create a enumerate datatype EnumType enumtyp(sizeof(short)); - enumtyp.insert("RED", (enum_val=0,&enum_val)); - enumtyp.insert("GREEN", (enum_val=1,&enum_val)); - enumtyp.insert("BLUE", (enum_val=2,&enum_val)); - enumtyp.insert("ORANGE", (enum_val=3,&enum_val)); - enumtyp.insert("YELLOW", (enum_val=4,&enum_val)); + enumtyp.insert("RED", (enum_val = 0, &enum_val)); + enumtyp.insert("GREEN", (enum_val = 1, &enum_val)); + enumtyp.insert("BLUE", (enum_val = 2, &enum_val)); + enumtyp.insert("ORANGE", (enum_val = 3, &enum_val)); + enumtyp.insert("YELLOW", (enum_val = 4, &enum_val)); // Encode compound type in a buffer enumtyp.encode(); @@ -884,7 +889,7 @@ static void test_encode_decode() verify_val(enumtyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__); // Decode enumeration type's buffer to a new EnumType - EnumType* decoded_enum_ptr(static_cast<EnumType *>(enumtyp.decode())); + EnumType *decoded_enum_ptr(static_cast<EnumType *>(enumtyp.decode())); // Verify that the datatype was copied exactly via encoding/decoding verify_val(enumtyp == *decoded_enum_ptr, true, "DataType::decode", __LINE__, __FILE__); @@ -916,7 +921,7 @@ static void test_encode_decode() verify_val(vlsttyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__); // Decode the variable-length type's buffer to a new StrType - StrType* decoded_str_ptr(static_cast<StrType *>(vlsttyp.decode())); + StrType *decoded_str_ptr(static_cast<StrType *>(vlsttyp.decode())); verify_val(vlsttyp == *decoded_str_ptr, true, "DataType::decode", __LINE__, __FILE__); verify_val(decoded_str_ptr->isVariableStr(), true, "DataType::decode", __LINE__, __FILE__); @@ -926,7 +931,7 @@ static void test_encode_decode() // Test decoding the type by way of DataType* // Decode variable-length string type to a new DataType - DataType* decoded_vlstr_ptr(vlsttyp.decode()); + DataType *decoded_vlstr_ptr(vlsttyp.decode()); // Create a StrType instance from the DataType object and verify it StrType decoded_vlsttyp(decoded_vlstr_ptr->getId()); @@ -951,7 +956,7 @@ static void test_encode_decode() verify_val(arrtyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__); // Create an ArrayType instance from the decoded pointer and verify it - ArrayType* decoded_arr_ptr(static_cast<ArrayType *>(arrtyp.decode())); + ArrayType *decoded_arr_ptr(static_cast<ArrayType *>(arrtyp.decode())); verify_val(arrtyp == *decoded_arr_ptr, true, "DataType::decode", __LINE__, __FILE__); @@ -983,7 +988,7 @@ static void test_encode_decode() verify_val(inttyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__); // Create an IntType instance from the decoded pointer and verify it - IntType* decoded_int_ptr(static_cast<IntType *>(inttyp.decode())); + IntType * decoded_int_ptr(static_cast<IntType *>(inttyp.decode())); H5T_sign_t int_sign = decoded_int_ptr->getSign(); verify_val(int_sign, H5T_SGN_NONE, "DataType::decode", __LINE__, __FILE__); verify_val(inttyp == *decoded_int_ptr, true, "DataType::decode", __LINE__, __FILE__); @@ -1004,27 +1009,25 @@ static void test_encode_decode() verify_val(flttyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__); // Decode the array type's buffer - DataType* decoded_flt_ptr(flttyp.decode()); + DataType *decoded_flt_ptr(flttyp.decode()); // Create a IntType instance from the decoded pointer and verify it FloatType decoded_flttyp(decoded_flt_ptr->getId()); verify_val(flttyp == decoded_flttyp, true, "DataType::decode", __LINE__, __FILE__); - //H5std_string norm_string; - //H5T_norm_t mant_norm = decoded_flttyp.getNorm(norm_string); - //verify_val(decoded_flttyp.isVariableStr(), true, "DataType::decode", __LINE__, __FILE__); + // H5std_string norm_string; + // H5T_norm_t mant_norm = decoded_flttyp.getNorm(norm_string); + // verify_val(decoded_flttyp.isVariableStr(), true, "DataType::decode", __LINE__, __FILE__); delete decoded_flt_ptr; PASSED(); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_encode_decode", __LINE__, __FILE__, E.getCDetailMsg()); } } - /*------------------------------------------------------------------------- * Function: test_operators * @@ -1038,9 +1041,10 @@ static void test_encode_decode() */ const H5std_string filename4("h5_type_operators.h5"); -static void test_operators() +static void +test_operators() { - short enum_val; + short enum_val; SUBTEST("DataType::operator== and DataType::operator!="); try { @@ -1073,9 +1077,9 @@ static void test_operators() // Create an enumerate datatype EnumType enumtyp(sizeof(short)); - enumtyp.insert("RED", (enum_val=0,&enum_val)); - enumtyp.insert("GREEN", (enum_val=1,&enum_val)); - enumtyp.insert("BLUE", (enum_val=2,&enum_val)); + enumtyp.insert("RED", (enum_val = 0, &enum_val)); + enumtyp.insert("GREEN", (enum_val = 1, &enum_val)); + enumtyp.insert("BLUE", (enum_val = 2, &enum_val)); // Verify that operator== and operator!= work properly verify_val(cmptyp == enumtyp, false, "DataType::operator==", __LINE__, __FILE__); @@ -1086,7 +1090,7 @@ static void test_operators() // // Create random atomic datatypes - IntType inttyp(PredType::NATIVE_INT); + IntType inttyp(PredType::NATIVE_INT); FloatType flttyp(PredType::NATIVE_FLOAT); // Get the NATIVE_INT member from the compound datatype above @@ -1106,13 +1110,11 @@ static void test_operators() PASSED(); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_operators", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_operators +} // test_operators - /*------------------------------------------------------------------------- * Function: test_types * @@ -1121,8 +1123,8 @@ static void test_operators() * Return None *------------------------------------------------------------------------- */ -extern "C" -void test_types() +extern "C" void +test_types() { // Output message about test being performed MESSAGE(5, ("Testing Generic Data Types\n")); @@ -1138,9 +1140,8 @@ void test_types() test_encode_decode(); test_operators(); -} // test_types() +} // test_types() - /*------------------------------------------------------------------------- * Function: cleanup_types * @@ -1149,9 +1150,9 @@ void test_types() * Return None *------------------------------------------------------------------------- */ -extern "C" -void cleanup_types() +extern "C" void +cleanup_types() { for (int i = 0; i < 3; i++) HDremove(FILENAME[i]); -} // cleanup_types +} // cleanup_types diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp index 2421a87..b371518 100644 --- a/c++/test/tvlstr.cpp +++ b/c++/test/tvlstr.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,26 +18,22 @@ EXTERNAL ROUTINES/VARIABLES: ***************************************************************************/ -#ifdef OLD_HEADER_FILENAME -#include <iostream.h> -#else #include <iostream> -#endif using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file // Data file used in most test functions const H5std_string FILENAME("tvlstr.h5"); // 1-D dataset with fixed dimensions -const int SPACE1_RANK = 1; +const int SPACE1_RANK = 1; const hsize_t SPACE1_DIM1 = 4; /*------------------------------------------------------------------------- @@ -137,10 +133,11 @@ static void test_vlstr_free_custom(void *_mem, void *info) const H5std_string DSET1_NAME("String_ds"); const H5std_string DSET1_DATA("String Dataset"); -static void test_vlstring_dataset() +static void +test_vlstring_dataset() { char *dynstring_ds_write = NULL; - char *string_ds_check = NULL; + char *string_ds_check = NULL; // Output message about test being performed SUBTEST("VL String on Datasets"); @@ -156,7 +153,7 @@ static void test_vlstring_dataset() Group root = file1.openGroup("/"); // Create dataspace for the dataset. - DataSpace ds_space (H5S_SCALAR); + DataSpace ds_space(H5S_SCALAR); // Create an dataset in the root group. DataSet dset1 = root.createDataSet(DSET1_NAME, vlst, ds_space); @@ -166,17 +163,19 @@ static void test_vlstring_dataset() // Read and verify the dataset string as a string of chars. dset1.read(&string_ds_check, vlst); - if(HDstrcmp(string_ds_check, DSET1_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,string_ds_check=%s\n",__LINE__, DSET1_DATA.c_str(), string_ds_check); + if (HDstrcmp(string_ds_check, DSET1_DATA.c_str()) != 0) + TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,string_ds_check=%s\n", __LINE__, + DSET1_DATA.c_str(), string_ds_check); - HDfree(string_ds_check); // note: no need for std::string test + HDfree(string_ds_check); // note: no need for std::string test string_ds_check = NULL; // Read and verify the dataset string as an std::string. H5std_string read_str; dset1.read(read_str, vlst); if (read_str != DSET1_DATA) - TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,read_str=%s\n",__LINE__, DSET1_DATA.c_str(), read_str.c_str()); + TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,read_str=%s\n", __LINE__, + DSET1_DATA.c_str(), read_str.c_str()); // Close the dataset. dset1.close(); @@ -184,7 +183,7 @@ static void test_vlstring_dataset() // Test scalar type dataset with 1 value. dset1 = root.createDataSet("test_scalar_small", vlst, ds_space); - dynstring_ds_write = (char*)HDcalloc(1, sizeof(char)); + dynstring_ds_write = (char *)HDcalloc(2, sizeof(char)); HDmemset(dynstring_ds_write, 'A', 1); // Write data to the dataset, then read it back. @@ -192,8 +191,9 @@ static void test_vlstring_dataset() dset1.read(&string_ds_check, vlst); // Verify data read. - if(HDstrcmp(string_ds_check,dynstring_ds_write)!=0) - TestErrPrintf("VL string datasets don't match!, dynstring_ds_write=%s, string_ds_check=%s\n",dynstring_ds_write,string_ds_check); + if (HDstrcmp(string_ds_check, dynstring_ds_write) != 0) + TestErrPrintf("VL string datasets don't match!, dynstring_ds_write=%s, string_ds_check=%s\n", + dynstring_ds_write, string_ds_check); HDfree(string_ds_check); string_ds_check = NULL; dset1.close(); @@ -209,16 +209,15 @@ static void test_vlstring_dataset() } // end try block // Catch all exceptions. - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_vlstring_dataset()", __LINE__, __FILE__, E.getCDetailMsg()); } - if(dynstring_ds_write) + if (dynstring_ds_write) HDfree(dynstring_ds_write); - if(string_ds_check) + if (string_ds_check) HDfree(string_ds_check); -} // test_vlstring_dataset() +} // test_vlstring_dataset() /*------------------------------------------------------------------------- * Function: test_vlstring_array_dataset @@ -234,22 +233,22 @@ static void test_vlstring_dataset() */ const H5std_string DSSTRARR_NAME("StringArray_dset"); -static void test_vlstring_array_dataset() +static void +test_vlstring_array_dataset() { - const char *string_ds_array[SPACE1_DIM1]= { - "Line 1", "Line 2", "Line 3", "Line 4" - }; // Information to write + const char *string_ds_array[SPACE1_DIM1] = {"Line 1", "Line 2", "Line 3", + "Line 4"}; // Information to write // Output message about test being performed SUBTEST("VL String Array on Datasets"); - H5File* file1 = NULL; + H5File *file1 = NULL; try { // Create file. file1 = new H5File(FILENAME, H5F_ACC_RDWR); // Create dataspace for datasets. - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace ds_space(SPACE1_RANK, dims1); // Create a datatype to refer to. @@ -265,10 +264,10 @@ static void test_vlstring_array_dataset() dataset.read(string_ds_check, vlst); hsize_t ii; - for (ii = 0; ii < SPACE1_DIM1; ii++) - { - if(HDstrcmp(string_ds_check[ii], string_ds_array[ii])!=0) - TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n",__LINE__, string_ds_array[ii], string_ds_check[ii]); + for (ii = 0; ii < SPACE1_DIM1; ii++) { + if (HDstrcmp(string_ds_check[ii], string_ds_array[ii]) != 0) + TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n", __LINE__, + string_ds_array[ii], string_ds_check[ii]); HDfree(string_ds_check[ii]); } @@ -286,14 +285,14 @@ static void test_vlstring_array_dataset() // Create and write another dataset. DataSet dataset2(file1->createDataSet("Dataset2", vlst, scalar_space)); - char *wdata2 = (char*)HDcalloc(65534, sizeof(char)); + char * wdata2 = (char *)HDcalloc(65534, sizeof(char)); HDmemset(wdata2, 'A', 65533); dataset2.write(&wdata2, vlst); char *rdata2; dataset2.read(&rdata2, vlst); - if (HDstrcmp(wdata2, rdata2)!=0) - TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n",__LINE__, wdata2, rdata2); + if (HDstrcmp(wdata2, rdata2) != 0) + TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n", __LINE__, wdata2, rdata2); // Release resources from second dataset operation. scalar_space.close(); @@ -310,12 +309,11 @@ static void test_vlstring_array_dataset() } // end try // Catch all exceptions. - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_vlstring_array_dataset()", __LINE__, __FILE__, E.getCDetailMsg()); } - if(file1) + if (file1) delete file1; } // end test_vlstring_array_dataset() @@ -332,11 +330,12 @@ static void test_vlstring_array_dataset() * *------------------------------------------------------------------------- */ -static void test_vlstrings_special() +static void +test_vlstrings_special() { - const char *wdata[SPACE1_DIM1] = {"one", "two", "", "four"}; + const char *wdata[SPACE1_DIM1] = {"one", "two", "", "four"}; const char *wdata2[SPACE1_DIM1] = {NULL, NULL, NULL, NULL}; - char *rdata[SPACE1_DIM1]; // Information read in + char * rdata[SPACE1_DIM1]; // Information read in // Output message about test being performed. SUBTEST("Special VL Strings"); @@ -346,7 +345,7 @@ static void test_vlstrings_special() H5File file1(FILENAME, H5F_ACC_TRUNC); // Create dataspace for datasets. - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create a datatype to refer to. @@ -360,30 +359,29 @@ static void test_vlstrings_special() // Check data read in. hsize_t ii; // counting variable - for (ii=0; ii<SPACE1_DIM1; ii++) - if(rdata[ii]!=NULL) - TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n",(int)ii,rdata[ii]); + for (ii = 0; ii < SPACE1_DIM1; ii++) + if (rdata[ii] != NULL) + TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", (int)ii, rdata[ii]); // Write dataset to disk, then read it back. dataset.write(wdata, vlst); dataset.read(rdata, vlst); // Compare data read in. - for (ii = 0; ii < SPACE1_DIM1; ii++) - { + for (ii = 0; ii < SPACE1_DIM1; ii++) { size_t wlen = HDstrlen(wdata[ii]); size_t rlen = HDstrlen(rdata[ii]); - if(wlen != rlen) - { - TestErrPrintf("VL data lengths don't match!, strlen(wdata[%d])=%u, strlen(rdata[%d])=%u\n", (int)ii, (unsigned)wlen, (int)ii, (unsigned)rlen); + if (wlen != rlen) { + TestErrPrintf("VL data lengths don't match!, strlen(wdata[%d])=%u, strlen(rdata[%d])=%u\n", + (int)ii, (unsigned)wlen, (int)ii, (unsigned)rlen); continue; } // end if - if(HDstrcmp(wdata[ii],rdata[ii]) != 0) - { - TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", (int)ii, wdata[ii], (int)ii, rdata[ii]); + if (HDstrcmp(wdata[ii], rdata[ii]) != 0) { + TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", (int)ii, wdata[ii], + (int)ii, rdata[ii]); continue; } // end if - } // end for + } // end for // Reclaim the read VL data. DataSet::vlenReclaim((void *)rdata, vlst, sid1); @@ -398,7 +396,7 @@ static void test_vlstrings_special() // Create the property list and set the fill value for the second // dataset. DSetCreatPropList dcpl; - char *fill = NULL; // Fill value + char * fill = NULL; // Fill value dcpl.setFillValue(vlst, &fill); dataset = file1.createDataSet("Dataset4", vlst, sid1, dcpl); @@ -409,9 +407,9 @@ static void test_vlstrings_special() dataset.read(rdata, vlst); // Check data read in. - for (ii=0; ii<SPACE1_DIM1; ii++) - if(rdata[ii]!=NULL) - TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n",(int)ii,rdata[ii]); + for (ii = 0; ii < SPACE1_DIM1; ii++) + if (rdata[ii] != NULL) + TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", (int)ii, rdata[ii]); // Try to write nil strings to disk. dataset.write(wdata2, vlst); @@ -420,9 +418,9 @@ static void test_vlstrings_special() dataset.read(rdata, vlst); // Check data read in. - for (ii=0; ii<SPACE1_DIM1; ii++) - if(rdata[ii]!=NULL) - TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n",(int)ii,rdata[ii]); + for (ii = 0; ii < SPACE1_DIM1; ii++) + if (rdata[ii] != NULL) + TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", (int)ii, rdata[ii]); // Close objects and file. dataset.close(); @@ -434,8 +432,7 @@ static void test_vlstrings_special() } // end try // Catch all exceptions. - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_vlstrings_special()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_vlstrings_special @@ -452,14 +449,15 @@ static void test_vlstrings_special() * *------------------------------------------------------------------------- */ -const H5std_string VLSTR_TYPE("vl_string_type"); +const H5std_string VLSTR_TYPE("vl_string_type"); -static void test_vlstring_type() +static void +test_vlstring_type() { // Output message about test being performed. SUBTEST("VL String Type"); - H5File* file1 = NULL; + H5File *file1 = NULL; try { // Open file. file1 = new H5File(FILENAME, H5F_ACC_RDWR); @@ -525,12 +523,11 @@ static void test_vlstring_type() } // end try block // Catch all exceptions. - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_vlstring_type()", __LINE__, __FILE__, E.getCDetailMsg()); } - if(file1) + if (file1) delete file1; } // end test_vlstring_type() @@ -546,7 +543,8 @@ static void test_vlstring_type() * *------------------------------------------------------------------------- */ -static void test_compact_vlstring() +static void +test_compact_vlstring() { // Output message about test being performed SUBTEST("VL Strings on Compact Dataset"); @@ -556,7 +554,7 @@ static void test_compact_vlstring() H5File file1(FILENAME, H5F_ACC_TRUNC); // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create a datatype to refer to @@ -574,21 +572,23 @@ static void test_compact_vlstring() dataset.write(wdata, vlst); // Read dataset from disk - char *rdata[SPACE1_DIM1]; // Information read in + char *rdata[SPACE1_DIM1]; // Information read in dataset.read(rdata, vlst); // Compare data read in hsize_t i; - for (i=0; i<SPACE1_DIM1; i++) { - if (HDstrlen(wdata[i])!=strlen(rdata[i])) { - TestErrPrintf("VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n",(int)i,(int)strlen(wdata[i]),(int)i,(int)strlen(rdata[i])); + for (i = 0; i < SPACE1_DIM1; i++) { + if (HDstrlen(wdata[i]) != strlen(rdata[i])) { + TestErrPrintf("VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n", + (int)i, (int)strlen(wdata[i]), (int)i, (int)strlen(rdata[i])); continue; } // end if - if (HDstrcmp(wdata[i],rdata[i]) != 0) { - TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n",(int)i,wdata[i],(int)i,rdata[i]); + if (HDstrcmp(wdata[i], rdata[i]) != 0) { + TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", (int)i, wdata[i], + (int)i, rdata[i]); continue; } // end if - } // end for + } // end for // Reclaim the read VL data DataSet::vlenReclaim((void *)rdata, vlst, sid1); @@ -604,11 +604,10 @@ static void test_compact_vlstring() } // end try // Catch all exceptions. - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_compact_vlstrings()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_compact_vlstrings +} // test_compact_vlstrings /*------------------------------------------------------------------------- * Function: test_vlstring_attribute @@ -622,11 +621,12 @@ static void test_compact_vlstring() * *------------------------------------------------------------------------- */ -static char *string_att_write=NULL; +static char * string_att_write = NULL; const H5std_string ATTRSTR_NAME("String_attr"); const H5std_string ATTRSTR_DATA("String Attribute"); -static void test_vlstring_attribute() +static void +test_vlstring_attribute() { // Output message about test being performed SUBTEST("VL String on Attributes"); @@ -642,7 +642,7 @@ static void test_vlstring_attribute() Group root = file1.openGroup("/"); // Create dataspace for the attribute. - DataSpace att_space (H5S_SCALAR); + DataSpace att_space(H5S_SCALAR); // Create an attribute for the root group. Attribute gr_attr = root.createAttribute(ATTRSTR_NAME, vlst, att_space); @@ -653,16 +653,18 @@ static void test_vlstring_attribute() // Read and verify the attribute string as a string of chars. char *string_att_check; gr_attr.read(vlst, &string_att_check); - if(HDstrcmp(string_att_check, ATTRSTR_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,string_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), string_att_check); + if (HDstrcmp(string_att_check, ATTRSTR_DATA.c_str()) != 0) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,string_att_check=%s\n", + __LINE__, ATTRSTR_DATA.c_str(), string_att_check); - HDfree(string_att_check); // note: no need for std::string test + HDfree(string_att_check); // note: no need for std::string test // Read and verify the attribute string as an std::string. H5std_string read_str; gr_attr.read(vlst, read_str); if (read_str != ATTRSTR_DATA) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_str=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_str.c_str()); + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_str=%s\n", __LINE__, + ATTRSTR_DATA.c_str(), read_str.c_str()); // Close group's attribute. gr_attr.close(); @@ -670,7 +672,7 @@ static void test_vlstring_attribute() // Test creating a "large" sized string attribute gr_attr = root.createAttribute("test_scalar_large", vlst, att_space); - string_att_write = (char*)HDcalloc(8192, sizeof(char)); + string_att_write = (char *)HDcalloc(8192, sizeof(char)); HDmemset(string_att_write, 'A', 8191); // Write data to the attribute, then read it back. @@ -678,8 +680,9 @@ static void test_vlstring_attribute() gr_attr.read(vlst, &string_att_check); // Verify data read. - if(HDstrcmp(string_att_check,string_att_write)!=0) - TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check); + if (HDstrcmp(string_att_check, string_att_write) != 0) + TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n", + string_att_write, string_att_check); // Release resources. HDfree(string_att_check); @@ -691,11 +694,10 @@ static void test_vlstring_attribute() } // end try block // Catch all exceptions. - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_vlstring_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_vlstring_attribute() +} // test_vlstring_attribute() #if 0 /*------------------------------------------------------------------------- @@ -774,11 +776,11 @@ static void test_read_vl_string_attribute() */ const H5std_string ATTRSTRARR_NAME("StringArray_attr"); -static void test_vlstring_array_attribute() +static void +test_vlstring_array_attribute() { - const char *string_att_array[SPACE1_DIM1]= { - "Line 1", "Line 2", "Line 3", "Line 4" - }; // Information to write + const char *string_att_array[SPACE1_DIM1] = {"Line 1", "Line 2", "Line 3", + "Line 4"}; // Information to write // Output message about test being performed SUBTEST("VL String Array on Attributes"); @@ -794,7 +796,7 @@ static void test_vlstring_array_attribute() Group root = file1.openGroup("/"); // Create dataspace for datasets. - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace att_space(SPACE1_RANK, dims1); // Create an attribute for the root group. @@ -809,12 +811,12 @@ static void test_vlstring_array_attribute() gr_attr.read(vlst, &string_att_check); hsize_t ii; - for (ii = 0; ii < SPACE1_DIM1; ii++) - { - if(HDstrcmp(string_att_check[ii], string_att_array[ii])!=0) - TestErrPrintf("Line %d: Attribute data different: written=%s,read=%s\n",__LINE__, string_att_check[ii], string_att_check[ii]); + for (ii = 0; ii < SPACE1_DIM1; ii++) { + if (HDstrcmp(string_att_check[ii], string_att_array[ii]) != 0) + TestErrPrintf("Line %d: Attribute data different: written=%s,read=%s\n", __LINE__, + string_att_check[ii], string_att_check[ii]); - HDfree(string_att_check[ii]); // note: no need for std::string test + HDfree(string_att_check[ii]); // note: no need for std::string test } // Close group's attribute. @@ -825,15 +827,14 @@ static void test_vlstring_array_attribute() } // end try block // Catch all exceptions. - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_vlstring_array_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_vlstring_array_attribute() +} // test_vlstring_array_attribute() /* Helper routine for test_vl_rewrite() */ -static void write_scalar_dset(H5File& file, DataType& type, DataSpace& space, - char *name, char *data) +static void +write_scalar_dset(H5File &file, DataType &type, DataSpace &space, char *name, char *data) { DataSet dset; try { @@ -841,34 +842,34 @@ static void write_scalar_dset(H5File& file, DataType& type, DataSpace& space, dset.write(&data, type, space, space); dset.close(); } // end try - catch (FileIException& ferr) { + catch (FileIException &ferr) { throw; } - catch (DataSetIException& derr) { + catch (DataSetIException &derr) { throw; } } /* Helper routine for test_vl_rewrite() */ -static void read_scalar_dset(H5File& file, DataType& type, DataSpace& space, - char *name, char *data) +static void +read_scalar_dset(H5File &file, DataType &type, DataSpace &space, char *name, char *data) { - char *data_read; + char * data_read; DataSet dset; try { dset = file.openDataSet(name); dset.read(&data_read, type, space, space); dset.close(); - if(HDstrcmp(data, data_read)) + if (HDstrcmp(data, data_read) != 0) TestErrPrintf("Expected %s for dataset %s but read %s\n", data, name, data_read); HDfree(data_read); } // end try - catch (FileIException& ferr) { + catch (FileIException &ferr) { throw; } - catch (DataSetIException& derr) { + catch (DataSetIException &derr) { throw; } } @@ -887,9 +888,10 @@ static void read_scalar_dset(H5File& file, DataType& type, DataSpace& space, *------------------------------------------------------------------------- */ const H5std_string FILENAME2("tvlstr2.h5"); -const int REWRITE_NDATASETS = 32; +const int REWRITE_NDATASETS = 32; -static void test_vl_rewrite() +static void +test_vl_rewrite() { // Output message about test being performed SUBTEST("I/O on VL strings with link/unlink"); @@ -903,37 +905,37 @@ static void test_vl_rewrite() StrType type(0, H5T_VARIABLE); // Create dataspace for the attribute. - DataSpace space (H5S_SCALAR); + DataSpace space(H5S_SCALAR); // Create in file 1. - int i; + int i; char name[256]; // Buffer for names & data - for (i=0; i<REWRITE_NDATASETS; i++) { + for (i = 0; i < REWRITE_NDATASETS; i++) { sprintf(name, "/set_%d", i); write_scalar_dset(file1, type, space, name, name); } // Effectively copy data from file 1 to 2. - for (i=0; i<REWRITE_NDATASETS; i++) { + for (i = 0; i < REWRITE_NDATASETS; i++) { sprintf(name, "/set_%d", i); read_scalar_dset(file1, type, space, name, name); write_scalar_dset(file2, type, space, name, name); } // Read back from file 2. - for (i=0; i<REWRITE_NDATASETS; i++) { + for (i = 0; i < REWRITE_NDATASETS; i++) { sprintf(name, "/set_%d", i); read_scalar_dset(file2, type, space, name, name); } // Remove from file 2. - for (i=0; i<REWRITE_NDATASETS; i++) { + for (i = 0; i < REWRITE_NDATASETS; i++) { sprintf(name, "/set_%d", i); file2.unlink(name); } // Effectively copy from file 1 to file 2. - for (i=0; i<REWRITE_NDATASETS; i++) { + for (i = 0; i < REWRITE_NDATASETS; i++) { sprintf(name, "/set_%d", i); read_scalar_dset(file1, type, space, name, name); write_scalar_dset(file2, type, space, name, name); @@ -949,8 +951,7 @@ static void test_vl_rewrite() } // end try // Catch all exceptions. - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_vl_rewrite()", __LINE__, __FILE__, E.getCDetailMsg()); } } // end test_vl_rewrite() @@ -967,8 +968,8 @@ static void test_vl_rewrite() * *------------------------------------------------------------------------- */ -extern "C" -void test_vlstrings() +extern "C" void +test_vlstrings() { // Output message about test being performed MESSAGE(5, ("Testing Variable-Length Strings")); @@ -990,9 +991,8 @@ void test_vlstrings() // Test writing VL datasets in files with lots of unlinking test_vl_rewrite(); -} // test_vlstrings() +} // test_vlstrings() - /*------------------------------------------------------------------------- * Function: cleanup_vlstrings * @@ -1001,10 +1001,9 @@ void test_vlstrings() * Return none *------------------------------------------------------------------------- */ -extern "C" -void cleanup_vlstrings() +extern "C" void +cleanup_vlstrings() { HDremove(FILENAME.c_str()); HDremove(FILENAME2.c_str()); } - |