Beispiel #1
0
//--------------------------------------------------------------------------
// Function:	CommonFG::unlink
///\brief	This is an overloaded member function, provided for convenience.
///		It differs from the above function in that it takes an
///		\c std::string for \a name.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void CommonFG::unlink( const H5std_string& name ) const
{
   unlink( name.c_str() );
}
Beispiel #2
0
//--------------------------------------------------------------------------
// Function:	H5File::isHdf5
///\brief	This is an overloaded member function, provided for convenience.
///		It takes an \c H5std_string for \a name. (Static)
///\param	name - IN: Name of the file - \c H5std_string
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
bool H5File::isHdf5(const H5std_string& name )
{
   return( isHdf5( name.c_str()) );
}
Beispiel #3
0
//--------------------------------------------------------------------------
// 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
///		FileCreatPropList::DEFAULT
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
H5File::H5File( const H5std_string& name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : H5Location(0)
{
   p_get_file(name.c_str(), flags, create_plist, access_plist);
}
Beispiel #4
0
//--------------------------------------------------------------------------
// Function:	PropList::getPropSize
///\brief	This is an overloaded member function, provided for convenience.
/// 		It differs from the above function only in what arguments it
///		accepts.
///\param	name - IN: Name of property to query - \c H5std_string
///
// Programmer:  Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
size_t PropList::getPropSize(const H5std_string& name) const
{
   return (getPropSize(name.c_str()));
}
Beispiel #5
0
//--------------------------------------------------------------------------
// Function:	PropList::setProperty
///\brief	This is an overloaded member function, provided for convenience.
/// 		It differs from the above function only in what arguments it
///		accepts.
///\param	name - IN: Name of property to set - \c H5std_string
///\param	strg - IN: Value for the property is a \c H5std_string
// Programmer:  Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
void PropList::setProperty(const H5std_string& name, H5std_string& strg) const
{
   setProperty(name.c_str(), strg.c_str());
}
Beispiel #6
0
/*-------------------------------------------------------------------------
 * Function:    test_file_create
 *
 * Purpose:     Test file and template creations
 *
 * Return:      None
 *
 * Programmer:  Binh-Minh Ribler (use C version)
 *              January, 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 hsize_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.
 *
 *-------------------------------------------------------------------------
 */
static void test_file_create()
{
    // Output message about test being performed
    SUBTEST("File Creation I/O");

    // Test create with various sequences of H5F_ACC_EXCL and
    // H5F_ACC_TRUNC flags

    // Create with H5F_ACC_EXCL
    // First ensure the file does not exist
    remove(FILE1.c_str());

    // Setting this to NULL for cleaning up in failure situations
    H5File* file1 = NULL;
    try {
	// Create file FILE1
	file1 = new H5File (FILE1, H5F_ACC_EXCL);

	// try to create the same file with H5F_ACC_TRUNC. This should fail
	// because file1 is the same file and is currently open.
#ifndef H5_HAVE_FILE_VERSIONS
	try {
	    H5File file2 (FILE1, H5F_ACC_TRUNC);  // should throw E

	    // Should FAIL but didn't, so throw an invalid action exception
	    throw InvalidActionException("H5File constructor", "Attempted to create an existing file.");
	}
	catch( FileIException E ) // catch truncating existing file
	{} // do nothing, FAIL expected
#endif
	// Close file1
	delete file1;
	file1 = NULL;

	// Try again with H5F_ACC_EXCL. This should fail because the file
	// already exists from the previous steps.
	try {
	    H5File file2(FILE1, H5F_ACC_EXCL);  // should throw E

	    // Should FAIL but didn't, so throw an invalid action exception
	    throw InvalidActionException("H5File constructor", "File already exists.");
	}
	catch( FileIException E ) // catching creating existing file
	{} // do nothing, FAIL expected
    	// Test create with H5F_ACC_TRUNC. This will truncate the existing file.
	file1 = new H5File (FILE1, H5F_ACC_TRUNC);

#ifndef H5_HAVE_FILE_VERSIONS
	// Try to truncate first file again. This should fail because file1
	// is the same file and is currently open.
    	try {
	    H5File file2 (FILE1, H5F_ACC_TRUNC);   // should throw E

	    // Should FAIL but didn't, so throw an invalid action exception
	    throw InvalidActionException("H5File constructor", "H5F_ACC_TRUNC attempt on an opened file.");
	}
	catch( FileIException E ) // catching truncating opened file
	{} // do nothing, FAIL expected
#endif
     	// Try with H5F_ACC_EXCL. This should fail too because the file already
     	// exists.
    	try {
	    H5File file3 (FILE1, H5F_ACC_EXCL);  // should throw E

	    // Should FAIL but didn't, so throw an invalid action exception
	    throw InvalidActionException("H5File constructor", "H5F_ACC_EXCL attempt on an existing file.");
    	}
	catch( FileIException E ) // catching H5F_ACC_EXCL on existing file
	{} // do nothing, FAIL expected

    	// Get the file-creation template
	FileCreatPropList tmpl1 = file1->getCreatePlist();

	hsize_t ublock = tmpl1.getUserblock();
	verify_val((long)ublock, (long)F1_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__);

    	size_t  parm1, parm2;		// file-creation parameters
	tmpl1.getSizes( parm1, parm2);
	verify_val(parm1, F1_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
	verify_val(parm2, F1_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);

        unsigned  iparm1,iparm2;        // file-creation parameters
        tmpl1.getSymk( iparm1, iparm2);
        verify_val(iparm1, F1_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);
        verify_val(iparm2, F1_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);

	// tmpl1 is automatically closed; if error occurs, it'll be
	// caught in the catch block

	// Close first file
	delete file1;
    }
    catch (InvalidActionException E)
    {
        cerr << " *FAILED*" << endl;
        cerr << "    <<<  " << E.getDetailMsg() << "  >>>" << endl << endl;
        if (file1 != NULL) // clean up
            delete file1;
    }
    // catch all other exceptions
    catch (Exception E)
    {
	issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg());
        if (file1 != NULL) // clean up
            delete file1;
    }

    // Setting this to NULL for cleaning up in failure situations
    FileCreatPropList* tmpl1 = NULL;
    try
    {
    	// Create a new file with a non-standard file-creation template
	tmpl1 = new FileCreatPropList;

    	// Set the new file-creation parameters
	tmpl1->setUserblock (F2_USERBLOCK_SIZE);
	tmpl1->setSizes( F2_OFFSET_SIZE, F2_LENGTH_SIZE );
	tmpl1->setSymk( F2_SYM_INTERN_K, F2_SYM_LEAF_K );

     	// Try to create second file, with non-standard file-creation template
     	// params.
	H5File file2( FILE2, H5F_ACC_TRUNC, *tmpl1 );

    	// Release file-creation template
	delete tmpl1;
	tmpl1 = NULL;

	// Get the file-creation template
	tmpl1 = new FileCreatPropList (file2.getCreatePlist());

	// Get the file-creation parameters
	hsize_t ublock = tmpl1->getUserblock();
	verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__);

    	size_t  parm1, parm2;		// file-creation parameters
	tmpl1->getSizes( parm1, parm2);
	verify_val(parm1, F2_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
	verify_val(parm2, F2_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);

        unsigned  iparm1,iparm2;	// file-creation parameters
        tmpl1->getSymk( iparm1, iparm2);
        verify_val(iparm1, F2_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);
        verify_val(iparm2, F2_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);

	// Clone the file-creation template
	FileCreatPropList tmpl2;
	tmpl2.copy (*tmpl1);

	// Release file-creation template
	delete tmpl1;
	tmpl1 = NULL;

	// Set the new file-creation parameter
	tmpl2.setUserblock( F3_USERBLOCK_SIZE );

	// Try to create second file, with non-standard file-creation template
	// params
	H5File file3( FILE3, H5F_ACC_TRUNC, tmpl2 );

	// Get the file-creation template
	tmpl1 = new FileCreatPropList (file3.getCreatePlist());

	// Get the file-creation parameters
	ublock = tmpl1->getUserblock();
	verify_val((long)ublock, (long)F3_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__);

	tmpl1->getSizes( parm1, parm2);
	verify_val(parm1, F3_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
	verify_val(parm2, F3_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);

    	tmpl1->getSymk( iparm1, iparm2);
	verify_val(iparm1, F3_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);
	verify_val(iparm2, F3_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__);

	// Release file-creation template
	delete tmpl1;
	PASSED();
    }
    // catch all exceptions
    catch (Exception E)
    {
	issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg());
	if (tmpl1 != NULL)  // clean up
	    delete tmpl1;
    }
}   // test_file_create()
Beispiel #7
0
//--------------------------------------------------------------------------
// Function:	PropList::propExist
///\brief	This is an overloaded member function, provided for convenience.
/// 		It differs from the above function only in what arguments it
///		accepts.
///\param	name - IN: Name of property to check for - \c H5std_string
// Programmer:  Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
bool PropList::propExist(const H5std_string& name ) const
{
   return( propExist( name.c_str()) );
}
Beispiel #8
0
//--------------------------------------------------------------------------
// Function:	CommonFG::removeComment
///\brief	This is an overloaded member function, provided for convenience.
///		It differs from the above function in that it takes an
///		\c std::string for \a name.
// Programmer	Binh-Minh Ribler - May 2005
//--------------------------------------------------------------------------
void CommonFG::removeComment(const H5std_string& name) const
{
   removeComment (name.c_str());
}
Beispiel #9
0
//--------------------------------------------------------------------------
// Function:	CommonFG::getComment
///\brief	This is an overloaded member function, provided for convenience.
///		It differs from the above function in that it takes an
///		\c std::string for \a name.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
H5std_string CommonFG::getComment( const H5std_string& name, size_t bufsize ) const
{
   return( getComment( name.c_str(), bufsize ));
}
Beispiel #10
0
//--------------------------------------------------------------------------
// Function:	CommonFG::getLinkval
///\brief	This is an overloaded member function, provided for convenience.
///		It differs from the above function in that it takes an
///		\c std::string for \a name.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
H5std_string CommonFG::getLinkval( const H5std_string& name, size_t size ) const
{
   return( getLinkval( name.c_str(), size ));
}
Beispiel #11
0
//--------------------------------------------------------------------------
// Function:	CommonFG::setComment
///\brief	This is an overloaded member function, provided for convenience.
///		It differs from the above function in that it takes an
///		\c std::string for \a name and \a comment.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void CommonFG::setComment( const H5std_string& name, const H5std_string& comment ) const
{
   setComment( name.c_str(), comment.c_str() );
}
Beispiel #12
0
//--------------------------------------------------------------------------
// 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 std::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 );
}
Beispiel #13
0
//--------------------------------------------------------------------------
// 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 std::string for \a name.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void CommonFG::getObjinfo( const H5std_string& name, hbool_t follow_link, H5G_stat_t& statbuf ) const
{
   getObjinfo( name.c_str(), follow_link, statbuf );
}
Beispiel #14
0
//--------------------------------------------------------------------------
// Function:	CommonFG::move
///\brief	This is an overloaded member function, provided for convenience.
///		It differs from the above function in that it takes an
///		\c std::string for \a src and \a dst.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void CommonFG::move( const H5std_string& src, const H5std_string& dst ) const
{
   move( src.c_str(), dst.c_str() );
}
Beispiel #15
0
//--------------------------------------------------------------------------
// Function:	DataType::unregister
///\brief	This is an overloaded member function, provided for convenience.
///		It differs from the above function only in the type of the
///		argument \a name.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void DataType::unregister( H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func ) const
{
   unregister( pers, name.c_str(), dest, func );
}
Beispiel #16
0
//--------------------------------------------------------------------------
// Function:	CommonFG::mount
///\brief	This is an overloaded member function, provided for convenience.
///		It differs from the above function in that it takes an
///		\c std::string for \a name.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void CommonFG::mount( const H5std_string& name, H5File& child, PropList& plist ) const
{
   mount( name.c_str(), child, plist );
}
Beispiel #17
0
//--------------------------------------------------------------------------
// Function:	DataType::setTag
///\brief	This is an overloaded member function, provided for convenience.
///		It differs from the above function only in the type of the
///		argument \a name.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void DataType::setTag( const H5std_string& tag ) const
{
   setTag( tag.c_str());
}
Beispiel #18
0
//--------------------------------------------------------------------------
// 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 std::string for \a name.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void CommonFG::unmount( const H5std_string& name ) const
{
   unmount( name.c_str() );
}
Beispiel #19
0
//--------------------------------------------------------------------------
// Function:	PropList::copyProp
///\brief	This is an overloaded member function, provided for convenience.
/// 		It differs from the above function only in what arguments it
///		accepts. - Obsolete
///\param	dest - IN: Destination property list or class
///\param	src  - IN: Source property list or class
///\param	name - IN: Name of the property to copy - \c H5std_string
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void PropList::copyProp( PropList& dest, PropList& src, const H5std_string& name ) const
{
   copyProp( dest, src, name.c_str());
}
Beispiel #20
0
//--------------------------------------------------------------------------
// 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 std::string for \a name.
// Programmer	Binh-Minh Ribler - Jul, 2005
//--------------------------------------------------------------------------
VarLenType CommonFG::openVarLenType( const H5std_string& name ) const
{
   return( openVarLenType( name.c_str()) );
}
Beispiel #21
0
//--------------------------------------------------------------------------
// Function:	PropList::getProperty
///\brief	This is an overloaded member function, provided for convenience.
///   		It differs from the above function only in what arguments it
///		accepts.
///\param	name -  IN: Name of property to query - \c H5std_string
///\return	The property that is a \c H5std_string.
// Programmer:  Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
H5std_string PropList::getProperty(const H5std_string& name) const
{
   return (getProperty(name.c_str()));
}
Beispiel #22
0
//--------------------------------------------------------------------------
// 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 std::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 ));
}
Beispiel #23
0
//--------------------------------------------------------------------------
// Function:	PropList::setProperty
///\brief	This is an overloaded member function, provided for convenience.
/// 		It differs from the above function only in what arguments it
///		accepts.
///\param	name  - IN: Name of property to set - \c H5std_string
///\param	value - IN: Void pointer to the value for the property
// Programmer:  Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
void PropList::setProperty(const H5std_string& name, void* value) const
{
   setProperty(name.c_str(), value);
}
Beispiel #24
0
void cleanup_object()
{
    HDremove(FILE_OBJECTS.c_str());
} // cleanup_objects
Beispiel #25
0
//--------------------------------------------------------------------------
// Function:	PropList::removeProp
///\brief	This is an overloaded member function, provided for convenience.
/// 		It differs from the above function only in what arguments it
///		accepts.
///\param	name - IN: Name of property to remove - \c H5std_string
// Programmer:  Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
void PropList::removeProp(const H5std_string& name) const
{
   removeProp(name.c_str());
}
//--------------------------------------------------------------------------
// Function:	DataType::commit
///\brief	This is an overloaded member function, provided for convenience.
///		It differs from the above function only in the type of the
///		argument \a name.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void DataType::commit(H5File& loc, const H5std_string& name)
{
   p_commit(loc.getLocId(), name.c_str());
}
Beispiel #27
0
//--------------------------------------------------------------------------
// Function:	H5File::openFile
///\brief	This is an overloaded member function, provided for convenience.
///		It takes an \c H5std_string for \a name.
///\param	name         - IN: Name of the file - \c H5std_string
///\param	flags        - IN: File access flags
///\param	access_plist - IN: File access property list.  Default to
///		FileAccPropList::DEFAULT
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void H5File::openFile(const H5std_string& name, unsigned int flags, const FileAccPropList& access_plist)
{
    openFile(name.c_str(), flags, access_plist);
}
Beispiel #28
0
//--------------------------------------------------------------------------
// Function:	DataType::commit
///\brief	This is an overloaded member function, kept for backward
///		compatibility.  It differs from the above function in that it
///		misses const's.  This wrapper will be removed in future release.
///\param	loc - IN: A location (file, dataset, datatype, or group)
///\param	name - IN: Name of the datatype
///\exception	H5::DataTypeIException
// Programmer	Binh-Minh Ribler - Jan, 2007
//--------------------------------------------------------------------------
void DataType::commit(H5Location& loc, const H5std_string& name)
{
   p_commit(loc.getId(), name.c_str());
}
Beispiel #29
0
//--------------------------------------------------------------------------
// Function:	FileAccPropList::setSplit
///\brief	This is an overloaded member function, provided for convenience.
///		It takes character arguments as \c H5std_string.
///\param	meta_plist  - IN: File access plist for the metadata file
///\param	raw_plist   - IN: File access plist for the raw data file
///\param	meta_ext    - IN: Metadata filename extension as \c H5std_string
///\param	raw_ext     - IN: Raw data filename extension as \c H5std_string
///\exception	H5::PropListIException
// Programmer:  Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccPropList& raw_plist, const H5std_string& meta_ext, const H5std_string& raw_ext ) const
{
   setSplit( meta_plist, raw_plist, meta_ext.c_str(), raw_ext.c_str() );
}
Beispiel #30
0
//--------------------------------------------------------------------------
// Function:	CommonFG::link
///\brief	This is an overloaded member function, provided for convenience.
///		It differs from the above function in that it takes an
///		\c std::string for \a curr_name and \a new_name.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void CommonFG::link( H5L_type_t link_type, const H5std_string& curr_name, const H5std_string& new_name ) const
{
   link( link_type, curr_name.c_str(), new_name.c_str() );
}