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


C++ H5std_string类代码示例

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


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

示例1: write

//--------------------------------------------------------------------------
// Function:	Attribute::write
///\brief	This is an overloaded member function, provided for convenience.
///		It writes a \a H5std_string to this attribute.
///\param	mem_type  - IN: Attribute datatype (in memory)
///\param	strg      - IN: Data to be written
///\exception	H5::AttributeIException
// Programmer	Binh-Minh Ribler - Apr, 2003
//--------------------------------------------------------------------------
void Attribute::write(const DataType& mem_type, const H5std_string& strg) const
{
    // Check if this attribute has variable-len string or fixed-len string and
    // proceed appropriately.
    htri_t is_variable_len = H5Tis_variable_str(mem_type.getId());
    if (is_variable_len < 0)
    {
	throw AttributeIException("Attribute::write", "H5Tis_variable_str failed");
    }
    // Convert string to C-string
    const char* strg_C;
    strg_C = strg.c_str();  // strg_C refers to the contents of strg as a C-str
    herr_t ret_value = 0;

    // Pass string in differently depends on variable or fixed length
    if (!is_variable_len)
    {
	ret_value = H5Awrite(id, mem_type.getId(), strg_C);
    }
    else
    {
	// passing third argument by address
	ret_value = H5Awrite(id, mem_type.getId(), &strg_C);
    }
    if (ret_value < 0)
    {
	throw AttributeIException("Attribute::write", "H5Awrite failed");
    }
}
开发者ID:Hulalazz,项目名称:rnnlib,代码行数:38,代码来源:H5Attribute.cpp

示例2: 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);
}
开发者ID:Hulalazz,项目名称:rnnlib,代码行数:47,代码来源:H5Attribute.cpp

示例3: H5Location

