summaryrefslogtreecommitdiffstats
path: root/.fossil-settings
ModeNameSize
-rw-r--r--binary-glob18logstatsplain
-rw-r--r--crnl-glob155logstatsplain
-rw-r--r--encoding-glob155logstatsplain
-rw-r--r--ignore-glob232logstatsplain
+- src/H5T.c | 3736 +-- src/H5TS.c | 98 +- src/H5TSprivate.h | 110 +- src/H5Tarray.c | 146 +- src/H5Tbit.c | 138 +- src/H5Tcommit.c | 512 +- src/H5Tcompound.c | 231 +- src/H5Tconv.c | 6330 ++-- src/H5Tcset.c | 49 +- src/H5Tdbg.c | 106 +- src/H5Tdeprec.c | 85 +- src/H5Tenum.c | 304 +- src/H5Tfields.c | 350 +- src/H5Tfixed.c | 42 +- src/H5Tfloat.c | 202 +- src/H5Tmodule.h | 7 +- src/H5Tnative.c | 1013 +- src/H5Toffset.c | 89 +- src/H5Toh.c | 88 +- src/H5Topaque.c | 35 +- src/H5Torder.c | 117 +- src/H5Tpad.c | 33 +- src/H5Tpkg.h | 1472 +- src/H5Tprecis.c | 95 +- src/H5Tprivate.h | 124 +- src/H5Tpublic.h | 586 +- src/H5Tref.c | 604 +- src/H5Tstrpad.c | 37 +- src/H5Tvisit.c | 60 +- src/H5Tvlen.c | 349 +- src/H5UC.c | 26 +- src/H5UCprivate.h | 14 +- src/H5VL.c | 238 +- src/H5VLcallback.c | 3223 +- src/H5VLconnector.h | 382 +- src/H5VLconnector_passthru.h | 193 +- src/H5VLint.c | 830 +- src/H5VLmodule.h | 7 +- src/H5VLnative.c | 322 +- src/H5VLnative.h | 112 +- src/H5VLnative_attr.c | 626 +- src/H5VLnative_blob.c | 171 +- src/H5VLnative_dataset.c | 710 +- src/H5VLnative_datatype.c | 154 +- src/H5VLnative_file.c | 1065 +- src/H5VLnative_group.c | 296 +- src/H5VLnative_introspect.c | 10 +- src/H5VLnative_link.c | 480 +- src/H5VLnative_object.c | 790 +- src/H5VLnative_private.h | 148 +- src/H5VLnative_token.c | 34 +- src/H5VLpassthru.c | 1277 +- src/H5VLpassthru.h | 16 +- src/H5VLpkg.h | 35 +- src/H5VLprivate.h | 212 +- src/H5VLpublic.h | 70 +- src/H5VM.c | 701 +- src/H5VMprivate.h | 313 +- src/H5WB.c | 63 +- src/H5WBprivate.h | 10 +- src/H5Z.c | 564 +- src/H5Zdeflate.c | 169 +- src/H5Zfletcher32.c | 93 +- src/H5Zmodule.h | 7 +- src/H5Znbit.c | 1302 +- src/H5Zpkg.h | 3 +- src/H5Zprivate.h | 80 +- src/H5Zpublic.h | 132 +- src/H5Zscaleoffset.c | 2190 +- src/H5Zshuffle.c | 308 +- src/H5Zszip.c | 217 +- src/H5Ztrans.c | 1358 +- src/H5api_adpt.h | 325 +- src/H5checksum.c | 210 +- src/H5dbg.c | 45 +- src/H5detect.c | 1135 +- src/H5make_libsettings.c | 96 +- src/H5mpi.c | 137 +- src/H5private.h | 2630 +- src/H5public.h | 367 +- src/H5system.c | 400 +- src/H5timer.c | 148 +- src/H5trace.c | 1379 +- src/H5win32defs.h | 245 +- src/hdf5.h | 68 +- test/H5srcdir.h | 1 - test/accum.c | 1352 +- test/accum_swmr_reader.c | 72 +- test/app_ref.c | 122 +- test/atomic_reader.c | 121 +- test/atomic_writer.c | 63 +- test/big.c | 497 +- test/bittests.c | 1205 +- test/btree2.c | 6008 ++-- test/cache.c | 36115 +++++++++++------------ test/cache_api.c | 1833 +- test/cache_common.c | 3889 +-- test/cache_common.h | 1209 +- test/cache_image.c | 4115 ++- test/cache_logging.c | 101 +- test/cache_tagging.c | 3034 +- test/chunk_info.c | 1312 +- test/cmpd_dset.c | 1952 +- test/cork.c | 1471 +- test/cross_read.c | 189 +- test/dangle.c | 392 +- test/del_many_dense_attrs.c | 96 +- test/direct_chunk.c | 1585 +- test/dsets.c | 12387 ++++---- test/dt_arith.c | 5668 ++-- test/dtransform.c | 960 +- test/dtypes.c | 6286 ++-- test/earray.c | 1475 +- test/efc.c | 2718 +- test/enc_dec_plist.c | 452 +- test/enc_dec_plist_cross_platform.c | 101 +- test/enum.c | 710 +- test/err_compat.c | 241 +- test/error_test.c | 215 +- test/evict_on_close.c | 515 +- test/extend.c | 261 +- test/external.c | 935 +- test/external_common.c | 49 +- test/external_common.h | 9 +- test/external_env.c | 117 +- test/external_fname.h | 12 +- test/farray.c | 771 +- test/fheap.c | 9929 ++++--- test/file_image.c | 634 +- test/filenotclosed.c | 65 +- test/fillval.c | 2434 +- test/filter_fail.c | 279 +- test/filter_plugin.c | 328 +- test/filter_plugin1_dsets.c | 47 +- test/filter_plugin2_dsets.c | 46 +- test/filter_plugin3_dsets.c | 55 +- test/filter_plugin4_groups.c | 56 +- test/flush1.c | 183 +- test/flush2.c | 209 +- test/flushrefresh.c | 1067 +- test/freespace.c | 1947 +- test/gen_bad_compound.c | 22 +- test/gen_bad_offset.c | 69 +- test/gen_bad_ohdr.c | 66 +- test/gen_bogus.c | 107 +- test/gen_bounds.c | 764 +- test/gen_cross.c | 672 +- test/gen_deflate.c | 61 +- test/gen_file_image.c | 44 +- test/gen_filespace.c | 79 +- test/gen_filters.c | 180 +- test/gen_mergemsg.c | 50 +- test/gen_new_array.c | 68 +- test/gen_new_fill.c | 87 +- test/gen_new_group.c | 76 +- test/gen_new_mtime.c | 13 +- test/gen_new_super.c | 16 +- test/gen_noencoder.c | 29 +- test/gen_nullspace.c | 20 +- test/gen_old_array.c | 71 +- test/gen_old_group.c | 26 +- test/gen_old_layout.c | 30 +- test/gen_old_mtime.c | 14 +- test/gen_plist.c | 383 +- test/gen_sizes_lheap.c | 15 +- test/gen_specmetaread.c | 26 +- test/gen_udlinks.c | 104 +- test/genall5.c | 1189 +- test/genall5.h | 4 +- test/getname.c | 3371 ++- test/gheap.c | 317 +- test/h5test.c | 834 +- test/h5test.h | 271 +- test/hdfs.c | 754 +- test/hyperslab.c | 863 +- test/istore.c | 512 +- test/lheap.c | 103 +- test/links.c | 18310 +++++++----- test/links_env.c | 108 +- test/mf.c | 4637 +-- test/mirror_vfd.c | 1213 +- test/mount.c | 3241 +- test/mtime.c | 117 +- test/ntypes.c | 2230 +- test/null_vol_connector.c | 210 +- test/null_vol_connector.h | 5 +- test/objcopy.c | 13512 +++++---- test/objcopy_ref.c | 1584 +- test/ohdr.c | 1575 +- test/page_buffer.c | 1294 +- test/pool.c | 368 +- test/reserved.c | 363 +- test/ros3.c | 882 +- test/s3comms.c | 1661 +- test/set_extent.c | 1886 +- test/space_overflow.c | 15 +- test/stab.c | 1093 +- test/swmr.c | 4235 ++- test/swmr_addrem_writer.c | 182 +- test/swmr_check_compat_vfd.c | 7 +- test/swmr_common.c | 87 +- test/swmr_common.h | 32 +- test/swmr_generator.c | 173 +- test/swmr_reader.c | 240 +- test/swmr_remove_reader.c | 227 +- test/swmr_remove_writer.c | 150 +- test/swmr_sparse_reader.c | 188 +- test/swmr_sparse_writer.c | 194 +- test/swmr_start_write.c | 253 +- test/swmr_writer.c | 186 +- test/tarray.c | 1164 +- test/tattr.c | 3760 +-- test/tcheck_version.c | 70 +- test/tchecksum.c | 44 +- test/tconfig.c | 47 +- test/tcoords.c | 392 +- test/testframe.c | 331 +- test/testhdf5.c | 45 +- test/testhdf5.h | 274 +- test/testmeta.c | 108 +- test/tfile.c | 2620 +- test/tgenprop.c | 783 +- test/th5o.c | 400 +- test/th5s.c | 1283 +- test/theap.c | 516 +- test/thread_id.c | 56 +- test/tid.c | 365 +- test/timer.c | 151 +- test/titerate.c | 560 +- test/tmeta.c | 106 +- test/tmisc.c | 2169 +- test/trefer.c | 949 +- test/trefer_deprec.c | 627 +- test/trefer_shutdown.c | 2 +- test/trefstr.c | 167 +- test/tselect.c | 12065 ++++---- test/tskiplist.c | 1007 +- test/tsohm.c | 1459 +- test/ttime.c | 96 +- test/ttsafe.c | 42 +- test/ttsafe.h | 26 +- test/ttsafe_acreate.c | 72 +- test/ttsafe_attr_vlen.c | 53 +- test/ttsafe_cancel.c | 117 +- test/ttsafe_dcreate.c | 82 +- test/ttsafe_error.c | 68 +- test/ttst.c | 220 +- test/tunicode.c | 1128 +- test/tvlstr.c | 382 +- test/tvltypes.c | 1793 +- test/twriteorder.c | 237 +- test/unlink.c | 2406 +- test/unregister.c | 182 +- test/use.h | 66 +- test/use_append_chunk.c | 51 +- test/use_append_chunk_mirror.c | 74 +- test/use_append_mchunks.c | 57 +- test/use_common.c | 306 +- test/use_disable_mdc_flushes.c | 483 +- test/vds.c | 8414 +++--- test/vds_env.c | 234 +- test/vds_swmr.h | 20 +- test/vds_swmr_gen.c | 157 +- test/vds_swmr_reader.c | 98 +- test/vds_swmr_writer.c | 98 +- test/vfd.c | 1686 +- test/vol.c | 485 +- test/vol_plugin.c | 167 +- testpar/t_2Gio.c | 2758 +- testpar/t_bigio.c | 1801 +- testpar/t_cache.c | 5147 ++-- testpar/t_cache_image.c | 2460 +- testpar/t_chunk_alloc.c | 243 +- testpar/t_coll_chunk.c | 1191 +- testpar/t_coll_md_read.c | 211 +- testpar/t_dset.c | 2481 +- testpar/t_file.c | 474 +- testpar/t_file_image.c | 285 +- testpar/t_filter_read.c | 406 +- testpar/t_filters_parallel.c | 3533 +-- testpar/t_filters_parallel.h | 301 +- testpar/t_init_term.c | 31 +- testpar/t_mdset.c | 1675 +- testpar/t_mpi.c | 618 +- testpar/t_pflush1.c | 105 +- testpar/t_pflush2.c | 115 +- testpar/t_ph5basic.c | 28 +- testpar/t_pread.c | 1105 +- testpar/t_prestart.c | 89 +- testpar/t_prop.c | 179 +- testpar/t_pshutdown.c | 76 +- testpar/t_shapesame.c | 3309 +-- testpar/t_span_tree.c | 2661 +- testpar/testpar.h | 97 +- testpar/testphdf5.c | 514 +- testpar/testphdf5.h | 297 +- tools/lib/h5diff.c | 1223 +- tools/lib/h5diff.h | 155 +- tools/lib/h5diff_array.c | 2365 +- tools/lib/h5diff_attr.c | 334 +- tools/lib/h5diff_dset.c | 608 +- tools/lib/h5diff_util.c | 327 +- tools/lib/h5tools.c | 836 +- tools/lib/h5tools.h | 416 +- tools/lib/h5tools_dump.c | 3116 +- tools/lib/h5tools_dump.h | 100 +- tools/lib/h5tools_error.h | 262 +- tools/lib/h5tools_filters.c | 182 +- tools/lib/h5tools_ref.c | 99 +- tools/lib/h5tools_ref.h | 1 - tools/lib/h5tools_str.c | 1024 +- tools/lib/h5tools_str.h | 45 +- tools/lib/h5tools_type.c | 10 +- tools/lib/h5tools_utils.c | 411 +- tools/lib/h5tools_utils.h | 96 +- tools/lib/h5trav.c | 542 +- tools/lib/h5trav.h | 94 +- tools/lib/io_timer.c | 116 +- tools/lib/io_timer.h | 46 +- tools/lib/ph5diff.h | 33 +- tools/libtest/h5tools_test_utils.c | 768 +- tools/src/h5copy/h5copy.c | 338 +- tools/src/h5diff/h5diff_common.c | 914 +- tools/src/h5diff/h5diff_common.h | 5 +- tools/src/h5diff/h5diff_main.c | 54 +- tools/src/h5diff/ph5diff_main.c | 120 +- tools/src/h5dump/h5dump.c | 1416 +- tools/src/h5dump/h5dump.h | 102 +- tools/src/h5dump/h5dump_ddl.c | 1500 +- tools/src/h5dump/h5dump_ddl.h | 29 +- tools/src/h5dump/h5dump_defines.h | 57 +- tools/src/h5dump/h5dump_extern.h | 97 +- tools/src/h5dump/h5dump_xml.c | 3038 +- tools/src/h5dump/h5dump_xml.h | 18 +- tools/src/h5format_convert/h5format_convert.c | 259 +- tools/src/h5import/h5import.c | 4984 ++-- tools/src/h5import/h5import.h | 196 +- tools/src/h5jam/h5jam.c | 313 +- tools/src/h5jam/h5unjam.c | 201 +- tools/src/h5ls/h5ls.c | 1227 +- tools/src/h5repack/h5repack.c | 225 +- tools/src/h5repack/h5repack.h | 199 +- tools/src/h5repack/h5repack_copy.c | 1485 +- tools/src/h5repack/h5repack_filters.c | 311 +- tools/src/h5repack/h5repack_main.c | 410 +- tools/src/h5repack/h5repack_opttable.c | 106 +- tools/src/h5repack/h5repack_parse.c | 314 +- tools/src/h5repack/h5repack_refs.c | 546 +- tools/src/h5repack/h5repack_verify.c | 366 +- tools/src/h5stat/h5stat.c | 1107 +- tools/src/misc/h5clear.c | 196 +- tools/src/misc/h5debug.c | 487 +- tools/src/misc/h5mkgrp.c | 126 +- tools/src/misc/h5repart.c | 334 +- tools/test/h5copy/dynlib_copy.c | 54 +- tools/test/h5copy/h5copygentest.c | 465 +- tools/test/h5diff/dynlib_diff.c | 54 +- tools/test/h5diff/h5diffgentest.c | 3663 ++- tools/test/h5dump/binread.c | 21 +- tools/test/h5dump/dynlib_dump.c | 54 +- tools/test/h5dump/h5dumpgentest.c | 6451 ++-- tools/test/h5format_convert/h5fc_chk_idx.c | 53 +- tools/test/h5format_convert/h5fc_gentest.c | 587 +- tools/test/h5import/h5importtest.c | 505 +- tools/test/h5jam/getub.c | 73 +- tools/test/h5jam/h5jamgentest.c | 395 +- tools/test/h5jam/tellub.c | 62 +- tools/test/h5ls/dynlib_ls.c | 54 +- tools/test/h5repack/dynlib_rpk.c | 58 +- tools/test/h5repack/dynlib_vrpk.c | 73 +- tools/test/h5repack/h5repackgentest.c | 183 +- tools/test/h5repack/h5repacktst.c | 3902 ++- tools/test/h5repack/testh5repack_detect_szip.c | 9 +- tools/test/h5stat/h5stat_gentest.c | 337 +- tools/test/misc/clear_open_chk.c | 10 +- tools/test/misc/h5clear_gentest.c | 312 +- tools/test/misc/h5perf_gentest.c | 654 +- tools/test/misc/h5repart_gentest.c | 50 +- tools/test/misc/repart_test.c | 50 +- tools/test/misc/talign.c | 114 +- tools/test/misc/vds/UC_1.h | 55 +- tools/test/misc/vds/UC_1_one_dim_gen.c | 177 +- tools/test/misc/vds/UC_2.h | 72 +- tools/test/misc/vds/UC_2_two_dims_gen.c | 192 +- tools/test/misc/vds/UC_3.h | 42 +- tools/test/misc/vds/UC_3_gaps_gen.c | 146 +- tools/test/misc/vds/UC_4.h | 38 +- tools/test/misc/vds/UC_4_printf_gen.c | 138 +- tools/test/misc/vds/UC_5.h | 31 +- tools/test/misc/vds/UC_5_stride_gen.c | 153 +- tools/test/misc/vds/UC_common.h | 19 +- tools/test/perform/chunk.c | 578 +- tools/test/perform/chunk_cache.c | 313 +- tools/test/perform/direct_write_perf.c | 430 +- tools/test/perform/iopipe.c | 188 +- tools/test/perform/overhead.c | 306 +- tools/test/perform/perf.c | 391 +- tools/test/perform/perf_meta.c | 618 +- tools/test/perform/pio_engine.c | 3628 +-- tools/test/perform/pio_perf.c | 1079 +- tools/test/perform/pio_perf.h | 86 +- tools/test/perform/pio_standalone.c | 114 +- tools/test/perform/pio_standalone.h | 676 +- tools/test/perform/sio_engine.c | 1166 +- tools/test/perform/sio_perf.c | 1038 +- tools/test/perform/sio_perf.h | 74 +- tools/test/perform/sio_standalone.c | 63 +- tools/test/perform/sio_standalone.h | 696 +- tools/test/perform/zip_perf.c | 342 +- utils/mirror_vfd/mirror_remote.c | 82 +- utils/mirror_vfd/mirror_remote.h | 23 +- utils/mirror_vfd/mirror_server.c | 197 +- utils/mirror_vfd/mirror_server_stop.c | 66 +- utils/mirror_vfd/mirror_writer.c | 314 +- 1118 files changed, 322298 insertions(+), 320102 deletions(-) diff --git a/c++/examples/chunks.cpp b/c++/examples/chunks.cpp index 03e2855..fdcb6d3 100644 --- a/c++/examples/chunks.cpp +++ b/c++/examples/chunks.cpp @@ -28,20 +28,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; - -int main (void) +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) { - 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 +51,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 +67,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 +80,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 +115,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 +159,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 +179,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 +199,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..45b001e 100644 --- a/c++/examples/compound.cpp +++ b/c++/examples/compound.cpp @@ -29,175 +29,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; - -int main(void) +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) { - /* 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..968c897 100644 --- a/c++/examples/create.cpp +++ b/c++/examples/create.cpp @@ -25,105 +25,99 @@ #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; - -int main (void) +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) { - /* - * 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..9145088 100644 --- a/c++/examples/extend_ds.cpp +++ b/c++/examples/extend_ds.cpp @@ -32,201 +32,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; - -int main (void) +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) { - /* - * 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 271c538..3d2c6d9 100644 --- a/c++/examples/h5group.cpp +++ b/c++/examples/h5group.cpp @@ -32,22 +32,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_info2_t *linfo, - void *opdata); +extern "C" herr_t file_info(hid_t loc_id, const char *name, const H5L_info2_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 +57,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 +70,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 +94,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 +107,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 +129,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 +161,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 +178,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 +227,3 @@ file_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *opdata H5Gclose(group); return 0; } - diff --git a/c++/examples/h5tutr_cmprss.cpp b/c++/examples/h5tutr_cmprss.cpp index e3cf978..23a7aba 100644 --- a/c++/examples/h5tutr_cmprss.cpp +++ b/c++/examples/h5tutr_cmprss.cpp @@ -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; jwrite(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..fdedadf 100644 --- a/c++/examples/h5tutr_crtatt.cpp +++ b/c++/examples/h5tutr_crtatt.cpp @@ -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..aef78d9 100644 --- a/c++/examples/h5tutr_crtdat.cpp +++ b/c++/examples/h5tutr_crtdat.cpp @@ -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..8e48eec 100644 --- a/c++/examples/h5tutr_crtgrp.cpp +++ b/c++/examples/h5tutr_crtgrp.cpp @@ -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..3414cee 100644 --- a/c++/examples/h5tutr_crtgrpar.cpp +++ b/c++/examples/h5tutr_crtgrpar.cpp @@ -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..8ada706 100644 --- a/c++/examples/h5tutr_crtgrpd.cpp +++ b/c++/examples/h5tutr_crtgrpd.cpp @@ -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..71a8ffb 100644 --- a/c++/examples/h5tutr_extend.cpp +++ b/c++/examples/h5tutr_extend.cpp @@ -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..4d265cd 100644 --- a/c++/examples/h5tutr_rdwt.cpp +++ b/c++/examples/h5tutr_rdwt.cpp @@ -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..d4b77c3 100644 --- a/c++/examples/h5tutr_subset.cpp +++ b/c++/examples/h5tutr_subset.cpp @@ -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..e088cce 100644 --- a/c++/examples/readdata.cpp +++ b/c++/examples/readdata.cpp @@ -29,184 +29,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/writedata.cpp b/c++/examples/writedata.cpp index eada2ed..61cd43a 100644 --- a/c++/examples/writedata.cpp +++ b/c++/examples/writedata.cpp @@ -32,31 +32,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 +66,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 +121,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 +136,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 +145,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 +155,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 +203,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 +223,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 +246,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 +269,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 +313,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 +324,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/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp index d59a3cb..da06f05 100644 --- a/c++/src/H5AbstractDs.cpp +++ b/c++/src/H5AbstractDs.cpp @@ -38,7 +38,7 @@ namespace H5 { ///\brief Default constructor // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AbstractDs::AbstractDs(){} +AbstractDs::AbstractDs() {} //-------------------------------------------------------------------------- // Function: AbstractDs default constructor @@ -61,19 +61,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 +83,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 +91,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 +108,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 +118,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 +136,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 +148,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 +166,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 +176,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 +194,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 +204,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 +222,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 +232,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 +250,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 +260,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 +278,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 +288,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 +306,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 +316,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()); } } @@ -326,4 +333,4 @@ VarLenType AbstractDs::getVarLenType() const //-------------------------------------------------------------------------- AbstractDs::~AbstractDs() {} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5AbstractDs.h b/c++/src/H5AbstractDs.h index 399e033..0c66845 100644 --- a/c++/src/H5AbstractDs.h +++ b/c++/src/H5AbstractDs.h @@ -34,49 +34,49 @@ 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 diff --git a/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp index 0dab8ef..877be13 100644 --- a/c++/src/H5ArrayType.cpp +++ b/c++/src/H5ArrayType.cpp @@ -50,7 +50,7 @@ ArrayType::ArrayType(const hid_t existing_id) : DataType(existing_id) {} ///\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 +62,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 +87,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 +106,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 +122,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 +147,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 +159,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 +169,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 +189,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 +198,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); } //-------------------------------------------------------------------------- @@ -206,4 +208,4 @@ int ArrayType::getArrayDims(hsize_t* dims) const //-------------------------------------------------------------------------- ArrayType::~ArrayType() {} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5ArrayType.h b/c++/src/H5ArrayType.h index d99b936..09f1592 100644 --- a/c++/src/H5ArrayType.h +++ b/c++/src/H5ArrayType.h @@ -23,44 +23,48 @@ 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 diff --git a/c++/src/H5AtomType.cpp b/c++/src/H5AtomType.cpp index 9408452..abebc3b 100644 --- a/c++/src/H5AtomType.cpp +++ b/c++/src/H5AtomType.cpp @@ -51,7 +51,7 @@ AtomType::AtomType(const hid_t existing_id) : DataType(existing_id) {} ///\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 +61,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 +81,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 +111,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 +124,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 +137,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 +158,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 +181,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 +205,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 +227,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 +251,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 +274,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"); } } @@ -294,4 +293,4 @@ void AtomType::setPad(H5T_pad_t lsb, H5T_pad_t msb) const 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..337aca6 100644 --- a/c++/src/H5AtomType.h +++ b/c++/src/H5AtomType.h @@ -26,54 +26,58 @@ 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 diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index 33f992a..131ce92 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -18,7 +18,7 @@ #endif #include -#include "H5private.h" // for HDfree +#include "H5private.h" // for HDfree #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -41,7 +41,7 @@ namespace H5 { using std::cerr; using std::endl; -class H5_DLLCPP H5Object; // forward declaration for UserData4Aiterate +class H5_DLLCPP H5Object; // forward declaration for UserData4Aiterate //-------------------------------------------------------------------------- // Function: Attribute default constructor @@ -56,7 +56,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 +82,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 +100,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 +135,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 +164,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 +190,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 +248,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 +282,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,7 +309,8 @@ 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 @@ -330,32 +318,28 @@ H5std_string Attribute::getName() const ssize_t name_size = H5Aget_name(id, static_cast(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 +355,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 +383,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 +428,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 +442,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 +465,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 +480,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 +503,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 +512,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 +538,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 +547,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 +569,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 +591,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 +619,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..8783c00 100644 --- a/c++/src/H5Attribute.h +++ b/c++/src/H5Attribute.h @@ -27,76 +27,79 @@ 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 diff --git a/c++/src/H5Classes.h b/c++/src/H5Classes.h index 8b1e6ed..618b46c 100644 --- a/c++/src/H5Classes.h +++ b/c++/src/H5Classes.h @@ -16,31 +16,31 @@ #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; -} +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..3390980 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -13,7 +13,7 @@ #include -#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 @@ -360,7 +376,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 +392,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..c3aef41 100644 --- a/c++/src/H5CommonFG.h +++ b/c++/src/H5CommonFG.h @@ -28,56 +28,55 @@ 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 diff --git a/c++/src/H5CompType.cpp b/c++/src/H5CompType.cpp index fe96bb0..58ce83c 100644 --- a/c++/src/H5CompType.cpp +++ b/c++/src/H5CompType.cpp @@ -45,7 +45,7 @@ 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 @@ -75,14 +75,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 +100,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 +119,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 +132,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 +144,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 +154,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 +173,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 +199,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 +229,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 +246,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 +283,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 +305,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 +327,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 +349,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 +371,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 +393,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 +415,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 +437,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 +492,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 +515,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 +534,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"); } } @@ -542,4 +551,4 @@ void CompType::setSize(size_t size) const //-------------------------------------------------------------------------- CompType::~CompType() {} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5CompType.h b/c++/src/H5CompType.h index d85e2ed..66392d9 100644 --- a/c++/src/H5CompType.h +++ b/c++/src/H5CompType.h @@ -23,99 +23,103 @@ 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 diff --git a/c++/src/H5Cpp.h b/c++/src/H5Cpp.h index 01fae45..e614d69 100644 --- a/c++/src/H5Cpp.h +++ b/c++/src/H5Cpp.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 diff --git a/c++/src/H5DaccProp.cpp b/c++/src/H5DaccProp.cpp index c6ff705..1c01b9b 100644 --- a/c++/src/H5DaccProp.cpp +++ b/c++/src/H5DaccProp.cpp @@ -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 @@ -94,7 +96,7 @@ 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 @@ -122,11 +124,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 +145,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"); } } @@ -159,4 +161,4 @@ void DSetAccPropList::getChunkCache(size_t &rdcc_nslots, size_t &rdcc_nbytes, d //-------------------------------------------------------------------------- DSetAccPropList::~DSetAccPropList() {} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5DaccProp.h b/c++/src/H5DaccProp.h index 111b4f5..a467fac 100644 --- a/c++/src/H5DaccProp.h +++ b/c++/src/H5DaccProp.h @@ -23,42 +23,46 @@ 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 diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index a071289..7720011 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -18,7 +18,7 @@ #endif #include -#include "H5private.h" // for HDfree +#include "H5private.h" // for HDfree #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -73,7 +73,7 @@ DataSet::DataSet(const hid_t existing_id) : H5Object(), AbstractDs(), id(existin ///\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 } @@ -93,7 +93,8 @@ DataSet::DataSet(const DataSet& original) : H5Object(), AbstractDs(), id(origina /// 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"); } @@ -109,7 +110,8 @@ DataSet::DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type, co ///\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"); } @@ -121,32 +123,32 @@ DataSet::DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type, co ///\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"); } } @@ -158,18 +160,18 @@ hid_t DataSet::p_get_type() const ///\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 +181,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); } //-------------------------------------------------------------------------- @@ -202,10 +204,11 @@ DSetAccPropList DataSet::getAccessPlist() const // 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); } //-------------------------------------------------------------------------- @@ -215,62 +218,55 @@ hsize_t DataSet::getStorageSize() const ///\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); } //-------------------------------------------------------------------------- @@ -280,16 +276,16 @@ size_t DataSet::getInMemDataSize() const ///\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); } //-------------------------------------------------------------------------- @@ -299,11 +295,11 @@ haddr_t DataSet::getOffset() const ///\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"); } } @@ -317,20 +313,20 @@ void DataSet::getSpaceStatus(H5D_space_status_t& status) const ///\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); } //-------------------------------------------------------------------------- @@ -346,7 +342,7 @@ hsize_t DataSet::getVlenBufSize(const DataType& type, const DataSpace& space) co // 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)); //} @@ -362,16 +358,17 @@ hsize_t DataSet::getVlenBufSize(const DataType& type, const DataSpace& space) co ///\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 = H5Treclaim(type_id, space_id, xfer_plist_id, buf); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::vlenReclaim", "H5Treclaim failed"); } } @@ -390,16 +387,17 @@ void DataSet::vlenReclaim(const DataType& type, const DataSpace& space, const DS // 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 = H5Treclaim(type_id, space_id, xfer_plist_id, buf); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::vlenReclaim", "H5Treclaim failed"); } } @@ -419,17 +417,18 @@ void DataSet::vlenReclaim(void* buf, const DataType& type, const DataSpace& spac /// 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"); } } @@ -453,28 +452,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); } } @@ -495,17 +494,18 @@ void DataSet::read(H5std_string& strg, const DataType& mem_type, const DataSpace /// 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"); } } @@ -520,39 +520,37 @@ void DataSet::write(const void* buf, const DataType& mem_type, const DataSpace& // 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"); } } @@ -574,15 +572,17 @@ void DataSet::write(const H5std_string& strg, const DataType& mem_type, const Da /// 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"); } @@ -598,10 +598,11 @@ int DataSet::iterateElems(void* buf, const DataType& type, const DataSpace& spac /// 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"); } @@ -616,14 +617,15 @@ void DataSet::extend(const hsize_t* size) const ///\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"); } } @@ -645,7 +647,8 @@ void DataSet::fillMemBuf(const void *fill, const DataType& fill_type, void *buf, // 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); //} @@ -659,13 +662,13 @@ void DataSet::fillMemBuf(const void *fill, const DataType& fill_type, void *buf, ///\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"); } } @@ -685,7 +688,7 @@ void DataSet::fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& s // 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); //} @@ -701,9 +704,10 @@ void DataSet::fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& s // 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); } //-------------------------------------------------------------------------- @@ -717,7 +721,9 @@ hid_t DataSet::getId() const // 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,22 +731,20 @@ 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; } } @@ -755,7 +759,9 @@ void DataSet::p_read_fixed_len(const hid_t mem_type_id, const hid_t mem_space_id // 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 +769,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"); } @@ -786,17 +791,18 @@ void DataSet::p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space // 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; } //-------------------------------------------------------------------------- @@ -809,7 +815,8 @@ void DataSet::p_setId(const hid_t new_id) // 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); } @@ -823,13 +830,12 @@ void f_PropList_setId(PropList* plist, hid_t new_id) ///\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 @@ -852,9 +858,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..0bf7589 100644 --- a/c++/src/H5DataSet.h +++ b/c++/src/H5DataSet.h @@ -26,109 +26,129 @@ 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); + + // 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 diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp index e8e5712..47fdbbc 100644 --- a/c++/src/H5DataSpace.cpp +++ b/c++/src/H5DataSpace.cpp @@ -33,7 +33,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 +45,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 +60,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 +70,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 +80,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 +96,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 +110,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 +137,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 +154,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 +185,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 +201,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 +226,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 +245,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 +263,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 +286,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 +306,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 +324,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 +347,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 +361,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 +378,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 +394,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 +413,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 +434,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 +452,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 +474,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 +496,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 +520,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 +537,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 +553,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 +571,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 +598,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 +621,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 +640,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 +662,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 +690,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..b5e92bc 100644 --- a/c++/src/H5DataSpace.h +++ b/c++/src/H5DataSpace.h @@ -23,127 +23,132 @@ 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(); - // 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 + { + return ("DataSpace"); + } - // Gets the dataspace id. - virtual hid_t getId() const; + // Gets the dataspace id. + virtual hid_t getId() const; - // 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); #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 diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 0472975..565fb9a 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -82,8 +82,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 +98,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 +118,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 +148,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 +170,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 +189,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 +207,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 +233,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 +258,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 +270,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 +287,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 +299,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 +309,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 +339,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 +367,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 +385,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 +395,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 +409,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 +429,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 +447,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 +467,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 +479,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 +499,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 +513,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 +522,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 +537,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 +561,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 +591,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 +608,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 +627,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 +646,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 +655,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 +681,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 +700,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 +719,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 +738,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 +752,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 +769,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 +782,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 +808,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 +829,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 +850,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 +874,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 +899,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 +917,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 +939,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 +961,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 +1000,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..32badfe 100644 --- a/c++/src/H5DataType.h +++ b/c++/src/H5DataType.h @@ -26,152 +26,159 @@ 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 diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp index 79ff100..7163434 100644 --- a/c++/src/H5DcreatProp.cpp +++ b/c++/src/H5DcreatProp.cpp @@ -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 @@ -100,7 +102,7 @@ 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 @@ -125,11 +127,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 +145,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 +165,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 +190,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 +212,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 +237,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 +258,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 +284,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 +306,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 +325,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 +358,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 +378,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 +394,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 +426,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 +455,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 +487,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 +506,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 +516,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 +531,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 +554,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 +577,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 +602,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 +622,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 +638,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 +663,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 +679,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 +713,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 +740,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 +768,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); } @@ -795,4 +782,4 @@ void DSetCreatPropList::setVirtual(const DataSpace& vspace, const H5std_string s //-------------------------------------------------------------------------- DSetCreatPropList::~DSetCreatPropList() {} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h index 9f54e8d..e73ec32 100644 --- a/c++/src/H5DcreatProp.h +++ b/c++/src/H5DcreatProp.h @@ -27,121 +27,132 @@ 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 diff --git a/c++/src/H5DxferProp.cpp b/c++/src/H5DxferProp.cpp index 9cc6961..00dba7e 100644 --- a/c++/src/H5DxferProp.cpp +++ b/c++/src/H5DxferProp.cpp @@ -13,7 +13,7 @@ #include -#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 @@ -94,7 +97,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 +110,7 @@ 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 @@ -128,13 +131,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 +149,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 +167,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 +183,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 +206,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 +224,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 +240,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 +257,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 +272,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 +281,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 +290,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,7 +301,8 @@ 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 @@ -313,29 +312,27 @@ H5std_string DSetMemXferPropList::getDataTransform() const 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 +344,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 +361,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 +380,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 +398,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 +414,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 +434,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 +451,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 +473,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 +491,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 +521,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 +537,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); } //-------------------------------------------------------------------------- @@ -561,5 +554,4 @@ H5Z_EDC_t DSetMemXferPropList::getEDCCheck() const //-------------------------------------------------------------------------- DSetMemXferPropList::~DSetMemXferPropList() {} -} // end namespace - +} // namespace H5 diff --git a/c++/src/H5DxferProp.h b/c++/src/H5DxferProp.h index e53a03b..59ece6f 100644 --- a/c++/src/H5DxferProp.h +++ b/c++/src/H5DxferProp.h @@ -23,105 +23,108 @@ 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 H5Treclaim. - 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 H5Treclaim. + 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 H5Treclaim. - 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 H5Treclaim. + 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 diff --git a/c++/src/H5EnumType.cpp b/c++/src/H5EnumType.cpp index f9adc47..07cff07 100644 --- a/c++/src/H5EnumType.cpp +++ b/c++/src/H5EnumType.cpp @@ -13,7 +13,7 @@ #include -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -50,14 +50,14 @@ 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 +69,7 @@ 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 +78,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 +96,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 +121,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 +140,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 +153,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 +165,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 +176,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 +193,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 +208,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 +237,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 +254,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 +270,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 +287,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 +300,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 +320,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"); } } @@ -336,4 +337,4 @@ void EnumType::getMemberValue(unsigned memb_no, void *value) const //-------------------------------------------------------------------------- EnumType::~EnumType() {} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5EnumType.h b/c++/src/H5EnumType.h index 4797ee7..e3d9a50 100644 --- a/c++/src/H5EnumType.h +++ b/c++/src/H5EnumType.h @@ -24,61 +24,65 @@ 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 diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index 7431e6c..5fcd1cf 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -35,7 +35,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 +46,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 +61,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 +98,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 +140,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 +155,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 +175,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 +193,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 +243,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 +259,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 +272,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 +284,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 +296,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 +309,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 +330,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); //} @@ -339,7 +350,7 @@ 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,7 +358,10 @@ 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. @@ -362,7 +376,7 @@ 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,7 +384,10 @@ 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. @@ -385,7 +402,7 @@ 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,7 +410,10 @@ 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. @@ -408,7 +428,7 @@ 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,7 +436,10 @@ 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. @@ -431,7 +454,7 @@ 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,7 +462,10 @@ 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. @@ -454,7 +480,7 @@ 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,7 +488,10 @@ 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. @@ -477,7 +506,7 @@ 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,7 +514,10 @@ 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. @@ -500,7 +532,7 @@ 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,7 +540,10 @@ 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. @@ -523,7 +558,7 @@ 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,7 +566,10 @@ 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. @@ -546,7 +584,7 @@ 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,7 +592,10 @@ 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. @@ -569,7 +610,7 @@ 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,7 +618,10 @@ 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. @@ -592,7 +636,7 @@ 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 +644,14 @@ 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() {} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Exception.h b/c++/src/H5Exception.h index cb14a4c..44edac2 100644 --- a/c++/src/H5Exception.h +++ b/c++/src/H5Exception.h @@ -19,9 +19,9 @@ namespace H5 { #ifdef H5_NO_STD - #define H5std_string ::string +#define H5std_string ::string #else - #define H5std_string std::string +#define H5std_string std::string #endif /*! \class Exception @@ -30,150 +30,148 @@ 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(); }; 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(); }; 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(); }; 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(); }; 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(); }; 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(); }; 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(); }; 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(); }; 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(); }; 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(); }; 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(); }; 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(); }; // end of IdComponentException } // namespace H5 diff --git a/c++/src/H5FaccProp.cpp b/c++/src/H5FaccProp.cpp index a028e00..78a4a74 100644 --- a/c++/src/H5FaccProp.cpp +++ b/c++/src/H5FaccProp.cpp @@ -37,7 +37,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 +50,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 +65,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 +77,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 +87,7 @@ void FileAccPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for default property //-------------------------------------------------------------------------- -const FileAccPropList& FileAccPropList::DEFAULT = *getConstant(); +const FileAccPropList &FileAccPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -102,7 +104,7 @@ 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 @@ -119,11 +121,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 +141,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 +162,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 +178,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 +194,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 +219,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 +237,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 +257,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 +276,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 +297,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 +323,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 +346,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 +365,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 +386,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 +406,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 +422,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 +446,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 +465,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 +479,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 +504,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 +522,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 +541,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 +560,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 +588,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 +607,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 +623,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 +639,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 +661,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 +677,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 +703,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 +726,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 @@ -759,11 +764,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"); } } @@ -795,11 +800,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"); } } @@ -811,4 +816,4 @@ void FileAccPropList::getLibverBounds(H5F_libver_t& libver_low, H5F_libver_t& li //-------------------------------------------------------------------------- FileAccPropList::~FileAccPropList() {} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5FaccProp.h b/c++/src/H5FaccProp.h index ee90fa4..10bf728 100644 --- a/c++/src/H5FaccProp.h +++ b/c++/src/H5FaccProp.h @@ -23,145 +23,145 @@ 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 diff --git a/c++/src/H5FcreatProp.cpp b/c++/src/H5FcreatProp.cpp index 9b0fecc..4bbebfd 100644 --- a/c++/src/H5FcreatProp.cpp +++ b/c++/src/H5FcreatProp.cpp @@ -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 @@ -91,7 +93,7 @@ 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 @@ -115,13 +117,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 +137,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 +153,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 +176,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 +193,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 +214,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 +234,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 +254,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 +273,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 +302,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 +323,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 +341,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 +359,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); } //-------------------------------------------------------------------------- @@ -383,4 +378,4 @@ hsize_t FileCreatPropList::getFileSpacePagesize() const //-------------------------------------------------------------------------- FileCreatPropList::~FileCreatPropList() {} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5FcreatProp.h b/c++/src/H5FcreatProp.h index cc28920..d19b60d 100644 --- a/c++/src/H5FcreatProp.h +++ b/c++/src/H5FcreatProp.h @@ -23,82 +23,86 @@ 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 diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index b9ecded..2ed3508 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -41,8 +41,8 @@ #include "H5Alltypes.h" namespace H5 { - using std::cerr; - using std::endl; +using std::cerr; +using std::endl; //-------------------------------------------------------------------------- // Function H5File default constructor @@ -81,11 +81,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 +109,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 +129,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 +182,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() { id = original.getId(); incRefCount(); // increment number of references to this id @@ -190,7 +196,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_accessible to determine whether the file is in // HDF5 format. It returns positive value, 0, or negative value @@ -213,9 +220,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())); } //-------------------------------------------------------------------------- @@ -228,12 +236,13 @@ bool H5File::isHdf5(const H5std_string& name) ///\exception H5::FileIException // September 2018 //-------------------------------------------------------------------------- -bool H5File::isAccessible(const char* name, const FileAccPropList& access_plist) +bool +H5File::isAccessible(const char *name, const FileAccPropList &access_plist) { // Calls C routine H5Fis_accessible to determine whether the file is in // HDF5 format. It returns positive value, 0, or negative value - hid_t access_plist_id = access_plist.getId(); - htri_t ret_value = H5Fis_accessible(name, access_plist_id); + hid_t access_plist_id = access_plist.getId(); + htri_t ret_value = H5Fis_accessible(name, access_plist_id); if (ret_value > 0) return true; else if (ret_value == 0) @@ -253,9 +262,10 @@ bool H5File::isAccessible(const char* name, const FileAccPropList& access_plist) /// FileAccPropList::DEFAULT // September 2018 //-------------------------------------------------------------------------- -bool H5File::isAccessible(const H5std_string& name, const FileAccPropList& access_plist) +bool +H5File::isAccessible(const H5std_string &name, const FileAccPropList &access_plist) { - return(isAccessible(name.c_str(), access_plist)); + return (isAccessible(name.c_str(), access_plist)); } //-------------------------------------------------------------------------- @@ -276,18 +286,19 @@ bool H5File::isAccessible(const H5std_string& name, const FileAccPropList& acces /// // 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"); } @@ -303,7 +314,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); } @@ -324,12 +336,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()); } @@ -347,19 +360,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"); } } @@ -371,16 +383,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 { @@ -398,11 +410,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"); } } @@ -414,17 +426,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, @@ -446,11 +457,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); @@ -481,11 +492,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"); } } @@ -509,12 +520,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"); } } @@ -534,7 +545,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); //} @@ -549,11 +560,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"); } } @@ -568,12 +579,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); @@ -589,12 +600,12 @@ hsize_t H5File::getFileSize() const /// order to retrieve the unique 'file number' for the file. // Programmer Quincey Koziol - April 13, 2019 //-------------------------------------------------------------------------- -unsigned long H5File::getFileNum() const +unsigned long +H5File::getFileNum() const { - unsigned long fileno = 0; - herr_t ret_value = H5Fget_fileno(id, &fileno); - if (ret_value < 0) - { + unsigned long fileno = 0; + herr_t ret_value = H5Fget_fileno(id, &fileno); + if (ret_value < 0) { throw FileIException("H5File::getFileNum", "H5Fget_fileno failed"); } return (fileno); @@ -612,9 +623,10 @@ unsigned long H5File::getFileNum() 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 @@ -626,7 +638,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(); } @@ -643,9 +656,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()); } //-------------------------------------------------------------------------- @@ -660,13 +674,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 @@ -681,13 +696,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 @@ -708,7 +722,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::"); @@ -729,9 +744,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 1b1227f..9231d5f 100644 --- a/c++/src/H5File.h +++ b/c++/src/H5File.h @@ -23,111 +23,117 @@ 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(); - // 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; - // Returns the 'file number' of the HDF5 file. - unsigned long getFileNum() const; + // Returns the 'file number' of the HDF5 file. + unsigned long getFileNum() 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); - // Determines if a file, specified by its name, can be accessed as HDF5 - static bool isAccessible(const char* name, const FileAccPropList& access_plist = FileAccPropList::DEFAULT); - static bool isAccessible(const H5std_string& name, const FileAccPropList& access_plist = FileAccPropList::DEFAULT); + // Determines if a file, specified by its name, can be accessed as HDF5 + static bool isAccessible(const char * name, + const FileAccPropList &access_plist = FileAccPropList::DEFAULT); + static bool isAccessible(const H5std_string & name, + const FileAccPropList &access_plist = FileAccPropList::DEFAULT); - // 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 + { + 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; - // For CommonFG to get the file id. - virtual hid_t getLocId() const; + // For CommonFG to get the file id. + virtual hid_t getLocId() const; - // 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; - // 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); #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 - diff --git a/c++/src/H5FloatType.cpp b/c++/src/H5FloatType.cpp index aba826e..7979cfa 100644 --- a/c++/src/H5FloatType.cpp +++ b/c++/src/H5FloatType.cpp @@ -49,7 +49,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 +63,14 @@ 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 +80,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 +104,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 +123,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 +136,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 +148,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 +162,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 +183,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 +199,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 +217,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 +241,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 +255,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 +270,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 +294,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 +308,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 +328,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"); } } @@ -344,4 +344,4 @@ void FloatType::setInpad(H5T_pad_t inpad) const //-------------------------------------------------------------------------- FloatType::~FloatType() {} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5FloatType.h b/c++/src/H5FloatType.h index f74a9ae..2368113 100644 --- a/c++/src/H5FloatType.h +++ b/c++/src/H5FloatType.h @@ -23,59 +23,63 @@ 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 diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index 7132bdf..a1f7dcd 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -42,8 +42,8 @@ #include "H5Alltypes.h" namespace H5 { - using std::cerr; - using std::endl; +using std::cerr; +using std::endl; //-------------------------------------------------------------------------- // Function: Group default constructor @@ -58,7 +58,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 +70,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 +91,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 +121,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 +134,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 +158,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 +178,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 +196,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 +215,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 +237,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 +263,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 +286,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..7b9dc54 100644 --- a/c++/src/H5Group.h +++ b/c++/src/H5Group.h @@ -22,57 +22,63 @@ 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(); - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("Group"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + 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; - // for CommonFG to get the file id. - virtual hid_t getLocId() const; + // for CommonFG to get the file id. + virtual hid_t getLocId() const; - // 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; - // Destructor - virtual ~Group(); + // Destructor + virtual ~Group(); - // 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); #endif // DOXYGEN_SHOULD_SKIP_THIS - private: - hid_t id; // HDF5 group id + private: + hid_t id; // HDF5 group id }; // end of Group } // namespace H5 diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index 40520aa..ca54551 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -13,7 +13,7 @@ #include -#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); @@ -338,7 +347,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 +365,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 +383,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 +392,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 +425,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 +448,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..8db1af2 100644 --- a/c++/src/H5IdComponent.h +++ b/c++/src/H5IdComponent.h @@ -25,85 +25,88 @@ 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 "::"; - // is returned by fromClass(). - H5std_string inMemFunc(const char* func_name) const; + // Makes and returns the string "::"; + // 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 diff --git a/c++/src/H5Include.h b/c++/src/H5Include.h index a180430..c26ba33 100644 --- a/c++/src/H5Include.h +++ b/c++/src/H5Include.h @@ -23,18 +23,17 @@ #undef true #endif typedef int bool; -const bool false = 0; -const bool true = 1; +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 diff --git a/c++/src/H5IntType.cpp b/c++/src/H5IntType.cpp index 01c20e9..7f3bcb5 100644 --- a/c++/src/H5IntType.cpp +++ b/c++/src/H5IntType.cpp @@ -47,7 +47,7 @@ IntType::IntType() {} ///\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 +56,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 +70,7 @@ 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 +79,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 +103,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 +122,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 +135,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 +147,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 +157,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 +177,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"); } } @@ -194,4 +194,4 @@ void IntType::setSign(H5T_sign_t sign) const //-------------------------------------------------------------------------- IntType::~IntType() {} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5IntType.h b/c++/src/H5IntType.h index 496872b..e8bccca 100644 --- a/c++/src/H5IntType.h +++ b/c++/src/H5IntType.h @@ -23,41 +23,45 @@ 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 diff --git a/c++/src/H5LaccProp.cpp b/c++/src/H5LaccProp.cpp index 1905cce..bd9cd1b 100644 --- a/c++/src/H5LaccProp.cpp +++ b/c++/src/H5LaccProp.cpp @@ -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 @@ -92,7 +94,7 @@ 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 @@ -111,12 +113,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 +131,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); } //-------------------------------------------------------------------------- @@ -148,4 +150,4 @@ size_t LinkAccPropList::getNumLinks() const //-------------------------------------------------------------------------- LinkAccPropList::~LinkAccPropList() {} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5LaccProp.h b/c++/src/H5LaccProp.h index ec5e54f..337f0b7 100644 --- a/c++/src/H5LaccProp.h +++ b/c++/src/H5LaccProp.h @@ -23,43 +23,47 @@ 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 diff --git a/c++/src/H5LcreatProp.cpp b/c++/src/H5LcreatProp.cpp index bde9339..e40d6ba 100644 --- a/c++/src/H5LcreatProp.cpp +++ b/c++/src/H5LcreatProp.cpp @@ -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 @@ -92,7 +94,7 @@ 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 @@ -111,12 +113,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 +131,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 +151,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 +168,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); } //-------------------------------------------------------------------------- @@ -185,4 +187,4 @@ H5T_cset_t LinkCreatPropList::getCharEncoding() const //-------------------------------------------------------------------------- LinkCreatPropList::~LinkCreatPropList() {} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5LcreatProp.h b/c++/src/H5LcreatProp.h index 908ef63..7194bdc 100644 --- a/c++/src/H5LcreatProp.h +++ b/c++/src/H5LcreatProp.h @@ -23,50 +23,54 @@ 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 diff --git a/c++/src/H5Library.cpp b/c++/src/H5Library.cpp index fde5599..8b8d7ba 100644 --- a/c++/src/H5Library.cpp +++ b/c++/src/H5Library.cpp @@ -14,7 +14,7 @@ #include #include -#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,14 @@ 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..d3f2831 100644 --- a/c++/src/H5Library.h +++ b/c++/src/H5Library.h @@ -24,47 +24,46 @@ 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 diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index 89a7890..687ff5b 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -15,7 +15,7 @@ #include using namespace std; -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -88,7 +88,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 +111,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 +128,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 +145,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 +166,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 +183,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 +214,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 +229,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 +242,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 +257,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 +274,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 +289,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 +310,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 +319,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(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,7 +341,8 @@ 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 @@ -340,14 +352,12 @@ H5std_string H5Location::getComment(const char* name, size_t buf_size) const 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 +365,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 +379,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,9 +393,10 @@ 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 +410,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 +435,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 +462,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 +488,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 +512,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 +532,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 +543,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 +561,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 +581,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 +608,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,14 +636,14 @@ 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 +664,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,22 +691,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); } - //-------------------------------------------------------------------------- // Function: H5Location::getRegion ///\brief Retrieves a dataspace with the region pointed to selected. @@ -703,24 +721,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 +785,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 +797,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 +810,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 +832,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 +855,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 +876,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 +891,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 +904,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 +917,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 +941,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 +963,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 +978,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 +997,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 +1025,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 +1046,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 +1067,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 +1090,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 +1112,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 +1136,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 +1158,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 +1189,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 +1211,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 +1222,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 +1239,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 +1261,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 +1278,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 +1299,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 +1321,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 +1343,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 +1364,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 +1385,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 +1406,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 +1420,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 +1433,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 +1448,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); } @@ -1415,7 +1466,8 @@ void H5Location::unlink(const H5std_string& name, const LinkAccPropList& lapl) c /// \li \c H5O_INFO_ALL // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getNativeObjinfo(H5O_native_info_t& objinfo, unsigned fields) const +void +H5Location::getNativeObjinfo(H5O_native_info_t &objinfo, unsigned fields) const { // Use C API to get information of the object @@ -1441,7 +1493,9 @@ void H5Location::getNativeObjinfo(H5O_native_info_t& objinfo, unsigned fields) c /// \li \c H5O_INFO_ALL // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getNativeObjinfo(const char* name, H5O_native_info_t& objinfo, unsigned fields, const LinkAccPropList& lapl) const +void +H5Location::getNativeObjinfo(const char *name, H5O_native_info_t &objinfo, unsigned fields, + const LinkAccPropList &lapl) const { // Use C API to get information of the object herr_t ret_value = H5Oget_native_info_by_name(getId(), name, &objinfo, fields, lapl.getId()); @@ -1463,7 +1517,9 @@ void H5Location::getNativeObjinfo(const char* name, H5O_native_info_t& objinfo, ///\param lapl - IN: Link access property list // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getNativeObjinfo(const H5std_string& name, H5O_native_info_t& objinfo, unsigned fields, const LinkAccPropList& lapl) const +void +H5Location::getNativeObjinfo(const H5std_string &name, H5O_native_info_t &objinfo, unsigned fields, + const LinkAccPropList &lapl) const { getNativeObjinfo(name.c_str(), objinfo, fields, lapl); } @@ -1486,13 +1542,13 @@ void H5Location::getNativeObjinfo(const H5std_string& name, H5O_native_info_t& o /// \li \c H5O_INFO_ALL // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getNativeObjinfo(const char* grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_native_info_t& objinfo, unsigned fields, - const LinkAccPropList& lapl) const +void +H5Location::getNativeObjinfo(const char *grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + H5O_native_info_t &objinfo, unsigned fields, const LinkAccPropList &lapl) const { // Use C API to get information of the object - herr_t ret_value = H5Oget_native_info_by_idx(getId(), grp_name, idx_type, order, - idx, &objinfo, fields, lapl.getId()); + herr_t ret_value = + H5Oget_native_info_by_idx(getId(), grp_name, idx_type, order, idx, &objinfo, fields, lapl.getId()); // Throw exception if C API returns failure if (ret_value < 0) @@ -1511,9 +1567,10 @@ void H5Location::getNativeObjinfo(const char* grp_name, H5_index_t idx_type, ///\param lapl - IN: Link access property list // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getNativeObjinfo(const H5std_string& grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_native_info_t& objinfo, unsigned fields, - const LinkAccPropList& lapl) const +void +H5Location::getNativeObjinfo(const H5std_string &grp_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t idx, H5O_native_info_t &objinfo, unsigned fields, + const LinkAccPropList &lapl) const { getNativeObjinfo(grp_name.c_str(), idx_type, order, idx, objinfo, fields, lapl); } @@ -1533,7 +1590,8 @@ void H5Location::getNativeObjinfo(const H5std_string& grp_name, H5_index_t idx_t /// \li \c H5O_INFO_ALL // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(H5O_info2_t& objinfo, unsigned fields) const +void +H5Location::getObjinfo(H5O_info2_t &objinfo, unsigned fields) const { // Use C API to get information of the object @@ -1562,7 +1620,9 @@ void H5Location::getObjinfo(H5O_info2_t& objinfo, unsigned fields) const /// \li \c H5O_INFO_ALL // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const char* name, H5O_info2_t& objinfo, unsigned fields, const LinkAccPropList& lapl) const +void +H5Location::getObjinfo(const char *name, H5O_info2_t &objinfo, unsigned fields, + const LinkAccPropList &lapl) const { // Use C API to get information of the object herr_t ret_value = H5Oget_info_by_name3(getId(), name, &objinfo, fields, lapl.getId()); @@ -1584,7 +1644,9 @@ void H5Location::getObjinfo(const char* name, H5O_info2_t& objinfo, unsigned fie ///\param lapl - IN: Link access property list // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const H5std_string& name, H5O_info2_t& objinfo, unsigned fields, const LinkAccPropList& lapl) const +void +H5Location::getObjinfo(const H5std_string &name, H5O_info2_t &objinfo, unsigned fields, + const LinkAccPropList &lapl) const { getObjinfo(name.c_str(), objinfo, fields, lapl); } @@ -1610,13 +1672,13 @@ void H5Location::getObjinfo(const H5std_string& name, H5O_info2_t& objinfo, unsi /// \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_info2_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_info2_t &objinfo, unsigned fields, const LinkAccPropList &lapl) const { // Use C API to get information of the object - herr_t ret_value = H5Oget_info_by_idx3(getId(), grp_name, idx_type, order, - idx, &objinfo, fields, lapl.getId()); + herr_t ret_value = + H5Oget_info_by_idx3(getId(), grp_name, idx_type, order, idx, &objinfo, fields, lapl.getId()); // Throw exception if C API returns failure if (ret_value < 0) @@ -1635,9 +1697,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_info2_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_info2_t &objinfo, unsigned fields, const LinkAccPropList &lapl) const { getObjinfo(grp_name.c_str(), idx_type, order, idx, objinfo, fields, lapl); } @@ -1655,7 +1717,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) @@ -1669,7 +1732,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); } @@ -1681,7 +1745,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) @@ -1695,7 +1760,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); } @@ -1711,7 +1777,8 @@ void H5Location::getObjinfo(const H5std_string& name, H5G_stat_t& statbuf) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // 2000 //-------------------------------------------------------------------------- -H5L_info2_t H5Location::getLinkInfo(const char* link_name, const LinkAccPropList& lapl) const +H5L_info2_t +H5Location::getLinkInfo(const char *link_name, const LinkAccPropList &lapl) const { H5L_info2_t linkinfo; // link info structure @@ -1719,7 +1786,7 @@ H5L_info2_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); } //-------------------------------------------------------------------------- @@ -1728,9 +1795,10 @@ H5L_info2_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_info2_t H5Location::getLinkInfo(const H5std_string& link_name, const LinkAccPropList& lapl) const +H5L_info2_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)); } //-------------------------------------------------------------------------- @@ -1742,17 +1810,17 @@ H5L_info2_t H5Location::getLinkInfo(const H5std_string& link_name, const LinkAcc ///\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_info2_t linkinfo; - char *value_C; // value in C string - size_t val_size = size; - H5std_string value = ""; - herr_t ret_value; + H5L_info2_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_info2(getId(), name, &linkinfo, H5P_DEFAULT); if (ret_value < 0) throwException("getLinkval", "H5Lget_info to find buffer size failed"); @@ -1761,22 +1829,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); } //-------------------------------------------------------------------------- @@ -1786,9 +1852,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)); } //-------------------------------------------------------------------------- @@ -1800,7 +1867,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(); @@ -1829,7 +1897,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); //} @@ -1840,7 +1908,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); } @@ -1856,7 +1925,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); //} @@ -1868,7 +1937,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); @@ -1885,7 +1955,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()); } @@ -1904,14 +1975,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); } //-------------------------------------------------------------------------- @@ -1921,9 +1992,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 */ @@ -1934,12 +2006,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); } @@ -1959,28 +2032,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); } @@ -2001,10 +2076,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); @@ -2017,22 +2094,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); } @@ -2054,10 +2131,11 @@ 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_info2_t objinfo; - H5O_type_t objtype = H5O_TYPE_UNKNOWN; + H5O_type_t objtype = H5O_TYPE_UNKNOWN; // Use C API to get information of the object herr_t ret_value = H5Oget_info_by_name3(getId(), objname, &objinfo, H5O_INFO_BASIC, H5P_DEFAULT); @@ -2067,19 +2145,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); } //-------------------------------------------------------------------------- @@ -2092,11 +2169,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); } //-------------------------------------------------------------------------- @@ -2128,33 +2206,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_info2_t objinfo; - H5O_type_t objtype = H5O_TYPE_UNKNOWN; + H5O_type_t objtype = H5O_TYPE_UNKNOWN; // Use C API to get information of the object - ret_value = H5Oget_info_by_idx3(getId(), objname, index_type, order, index, &objinfo, H5O_INFO_BASIC, H5P_DEFAULT); + ret_value = H5Oget_info_by_idx3(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); } //-------------------------------------------------------------------------- @@ -2171,25 +2251,26 @@ 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_native_info_t objinfo; - unsigned version = 0; + unsigned version = 0; // Use C API to get information of the object - herr_t ret_value = H5Oget_native_info_by_name(getId(), objname, &objinfo, H5O_NATIVE_INFO_HDR, H5P_DEFAULT); + herr_t ret_value = + H5Oget_native_info_by_name(getId(), objname, &objinfo, H5O_NATIVE_INFO_HDR, H5P_DEFAULT); // Throw exception if C API returns failure 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); } //-------------------------------------------------------------------------- @@ -2202,11 +2283,12 @@ 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 @@ -2220,13 +2302,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); } //-------------------------------------------------------------------------- @@ -2242,10 +2325,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 @@ -2258,22 +2342,30 @@ 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); } @@ -2294,7 +2386,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); } @@ -2325,7 +2418,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); } @@ -2339,4 +2433,4 @@ H5Location::~H5Location() {} #endif // DOXYGEN_SHOULD_SKIP_THIS -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Location.h b/c++/src/H5Location.h index 3c30715..3ea58cd 100644 --- a/c++/src/H5Location.h +++ b/c++/src/H5Location.h @@ -15,7 +15,7 @@ #ifndef __H5Location_H #define __H5Location_H -#include "H5Classes.h" // constains forward class declarations +#include "H5Classes.h" // constains forward class declarations namespace H5 { @@ -29,319 +29,312 @@ 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_info2_t getLinkInfo(const char* link_name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - H5L_info2_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_info2_t& objinfo, unsigned fields = H5O_INFO_BASIC) const; - - // Retrieves information about an HDF5 object, given its name. - void getObjinfo(const char* name, H5O_info2_t& objinfo, - unsigned fields = H5O_INFO_BASIC, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void getObjinfo(const H5std_string& name, H5O_info2_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_info2_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_info2_t& objinfo, - unsigned fields = H5O_INFO_BASIC, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Retrieves native native information about an HDF5 object. - void getNativeObjinfo(H5O_native_info_t& objinfo, unsigned fields = H5O_NATIVE_INFO_HDR) const; - - // Retrieves native information about an HDF5 object, given its name. - void getNativeObjinfo(const char* name, H5O_native_info_t& objinfo, - unsigned fields = H5O_NATIVE_INFO_HDR, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void getNativeObjinfo(const H5std_string& name, H5O_native_info_t& objinfo, - unsigned fields = H5O_NATIVE_INFO_HDR, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Retrieves native information about an HDF5 object, given its index. - void getNativeObjinfo(const char* grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_native_info_t& objinfo, - unsigned fields = H5O_NATIVE_INFO_HDR, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void getNativeObjinfo(const H5std_string& grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_native_info_t& objinfo, - unsigned fields = H5O_NATIVE_INFO_HDR, - 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_info2_t getLinkInfo(const char * link_name, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + H5L_info2_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_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC) const; + + // Retrieves information about an HDF5 object, given its name. + void getObjinfo(const char *name, H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + void getObjinfo(const H5std_string &name, H5O_info2_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_info2_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_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + + // Retrieves native native information about an HDF5 object. + void getNativeObjinfo(H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR) const; + + // Retrieves native information about an HDF5 object, given its name. + void getNativeObjinfo(const char *name, H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + void getNativeObjinfo(const H5std_string &name, H5O_native_info_t &objinfo, + unsigned fields = H5O_NATIVE_INFO_HDR, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + + // Retrieves native information about an HDF5 object, given its index. + void getNativeObjinfo(const char *grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + void getNativeObjinfo(const H5std_string &grp_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t idx, H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR, + 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 diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp index 081cab7..3feed51 100644 --- a/c++/src/H5Object.cpp +++ b/c++/src/H5Object.cpp @@ -13,7 +13,7 @@ #include -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -42,23 +42,23 @@ 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" herr_t +userAttrOpWrpr(hid_t loc_id, const char *attr_name, const H5A_info_t *ainfo, void *op_data) { - H5std_string s_attr_name = H5std_string(attr_name); - UserData4Aiterate* myData = reinterpret_cast (op_data); + H5std_string s_attr_name = H5std_string(attr_name); + UserData4Aiterate *myData = reinterpret_cast(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 H5Ovisit3 -extern "C" herr_t userVisitOpWrpr(hid_t obj_id, const char *attr_name, - const H5O_info2_t *obj_info, void *op_data) +extern "C" herr_t +userVisitOpWrpr(hid_t obj_id, const char *attr_name, const H5O_info2_t *obj_info, void *op_data) { - H5std_string s_attr_name = H5std_string(attr_name); - UserData4Visit* myData = reinterpret_cast (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(op_data); + int status = myData->op(*myData->obj, s_attr_name, obj_info, myData->opData); return status; } @@ -78,7 +78,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 +106,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 +132,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 +147,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 +168,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 +182,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(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(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 +212,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(*_idx) : 0; - int ret_value = H5Aiterate2(getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, - userAttrOpWrpr, static_cast(userData)); + int ret_value = + H5Aiterate2(getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, userAttrOpWrpr, static_cast(userData)); // release memory delete userData; @@ -229,9 +233,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(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"); } @@ -268,16 +272,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 = H5Ovisit3(getId(), idx_type, order, userVisitOpWrpr, static_cast(userData), fields); + herr_t ret_value = + H5Ovisit3(getId(), idx_type, order, userVisitOpWrpr, static_cast(userData), fields); // Release memory delete userData; @@ -300,10 +307,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_native_info_t objinfo; - unsigned version = 0; + unsigned version = 0; // Use C API to get information of the object herr_t ret_value = H5Oget_native_info(getId(), &objinfo, H5O_NATIVE_INFO_HDR); @@ -312,13 +320,12 @@ unsigned H5Object::objVersion() const if (ret_value < 0) throw Exception(inMemFunc("objVersion"), "H5Oget_native_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); } //-------------------------------------------------------------------------- @@ -328,14 +335,15 @@ unsigned H5Object::objVersion() const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int H5Object::getNumAttrs() const +int +H5Object::getNumAttrs() const { - H5O_info2_t oinfo; /* Object info */ + H5O_info2_t oinfo; /* Object info */ - if(H5Oget_info3(getId(), &oinfo, H5O_INFO_NUM_ATTRS) < 0) + if (H5Oget_info3(getId(), &oinfo, H5O_INFO_NUM_ATTRS) < 0) throw AttributeIException(inMemFunc("getNumAttrs"), "H5Oget_info failed"); else - return(static_cast(oinfo.num_attrs)); + return (static_cast(oinfo.num_attrs)); } //-------------------------------------------------------------------------- @@ -345,7 +353,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, @@ -353,7 +362,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"); @@ -366,9 +375,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())); } //-------------------------------------------------------------------------- @@ -378,7 +388,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) @@ -392,7 +403,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()); } @@ -405,7 +417,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) @@ -419,9 +432,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()); } //-------------------------------------------------------------------------- @@ -430,22 +444,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); } //-------------------------------------------------------------------------- @@ -455,7 +468,8 @@ 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 @@ -463,31 +477,28 @@ H5std_string H5Object::getObjName() const ssize_t name_size = H5Iget_name(getId(), NULL, static_cast(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); } //-------------------------------------------------------------------------- @@ -503,35 +514,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 @@ -543,4 +553,4 @@ ssize_t H5Object::getObjName(H5std_string& obj_name, size_t len) const H5Object::~H5Object() {} #endif // DOXYGEN_SHOULD_SKIP_THIS -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Object.h b/c++/src/H5Object.h index a63229c..104e2a5 100644 --- a/c++/src/H5Object.h +++ b/c++/src/H5Object.h @@ -40,94 +40,92 @@ 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 H5Ovisit3(). -typedef int (*visit_operator_t)(H5Object& obj, - const H5std_string attr_name, - const H5O_info2_t *oinfo, - void *operator_data); +typedef int (*visit_operator_t)(H5Object &obj, const H5std_string attr_name, const H5O_info2_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 = 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) = 0; - // Noop destructor. - virtual ~H5Object(); + // Noop destructor. + virtual ~H5Object(); #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5OcreatProp.cpp b/c++/src/H5OcreatProp.cpp index 0542d5e..a5af9df 100644 --- a/c++/src/H5OcreatProp.cpp +++ b/c++/src/H5OcreatProp.cpp @@ -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 @@ -92,7 +94,7 @@ 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 @@ -116,11 +118,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 +141,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 +170,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 +192,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); } //-------------------------------------------------------------------------- @@ -209,4 +211,4 @@ unsigned ObjCreatPropList::getAttrCrtOrder() const //-------------------------------------------------------------------------- ObjCreatPropList::~ObjCreatPropList() {} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5OcreatProp.h b/c++/src/H5OcreatProp.h index 1d5dd55..ffafd44 100644 --- a/c++/src/H5OcreatProp.h +++ b/c++/src/H5OcreatProp.h @@ -23,49 +23,52 @@ 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 diff --git a/c++/src/H5PredType.cpp b/c++/src/H5PredType.cpp index 57ba5e5..0339f4e 100644 --- a/c++/src/H5PredType.cpp +++ b/c++/src/H5PredType.cpp @@ -41,10 +41,7 @@ namespace H5 { // the provided HDF5 predefined datatype. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PredType::PredType(const hid_t predtype_id) : AtomType(predtype_id) -{ - id = H5Tcopy(predtype_id); -} +PredType::PredType(const hid_t predtype_id) : AtomType(predtype_id) { id = H5Tcopy(predtype_id); } //-------------------------------------------------------------------------- // Function: PredType default constructor @@ -60,7 +57,7 @@ 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 +70,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(H5Location &loc, 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 @@ -115,180 +118,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 +308,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 +323,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 +334,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 +379,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 +519,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 +715,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 +1108,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..2d1185b 100644 --- a/c++/src/H5PredType.h +++ b/c++/src/H5PredType.h @@ -26,412 +26,416 @@ 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 diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index a01878c..c64ecf8 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -19,16 +19,15 @@ #include -#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 +35,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 +47,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 +62,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 +72,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 +82,7 @@ void PropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for default property. //-------------------------------------------------------------------------- -const PropList& PropList::DEFAULT = *getConstant(); +const PropList &PropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -98,7 +99,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 +124,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 +156,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 +173,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 +202,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 +218,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 +237,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 +253,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 +274,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 +291,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 +310,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 +333,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 +353,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 +375,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 +399,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 +415,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 +436,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 +454,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 +486,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 +500,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 +519,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 +538,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())); } @@ -544,15 +551,15 @@ size_t PropList::getPropSize(const H5std_string& name) const /// a NULL 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; @@ -564,12 +571,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 +593,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 +609,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 +630,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 +647,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 +660,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 +675,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 +688,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 +703,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 +716,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 +731,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 +752,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 +769,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 +784,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 +805,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 +831,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..805f6da 100644 --- a/c++/src/H5PropList.h +++ b/c++/src/H5PropList.h @@ -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*