diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2014-04-17 23:25:01 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2014-04-17 23:25:01 (GMT) |
commit | a75e8dd654268ba1dd35abf3a78da2f115802029 (patch) | |
tree | 55ce2f23d860187f021d11c3611fa43c314eff6b /c++ | |
parent | ca6e13d3dff9c188d80cb84876cf3ccfeb6b6203 (diff) | |
download | hdf5-a75e8dd654268ba1dd35abf3a78da2f115802029.zip hdf5-a75e8dd654268ba1dd35abf3a78da2f115802029.tar.gz hdf5-a75e8dd654268ba1dd35abf3a78da2f115802029.tar.bz2 |
[svn-r25061] Description:
Put back overloaded functions for backward compatibility:
- were replaced by better prototyped versions, such as Attribute::getName.
- were modified to add const to constant arguments.
Added notes for future removal in documentation.
Platforms tested:
Linux/ppc64 (ostrich)
Linux/32 2.6 (jam)
SunOS 5.11 (emu)
Diffstat (limited to 'c++')
-rw-r--r-- | c++/src/H5Attribute.cpp | 42 | ||||
-rw-r--r-- | c++/src/H5Attribute.h | 6 | ||||
-rw-r--r-- | c++/src/H5CommonFG.cpp | 35 | ||||
-rw-r--r-- | c++/src/H5CommonFG.h | 2 | ||||
-rw-r--r-- | c++/src/H5DataSet.cpp | 60 | ||||
-rw-r--r-- | c++/src/H5DataSet.h | 8 | ||||
-rw-r--r-- | c++/src/H5DataSpace.cpp | 14 | ||||
-rw-r--r-- | c++/src/H5DataSpace.h | 2 | ||||
-rw-r--r-- | c++/src/H5DataType.cpp | 30 | ||||
-rw-r--r-- | c++/src/H5DataType.h | 4 | ||||
-rw-r--r-- | c++/src/H5DcreatProp.cpp | 5 | ||||
-rw-r--r-- | c++/src/H5DcreatProp.h | 2 | ||||
-rw-r--r-- | c++/src/H5Exception.cpp | 4 | ||||
-rw-r--r-- | c++/src/H5Exception.h | 2 | ||||
-rw-r--r-- | c++/src/H5FaccProp.cpp | 43 | ||||
-rw-r--r-- | c++/src/H5FaccProp.h | 19 | ||||
-rw-r--r-- | c++/src/H5File.cpp | 17 | ||||
-rw-r--r-- | c++/src/H5File.h | 3 | ||||
-rw-r--r-- | c++/src/H5PredType.cpp | 4 | ||||
-rw-r--r-- | c++/src/H5PredType.h | 24 | ||||
-rw-r--r-- | c++/test/tattr.cpp | 36 | ||||
-rw-r--r-- | c++/test/ttypes.cpp | 17 |
22 files changed, 325 insertions, 54 deletions
diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index 204535e..bdd0ac0 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -379,6 +379,27 @@ H5std_string Attribute::getName() const //-------------------------------------------------------------------------- // Function: Attribute::getName +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an integer +/// specifying a desired length to be retrieved of the name. +///\return Name (or part of name) of the attribute +///\param len - IN: Desired length of the name +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - 2000 +// Modification +// Mar 2014 - BMR +// Revised to use the new getName() below +//-------------------------------------------------------------------------- +H5std_string Attribute::getName(size_t len) const +{ + H5std_string attr_name; + ssize_t name_size = getName(attr_name, len); + return(attr_name); + // let caller catch exception if any +} + +//-------------------------------------------------------------------------- +// 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 @@ -391,7 +412,8 @@ H5std_string Attribute::getName() const // Programmer Binh-Minh Ribler - Nov, 2001 // Modification // Mar 2014 - BMR -// Revised to allow the argument "len" to be skipped +// 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 { @@ -425,6 +447,24 @@ ssize_t Attribute::getName(H5std_string& attr_name, size_t len) const } //-------------------------------------------------------------------------- +// Function: Attribute::getName +///\brief This function is replaced by the previous function, which +/// provides more convenient prototype. It will be removed +/// in future release. +///\param len - IN: Desired length of the name +///\param attr_name - OUT: Buffer for the name string +///\return Actual length of the attribute name +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - Nov, 2001 +// Modification +// Modified to call its replacement. -BMR, 2014/04/16 +//-------------------------------------------------------------------------- +ssize_t Attribute::getName( size_t len, H5std_string& attr_name ) const +{ + return (getName(attr_name, len)); +} + +//-------------------------------------------------------------------------- // Function: Attribute::getStorageSize ///\brief Returns the amount of storage size required for this attribute. ///\return Size of the storage or 0, for no data diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h index 8ec04af..f57b922 100644 --- a/c++/src/H5Attribute.h +++ b/c++/src/H5Attribute.h @@ -39,8 +39,12 @@ class H5_DLLCPP Attribute : public AbstractDs, public IdComponent { // Gets the name of this attribute. ssize_t getName(char* attr_name, size_t buf_size = 0) const; - ssize_t getName(H5std_string& attr_name, size_t len = 0) const; + H5std_string getName(size_t len) const; H5std_string getName() const; + ssize_t getName(H5std_string& attr_name, size_t len = 0) const; + // The overloaded function below is replaced by the one above and it + // is kept for backward compatibility purpose. + ssize_t getName( size_t buf_size, H5std_string& attr_name ) const; // Gets a copy of the dataspace for this attribute. virtual DataSpace getSpace() const; diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp index ee5c368..d296db4 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -467,7 +467,7 @@ H5std_string CommonFG::getLinkval( const H5std_string& name, size_t size ) const ///\param child - IN: File to mount ///\param plist - IN: Property list to use ///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2014 (original 2000) //-------------------------------------------------------------------------- void CommonFG::mount(const char* name, const H5File& child, const PropList& plist ) const { @@ -485,14 +485,41 @@ void CommonFG::mount(const char* name, const H5File& child, const PropList& plis //-------------------------------------------------------------------------- // Function: CommonFG::mount +///\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 name - IN: Name of the group +///\param child - IN: File to mount +///\param plist - IN: Property list to use +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +void CommonFG::mount(const char* name, H5File& child, PropList& plist) const +{ + mount(name, (const H5File)child, (const PropList)plist); +} + +//-------------------------------------------------------------------------- +// 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 H5std_string for \a name. +/// It takes an \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void CommonFG::mount(const H5std_string& name, const H5File& child, const PropList& plist) const { - mount( name.c_str(), child, plist ); + mount(name.c_str(), child, plist); +} + +//-------------------------------------------------------------------------- +// Function: CommonFG::mount +///\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. +// Programmer Binh-Minh Ribler - 2014 +//-------------------------------------------------------------------------- +void CommonFG::mount(const H5std_string& name, H5File& child, PropList& plist) const +{ + mount(name.c_str(), (const H5File)child, (const PropList)plist); } //-------------------------------------------------------------------------- diff --git a/c++/src/H5CommonFG.h b/c++/src/H5CommonFG.h index 4cb366f..5c8a142 100644 --- a/c++/src/H5CommonFG.h +++ b/c++/src/H5CommonFG.h @@ -101,7 +101,9 @@ class H5_DLLCPP CommonFG { // Mounts the file 'child' onto this location. void mount(const char* name, const H5File& child, const PropList& plist) const; + void mount(const char* name, H5File& child, PropList& plist) const; // backward compatibility void mount(const H5std_string& name, const H5File& child, const PropList& plist) const; + void mount(const H5std_string& name, H5File& child, PropList& plist) const; // backward compatibility // Unmounts the file named 'name' from this parent location. void unmount(const char* name) const; diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index 7e4fa4f..c34769e 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -313,6 +313,20 @@ hsize_t DataSet::getVlenBufSize(const DataType& type, const DataSpace& space ) c } //-------------------------------------------------------------------------- +// Function: DataSet::getVlenBufSize +///\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. +///\return Amount of storage +///\exception H5::DataSetIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +hsize_t DataSet::getVlenBufSize( DataType& type, DataSpace& space ) const +{ + return(getVlenBufSize((const DataType)type, (const DataSpace)space)); +} + +//-------------------------------------------------------------------------- // Function: DataSet::vlenReclaim ///\brief Reclaims VL datatype memory buffers. ///\param type - IN: Datatype, which is the datatype stored in the buffer @@ -577,9 +591,11 @@ void DataSet::extend( const hsize_t* size ) const ///\param buf_type - IN: Datatype of the elements in buffer ///\param space - IN: Dataspace describing memory buffer & containing selection to use ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2014 +// Modification +// Used the non-const version. //-------------------------------------------------------------------------- -void DataSet::fillMemBuf(const void *fill, const DataType& fill_type, void *buf, const DataType& buf_type, const DataSpace& space) +void DataSet::fillMemBuf(const void *fill, const DataType& fill_type, void *buf, const DataType& buf_type, const DataSpace& space) const { hid_t fill_type_id = fill_type.getId(); hid_t buf_type_id = buf_type.getId(); @@ -593,16 +609,32 @@ void DataSet::fillMemBuf(const void *fill, const DataType& fill_type, void *buf, //-------------------------------------------------------------------------- // Function: DataSet::fillMemBuf -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it only takes the -/// the last three arguments. +///\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 fill - IN: Pointer to fill value to use - default NULL +///\param fill_type - IN: Datatype of the fill value ///\param buf - IN/OUT: Memory buffer to fill selection within ///\param buf_type - IN: Datatype of the elements in buffer ///\param space - IN: Dataspace describing memory buffer & containing selection to use ///\exception H5::DataSetIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& space) +void DataSet::fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& space) +{ + fillMemBuf(fill, (const DataType)fill_type, buf, (const DataType)buf_type, (const DataSpace)space); +} + +//-------------------------------------------------------------------------- +// Function: DataSet::fillMemBuf +///\brief Fills a selection in memory with 0. +///\param buf - IN/OUT: Memory buffer to fill selection within +///\param buf_type - IN: Datatype of the elements in buffer +///\param space - IN: Dataspace describing memory buffer & containing selection to use +///\exception H5::DataSetIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +void DataSet::fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& space) const { hid_t buf_type_id = buf_type.getId(); hid_t space_id = space.getId(); @@ -614,6 +646,22 @@ void DataSet::fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& s } //-------------------------------------------------------------------------- +// Function: DataSet::fillMemBuf +///\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 buf - IN/OUT: Memory buffer to fill selection within +///\param buf_type - IN: Datatype of the elements in buffer +///\param space - IN: Dataspace describing memory buffer & containing selection to use +///\exception H5::DataSetIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +void DataSet::fillMemBuf(void *buf, DataType& buf_type, DataSpace& space) +{ + fillMemBuf(buf, (const DataType)buf_type, (const DataSpace)space); +} + +//-------------------------------------------------------------------------- // Function: DataSet::getId ///\brief Get the id of this dataset. ///\return DataSet identifier diff --git a/c++/src/H5DataSet.h b/c++/src/H5DataSet.h index d5b3d92..529466a 100644 --- a/c++/src/H5DataSet.h +++ b/c++/src/H5DataSet.h @@ -37,9 +37,12 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs { void extend( const hsize_t* size ) const; // Fills a selection in memory with a value - void fillMemBuf(const void *fill, const DataType& fill_type, void *buf, const DataType& buf_type, const DataSpace& space); + void fillMemBuf(const void *fill, const DataType& fill_type, void *buf, const DataType& buf_type, const DataSpace& space) const; + void fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& space); // kept for backward compatibility + // Fills a selection in memory with zero - void fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& space); + void fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& space) const; + void fillMemBuf(void *buf, DataType& buf_type, DataSpace& space); // kept for backward compatibility // Gets the creation property list of this dataset. DSetCreatPropList getCreatePlist() const; @@ -61,6 +64,7 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs { // Returns the number of bytes required to store VL data. hsize_t getVlenBufSize(const DataType& type, const DataSpace& space ) const; + hsize_t getVlenBufSize(DataType& type, DataSpace& space) const; // kept for backward compatibility // Reclaims VL datatype memory buffers. static void vlenReclaim(const DataType& type, const DataSpace& space, const DSetMemXferPropList& xfer_plist, void* buf ); diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp index 4ad73ab..6ad8c8d 100644 --- a/c++/src/H5DataSpace.cpp +++ b/c++/src/H5DataSpace.cpp @@ -290,6 +290,20 @@ void DataSpace::extentCopy (const DataSpace& dest_space) const } //-------------------------------------------------------------------------- +// Function: DataSpace::extentCopy +///\brief This is an overloaded member function, kept for backward +/// compatibility. It differs from the above function in that it +/// misses const. This wrapper will be removed in future release. +///\param dest_space - IN: Dataspace to copy from +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +void DataSpace::extentCopy( DataSpace& dest_space ) const +{ + extentCopy((const DataSpace)dest_space); +} + +//-------------------------------------------------------------------------- // Function: DataSpace::setExtentSimple ///\brief Sets or resets the size of an existing dataspace. ///\param rank - IN: Rank of the dataspace diff --git a/c++/src/H5DataSpace.h b/c++/src/H5DataSpace.h index eab6218..9efecdf 100644 --- a/c++/src/H5DataSpace.h +++ b/c++/src/H5DataSpace.h @@ -44,6 +44,8 @@ class H5_DLLCPP DataSpace : public IdComponent { // Copies the extent of this dataspace. void extentCopy(const DataSpace& dest_space) const; + // Kept for backward compatibility only. + void extentCopy(DataSpace& dest_space) const; // Gets the bounding box containing the current selection. void getSelectBounds( hsize_t* start, hsize_t* end ) const; diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 0195fb1..afc5678 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -273,6 +273,21 @@ void DataType::commit(const H5Location& loc, const char* name) //-------------------------------------------------------------------------- // 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 char* name) +{ + p_commit(loc.getId(), name); +} + +//-------------------------------------------------------------------------- +// 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. @@ -284,6 +299,21 @@ void DataType::commit(const H5Location& loc, const H5std_string& name) } //-------------------------------------------------------------------------- +// 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()); +} + +//-------------------------------------------------------------------------- // Function: DataType::committed ///\brief Determines whether a datatype is a named type or a /// transient type. diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h index ab54ba6..064bfe1 100644 --- a/c++/src/H5DataType.h +++ b/c++/src/H5DataType.h @@ -56,6 +56,10 @@ class H5_DLLCPP DataType : public H5Object { // a named datatype which can be accessed from the location. void commit(const H5Location& loc, const char* name); void commit(const H5Location& loc, const H5std_string& name); + // These two overloaded functions are kept for backward compatibility + // only; they missed the const. + void commit(H5Location& loc, const char* name); + void commit(H5Location& loc, const H5std_string& name); // Determines whether this datatype is a named datatype or // a transient datatype. diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp index 4d46a7d..2b124ee 100644 --- a/c++/src/H5DcreatProp.cpp +++ b/c++/src/H5DcreatProp.cpp @@ -356,8 +356,11 @@ int DSetCreatPropList::getNfilters() const ///\exception H5::PropListIException ///\par Description /// Failure occurs when \a filter_number is out of range. +// Note: the first argument was mistakenly typed as int instead +// of unsigned int, but for backward compatibility, it cannot be +// changed. -BMR (2014/04/15) //-------------------------------------------------------------------------- -H5Z_filter_t DSetCreatPropList::getFilter(unsigned int filter_number, +H5Z_filter_t DSetCreatPropList::getFilter(int filter_number, unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, size_t namelen, char name[], unsigned int& filter_config) const { diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h index 8794971..7434b9b 100644 --- a/c++/src/H5DcreatProp.h +++ b/c++/src/H5DcreatProp.h @@ -68,7 +68,7 @@ class H5_DLLCPP DSetCreatPropList : public PropList { void setFillValue( const DataType& fvalue_type, const void* value ) const; // Returns information about a filter in a pipeline. - H5Z_filter_t getFilter(unsigned int filter_number, unsigned int& flags, size_t& cd_nelmts, unsigned int* cd_values, size_t namelen, char name[], unsigned int &filter_config) const; + H5Z_filter_t getFilter(int filter_number, unsigned int& flags, size_t& cd_nelmts, unsigned int* cd_values, size_t namelen, char name[], unsigned int &filter_config) const; // Returns information about a filter in a pipeline given the filter id. void getFilterById(H5Z_filter_t filter_id, unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, size_t namelen, char name[], unsigned int &filter_config) const; diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index 492abed..7385341 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -295,12 +295,12 @@ const char* Exception::getCFuncName() const } //-------------------------------------------------------------------------- -// Function: Exception::printError +// Function: Exception::printError (static) ///\brief Prints the error stack in a default manner. ///\param stream - IN: File pointer // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::printError( FILE* stream ) const +void Exception::printError( FILE* stream ) { herr_t ret_value = H5Eprint2( H5E_DEFAULT, stream ); // print to stderr if( ret_value < 0 ) diff --git a/c++/src/H5Exception.h b/c++/src/H5Exception.h index 7d71022..267c84b 100644 --- a/c++/src/H5Exception.h +++ b/c++/src/H5Exception.h @@ -72,7 +72,7 @@ class H5_DLLCPP Exception { H5E_walk2_t func, void* client_data); // Prints the error stack in a default manner. - virtual void printError( FILE* stream = NULL ) const; + static void printError( FILE* stream = NULL ); // Default constructor Exception(); diff --git a/c++/src/H5FaccProp.cpp b/c++/src/H5FaccProp.cpp index ddd0708..5696742 100644 --- a/c++/src/H5FaccProp.cpp +++ b/c++/src/H5FaccProp.cpp @@ -277,13 +277,30 @@ void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccP //-------------------------------------------------------------------------- // Function: FileAccPropList::setSplit +///\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 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 char* +///\param raw_ext - IN: Raw data filename extension as \c char* +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +// Note: Retiring April, 2014 +//-------------------------------------------------------------------------- +void FileAccPropList::setSplit(FileAccPropList& meta_plist, FileAccPropList& raw_plist, const char* meta_ext, const char* raw_ext ) const +{ + setSplit((const FileAccPropList)meta_plist, (const FileAccPropList)raw_plist, meta_ext, raw_ext); +} + +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setSplit ///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function only in what arguments it -/// accepts. +/// 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 string -///\param raw_ext - IN: Raw data filename extension as \c string +///\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 //-------------------------------------------------------------------------- @@ -292,6 +309,24 @@ void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccP setSplit( meta_plist, raw_plist, meta_ext.c_str(), raw_ext.c_str() ); } +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setSplit +///\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 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 string +///\param raw_ext - IN: Raw data filename extension as \c string +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +// Note: Retiring April, 2014 +//-------------------------------------------------------------------------- +void FileAccPropList::setSplit(FileAccPropList& meta_plist, FileAccPropList& raw_plist, const H5std_string& meta_ext, const H5std_string& raw_ext ) const +{ + setSplit((const FileAccPropList)meta_plist, (const FileAccPropList)raw_plist, meta_ext.c_str(), raw_ext.c_str() ); +} + // Stream Virtual File Driver had been removed from the main library. // FileAccPropList::[s,g]etStream are now removed from the C++ API. // -BMR, March, 2012 diff --git a/c++/src/H5FaccProp.h b/c++/src/H5FaccProp.h index 5b41ecd..861ac4c 100644 --- a/c++/src/H5FaccProp.h +++ b/c++/src/H5FaccProp.h @@ -62,10 +62,21 @@ class H5_DLLCPP FileAccPropList : public PropList { FileAccPropList getFamily(hsize_t& memb_size) const; // Emulates the old split file driver, - void setSplit(const FileAccPropList& meta_plist, const FileAccPropList& raw_plist, - const char* meta_ext = ".meta", const char* raw_ext = ".raw" ) const; - void setSplit(const FileAccPropList& meta_plist, const FileAccPropList& raw_plist, - const H5std_string& meta_ext, const H5std_string& raw_ext ) const; + void setSplit(const FileAccPropList& meta_plist, + const FileAccPropList& raw_plist, + const char* meta_ext = ".meta", + const char* raw_ext = ".raw" ) const; + void setSplit(const FileAccPropList& meta_plist, + const FileAccPropList& raw_plist, + const H5std_string& meta_ext = ".meta", + const H5std_string& raw_ext = ".raw") const; + // These two overloaded functions are kept for backward compatibility + // only; they missed the const's and will be removed in future release. + void setSplit(FileAccPropList& meta_plist, FileAccPropList& raw_plist, + const char* meta_ext=".meta", const char* raw_ext=".raw") const; + void setSplit(FileAccPropList& meta_plist, FileAccPropList& raw_plist, + const H5std_string& meta_ext=".meta", + const H5std_string& raw_ext=".raw") const; // Sets the maximum size of the data sieve buffer. void setSieveBufSize(size_t bufsize) const; diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index 9669aa7..e4ac4a1 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -454,6 +454,23 @@ void H5File::getVFDHandle(const FileAccPropList& fapl, void **file_handle) const //-------------------------------------------------------------------------- // Function: H5File::getVFDHandle +///\brief This is an overloaded member function, kept for backward +/// compatibility. It differs from the above function in that it +/// misses const. This wrapper will be removed in future release. +///\param fapl - File access property list +///\param file_handle - Pointer to the file handle being used by +/// the low-level virtual file driver +///\exception H5::FileIException +// Programmer Binh-Minh Ribler - May 2004 +// Note: Retiring April, 2014 +//-------------------------------------------------------------------------- +void H5File::getVFDHandle(FileAccPropList& fapl, void **file_handle) const +{ + getVFDHandle((const FileAccPropList)fapl, file_handle); +} + +//-------------------------------------------------------------------------- +// Function: H5File::getVFDHandle ///\brief This is an overloaded member function, provided for convenience. /// It differs from the above function only in what arguments it /// accepts. diff --git a/c++/src/H5File.h b/c++/src/H5File.h index cd7563c..0ef85b5 100644 --- a/c++/src/H5File.h +++ b/c++/src/H5File.h @@ -67,8 +67,9 @@ class H5_DLLCPP H5File : public H5Location, public CommonFG { void getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const; // Returns the pointer to the file handle of the low-level file driver. - void getVFDHandle(const FileAccPropList& fapl, void **file_handle) const; void getVFDHandle(void **file_handle) const; + void getVFDHandle(const FileAccPropList& fapl, void **file_handle) const; + void getVFDHandle(FileAccPropList& fapl, void **file_handle) const; // kept for backward compatibility // Determines if a file, specified by its name, is in HDF5 format static bool isHdf5(const char* name ); diff --git a/c++/src/H5PredType.cpp b/c++/src/H5PredType.cpp index 727a09d..6dbee98 100644 --- a/c++/src/H5PredType.cpp +++ b/c++/src/H5PredType.cpp @@ -272,12 +272,12 @@ PredType& PredType::operator=( const PredType& rhs ) #ifndef DOXYGEN_SHOULD_SKIP_THIS // These dummy functions do not inherit from DataType - they'll // throw an DataTypeIException if invoked. -void PredType::commit(const H5Location& loc, const char* name ) +void PredType::commit(H5Location& loc, const char* name ) { throw DataTypeIException("PredType::commit", "Error: Attempted to commit a predefined datatype. Invalid operation!" ); } -void PredType::commit(const H5Location& loc, const H5std_string& name ) +void PredType::commit(H5Location& loc, const H5std_string& name ) { commit( loc, name.c_str()); } diff --git a/c++/src/H5PredType.h b/c++/src/H5PredType.h index 981a29c..494b169 100644 --- a/c++/src/H5PredType.h +++ b/c++/src/H5PredType.h @@ -230,18 +230,18 @@ class H5_DLLCPP PredType : public AtomType { static const PredType NATIVE_UINT_FAST64; #endif /* H5_SIZEOF_UINT_FAST64_T */ - /*! \brief This dummy function do not inherit from DataType - it will - throw a DataTypeIException if invoked. - */ - void commit(const H5Location& loc, const H5std_string& name ); - /*! \brief This dummy function do not inherit from DataType - it will - throw a DataTypeIException if invoked. - */ - void commit(const H5Location& loc, const char* name ); - /*! \brief This dummy function do not inherit from DataType - it will - throw a DataTypeIException if invoked. - */ - bool committed(); + /*! \brief This dummy function do not inherit from DataType - it will + throw a DataTypeIException if invoked. + */ + void commit(H5Location& loc, const H5std_string& name ); + /*! \brief This dummy function do not inherit from DataType - it will + throw a DataTypeIException if invoked. + */ + void commit(H5Location& loc, const char* name ); + /*! \brief This dummy function do not inherit from DataType - it will + throw a DataTypeIException if invoked. + */ + bool committed(); protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index 9abdd83..29f50f8 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -248,16 +248,20 @@ static void test_attr_basic_write() ** ** Test these functions: ** A. ssize_t Attribute::getName(char* attr_name, size_t buf_size) -** 1. With arbitrary buf_size that is larger than the name size -** 2. With arbitrary buf_size that is smaller than the name's length. -** 3. With a buf_size that equals the name's length. +** 1. With arbitrary buf_size that is larger than the name size +** 2. With arbitrary buf_size that is smaller than the name's length. +** 3. With a buf_size that equals the name's length. ** ** B. ssize_t Attribute::getName(H5std_string& attr_name, size_t buf_size) -** With buffer smaller than the actual name +** 1. With buffer smaller than the actual name +** 2. Same test but with retiring overloaded function +** ssize_t Attribute::getName(size_t buf_size, H5std_string& attr_name) ** -** C. H5std_string Attribute::getName() with file's and dataset's attrs. +** C. H5std_string Attribute::getName() ** -** D. ssize_t Attribute::getName(H5std_string& attr_name, size_t buf_size) +** D. H5std_string Attribute::getName(size_t len) +** +** E. ssize_t Attribute::getName(H5std_string& attr_name, size_t buf_size) ** With buffer size equals the name's length, i.e., buf_size=0 ** ****************************************************************/ @@ -324,6 +328,14 @@ static void test_attr_getname() buf_size = 4; H5std_string fattr1_name2; name_size = fattr1.getName(fattr1_name2, buf_size); + verify_val(fattr1_name2, "File", "Attribute::getName", __LINE__, __FILE__); + + // Same test as above, but with deprecated overloaded function + // ssize_t Attribute::getName(size_t buf_size, H5std_string& attr_name) + // using buffer smaller than the actual name + H5std_string fattr1_name2a; + name_size = fattr1.getName(fattr1_name2a, buf_size); + verify_val(fattr1_name2a, "File", "Attribute::getName", __LINE__, __FILE__); // C. Get file attribute's name with // H5std_string Attribute::getName() @@ -331,7 +343,8 @@ static void test_attr_getname() verify_val(fattr1_name3, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__); // - // Open the dataset DSET1_NAME and test getName with its attribute + // D. Test getName getting part of an attribute's name using + // H5std_string Attribute::getName(len) // // Open dataset DSET1_NAME @@ -345,12 +358,11 @@ static void test_attr_getname() // Open attribute Attribute attr1(dataset.openAttribute(ATTR1_NAME)); - // Get dataset attribute's name with - // H5std_string Attribute::getName() - H5std_string dattr_name1 = attr1.getName(); - verify_val(dattr_name1, ATTR1_NAME, "Attribute::getName", __LINE__, __FILE__); + size_t len = 4; + H5std_string dattr_name1 = attr1.getName(len); + verify_val(dattr_name1, "Attr", "Attribute::getName", __LINE__, __FILE__); - // D. Get attribute name with + // E. Get dataset's attribute name with // H5std_string Attribute::getName(H5std_string attr_name, buf_size=0) H5std_string dattr_name2; name_size = attr1.getName(dattr_name2); diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp index 933181c..e9e1427 100644 --- a/c++/test/ttypes.cpp +++ b/c++/test/ttypes.cpp @@ -414,6 +414,23 @@ static void test_named () IntType itype(PredType::NATIVE_INT); itype.commit(file, "native-int"); + // Test commit passing in const H5File& for prototype with const + try + { + // Create random char type + IntType atype(PredType::NATIVE_UCHAR); + + // Creating group, declared as const + const Group const_grp = file.createGroup("GR as loc"); + + // Commit type passing in const group; compilation would fail if + // no matching prototype + atype.commit(const_grp, "random uchar"); + } // end of try block + catch (Exception E) { + issue_fail_msg("test_named", __LINE__, __FILE__, "Commit at const group"); + } + // Check that it is committed. if (itype.committed() == false) cerr << "IntType::committed() returned false" << endl; |