//--------------------------------------------------------------------------
// Function:	H5File overloaded constructor
///\brief	This is another overloaded constructor.  It differs from the
///		above constructor only in the type of the \a name argument.
///\param	name - IN: Name of the file - \c H5std_string
///\param	flags - IN: File access flags
///\param	create_plist - IN: File creation property list, used when
///		modifying default file meta-data.  Default to
///		FileCreatPropList::DEFAULT
///\param	access_plist - IN: File access property list.  Default to
///		FileAccPropList::DEFAULT
// Notes	With a PGI compiler (~2012-2013), the exception thrown by p_get_file
//		could not be caught in the applications.  Added try block here
//		to catch then re-throw it. -BMR 2013/03/21
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
H5File::H5File( const H5std_string& name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : H5Location(), id(0)
{
    try {
	p_get_file(name.c_str(), flags, create_plist, access_plist);
    } catch (FileIException open_file) {
	throw open_file;
    }
}
开发者ID:Hulalazz,项目名称:rnnlib,代码行数:24,代码来源:H5File.cpp

示例4: ReferenceException

//--------------------------------------------------------------------------
// Function:	H5Location::reference
///\brief	This is an overloaded member function, provided for convenience.
///		It differs from the above function in that it takes an
///		\c H5std_string for \a name.
///\param	ref - IN: Reference pointer
///\param	name - IN: Name of the object to be referenced
///\param	dataspace - IN: Dataspace with selection
///\param	ref_type - IN: Type of reference to query, valid values are:
///		\li \c H5R_OBJECT         - Reference is an object reference.
///		\li \c H5R_DATASET_REGION - Reference is a dataset region
///			reference. (default)
///\exception	H5::ReferenceException
///\note	This method is more suitable for a dataset region reference.
// Programmer	Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
void H5Location::reference(void* ref, const H5std_string& name, const DataSpace& dataspace, H5R_type_t ref_type) const
{
   try {
      p_reference(ref, name.c_str(), dataspace.getId(), ref_type);
   }
   catch (ReferenceException E) {
      throw ReferenceException(inMemFunc("reference"), E.getDetailMsg());
   }
}
开发者ID:Hulalazz,项目名称:rnnlib,代码行数:25,代码来源:H5Location.cpp

示例5: test_get_objtype

/*-------------------------------------------------------------------------
 * Function:	test_get_objtype
 *
 * Purpose:	Tests getting object type
 *
 * Return:	Success:	0
 *		Failure:	-1
 *
 * Programmer:	Binh-Minh Ribler
 *		Friday, March 4, 2014
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
static void test_get_objtype()
{
    SUBTEST("H5File::childObjType and H5Group::childObjType");

    try {
	// Open file
	H5File file(FILE_OBJECTS, H5F_ACC_RDWR);

	// Open the top group
	Group grp1 = file.openGroup(GROUP1);

	// Create a datatype and save it
	DataType dtype(PredType::STD_I32LE);
	dtype.commit(grp1, "STD_I32LE");

	// Get and verify object type with
	// H5O_type_t childObjType(const H5std_string& objname)
	H5O_type_t objtype = file.childObjType(DSET_IN_FILE);
	verify_val(objtype, H5O_TYPE_DATASET, "DataSet::childObjType", __LINE__, __FILE__);

	// Get and verify object type with
	// H5O_type_t childObjType(const char* objname)
	objtype = grp1.childObjType(GROUP1_1.c_str());
	verify_val(objtype, H5O_TYPE_GROUP, "DataSet::childObjType", __LINE__, __FILE__);

	// Get and verify object type with
	// H5O_type_t childObjType(hsize_t index, H5_index_t index_type,
	// H5_iter_order_t order, const char* objname=".")
	objtype = grp1.childObjType((hsize_t)1, H5_INDEX_NAME, H5_ITER_INC);
	verify_val(objtype, H5O_TYPE_NAMED_DATATYPE, "DataSet::childObjType", __LINE__, __FILE__);

	// Get and verify object type with
	// H5O_type_t childObjType(hsize_t index,
	// H5_index_t index_type=H5_INDEX_NAME,
	// H5_iter_order_t order=H5_ITER_INC, const char* objname=".")
	objtype = grp1.childObjType((hsize_t)2);
	verify_val(objtype, H5O_TYPE_GROUP, "DataSet::childObjType", __LINE__, __FILE__);

	// Everything will be closed as they go out of scope

	PASSED();
    }	// try block

    // catch all other exceptions
    catch (Exception& E)
    {
	issue_fail_msg("test_get_objtype", __LINE__, __FILE__);
    }
}   // test_get_objtype
开发者ID:flexi-framework,项目名称:HDF5,代码行数:64,代码来源:tobject.cpp

示例6: insertMember

//--------------------------------------------------------------------------
// Function:	CompType::insertMember
///\brief	Inserts a new member to this compound datatype.
///\param	name - IN: Name of the new member
///\param	offset - IN: Offset in memory structure of the field to insert
///\param	new_member - IN: New member to be inserted
///\exception	H5::DataTypeIException
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void CompType::insertMember( const H5std_string& name, size_t offset, const DataType& new_member ) const
{
   // Convert string to C-string
   const char* name_C;
   name_C = name.c_str();  // name_C refers to the contents of name as a C-str

   hid_t new_member_id = new_member.getId();  // get new_member id for C API

   // Call C routine H5Tinsert to add the new member
   herr_t ret_value = H5Tinsert( id, name_C, offset, new_member_id );
   if( ret_value < 0 )
   {
      throw DataTypeIException("CompType::insertMember", "H5Tinsert failed");
   }
}
开发者ID:Andy-Sun,项目名称:VTK,代码行数:24,代码来源:H5CompType.cpp

示例7: write

//--------------------------------------------------------------------------
// Function:	DataSet::write
///\brief	This is an overloaded member function, provided for convenience.
///		It takes a reference to a \c H5std_string for the buffer.
// Programmer	Binh-Minh Ribler - 2000
// Modification
//	Jul 2009
//		Modified to pass the buffer into H5Dwrite properly depending
//		whether the dataset has variable- or fixed-length string.
//--------------------------------------------------------------------------
void DataSet::write( const H5std_string& strg, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist ) const
{
    // Check if this attribute has variable-len string or fixed-len string and
    // proceed appropriately.
    htri_t is_variable_len = H5Tis_variable_str(mem_type.getId());
    if (is_variable_len < 0)
    {
        throw DataSetIException("DataSet::write", "H5Tis_variable_str failed");
    }

   // Obtain identifiers for C API
   hid_t mem_type_id = mem_type.getId();
   hid_t mem_space_id = mem_space.getId();
   hid_t file_space_id = file_space.getId();
   hid_t xfer_plist_id = xfer_plist.getId();

    // Convert string to C-string
    const char* strg_C;
    strg_C = strg.c_str();  // strg_C refers to the contents of strg as a C-str
    herr_t ret_value = 0;

    // Pass string in differently depends on variable or fixed length
    if (!is_variable_len)
    {
        ret_value = H5Dwrite( id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, strg_C );
    }
    else
    {
        // passing string argument by address
        ret_value = H5Dwrite( id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, &strg_C );
    }
    if (ret_value < 0)
    {
        throw DataSetIException("DataSet::write", "H5Dwrite failed");
    }
}
开发者ID:CapeDrew,项目名称:DITK,代码行数:46,代码来源:H5DataSet.cpp

示例8: openVarLenType

//--------------------------------------------------------------------------
// Function:	CommonFG::openVarLenType
///\brief	This is an overloaded member function, provided for convenience.
///		It differs from the above function in that it takes an
///		\c H5std_string for \a name.
// Programmer	Binh-Minh Ribler - Jul, 2005
//--------------------------------------------------------------------------
VarLenType CommonFG::openVarLenType( const H5std_string& name ) const
{
   return( openVarLenType( name.c_str()) );
}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:11,代码来源:H5CommonFG.cpp

示例9: unmount

//--------------------------------------------------------------------------
// Function:	CommonFG::unmount
///\brief	This is an overloaded member function, provided for convenience.
///		It differs from the above function in that it takes an
///		\c H5std_string for \a name.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void CommonFG::unmount( const H5std_string& name ) const
{
   unmount( name.c_str() );
}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:11,代码来源:H5CommonFG.cpp

示例10: test_file_attribute

static void test_file_attribute()
{
    int rdata[ATTR1_DIM1];
    int i;

    // Output message about test being performed
    SUBTEST("File Attribute");

    H5std_string file_name;
    try {
        // Create a file using default properties.
        H5File file5(FILE5, H5F_ACC_TRUNC);

        // Create the data space
        hsize_t dims[RANK1] = {ATTR1_DIM1};
        DataSpace space(RANK1, dims);

        // Create two attributes for the file
        Attribute fattr1(file5.createAttribute(FATTR1_NAME, PredType::NATIVE_FLOAT, space));
        Attribute fattr2(file5.createAttribute(FATTR2_NAME, PredType::NATIVE_INT, space));

        fattr2.write(PredType::NATIVE_INT, fattr_data);

        try {
            // Try to create the same attribute again (should fail)
            Attribute fattr_dup(file5.createAttribute(FATTR2_NAME, PredType::NATIVE_INT, space));
            // Should FAIL but didn't, so throw an invalid action exception
            throw InvalidActionException("H5File createAttribute", "Attempted to create an existing attribute.");
        }
        catch (AttributeIException& E) // catch creating existing attribute
        {} // do nothing, FAIL expected

        // Create a new dataset
        DataSet dataset(file5.createDataSet (DSETNAME, PredType::NATIVE_INT, space));

        // Create an attribute for the dataset
        Attribute dattr(dataset.createAttribute(DATTRNAME, PredType::NATIVE_INT, space));

        // Write data to the second file attribute
        dattr.write(PredType::NATIVE_INT, dattr_data);

        // Test flushing out the data from the attribute object
        dattr.flush(H5F_SCOPE_GLOBAL);

        // Get and verify the number of all objects in the file
        // Current: 1 file, 2 file attr, 1 ds, and 1 ds attr.
        ssize_t num_objs = file5.getObjCount(H5F_OBJ_ALL);
        verify_val(num_objs, 5, "H5File::getObjCount", __LINE__, __FILE__);

        num_objs = file5.getObjCount(H5F_OBJ_GROUP);
        verify_val(num_objs, 0, "H5File::getObjCount(H5F_OBJ_GROUP)", __LINE__, __FILE__);
        num_objs = file5.getObjCount(H5F_OBJ_DATASET);
        verify_val(num_objs, 1, "H5File::getObjCount(H5F_OBJ_DATASET)", __LINE__, __FILE__);
        num_objs = file5.getObjCount(H5F_OBJ_ATTR);
        verify_val(num_objs, 3, "H5File::getObjCount(H5F_OBJ_ATTR)", __LINE__, __FILE__);
        num_objs = file5.getObjCount(H5F_OBJ_DATATYPE);
        verify_val(num_objs, 0, "H5File::getObjCount(H5F_OBJ_DATATYPE)", __LINE__, __FILE__);
        num_objs = file5.getObjCount(H5F_OBJ_FILE);
        verify_val(num_objs, 1, "H5File::getObjCount(H5F_OBJ_FILE)", __LINE__, __FILE__);
        
        // Get the file name using the attributes
        H5std_string fname = fattr1.getFileName();
        verify_val(fname, FILE5, "H5File::getFileName()", __LINE__, __FILE__);

        fname.clear();
        fname = dattr.getFileName();
        verify_val(fname, FILE5, "H5File::getFileName()", __LINE__, __FILE__);

        // Get the class of a file attribute's datatype
        H5T_class_t atclass = fattr1.getTypeClass();
        verify_val(atclass, H5T_FLOAT, "Attribute::getTypeClass()", __LINE__, __FILE__);

        // Get and verify the number of attributes attached to a file
        int n_attrs = file5.getNumAttrs();
        verify_val(n_attrs, 2, "H5File::getNumAttrs()", __LINE__, __FILE__);

        // Get and verify the number of attributes attached to a dataset
        n_attrs = 0;
        n_attrs = dataset.getNumAttrs();
        verify_val(n_attrs, 1, "DataSet::getNumAttrs()", __LINE__, __FILE__);

        // Read back attribute's data
        HDmemset(rdata, 0, sizeof(rdata));
        dattr.read(PredType::NATIVE_INT, rdata);
        /* Check results */
        for (i = 0; i < ATTR1_DIM1; i++) {
            if (rdata[i] != dattr_data[i]) {
                H5_FAILED();
                cerr << endl;
                cerr << "element [" << i << "] is " << rdata[i] <<
                        "but should have been " << dattr_data[i] << endl;
                }
            }
        PASSED();
    }   // end of try block

    catch (Exception& E)
    {
        issue_fail_msg("test_file_attribute()", __LINE__, __FILE__, E.getCDetailMsg());
    }
