This example shows how to create datasets.
#ifdef OLD_HEADER_FILENAME
#include <iostream.h>
#else
#include <iostream>
#endif
#include <string>
#include "H5Cpp.h"
const H5std_string FILE_NAME( "SDS.h5" );
const H5std_string DATASET_NAME( "IntArray" );
const int NX = 5;
const int NY = 6;
const int RANK = 2;
int main (void)
{
int i, j;
int data[NX][NY];
for (j = 0; j < NX; j++)
{
for (i = 0; i < NY; i++)
data[j][i] = i + j;
}
try
{
Exception::dontPrint();
H5File file( FILE_NAME, H5F_ACC_TRUNC );
hsize_t dimsf[2];
dimsf[0] = NX;
dimsf[1] = NY;
IntType datatype( PredType::NATIVE_INT );
datatype.setOrder( H5T_ORDER_LE );
dataset.
write( data, PredType::NATIVE_INT );
}
{
return -1;
}
{
return -1;
}
{
return -1;
}
{
return -1;
}
return 0;
}
Class DataSet operates on HDF5 datasets.
Definition: H5DataSet.h:28
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
Writes raw data from an application buffer to a dataset.
Definition: H5DataSet.cpp:498
Definition: H5Exception.h:137
Class DataSpace inherits from IdComponent and provides wrappers for the HDF5's dataspaces.
Definition: H5DataSpace.h:25
Definition: H5Exception.h:109
Definition: H5Exception.h:116
static void printErrorStack(FILE *stream=stderr, hid_t err_stack=H5E_DEFAULT)
Prints the error stack in a default manner.
Definition: H5Exception.cpp:302
Definition: H5Exception.h:95
Class H5File represents an HDF5 file and inherits from class Group as file is a root group.
Definition: H5File.h:25
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
IntType is a derivative of a DataType and operates on HDF5 integer datatype.
Definition: H5IntType.h:25
Definition: H5AbstractDs.cpp:34