本文整理汇总了C++中DSetCreatPropList::setLayout方法的典型用法代码示例。如果您正苦于以下问题:C++ DSetCreatPropList::setLayout方法的具体用法?C++ DSetCreatPropList::setLayout怎么用?C++ DSetCreatPropList::setLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DSetCreatPropList
的用法示例。
在下文中一共展示了DSetCreatPropList::setLayout方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_compact_vlstring
/*-------------------------------------------------------------------------
* Function: test_compact_vlstring
*
* Purpose: Test storing VL strings in compact datasets.
*
* Return: None
*
* Programmer: Binh-Minh Ribler (use C version)
* January, 2007
*
*-------------------------------------------------------------------------
*/
static void test_compact_vlstring()
{
// Output message about test being performed
SUBTEST("VL Strings on Compact Dataset");
try {
// Create file
H5File file1(FILENAME, H5F_ACC_TRUNC);
// Create dataspace for datasets
hsize_t dims1[] = {SPACE1_DIM1};
DataSpace sid1(SPACE1_RANK, dims1);
// Create a datatype to refer to
StrType vlst(0, H5T_VARIABLE);
// Create dataset create property list and set layout
DSetCreatPropList plist;
plist.setLayout(H5D_COMPACT);
// Create a dataset
DataSet dataset(file1.createDataSet("Dataset5", vlst, sid1, plist));
// Write dataset to disk
const char *wdata[SPACE1_DIM1] = {"one", "two", "three", "four"};
dataset.write(wdata, vlst);
// Read dataset from disk
char *rdata[SPACE1_DIM1]; // Information read in
dataset.read(rdata, vlst);
// Compare data read in
hsize_t i;
for (i=0; i<SPACE1_DIM1; i++) {
if (HDstrlen(wdata[i])!=strlen(rdata[i])) {
TestErrPrintf("VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n",(int)i,(int)strlen(wdata[i]),(int)i,(int)strlen(rdata[i]));
continue;
} // end if
if (HDstrcmp(wdata[i],rdata[i]) != 0) {
TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n",(int)i,wdata[i],(int)i,rdata[i]);
continue;
} // end if
} // end for
// Reclaim the read VL data
DataSet::vlenReclaim((void *)rdata, vlst, sid1);
// Close objects and file
dataset.close();
vlst.close();
sid1.close();
plist.close();
file1.close();
PASSED();
} // end try
// Catch all exceptions.
catch (Exception E)
{
issue_fail_msg("test_compact_vlstrings()", __LINE__, __FILE__, E.getCDetailMsg());
}
} // test_compact_vlstrings