本文整理汇总了C++中H5File::createGroup方法的典型用法代码示例。如果您正苦于以下问题:C++ H5File::createGroup方法的具体用法?C++ H5File::createGroup怎么用?C++ H5File::createGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类H5File
的用法示例。
在下文中一共展示了H5File::createGroup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: h5CreateMetaData
//'@title Function creates the groups for the meta data to be written to the h5 file
//'
//'@description Function to create the groups in the h5 file before it is populated.
//'This function is intended for internal use only
//'
//'@param filePath character path to the location where the h5 file will be written
//'@return int 0
// [[Rcpp::export]]
int h5CreateMetaData(std::string filePath)
{
H5File *file = new H5File(filePath, H5F_ACC_RDWR);
hsize_t dims[1] = {1};
// The variable length string type
StrType vlst(0, H5T_VARIABLE);
// Creating the meta data group
Group *metaGroup = new Group(file->createGroup("/MetaData"));
// File path
H5std_string fString("FilePath");
DataSpace fileDataSpace (1, dims, NULL);
DataSet fileDataSet;
// Create a dataset in the group
fileDataSet = metaGroup->createDataSet(fString, vlst, fileDataSpace);
fileDataSet.write(filePath, vlst);
// Create the factor group
Group *factorGroup = new Group(metaGroup->createGroup("/MetaData/Factor"));
fileDataSet.close(); //nn
factorGroup->close();
metaGroup->close();
file->close();
return 0;
}
示例2: orig_int
/*-------------------------------------------------------------------------
* Function: test_types
*
* Purpose: Test various types - should be moved to dtypes.cpp
*
* Return: Success: 0
*
* Failure: -1
*
* Programmer: Binh-Minh Ribler (using C version)
* February 17, 2001
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
test_types(H5File& file)
{
SUBTEST("Various datatypes");
size_t i;
DataSet* dset = NULL;
try {
// Create a group in the file that was passed in from the caller
Group grp = file.createGroup ("typetests");
/* bitfield_1 */
unsigned char buf[32];
hsize_t nelmts = sizeof(buf);
DataType type;
try { // block of bitfield_1
// test copying a predefined type
type.copy (PredType::STD_B8LE);
// Test copying a user-defined type using DataType::copy
DataType copied_type;
copied_type.copy(type);
// Test copying a user-defined type using DataType::operator=
DataType another_copied_type;
another_copied_type = type;
// Test copying a user-defined int type using DataType::operator=
IntType orig_int(PredType::STD_B8LE);
DataType generic_type;
generic_type = orig_int;
// Test copying an integer predefined type
IntType new_int_type(PredType::STD_B8LE);
// Test copying an int predefined type using DataType::operator=
IntType another_int_type;
another_int_type = new_int_type;
DataSpace space (1, &nelmts);
dset = new DataSet(grp.createDataSet("bitfield_1", type, space));
// Fill buffer
for (i=0; i<sizeof buf; i++)
buf[i] = (unsigned char)0xff ^ (unsigned char)i;
// Write data from buf using all default dataspaces and property list
dset->write (buf, type);
// no failure in bitfield_1, close this dataset
delete dset;
} // end try block of bitfield_1
// catch exceptions thrown in try block of bitfield_1
catch (Exception E)
{
cerr << " FAILED" << endl;
cerr << " <<< " << "bitfield_1: " << E.getFuncName()
<< " - " << E.getDetailMsg() << " >>>" << endl << endl;
if (dset != NULL)
delete dset;
return -1;
}
/* bitfield_2 */
nelmts = sizeof(buf)/2;
try { // bitfield_2 block
type.copy (PredType::STD_B16LE);
DataSpace space (1, &nelmts);
dset = new DataSet(grp.createDataSet("bitfield_2", type, space));
// Fill buffer
for (i=0; i<sizeof(buf); i++)
buf[i] = (unsigned char)0xff ^ (unsigned char)i;
// Write data from buf using all default dataspaces and property
// list; if writing fails, deallocate dset and return.
dset->write (buf, type);
// no failure in bitfield_2, close this dataset and reset for
// variable reuse
delete dset;
dset = NULL;
//.........这里部分代码省略.........