summaryrefslogtreecommitdiffstats
path: root/c++/examples/h5tutr_crtgrpd.cpp
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
commitb2d661b508a7fc7a2592c13bc6bdc175551f075d (patch)
tree13baeb0d83a7c2a4c6299993c182b1227c2f6114 /c++/examples/h5tutr_crtgrpd.cpp
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'c++/examples/h5tutr_crtgrpd.cpp')
-rw-r--r--c++/examples/h5tutr_crtgrpd.cpp66
1 files changed, 30 insertions, 36 deletions
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;
}