summaryrefslogtreecommitdiffstats
path: root/c++/examples/h5tutr_crtgrpd.cpp
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-10-01 14:04:36 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-10-01 14:04:36 (GMT)
commitf1ba03cea5b82699a984c80bd2deac14fdc8df18 (patch)
treeebe777c3e0b83f4c4cec9212731da9ebe0a0cfd3 /c++/examples/h5tutr_crtgrpd.cpp
parent10343c197906415388f2a4c8d292e21d25cf7381 (diff)
downloadhdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.zip
hdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.tar.gz
hdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.tar.bz2
Source formatted
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;
}