本文整理汇总了C++中H5std_string::length方法的典型用法代码示例。如果您正苦于以下问题:C++ H5std_string::length方法的具体用法?C++ H5std_string::length怎么用?C++ H5std_string::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类H5std_string
的用法示例。
在下文中一共展示了H5std_string::length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getName
//--------------------------------------------------------------------------
// Function: Attribute::getName
///\brief Gets the name of this attribute, returning its length.
///\param attr_name - OUT: Buffer for the name string as \a H5std_string
///\param len - IN: Desired length of the name, default to 0
///\return Actual length of the attribute name
///\exception H5::AttributeIException
///\par Description
/// This function retrieves the attribute's name as a string. The
/// buf_size can specify a specific length or default to 0, in
/// which case the entire name will be retrieved.
// Programmer Binh-Minh Ribler - Nov, 2001
// Modification
// Mar 2014 - BMR
// Added to replace getName(size_t, H5std_string&) so that it'll
// allow the argument "len" to be skipped.
//--------------------------------------------------------------------------
ssize_t Attribute::getName(H5std_string& attr_name, size_t len) const
{
ssize_t name_size = 0;
// If no length is provided, get the entire attribute name
if (len == 0)
{
attr_name = getName();
name_size = attr_name.length();
}
// If length is provided, get that number of characters in name
else
{
char* name_C = new char[len+1]; // temporary C-string
HDmemset(name_C, 0, len+1); // clear buffer
// Use overloaded function
name_size = getName(name_C, len+1);
// Convert the C attribute name to return
attr_name = name_C;
// Clean up resource
delete []name_C;
}
// Otherwise, keep attr_name intact
// Return name size
return(name_size);
}
示例2: manydims_ds
/*-------------------------------------------------------------------------
* Function: test_h5s_basic
*
* Purpose Test basic H5S (dataspace) code
*
* Return None
*
* Programmer Binh-Minh Ribler (using C version)
* Mar 2001
*
* Modifications:
* January, 2005: C tests' macro VERIFY casts values to 'long' for all
* cases. Since there are no operator<< for 'long long'
* or int64 in VS C++ ostream, I casted the hssize_t values
* passed to verify_val to 'long' as well. If problems
* arises later, this will have to be specificly handled
* with a special routine.
* April 12, 2011: Raymond Lu
* Starting from the 1.8.7 release, we allow dimension
* size to be zero. So I took out the test against it.
*-------------------------------------------------------------------------
*/
static void test_h5s_basic()
{
hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2, SPACE2_DIM3, SPACE2_DIM4};
hsize_t dims3[H5S_MAX_RANK+1];
hsize_t tmax[4];
// Output message about test being performed
SUBTEST("Dataspace Manipulation");
try {
// Create simple dataspace sid1
DataSpace sid1 (SPACE1_RANK, dims1 );
// Get simple extent npoints of the dataspace sid1 and verify it
hssize_t n; // Number of dataspace elements
n = sid1.getSimpleExtentNpoints();
verify_val((long)n, (long)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3),
"DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
// Get the logical rank of dataspace sid1 and verify it
int rank; // Logical rank of dataspace
rank = sid1.getSimpleExtentNdims();
verify_val(rank, SPACE1_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__);
// Retrieves dimension size of dataspace sid1 and verify it
int ndims; // Number of dimensions
hsize_t tdims[4]; // Dimension array to test with
ndims = sid1.getSimpleExtentDims( tdims );
verify_val(ndims, SPACE1_RANK, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
verify_val(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(unsigned)), 0,
"DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
// Create simple dataspace sid2
hsize_t max2[] = {SPACE2_MAX1, SPACE2_MAX2, SPACE2_MAX3, SPACE2_MAX4};
DataSpace sid2 (SPACE2_RANK, dims2, max2);
// Get simple extent npoints of dataspace sid2 and verify it
n = sid2.getSimpleExtentNpoints();
verify_val((long)n, (long)(SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4),
"DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
// Get the logical rank of dataspace sid2 and verify it
rank = sid2.getSimpleExtentNdims();
verify_val(rank, SPACE2_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__);
// Retrieves dimension size and max size of dataspace sid2 and
// verify them
ndims = sid2.getSimpleExtentDims( tdims, tmax );
verify_val(HDmemcmp(tdims, dims2, SPACE2_RANK * sizeof(unsigned)), 0,
"DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
verify_val(HDmemcmp(tmax, max2, SPACE2_RANK * sizeof(unsigned)), 0,
"DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
// Check to be sure we can't create a simple data space that has too
// many dimensions.
try {
DataSpace manydims_ds(H5S_MAX_RANK+1, dims3, NULL);
// Should FAIL but didn't, so throw an invalid action exception
throw InvalidActionException("DataSpace constructor", "Library allowed overwrite of existing dataset");
}
catch (DataSpaceIException& E) // Simple data space with too many dims
{} // do nothing, exception expected
/*
* Try reading a file that has been prepared that has a dataset with a
* higher dimensionality than what the library can handle.
*
* If this test fails and the H5S_MAX_RANK variable has changed, follow
* the instructions in space_overflow.c for regenating the th5s.h5 file.
*/
char *tmp_str = new char[TESTFILE.length()+1];
strcpy(tmp_str, TESTFILE.c_str());
const char *testfile = H5_get_srcdir_filename(tmp_str);
delete []tmp_str;
// Create file
//.........这里部分代码省略.........