当前位置: 首页>>代码示例>>C++>>正文


C++ H5File::getComment方法代码示例

本文整理汇总了C++中H5File::getComment方法的典型用法代码示例。如果您正苦于以下问题:C++ H5File::getComment方法的具体用法?C++ H5File::getComment怎么用?C++ H5File::getComment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在H5File的用法示例。


在下文中一共展示了H5File::getComment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: space

/*-------------------------------------------------------------------------
 * Function:	test_create
 *
 * Purpose:	Attempts to create a dataset.
 *
 * Return:	Success:	0
 *
 *		Failure:	-1
 *
 * Programmer:	Binh-Minh Ribler (using C version)
 *		Friday, January 5, 2001
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static herr_t
test_create( H5File& file)
{
    SUBTEST("create, open, close");

    // Setting this to NULL for cleaning up in failure situations
    DataSet *dataset = NULL;
    try {
	// Create a data space
	hsize_t     dims[2];
	dims[0] = 256;
	dims[1] = 512;
	DataSpace space (2, dims, NULL);

	// Create a dataset using the default dataset creation properties.
	// We're not sure what they are, so we won't check.
	dataset = new DataSet (file.createDataSet
		(DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space));


	// Add a comment to the dataset
	file.setComment (DSET_DEFAULT_NAME, "This is a dataset");

	// Close the dataset
	delete dataset;
	dataset = NULL;

	// Try creating a dataset that already exists.  This should fail since a
	// dataset can only be created once.  If an exception is not thrown for
	// this action by createDataSet, then throw an invalid action exception.
	try {
	    dataset = new DataSet (file.createDataSet
			(DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space));

	    // continuation here, that means no exception has been thrown
	    throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset");
	}
	catch (FileIException E)	// catching invalid creating dataset
	{} // do nothing, exception expected

	// Open the dataset we created above and then close it.  This is one
	// way to open an existing dataset for accessing.
	dataset = new DataSet (file.openDataSet (DSET_DEFAULT_NAME));

	// Get and verify the name of this dataset, using
	// H5std_string getObjName()
	H5std_string ds_name = dataset->getObjName();
	verify_val(ds_name, DSET_DEFAULT_NAME_PATH, "DataSet::getObjName", __LINE__, __FILE__);

	// Get and verify the comment from this dataset, using
	// H5std_string getComment(const H5std_string& name, <buf_size=0, by default>)
	H5std_string comment = file.getComment(DSET_DEFAULT_NAME);
	verify_val(comment, "This is a dataset", "DataSet::getComment", __LINE__, __FILE__);

	// Close the dataset when accessing is completed
	delete dataset;

	// This is another way to open an existing dataset for accessing.
	DataSet another_dataset(file.openDataSet (DSET_DEFAULT_NAME));

	// Try opening a non-existent dataset.  This should fail so if an
	// exception is not thrown for this action by openDataSet, then
	// display failure information and throw an exception.
	try {
	    dataset = new DataSet (file.openDataSet( "does_not_exist" ));

	    // continuation here, that means no exception has been thrown
	    throw InvalidActionException("H5File::openDataSet", "Attempted to open a non-existent dataset");
	}
	catch (FileIException E ) // catching creating non-existent dataset
	{} // do nothing, exception expected

	// Create a new dataset that uses chunked storage instead of the default
	// layout.
	DSetCreatPropList create_parms;
	hsize_t     csize[2];
	csize[0] = 5;
	csize[1] = 100;
	create_parms.setChunk( 2, csize );

	dataset = new DataSet (file.createDataSet
		(DSET_CHUNKED_NAME, PredType::NATIVE_DOUBLE, space, create_parms));
	// Note: this one has no error message in C when failure occurs?

//.........这里部分代码省略.........
开发者ID:Hulalazz,项目名称:rnnlib,代码行数:101,代码来源:dsets.cpp


注:本文中的H5File::getComment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。