//.........这里部分代码省略.........
开发者ID:Starlink,项目名称:hdf5,代码行数:101,代码来源:tfile.cpp

示例11: reference

//--------------------------------------------------------------------------
// Function:    H5Object::reference
///\brief       This is an overloaded function, provided for your convenience.
///             It differs from the above function in that it takes an
///             \c H5std_string for the object's name.
///\param       ref - IN: Reference pointer
///\param       name - IN: Name of the object to be referenced - \c H5std_string
// Programmer   Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
void H5Object::reference(void* ref, const H5std_string& name) const
{
   reference(ref, name.c_str());
}
开发者ID:VisBlank,项目名称:hdf5,代码行数:13,代码来源:H5Object.cpp

示例12: removeAttr

//--------------------------------------------------------------------------
// Function:	H5Object::removeAttr
///\brief	This is an overloaded member function, provided for convenience.
///		It differs from the above function in that it takes
///		a reference to an \c H5std_string for \a name.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void H5Object::removeAttr( const H5std_string& name ) const
{
   removeAttr( name.c_str() );
}
开发者ID:VisBlank,项目名称:hdf5,代码行数:11,代码来源:H5Object.cpp

示例13: return

//--------------------------------------------------------------------------
// Function:	H5Object::createAttribute
///\brief	This is an overloaded member function, provided for convenience.
///		It differs from the above function in that it takes
///		a reference to an \c H5std_string for \a name.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
Attribute H5Object::createAttribute( const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const PropList& create_plist ) const
{
   return( createAttribute( name.c_str(), data_type, data_space, create_plist ));
}
开发者ID:VisBlank,项目名称:hdf5,代码行数:11,代码来源:H5Object.cpp

示例14: iterateElems

//--------------------------------------------------------------------------
// Function:	CommonFG::iterateElems
///\brief	This is an overloaded member function, provided for convenience.
///		It differs from the above function in that it takes an
///		\c H5std_string for \a name.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
int CommonFG::iterateElems( const H5std_string& name, int *idx, H5G_iterate_t op , void* op_data )
{
   return( iterateElems( name.c_str(), idx, op, op_data ));
}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:11,代码来源:H5CommonFG.cpp

示例15: getObjinfo

//--------------------------------------------------------------------------
// Function:	CommonFG::getObjinfo
///\brief	This is an overloaded member function, provided for convenience.
///		It differs from the above function in that it takes an
///		\c H5std_string for \a name.
// Programmer	Binh-Minh Ribler - Nov, 2005
//--------------------------------------------------------------------------
void CommonFG::getObjinfo( const H5std_string& name, H5G_stat_t& statbuf ) const
{
   getObjinfo( name.c_str(), statbuf );
}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:11,代码来源:H5CommonFG.cpp


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