diff options
author | lrknox <lrknox> | 2018-05-14 22:13:50 (GMT) |
---|---|---|
committer | lrknox <lrknox> | 2018-05-14 22:13:50 (GMT) |
commit | f1a33b351c456c0841fcb79b907707a9caa2fed5 (patch) | |
tree | 509d83cc12480b28993fccdf12b2d4cbaf03866c | |
parent | 1bfaecf413d0eeb7e0167376d7ccf892996156be (diff) | |
parent | db070002687b0062d5657280b7c6beb81e40ace9 (diff) | |
download | hdf5-f1a33b351c456c0841fcb79b907707a9caa2fed5.zip hdf5-f1a33b351c456c0841fcb79b907707a9caa2fed5.tar.gz hdf5-f1a33b351c456c0841fcb79b907707a9caa2fed5.tar.bz2 |
Merge branch 'hdf5_1_8' into hdf5_1_8_21
Somehow Binh-Minh's latest commits to the hdf5_1_8 branch were missed
when the hdf5_1_8_21 branch was created.
28 files changed, 1096 insertions, 632 deletions
diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp index 1391b44..92733ab 100644 --- a/c++/src/H5AbstractDs.cpp +++ b/c++/src/H5AbstractDs.cpp @@ -17,6 +17,8 @@ #include "H5Exception.h" #include "H5IdComponent.h" #include "H5PropList.h" +#include "H5StrcreatProp.h" +#include "H5LcreatProp.h" #include "H5LaccProp.h" #include "H5Location.h" #include "H5Object.h" diff --git a/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp index b0d65b0..857729c 100644 --- a/c++/src/H5ArrayType.cpp +++ b/c++/src/H5ArrayType.cpp @@ -17,6 +17,8 @@ #include "H5Exception.h" #include "H5IdComponent.h" #include "H5PropList.h" +#include "H5StrcreatProp.h" +#include "H5LcreatProp.h" #include "H5LaccProp.h" #include "H5Location.h" #include "H5Object.h" diff --git a/c++/src/H5AtomType.cpp b/c++/src/H5AtomType.cpp index 75180c5..bd46d7b 100644 --- a/c++/src/H5AtomType.cpp +++ b/c++/src/H5AtomType.cpp @@ -17,6 +17,8 @@ #include "H5Exception.h" #include "H5IdComponent.h" #include "H5PropList.h" +#include "H5StrcreatProp.h" +#include "H5LcreatProp.h" #include "H5LaccProp.h" #include "H5Location.h" #include "H5Object.h" diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index 739cda7..207d73c 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -27,6 +27,8 @@ #include "H5FcreatProp.h" #include "H5OcreatProp.h" #include "H5DcreatProp.h" +#include "H5StrcreatProp.h" +#include "H5LcreatProp.h" #include "H5LaccProp.h" #include "H5Location.h" #include "H5Object.h" diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h index 9ac21b5..cb07ab7 100644 --- a/c++/src/H5Attribute.h +++ b/c++/src/H5Attribute.h @@ -47,8 +47,8 @@ class H5_DLLCPP Attribute : public AbstractDs, public H5Location { 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; + // is kept for backward compatibility purpose. Removed in 1.8.21. + // 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 97900f6..314a9fe 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -299,13 +299,16 @@ void CommonFG::link(H5L_type_t link_type, const H5std_string& curr_name, const H link(link_type, curr_name.c_str(), new_name.c_str()); } +#if 0 //-------------------------------------------------------------------------- // Function: CommonFG::unlink -///\brief Removes the specified name at this location. +///\brief Deprecated - replaced by H5Location::unlink ///\param name - IN: Name of the object to be removed ///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - 2000 // Modification +// May 2018: +// This function is deprecated immediately, in 1.8.21, because +// its replacement has two arguments and one of them is a default. // 2007: QAK modified to use H5L APIs - BMR //-------------------------------------------------------------------------- void CommonFG::unlink(const char* name) const @@ -317,15 +320,17 @@ void CommonFG::unlink(const char* name) const //-------------------------------------------------------------------------- // 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 H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +///\brief Deprecated - replaced by H5Location::unlink +// Modification +// May 2018: +// This function is deprecated immediately, in 1.8.21, because +// its replacement has two arguments and one of them is a default. //-------------------------------------------------------------------------- void CommonFG::unlink(const H5std_string& name) const { unlink(name.c_str()); } +#endif //-------------------------------------------------------------------------- // Function: CommonFG::move @@ -338,9 +343,10 @@ void CommonFG::unlink(const H5std_string& name) const /// data in a file inaccessible with Group::move. Please refer /// to the Group Interface in the HDF5 User's Guide for details at: /// https://support.hdfgroup.org/HDF5/doc/UG/HDF5_Users_Guide-Responsive%20HTML5/index.html#t=HDF5_Users_Guide%2FGroups%2FHDF5_Groups.htm -// Programmer Binh-Minh Ribler - 2000 +// 2000 // Modification // 2007: QAK modified to use H5L APIs - BMR +// May 2018: Deprecated in favor of H5Location::moveLink (1.8.21) //-------------------------------------------------------------------------- void CommonFG::move(const char* src, const char* dst) const { @@ -354,7 +360,9 @@ void CommonFG::move(const char* src, const char* dst) const ///\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 src and \a dst. -// Programmer Binh-Minh Ribler - 2000 +// 2000 +// Modification +// May 2018: Deprecated in favor of H5Location::moveLink (1.8.21) //-------------------------------------------------------------------------- void CommonFG::move(const H5std_string& src, const H5std_string& dst) const { @@ -422,6 +430,8 @@ void CommonFG::getObjinfo(const H5std_string& name, H5G_stat_t& statbuf) const } #endif /* H5_NO_DEPRECATED_SYMBOLS */ +#if 0 +// Moved to H5Location in 1.8.21 //-------------------------------------------------------------------------- // Function: CommonFG::getLinkval ///\brief Returns the name of the object that the symbolic link points to. @@ -480,6 +490,8 @@ H5std_string CommonFG::getLinkval(const H5std_string& name, size_t size) const return(getLinkval(name.c_str(), size)); } +#endif + //-------------------------------------------------------------------------- // Function: CommonFG::mount ///\brief Mounts the file \a child onto this group. @@ -507,26 +519,6 @@ void CommonFG::mount(const char* name, const H5File& child, const PropList& plis //-------------------------------------------------------------------------- // Function: CommonFG::mount -// Purpose 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 -// Modification -// Modified to call its replacement. -BMR, 2014/04/16 -// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 -// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 -//-------------------------------------------------------------------------- -//void CommonFG::mount(const char* name, H5File& child, PropList& plist) const -//{ -// mount(name, child, plist); -//} - -//-------------------------------------------------------------------------- -// Function: CommonFG::mount ///\brief This is an overloaded member function, provided for convenience. /// It takes an \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 @@ -539,22 +531,6 @@ void CommonFG::mount(const H5std_string& name, const H5File& child, const PropLi } //-------------------------------------------------------------------------- -// Function: CommonFG::mount -// Purpose 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 -// Modification -// Modified to call its replacement. -BMR, 2014/04/16 -// Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 -// Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 -//-------------------------------------------------------------------------- -//void CommonFG::mount(const H5std_string& name, H5File& child, PropList& plist) const -//{ -// mount(name.c_str(), child, plist); -//} - -//-------------------------------------------------------------------------- // Function: CommonFG::unmount ///\brief Unmounts the specified file. ///\param name - IN: Name of the file to unmount diff --git a/c++/src/H5CommonFG.h b/c++/src/H5CommonFG.h index 5e43d8c..fa08263 100644 --- a/c++/src/H5CommonFG.h +++ b/c++/src/H5CommonFG.h @@ -47,8 +47,9 @@ class H5_DLLCPP CommonFG { DataSet openDataSet(const H5std_string& name) const; // Returns the value of a symbolic link. - H5std_string getLinkval(const char* link_name, size_t size=0) const; - H5std_string getLinkval(const H5std_string& link_name, size_t size=0) const; + // Moved to H5Location in 1.8.21. + //H5std_string getLinkval(const char* link_name, size_t size=0) const; + //H5std_string getLinkval(const H5std_string& link_name, size_t size=0) const; // Returns the number of objects in this group. hsize_t getNumObjs() const; @@ -92,24 +93,27 @@ class H5_DLLCPP CommonFG { // Creates a link of the specified type from new_name to current_name; // both names are interpreted relative to the specified location id. + // Deprecated in favor of H5Location::link overloaded (1.8.21) void link(H5L_type_t link_type, const char* curr_name, const char* new_name) const; void link(H5L_type_t link_type, const H5std_string& curr_name, const H5std_string& new_name) const; // Removes the specified name at this location. - void unlink(const char* name) const; - void unlink(const H5std_string& name) const; + // Deprecated in favor of H5Location::unlink overloaded (1.8.21) + // These functions can be removed immediately because their replacements + // have a default argument out of two. + //void unlink(const char* name) const; + //void unlink(const H5std_string& name) const; // 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; // removed from 1.8.18 and 1.10.1 void mount(const H5std_string& name, const H5File& child, const PropList& plist) const; - //void mount(const H5std_string& name, H5File& child, PropList& plist) const; // removed from 1.8.18 and 1.10.1 // Unmounts the file named 'name' from this parent location. void unmount(const char* name) const; void unmount(const H5std_string& name) const; // Renames an object at this location. + // Deprecated in favor of H5Location::moveLink (1.8.21) void move(const char* src, const char* dst) const; void move(const H5std_string& src, const H5std_string& dst) const; diff --git a/c++/src/H5CompType.cpp b/c++/src/H5CompType.cpp index 903a7c4..5ff610e 100644 --- a/c++/src/H5CompType.cpp +++ b/c++/src/H5CompType.cpp @@ -17,6 +17,8 @@ #include "H5Exception.h" #include "H5IdComponent.h" #include "H5PropList.h" +#include "H5StrcreatProp.h" +#include "H5LcreatProp.h" #include "H5LaccProp.h" #include "H5Location.h" #include "H5Object.h" diff --git a/c++/src/H5Cpp.h b/c++/src/H5Cpp.h index af7d1e5fa..4108831 100644 --- a/c++/src/H5Cpp.h +++ b/c++/src/H5Cpp.h @@ -20,6 +20,8 @@ #include "H5IdComponent.h" #include "H5DataSpace.h" #include "H5PropList.h" +#include "H5StrcreatProp.h" +#include "H5LcreatProp.h" #include "H5LaccProp.h" #include "H5Location.h" #include "H5Object.h" @@ -27,9 +29,7 @@ #include "H5Attribute.h" #include "H5OcreatProp.h" #include "H5DcreatProp.h" -#include "H5StrcreatProp.h" #include "H5AcreatProp.h" -#include "H5LcreatProp.h" #include "H5CommonFG.h" #include "H5DataType.h" #include "H5DxferProp.h" diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index 1dce28e..f8277f9 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -23,6 +23,8 @@ #include "H5Exception.h" #include "H5IdComponent.h" #include "H5PropList.h" +#include "H5StrcreatProp.h" +#include "H5LcreatProp.h" #include "H5LaccProp.h" #include "H5Location.h" #include "H5Object.h" diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index dc9b422..3ed8113 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -23,6 +23,8 @@ #include "H5Exception.h" #include "H5IdComponent.h" #include "H5PropList.h" +#include "H5StrcreatProp.h" +#include "H5LcreatProp.h" #include "H5LaccProp.h" #include "H5Location.h" #include "H5Object.h" diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp index 8e2468b..2e5b2e4 100644 --- a/c++/src/H5DcreatProp.cpp +++ b/c++/src/H5DcreatProp.cpp @@ -17,6 +17,8 @@ #include "H5Exception.h" #include "H5IdComponent.h" #include "H5PropList.h" +#include "H5StrcreatProp.h" +#include "H5LcreatProp.h" #include "H5LaccProp.h" #include "H5Location.h" #include "H5Object.h" diff --git a/c++/src/H5EnumType.cpp b/c++/src/H5EnumType.cpp index 4b06ca5..9bd359a 100644 --- a/c++/src/H5EnumType.cpp +++ b/c++/src/H5EnumType.cpp @@ -18,6 +18,8 @@ #include "H5Exception.h" #include "H5IdComponent.h" #include "H5PropList.h" +#include "H5StrcreatProp.h" +#include "H5LcreatProp.h" #include "H5LaccProp.h" #include "H5Location.h" #include "H5Object.h" diff --git a/c++/src/H5FloatType.cpp b/c++/src/H5FloatType.cpp index 05284f9..fb9fe58 100644 --- a/c++/src/H5FloatType.cpp +++ b/c++/src/H5FloatType.cpp @@ -17,6 +17,8 @@ #include "H5Exception.h" #include "H5IdComponent.h" #include "H5PropList.h" +#include "H5StrcreatProp.h" +#include "H5LcreatProp.h" #include "H5LaccProp.h" #include "H5Location.h" #include "H5Object.h" diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h index 20637b7..88c1a3b 100644 --- a/c++/src/H5Group.h +++ b/c++/src/H5Group.h @@ -55,6 +55,15 @@ class H5_DLLCPP Group : public H5Object, public CommonFG { // Creates a copy of an existing group using its id. Group(const hid_t group_id); + // The "using" lines below are to avoid the compilation error + // "error: request for member ‘link’ is ambiguous" when both CommonFG and + // H5Location have overloaded functions of the same name. CommonFG's + // member functions need to be kept for backward compatibility for a while. + // They can be removed after these functions are removed. + // -BMR, May 2018 + using H5Location::link; + using CommonFG::link; + protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS // Sets the group id. diff --git a/c++/src/H5IntType.cpp b/c++/src/H5IntType.cpp index 6af2dc2..8861434 100644 --- a/c++/src/H5IntType.cpp +++ b/c++/src/H5IntType.cpp @@ -17,6 +17,8 @@ #include "H5Exception.h" #include "H5IdComponent.h" #include "H5PropList.h" +#include "H5StrcreatProp.h" +#include "H5LcreatProp.h" #include "H5LaccProp.h" #include "H5Location.h" #include "H5Object.h" diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index 43ba34c..c62437c 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -18,13 +18,21 @@ #include "H5Exception.h" #include "H5IdComponent.h" #include "H5PropList.h" +#include "H5FaccProp.h" +#include "H5FcreatProp.h" +#include "H5OcreatProp.h" +#include "H5DcreatProp.h" +#include "H5StrcreatProp.h" +#include "H5LcreatProp.h" #include "H5LaccProp.h" #include "H5Location.h" #include "H5Object.h" #include "H5DataType.h" #include "H5DataSpace.h" #include "H5AbstractDs.h" -#include "H5Attribute.h" +#include "H5CommonFG.h" +#include "H5Group.h" +#include "H5File.h" namespace H5 { @@ -87,139 +95,15 @@ H5Location::H5Location() : IdComponent() {} Notes for H5A wrappers ====================== May, 2017 (1.8.19) - These H5A wrappers are copied to H5Object to prevent an attribute + The H5A wrappers are copied to H5Object to prevent an attribute id being passed in to H5A APIs. The original H5A wrapper functions here will be deprecated in future releases. +May, 2018 (1.8.21) + They are removed from 1.8.21 ***************************************************************************/ //-------------------------------------------------------------------------- -// Function: H5Location::createAttribute -///\brief Deprecated - replaced by H5Object::createAttribute() -// brief Creates an attribute for a group, dataset, or named datatype. -///\param name - IN: Name of the attribute -///\param data_type - IN: Datatype for the attribute -///\param data_space - IN: Dataspace for the attribute - only simple -/// dataspaces are allowed at this time -///\param create_plist - IN: Creation property list - default to -/// PropList::DEFAULT -///\return Attribute instance -///\exception H5::AttributeIException -///\par Description -/// The attribute name specified in \a name must be unique. -/// Attempting to create an attribute with the same name as an -/// existing attribute will raise an exception, leaving the -/// pre-existing attribute intact. To overwrite an existing -/// attribute with a new attribute of the same name, first -/// delete the existing one with \c H5Location::removeAttr, then -/// recreate it with this function. -// Programmer Binh-Minh Ribler - 2000 -// Modification -// - Moved to H5Object in 1.8.19. -BMR -//-------------------------------------------------------------------------- -Attribute H5Location::createAttribute(const char* name, const DataType& data_type, const DataSpace& data_space, const PropList& create_plist) const -{ - hid_t type_id = data_type.getId(); - hid_t space_id = data_space.getId(); - hid_t plist_id = create_plist.getId(); - hid_t attr_id = H5Acreate2(getId(), name, type_id, space_id, plist_id, H5P_DEFAULT); - - // If the attribute id is valid, create and return the Attribute object - if(attr_id > 0) - { - Attribute attr; - f_Attribute_setId(&attr, attr_id); - return(attr); - } - else - throw AttributeIException(inMemFunc("createAttribute"), "H5Acreate2 failed"); -} - -//-------------------------------------------------------------------------- -// Function: H5Location::createAttribute -///\brief Deprecated - replaced by 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 -// Modification -// - Moved to H5Object in 1.8.19. -BMR -//-------------------------------------------------------------------------- -Attribute H5Location::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)); -} - -//-------------------------------------------------------------------------- -// Function: H5Location::openAttribute -///\brief Deprecated - replaced by H5Object::openAttribute() -// brief Opens an attribute given its name. -///\param name - IN: Name of the attribute -///\return Attribute instance -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - 2000 -// Modification -// - Moved to H5Object in 1.8.19. -BMR -//-------------------------------------------------------------------------- -Attribute H5Location::openAttribute(const char* name) const -{ - hid_t attr_id = H5Aopen(getId(), name, H5P_DEFAULT); - if(attr_id > 0) - { - Attribute attr; - f_Attribute_setId(&attr, attr_id); - return(attr); - } - else - { - throw AttributeIException(inMemFunc("openAttribute"), "H5Aopen failed"); - } -} - -//-------------------------------------------------------------------------- -// Function: H5Location::openAttribute -///\brief Deprecated - replaced by H5Object::openAttribute() -// 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. -///\param name - IN: Name of the attribute -// Programmer Binh-Minh Ribler - 2000 -// Modification -// - Moved to H5Object in 1.8.19. -BMR -//-------------------------------------------------------------------------- -Attribute H5Location::openAttribute(const H5std_string& name) const -{ - return(openAttribute(name.c_str())); -} - -//-------------------------------------------------------------------------- -// Function: H5Location::openAttribute -///\brief Deprecated - replaced by H5Object::openAttribute() -// brief Opens an attribute given its index. -///\param idx - IN: Index of the attribute, a 0-based, non-negative integer -///\return Attribute instance -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - 2000 -// Modification -// - Moved to H5Object in 1.8.19. -BMR -//-------------------------------------------------------------------------- -Attribute H5Location::openAttribute(const unsigned int idx) const -{ - hid_t attr_id = H5Aopen_by_idx(getId(), ".", H5_INDEX_CRT_ORDER, - H5_ITER_INC, static_cast<hsize_t>(idx), H5P_DEFAULT, H5P_DEFAULT); - if(attr_id > 0) - { - Attribute attr; - f_Attribute_setId(&attr, attr_id); - return(attr); - } - else - { - throw AttributeIException(inMemFunc("openAttribute"), "H5Aopen_by_idx failed"); - } -} - -//-------------------------------------------------------------------------- // Function: H5Location::iterateAttrs ///\brief Iterates a user's function over all the attributes of an H5 /// object, which may be a group, dataset or named datatype. @@ -264,133 +148,21 @@ int H5Location::iterateAttrs(attr_operator_t user_op, unsigned *_idx, void *op_d } //-------------------------------------------------------------------------- -// Function: H5Location::attrExists -///\brief Deprecated - replaced by H5Object::attrExists() -// brief Checks whether the named attribute exists at this location. -///\param name - IN: Name of the attribute to be queried -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - 2013 -// Modification -// - Moved to H5Object in 1.8.19. -BMR -//-------------------------------------------------------------------------- -bool H5Location::attrExists(const char* name) const -{ - // Call C routine H5Aexists to determine whether an attribute exists - // at this location, which could be specified by a file, group, dataset, - // or named datatype. - herr_t ret_value = H5Aexists(getId(), name); - if(ret_value > 0) - return true; - else if(ret_value == 0) - return false; - else // Raise exception when H5Aexists returns a negative value - throw AttributeIException(inMemFunc("attrExists"), "H5Aexists failed"); -} - -//-------------------------------------------------------------------------- -// Function: H5Location::attrExists -///\brief Deprecated - replaced by H5Object::attrExists() -// 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. -///\param name - IN: Name of the attribute to be queried -// Programmer Binh-Minh Ribler - 2013 -// Modification -// - Moved to H5Object in 1.8.19. -BMR -//-------------------------------------------------------------------------- -bool H5Location::attrExists(const H5std_string& name) const -{ - return(attrExists(name.c_str())); -} - -//-------------------------------------------------------------------------- -// Function: H5Location::removeAttr -///\brief Deprecated - replaced by H5Object::removeAttr() -// brief Removes the named attribute from this object. -///\param name - IN: Name of the attribute to be removed -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - 2000 -// Modification -// - Moved to H5Object in 1.8.19. -BMR -//-------------------------------------------------------------------------- -void H5Location::removeAttr(const char* name) const -{ - herr_t ret_value = H5Adelete(getId(), name); - if(ret_value < 0) - throw AttributeIException(inMemFunc("removeAttr"), "H5Adelete failed"); -} - -//-------------------------------------------------------------------------- -// Function: H5Location::removeAttr -///\brief Deprecated - replaced by 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. -///\param name - IN: Name of the attribute to be removed -// Programmer Binh-Minh Ribler - 2000 -// Modification -// - Moved to H5Object in 1.8.19. -BMR -//-------------------------------------------------------------------------- -void H5Location::removeAttr(const H5std_string& name) const -{ - removeAttr(name.c_str()); -} - -//-------------------------------------------------------------------------- -// Function: H5Location::renameAttr -///\brief Deprecated - replaced by H5Object::renameAttr() -// brief Renames the named attribute from this object. -///\param oldname - IN: Name of the attribute to be renamed -///\param newname - IN: New name ame of the attribute -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - Mar, 2005 -// Modification -// - Moved to H5Object in 1.8.19. -BMR -//-------------------------------------------------------------------------- -void H5Location::renameAttr(const char* oldname, const char* newname) const -{ - herr_t ret_value = H5Arename(getId(), oldname, newname); - if (ret_value < 0) - throw AttributeIException(inMemFunc("renameAttr"), "H5Arename failed"); -} - -//-------------------------------------------------------------------------- -// Function: H5Location::renameAttr -///\brief Deprecated - replaced by H5Object::renameAttr() -// 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 the names. -// -///\param oldname - IN: Name of the attribute to be renamed -///\param newname - IN: New name ame of the attribute -///\exception H5::AttributeIException -// Programmer Binh-Minh Ribler - Mar, 2005 -// Modification -// - Moved to H5Object in 1.8.19. -BMR -//-------------------------------------------------------------------------- -void H5Location::renameAttr(const H5std_string& oldname, const H5std_string& newname) const -{ - renameAttr (oldname.c_str(), newname.c_str()); -} - -//-------------------------------------------------------------------------- // Function: H5Location::getNumAttrs -///\brief Deprecated - replaced by H5Object::getNumAttrs() -// brief Returns the number of attributes attached to this HDF5 object. +///\brief Returns the number of attributes attached to an HDF5 object. ///\return Number of attributes ///\exception H5::AttributeIException -// 2000 // Modification -// - Moved to H5Object in 1.8.19. -BMR +// - Moved from H5Object to allow passing an attribute id to the +// C API, in 1.8.20. //-------------------------------------------------------------------------- int H5Location::getNumAttrs() const { - H5O_info_t objinfo; /* Object info */ + H5O_info_t objinfo; /* Object info */ if(H5Oget_info(getId(), &objinfo) < 0) throwException("getNumAttrs", "H5Oget_info failed"); - else - return(static_cast<int>(objinfo.num_attrs)); + return(static_cast<int>(objinfo.num_attrs)); } //-------------------------------------------------------------------------- @@ -404,7 +176,7 @@ int H5Location::getNumAttrs() const /// H5::DataSetIException /// H5::DataTypeIException /// H5::AttributeIException -// Nov 2016 +// December 2016 //-------------------------------------------------------------------------- bool H5Location::nameExists(const char* name, const LinkAccPropList& lapl) const { @@ -424,9 +196,13 @@ bool H5Location::nameExists(const char* name, const LinkAccPropList& lapl) const ///\brief Checks if a link of a given name exists in a location. ///\param name - IN: Searched name - \c H5std_string ///\param lapl - IN: Link access property list -///\exception H5::LocationException -// Programmer Binh-Minh Ribler - Dec, 2016 -// Modification +///\exception One of the following: +/// H5::GroupIException +/// H5::FileIException +/// H5::DataSetIException +/// H5::DataTypeIException +/// H5::AttributeIException +// December 2016 //-------------------------------------------------------------------------- bool H5Location::nameExists(const H5std_string& name, const LinkAccPropList& lapl) const { @@ -807,6 +583,12 @@ H5std_string H5Location::getComment(const char* name, size_t buf_size) const ///\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. +///\exception One of the following: +/// H5::GroupIException +/// H5::FileIException +/// H5::DataSetIException +/// H5::DataTypeIException +/// H5::AttributeIException // July 2004 // Modification // Moved from CommonFG, Sep 2013 @@ -850,7 +632,12 @@ hid_t H5Location::openObjId(const char* obj_name, const LinkAccPropList& lapl) c ///\param obj_name - IN: Path to the object ///\param lapl - IN: Access property list for the link pointing to /// the object -///\exception H5::LocationException +///\exception One of the following: +/// H5::GroupIException +/// H5::FileIException +/// H5::DataSetIException +/// H5::DataTypeIException +/// H5::AttributeIException // May 2017 //-------------------------------------------------------------------------- hid_t H5Location::openObjId(const H5std_string& obj_name, const LinkAccPropList& lapl) const @@ -1035,20 +822,23 @@ void H5Location::dereference(const H5Location& loc, const void* ref, H5R_type_t //-------------------------------------------------------------------------- // Function: H5Location::dereference -///\brief Dereferences a reference into an HDF5 object, given an attribute. -///\param attr - IN: Attribute specifying the location of the referenced object -///\param ref - IN: Reference pointer -///\param ref_type - IN: Reference type -///\exception H5::ReferenceException -// Programmer Binh-Minh Ribler - Oct, 2006 +// brief Dereferences a reference into an HDF5 object, given an attribute. +// param attr - IN: Attribute specifying the location of the referenced object +// param ref - IN: Reference pointer +// param ref_type - IN: Reference type +// exception H5::ReferenceException +// October 2006 // Modification // May, 2008 // Corrected missing parameters. - BMR +// May, 2018 +// Removed in 1.8.21 because H5Location is Attribute's baseclass +// now. -BMR //-------------------------------------------------------------------------- -void H5Location::dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type) -{ - p_setId(p_dereference(attr.getId(), ref, ref_type, "dereference")); -} +//void H5Location::dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type) +//{ + //p_setId(p_dereference(attr.getId(), ref, ref_type, "dereference")); +//} #ifndef H5_NO_DEPRECATED_SYMBOLS //-------------------------------------------------------------------------- @@ -1203,6 +993,444 @@ DataSpace H5Location::getRegion(void *ref, H5R_type_t ref_type) const } //-------------------------------------------------------------------------- +// Function: H5Location::link +///\brief Creates a soft link from \a link_name to \a target_name. +///\param target_name - IN: Name of object, can be a non-existing object +///\param link_name - IN: Link name for the target name +///\param lcpl - IN: Link creation plist - default to LinkCreatPropList::DEFAULT +///\param lapl - IN: Link access plist - default to LinkAccPropList::DEFAULT +///\exception One of the following: +/// H5::GroupIException +/// H5::FileIException +/// H5::DataSetIException +/// H5::DataTypeIException +/// H5::AttributeIException +///\par Description +/// Note that both names are interpreted relative to the current +/// location. +/// For information on creating a soft link, please refer to the +/// H5Lcreate_soft APIs in the HDF5 C Reference Manual. +// May 2018 +//-------------------------------------------------------------------------- +void H5Location::link(const char *target_name, const char *link_name, + const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +{ + herr_t ret_value = -1; + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); + + ret_value = H5Lcreate_soft(target_name, getId(), link_name, lcpl_id, lapl_id); + if (ret_value < 0) + throwException("link", "creating soft link failed"); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::link +///\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 target_name and \a link_name. +// May 2018 +//-------------------------------------------------------------------------- +void H5Location::link(const H5std_string& target_name, + const H5std_string& link_name, const LinkCreatPropList& lcpl, + const LinkAccPropList& lapl) const +{ + link(target_name.c_str(), link_name.c_str(), lcpl, lapl); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::link +///\brief Creates a hard link from \a new_name to \a curr_name. +///\param curr_name - IN: Name of the existing object +///\param new_loc - IN: New location +///\param new_name - IN: New name for the object +///\param lcpl - IN: Link creation plist - default to LinkCreatPropList::DEFAULT +///\param lapl - IN: Link access plist - default to LinkAccPropList::DEFAULT +///\exception One of the following: +/// H5::GroupIException +/// H5::FileIException +/// H5::DataSetIException +/// H5::DataTypeIException +/// H5::AttributeIException +///\par Description +/// Note that both names are interpreted relative to the +/// specified location. +/// For information on creating a hard link, please refer to the +/// H5Lcreate_hard APIs in the HDF5 C Reference Manual. +// May 2018 +//-------------------------------------------------------------------------- +void H5Location::link(const char *curr_name, const H5Location& new_loc, + const char *new_name, const LinkCreatPropList& lcpl, + const LinkAccPropList& lapl) const +{ + herr_t ret_value = -1; + hid_t new_loc_id = new_loc.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); + + ret_value = H5Lcreate_hard(getId(), curr_name, new_loc.getId(), new_name, lcpl_id, lapl_id); + if (ret_value < 0) + throwException("link", "creating link failed"); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::link +///\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 curr_name and \a new_name. +// May 2018 +//-------------------------------------------------------------------------- +void H5Location::link(const H5std_string& curr_name, const H5Location& new_loc, + const H5std_string& new_name, const LinkCreatPropList& lcpl, + const LinkAccPropList& lapl) const +{ + link(curr_name.c_str(), new_loc, new_name.c_str(), lcpl, lapl); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::link +///\brief Creates a hard link from \a new_name to \a curr_name - can be +/// used to pass in H5L_SAME_LOC. +///\param curr_name - IN: Name of the existing object +///\param same_loc - IN: Location ID, or H5L_SAME_LOC +///\param new_name - IN: New name for the link +///\param lcpl - IN: Link creation plist - default to LinkCreatPropList::DEFAULT +///\param lapl - IN: Link access plist - default to LinkAccPropList::DEFAULT +///\exception One of the following: +/// H5::GroupIException +/// H5::FileIException +/// H5::DataSetIException +/// H5::DataTypeIException +/// H5::AttributeIException +///\par Description +/// Note that both names are interpreted relative to the +/// specified location. +/// For information on creating a hard link, please refer to the +/// H5Lcreate_hard APIs in the HDF5 C Reference Manual. +// May 2018 +//-------------------------------------------------------------------------- +void H5Location::link(const char *curr_name, const hid_t same_loc, + const char *new_name, const LinkCreatPropList& lcpl, + const LinkAccPropList& lapl) const +{ + herr_t ret_value = -1; + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); + + ret_value = H5Lcreate_hard(getId(), curr_name, same_loc, new_name, lcpl_id, lapl_id); + + if (ret_value < 0) + throwException("link", "creating link failed"); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::link +///\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 curr_name and \a new_name. +// May 2018 +//-------------------------------------------------------------------------- +void H5Location::link(const H5std_string& curr_name, const hid_t same_loc, + const H5std_string& new_name, const LinkCreatPropList& lcpl, + const LinkAccPropList& lapl) const +{ + link(curr_name.c_str(), same_loc, new_name.c_str(), lcpl, lapl); +} + + +//-------------------------------------------------------------------------- +// Function: H5Location::copyLink +///\brief Copies a link from one location to another. +///\param src_name - IN: Original name +///\param dst - IN: Destination location +///\param dst_name - IN: New name +///\param lcpl - IN: Link creation plist - default LinkCreatPropList::DEFAULT +///\param lapl - IN: Link access plist - default LinkAccPropList::DEFAULT +///\exception One of the following: +/// H5::GroupIException +/// H5::FileIException +/// H5::DataSetIException +/// H5::DataTypeIException +/// H5::AttributeIException +// May 2018 +//-------------------------------------------------------------------------- +void H5Location::copyLink(const char *src_name, const H5Location& dst, + const char *dst_name, const LinkCreatPropList& lcpl, + const LinkAccPropList& lapl) const +{ + herr_t ret_value; + hid_t dst_id = dst.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); + + ret_value = H5Lcopy(getId(), src_name, dst_id, dst_name, lcpl_id, lapl_id); + if(ret_value < 0) + throwException("copyLink", "H5Lcopy failed"); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::copyLink +///\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 src_name and \a dst_name. +// May 2018 +//-------------------------------------------------------------------------- +void H5Location::copyLink(const H5std_string& src_name, const H5Location& dst, + const H5std_string& dst_name, const LinkCreatPropList& lcpl, + const LinkAccPropList& lapl) const +{ + copyLink(src_name.c_str(), dst, dst_name.c_str(), lcpl, lapl); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::copyLink +///\brief Copies a link from a location into the same location. +///\param src_name - IN: Original name +///\param dst_name - IN: New name +///\param lcpl - IN: Link creation plist - default LinkCreatPropList::DEFAULT +///\param lapl - IN: Link access plist - default LinkAccPropList::DEFAULT +///\exception One of the following: +/// H5::GroupIException +/// H5::FileIException +/// H5::DataSetIException +/// H5::DataTypeIException +/// H5::AttributeIException +// May 2018 +//-------------------------------------------------------------------------- +void H5Location::copyLink(const char *src_name, + const char *dst_name, const LinkCreatPropList& lcpl, + const LinkAccPropList& lapl) const +{ + herr_t ret_value; + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); + + ret_value = H5Lcopy(getId(), src_name, H5L_SAME_LOC, dst_name, lcpl_id, lapl_id); + if(ret_value < 0) + throwException("copyLink", "H5Lcopy H5L_SAME_LOC failed"); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::copyLink +///\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 src_name and \a dst_name. +// May 2018 +//-------------------------------------------------------------------------- +void H5Location::copyLink(const H5std_string& src_name, + const H5std_string& dst_name, const LinkCreatPropList& lcpl, + const LinkAccPropList& lapl) const +{ + copyLink(src_name.c_str(), dst_name.c_str(), lcpl, lapl); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::moveLink +///\brief Renames a link in this location and moves it to a new location. +///\param src_name - IN: Original name +///\param dst - IN: Destination location +///\param dst_name - IN: New name +///\param lcpl - IN: Link creation plist - default LinkCreatPropList::DEFAULT +///\param lapl - IN: Link access plist - default LinkAccPropList::DEFAULT +///\exception One of the following: +/// H5::GroupIException +/// H5::FileIException +/// H5::DataSetIException +/// H5::DataTypeIException +/// H5::AttributeIException +///\note +/// Exercise care in moving groups as it is possible to render +/// data in a file inaccessible with H5Location::moveLink. Please refer +/// to the Group Interface in the HDF5 User's Guide for details. +// May 2018 +//-------------------------------------------------------------------------- +void H5Location::moveLink(const char* src_name, const H5Location& dst, + const char* dst_name, const LinkCreatPropList& lcpl, + const LinkAccPropList& lapl) const +{ + herr_t ret_value; + hid_t dst_id = dst.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); + + ret_value = H5Lmove(getId(), src_name, dst_id, dst_name, lcpl_id, lapl_id); + if (ret_value < 0) + throwException("moveLink", "H5Lmove failed"); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::moveLink +///\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 src_name and \a dst_name. +// May 2018 +//-------------------------------------------------------------------------- +void H5Location::moveLink(const H5std_string& src_name, const H5Location& dst, + const H5std_string& dst_name, const LinkCreatPropList& lcpl, + const LinkAccPropList& lapl) const +{ + moveLink(src_name.c_str(), dst, dst_name.c_str(), lcpl, lapl); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::moveLink +///\brief Renames a link in this location. +///\param src_name - IN: Original name +///\param dst_name - IN: New name +///\param lcpl - IN: Link creation plist - default LinkCreatPropList::DEFAULT +///\param lapl - IN: Link access plist - default LinkAccPropList::DEFAULT +///\exception One of the following: +/// H5::GroupIException +/// H5::FileIException +/// H5::DataSetIException +/// H5::DataTypeIException +/// H5::AttributeIException +///\note +/// Exercise care in moving groups as it is possible to render +/// data in a file inaccessible with H5Location::moveLink. Please refer +/// to the Group Interface in the HDF5 User's Guide for details. +// May 2018 +//-------------------------------------------------------------------------- +void H5Location::moveLink(const char* src_name, const char* dst_name, + const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +{ + herr_t ret_value; + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); + + ret_value = H5Lmove(getId(), src_name, H5L_SAME_LOC, dst_name, lcpl_id, lapl_id); + if (ret_value < 0) + throwException("moveLink", "H5Lmove H5L_SAME_LOC failed"); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::moveLink +///\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 src_name and \a dst_name. +// May 2018 +//-------------------------------------------------------------------------- +void H5Location::moveLink(const H5std_string& src_name, + const H5std_string& dst_name, const LinkCreatPropList& lcpl, + const LinkAccPropList& lapl) const +{ + moveLink(src_name.c_str(), dst_name.c_str(), lcpl, lapl); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::unlink +///\brief Removes the specified link from this location. +///\param name - IN: Name of the object to be removed +///\param lapl - IN: Link access plist - default to LinkAccPropList::DEFAULT +///\exception One of the following: +/// H5::GroupIException +/// H5::FileIException +/// H5::DataSetIException +/// H5::DataTypeIException +/// H5::AttributeIException +// May 2018 +// Developer's Note +// Originally, CommonFG::unlink was the wrapper of H5Gunlink, +// which was replaced by H5Ldelete. The name "unlink" was kept +// to help with backward compatibility. +//-------------------------------------------------------------------------- +void H5Location::unlink(const char* name, const LinkAccPropList& lapl) const +{ + herr_t ret_value = H5Ldelete(getId(), name, lapl.getId()); + if (ret_value < 0) + throwException("unlink", "H5Ldelete failed"); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::unlink +///\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. +// May 2018 +//-------------------------------------------------------------------------- +void H5Location::unlink(const H5std_string& name, const LinkAccPropList& lapl) const +{ + unlink(name.c_str(), lapl); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::getLinkInfo +///\brief Returns the information of the named link. +///\param link_name - IN: Symbolic link to the object +///\param lapl - IN: Link access plist - default LinkAccPropList::DEFAULT +///\return Name of the object +///\exception H5::FileIException/H5::GroupIException/H5::LocationException +// 2000 +//-------------------------------------------------------------------------- +H5L_info_t H5Location::getLinkInfo(const char* link_name, const LinkAccPropList& lapl) const +{ + H5L_info_t linkinfo; // link info structure + + herr_t ret_value = H5Lget_info(getId(), link_name, &linkinfo, lapl.getId()); + if (ret_value < 0) + throwException("getLinkInfo", "H5Lget_info to find buffer size failed"); + + return(linkinfo); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::getLinkInfo +///\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 link_name. +//-------------------------------------------------------------------------- +H5L_info_t H5Location::getLinkInfo(const H5std_string& link_name, const LinkAccPropList& lapl) const +{ + return(getLinkInfo(link_name.c_str(), lapl)); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::getLinkval +///\brief Returns the name of the object that the symbolic link points to. +///\param name - IN: Symbolic link to the object +///\param size - IN: Maximum number of characters of value to be returned +///\return Name of the object +///\exception H5::FileIException/H5::GroupIException/H5::LocationException +// 2000 +//-------------------------------------------------------------------------- +H5std_string H5Location::getLinkval(const char* name, size_t size) const +{ + H5L_info_t linkinfo; + char *value_C; // value in C string + size_t val_size = size; + H5std_string value = ""; + herr_t ret_value; + + // if user doesn't provide buffer size, determine it + if (size == 0) + { + ret_value = H5Lget_info(getId(), name, &linkinfo, H5P_DEFAULT); + if (ret_value < 0) + throwException("getLinkval", "H5Lget_info to find buffer size failed"); + + val_size = linkinfo.u.val_size; + } + + // if link has value, retrieve the value, otherwise, return null string + if (val_size > 0) + { + value_C = new char[val_size+1]; // temporary C-string for C API + HDmemset(value_C, 0, val_size+1); // clear buffer + + ret_value = H5Lget_val(getId(), name, value_C, val_size, H5P_DEFAULT); + if (ret_value < 0) + { + delete []value_C; + throwException("getLinkval", "H5Lget_val failed"); + } + + value = H5std_string(value_C); + delete []value_C; + } + return(value); +} + +//-------------------------------------------------------------------------- // Function: H5Location destructor ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 @@ -1211,18 +1439,10 @@ H5Location::~H5Location() {} //-------------------------------------------------------------------------- // Function: f_Attribute_setId - friend -// Purpose: This function is friend to class H5::Attribute so that it -// can set Attribute::id in order to work around a problem -// described in the JIRA issue HDFFV-7947. -// Applications shouldn't need to use it. -// param attr - IN/OUT: Attribute object to be changed -// param new_id - IN: New id to set -// Programmer Binh-Minh Ribler - 2015 +// Modification: +// Moved to H5Object.cpp after the rearrangement of classes +// -BMR, Dec 2016 //-------------------------------------------------------------------------- -void f_Attribute_setId(Attribute* attr, hid_t new_id) -{ - attr->p_setId(new_id); -} //-------------------------------------------------------------------------- // Function: f_DataSpace_setId - friend diff --git a/c++/src/H5Location.h b/c++/src/H5Location.h index 0316a53..e76a6fc 100644 --- a/c++/src/H5Location.h +++ b/c++/src/H5Location.h @@ -41,6 +41,9 @@ class UserData4Aiterate { // user data for attribute iteration // Inheritance: IdComponent class H5_DLLCPP H5Location : public IdComponent { public: + // Determines the number of attributes belong to this object. + int getNumAttrs() const; + // Checks if a link of a given name exists in this location bool nameExists(const char* name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; bool nameExists(const H5std_string& name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; @@ -60,10 +63,6 @@ class H5_DLLCPP H5Location : public IdComponent { void getObjectInfo(const H5std_string& name, H5O_info_t *oinfo, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - // Determines the number of attributes at this location. - // - moved to H5Object (1.8.20) - int getNumAttrs() const; // Deprecated - #ifndef H5_NO_DEPRECATED_SYMBOLS // Retrieves the type of object that an object reference points to. H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; @@ -118,6 +117,87 @@ class H5_DLLCPP H5Location : public IdComponent { // Closes an object opened by openObjId() static void closeObjId(hid_t obj_id); + // Creates a soft link from link_name to target_name. + void link(const char *target_name, const char *link_name, + const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + void link(const H5std_string& target_name, + const H5std_string& link_name, + const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + + // Creates a hard link from new_name to curr_name. + void link(const char *curr_name, + const H5Location& new_loc, const char *new_name, + const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + void link(const H5std_string& curr_name, + const H5Location& new_loc, const H5std_string& new_name, + const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + + // Creates a hard link from new_name to curr_name in same location. + void link(const char *curr_name, + const hid_t same_loc, const char *new_name, + const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + void link(const H5std_string& curr_name, + const hid_t same_loc, const H5std_string& new_name, + const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + + // Removes the specified link from this location. + void unlink(const char *link_name, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + void unlink(const H5std_string& link_name, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + + // Copies a link from this location to another. + void copyLink(const char *src_name, + const H5Location& dst, const char *dst_name, + const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + void copyLink(const H5std_string& src_name, + const H5Location& dst, const H5std_string& dst_name, + const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + + // Makes a copy of a link in the same location. + void copyLink(const char *src_name, const char *dst_name, + const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + void copyLink(const H5std_string& src_name, + const H5std_string& dst_name, + const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + + // Renames a link in this location and moves to a new location. + void moveLink(const char* src_name, + const H5Location& dst, const char* dst_name, + const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + void moveLink(const H5std_string& src_name, + const H5Location& dst, const H5std_string& dst_name, + const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + + // Renames a link in this location. + void moveLink(const char* src_name, const char* dst_name, + const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + void moveLink(const H5std_string& src_name, + const H5std_string& dst_name, + const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + + // Returns the information of the named link. + H5L_info_t getLinkInfo(const char* link_name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + H5L_info_t getLinkInfo(const H5std_string& link_name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + + // Returns the value of a symbolic link. + H5std_string getLinkval(const char* link_name, size_t size=0) const; + H5std_string getLinkval(const H5std_string& link_name, size_t size=0) const; + ///\brief Returns an identifier. (pure virtual) virtual hid_t getId() const = 0; @@ -127,23 +207,24 @@ class H5_DLLCPP H5Location : public IdComponent { These H5A wrappers are marked "deprecated" in 1.8.19. They are moved to H5Object to prevent the object id from being passed in to H5A APIs. + Updated: they are removed from source code in 1.8.21. ***************************************************************************/ // Creates an attribute for the specified object at this location // PropList is currently not used, so always be default. // Deprecated - virtual Attribute createAttribute(const char* name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const; - virtual Attribute createAttribute(const H5std_string& name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const; + //virtual Attribute createAttribute(const char* name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const; + //virtual Attribute createAttribute(const H5std_string& name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const; // Given its name, opens the attribute that belongs to an object at // this location. // Deprecated - virtual Attribute openAttribute(const char* name) const; - virtual Attribute openAttribute(const H5std_string& name) const; + //virtual Attribute openAttribute(const char* name) const; + //virtual Attribute openAttribute(const H5std_string& name) const; // Given its index, opens the attribute that belongs to an object at // this location. - virtual Attribute openAttribute(const unsigned int idx) const; // Deprecated + //virtual Attribute openAttribute(const unsigned int idx) const; // Deprecated // Iterate user's function over the attributes at this location. virtual int iterateAttrs(attr_operator_t user_op, unsigned* idx = NULL, @@ -151,24 +232,24 @@ class H5_DLLCPP H5Location : public IdComponent { // Checks whether the named attribute exists at this location. // Deprecated - virtual bool attrExists(const char* name) const; - virtual bool attrExists(const H5std_string& name) const; + //virtual bool attrExists(const char* name) const; + //virtual bool attrExists(const H5std_string& name) const; // Renames the named attribute to a new name. // Deprecated - virtual void renameAttr(const char* oldname, const char* newname) const; - virtual void renameAttr(const H5std_string& oldname, const H5std_string& newname) const; + //virtual void renameAttr(const char* oldname, const char* newname) const; + //virtual void renameAttr(const H5std_string& oldname, const H5std_string& newname) const; // Removes the named attribute from this location. // Deprecated - virtual void removeAttr(const char* name) const; - virtual void removeAttr(const H5std_string& name) const; + //virtual void removeAttr(const char* name) const; + //virtual void removeAttr(const H5std_string& name) const; /**************************** End of H5A note *******************************/ protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Default constructor, + // Default constructor H5Location(); // *** Deprecation warning *** diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp index 4697d9c..868a5d3 100644 --- a/c++/src/H5Object.cpp +++ b/c++/src/H5Object.cpp @@ -25,6 +25,8 @@ #include "H5IdComponent.h" #include "H5PropList.h" #include "H5DataSpace.h" +#include "H5StrcreatProp.h" +#include "H5LcreatProp.h" #include "H5AbstractDs.h" #include "H5LaccProp.h" #include "H5Location.h" @@ -34,11 +36,6 @@ namespace H5 { -#ifndef H5_NO_STD - using std::cerr; - using std::endl; -#endif // H5_NO_STD - #ifndef DOXYGEN_SHOULD_SKIP_THIS // userAttrOpWrpr simply interfaces between the user's function and the // C library function H5Aiterate2; used to resolve the different prototype @@ -64,32 +61,19 @@ namespace H5 { H5Object::H5Object() : H5Location() {} //-------------------------------------------------------------------------- -// Function: H5Object overloaded constructor (protected) -// Purpose Creates an H5Object object using the id of an existing HDF5 -// object. -// Parameters object_id - IN: Id of an existing HDF5 object -// Programmer Binh-Minh Ribler - 2000 -// *** Deprecation warning *** -// This constructor is no longer appropriate because the data member "id" had -// been moved to the sub-classes. It will be removed in 1.10 release. If its -// removal does not raise any problems in 1.10, it will be removed from 1.8 in -// subsequent releases. -// Removed in 1.8.18 and 1.10.1 - Aug 2016 +// Function: f_Attribute_setId - friend +// Purpose: This function is friend to class H5::Attribute so that it +// can set Attribute::id in order to work around a problem +// described in the JIRA issue HDFFV-7947. +// Applications shouldn't need to use it. +// param attr - IN/OUT: Attribute object to be changed +// param new_id - IN: New id to set +// Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -//H5Object::H5Object(const hid_t object_id) : H5Location() {} - -//-------------------------------------------------------------------------- -// Function: H5Object copy constructor -///\brief Copy constructor: makes a copy of the original H5Object -/// instance. -///\param original - IN: H5Object instance to copy -// Programmer Binh-Minh Ribler - 2000 -// *** Deprecation warning *** -// This constructor is no longer appropriate because the data member "id" had -// been moved to the sub-classes. It is removed from 1.8.15 because it is -// a noop and it can be generated by the compiler if needed. -//-------------------------------------------------------------------------- -// H5Object::H5Object(const H5Object& original) : H5Location() {} +void f_Attribute_setId(Attribute* attr, hid_t new_id) +{ + attr->p_setId(new_id); +} /*************************************************************************** Notes for H5A wrappers @@ -301,12 +285,14 @@ void H5Object::renameAttr(const H5std_string& oldname, const H5std_string& newna //-------------------------------------------------------------------------- // Function: H5Object::getNumAttrs -///\brief Returns the number of attributes attached to this HDF5 object. +///\brief Deprecated - replaced by H5Location::getNumAttrs() +// brief Returns the number of attributes attached to this HDF5 object. ///\return Number of attributes ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 // Modification -// - Moved from H5Location in 1.8.20. -BMR Oct, 2017 +// - Moved to H5Location to allow passing an attribute id to the +// C API, in 1.8.20. //-------------------------------------------------------------------------- int H5Object::getNumAttrs() const { @@ -314,8 +300,7 @@ int H5Object::getNumAttrs() const if(H5Oget_info(getId(), &oinfo) < 0) throwException("getNumAttrs", "H5Oget_info failed"); - else - return(static_cast<int>(oinfo.num_attrs)); + return(static_cast<int>(oinfo.num_attrs)); } //-------------------------------------------------------------------------- diff --git a/c++/src/H5PredType.cpp b/c++/src/H5PredType.cpp index 63061f7..0838f1c 100644 --- a/c++/src/H5PredType.cpp +++ b/c++/src/H5PredType.cpp @@ -17,6 +17,8 @@ #include "H5Exception.h" #include "H5IdComponent.h" #include "H5PropList.h" +#include "H5StrcreatProp.h" +#include "H5LcreatProp.h" #include "H5LaccProp.h" #include "H5Location.h" #include "H5Object.h" diff --git a/c++/src/H5StrType.cpp b/c++/src/H5StrType.cpp index 00fbe20..c2c5b92 100644 --- a/c++/src/H5StrType.cpp +++ b/c++/src/H5StrType.cpp @@ -17,6 +17,8 @@ #include "H5Exception.h" #include "H5IdComponent.h" #include "H5PropList.h" +#include "H5StrcreatProp.h" +#include "H5LcreatProp.h" #include "H5LaccProp.h" #include "H5Location.h" #include "H5Object.h" diff --git a/c++/src/H5StrcreatProp.cpp b/c++/src/H5StrcreatProp.cpp index 79749d8..b296a65 100644 --- a/c++/src/H5StrcreatProp.cpp +++ b/c++/src/H5StrcreatProp.cpp @@ -13,6 +13,11 @@ #include <string> +#include <iostream> + using std::cerr; + using std::endl; + + #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -21,6 +26,36 @@ namespace H5 { +#ifndef DOXYGEN_SHOULD_SKIP_THIS +// Currently, StrCreatPropList is an internal base class. + +//-------------------------------------------------------------------------- +// Function: StrCreatPropList default constructor +///\brief Default constructor: Creates a string create property list +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +StrCreatPropList::StrCreatPropList() : PropList(H5P_STRING_CREATE) {} + +//-------------------------------------------------------------------------- +// Function: StrCreatPropList copy constructor +///\brief Copy constructor: makes a copy of the original +/// StrCreatPropList object. +///\param original - IN: StrCreatPropList instance to copy +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +StrCreatPropList::StrCreatPropList(const StrCreatPropList& original) : PropList(original) {} + +//-------------------------------------------------------------------------- +// Function: StrCreatPropList overloaded constructor +///\brief Creates a file creation property list using the id of an +/// existing one. +///\param plist_id - IN: StrCreatPropList id to use +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +StrCreatPropList::StrCreatPropList(const hid_t plist_id) : PropList(plist_id) {} + +#endif // DOXYGEN_SHOULD_SKIP_THIS + //-------------------------------------------------------------------------- // Function: StrCreatPropList::setCharEncoding ///\brief Sets the character encoding of the string. diff --git a/c++/src/H5StrcreatProp.h b/c++/src/H5StrcreatProp.h index 7b07dd6..9679a55 100644 --- a/c++/src/H5StrcreatProp.h +++ b/c++/src/H5StrcreatProp.h @@ -37,14 +37,14 @@ class H5_DLLCPP StrCreatPropList : public PropList { #ifndef DOXYGEN_SHOULD_SKIP_THIS protected: // Creates a link creation property list. - StrCreatPropList() {}; + StrCreatPropList(); // Copy constructor: same as the original StrCreatPropList. - StrCreatPropList(const StrCreatPropList& original) {}; + StrCreatPropList(const StrCreatPropList& original); // Creates a copy of an existing link creation property list // using the property list id. - StrCreatPropList(const hid_t plist_id) {}; + StrCreatPropList(const hid_t plist_id); // Noop destructor virtual ~StrCreatPropList() {}; diff --git a/c++/src/H5VarLenType.cpp b/c++/src/H5VarLenType.cpp index 8d9e3a1..902de79 100644 --- a/c++/src/H5VarLenType.cpp +++ b/c++/src/H5VarLenType.cpp @@ -17,6 +17,8 @@ #include "H5Exception.h" #include "H5IdComponent.h" #include "H5PropList.h" +#include "H5StrcreatProp.h" +#include "H5LcreatProp.h" #include "H5LaccProp.h" #include "H5Location.h" #include "H5Object.h" diff --git a/c++/src/cpp_doc_config b/c++/src/cpp_doc_config index 1571b43..b368692 100644 --- a/c++/src/cpp_doc_config +++ b/c++/src/cpp_doc_config @@ -49,6 +49,7 @@ PROJECT_NAME = "HDF5 C++ API" # could be handy for archiving the generated documentation or if some version # control system is used. + PROJECT_NUMBER = "1.8.21-pre1, currently under development" # Using the PROJECT_BRIEF tag one can provide an optional one line description diff --git a/c++/test/tlinks.cpp b/c++/test/tlinks.cpp index 356bc1b..ae0d53a 100644 --- a/c++/test/tlinks.cpp +++ b/c++/test/tlinks.cpp @@ -433,6 +433,366 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) } // test_basic_links /*------------------------------------------------------------------------- + * Function: test_lcpl + * + * Purpose: Tests link creation property lists, specifically, the + * character encoding property. + * + * Return: Success: 0 + * Failure: number of errors + * May 2018 + *------------------------------------------------------------------------- + */ +const H5std_string GROUP1NAME("First_group"); +const H5std_string GROUP2NAME("Second_group"); +static void +test_lcpl(hid_t fapl_id, hbool_t new_format) +{ + H5L_info_t linfo; + char filename[1024]; + hsize_t dims[2]; + + if(new_format) + SUBTEST("Link creation property lists (w/new group format)") + else + SUBTEST("Link creation property lists") + + try + { + FileAccPropList fapl(fapl_id); + + // Create a new file. + h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename); + H5File file(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); + + // Create and link a group with the default LCPL. + Group grp_1(file.createGroup(GROUP1NAME)); + grp_1.close(); + + // Check that its character encoding is the default. + linfo = file.getLinkInfo(GROUP1NAME); + if(linfo.cset != H5T_CSET_ASCII) + throw InvalidActionException("H5Lget_info", "Character encoding is not default"); + + // Create and commit a datatype with the default LCPL. + IntType dtype(PredType::NATIVE_INT); + dtype.commit(file, "/type"); + dtype.close(); + + // Check that its character encoding is the default. + linfo = file.getLinkInfo("/type"); + verify_val(linfo.cset, H5T_CSET_ASCII, "Character encoding is not default", __LINE__, __FILE__); + + // Create a simple dataspace. + dims[0] = H5L_DIM1; + dims[1] = H5L_DIM2; + DataSpace dspace(2 ,dims); + + // Create a dataset using the default LCPL. + DataSet dset(file.createDataSet("/dataset", PredType::NATIVE_INT, dspace)); + dset.close(); + + // Check that its character encoding is the default. + linfo = file.getLinkInfo("/dataset"); + verify_val(linfo.cset, H5T_CSET_ASCII, "Character encoding is not default", __LINE__, __FILE__); + + // Create a link creation property list with the UTF-8 character encoding. + LinkCreatPropList lcpl; + lcpl.setCharEncoding(H5T_CSET_UTF8); + + // Create and link a group with the new LCPL. + Group grp_2(file.createGroup(GROUP2NAME, 0, lcpl)); + grp_2.close(); + + // Check that its character encoding is UTF-8. + linfo = file.getLinkInfo(GROUP2NAME); + verify_val(linfo.cset, H5T_CSET_UTF8, "Character encoding is not UTF-8", __LINE__, __FILE__); + + PASSED(); + } // end of try block + catch (Exception& E) + { + issue_fail_msg("test_lcpl()", __LINE__, __FILE__, E.getCDetailMsg()); + } +} // end test_lcpl() + +/*------------------------------------------------------------------------- + * Function: test_move + * + * Purpose: Tests wrappers of H5Lmove() + * + * Return: Success: 0 + * Failure: number of errors + * May 2018 + *------------------------------------------------------------------------- + */ +static void +test_move(hid_t fapl_id, hbool_t new_format) +{ + char filename[1024]; + + if(new_format) + SUBTEST("Group::moveLink (w/new group format)") + else + SUBTEST("Group::moveLink") + + try + { + FileAccPropList fapl(fapl_id); + + // Create two new files + h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename); + H5File file_a(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); + h5_fixname(FILENAME[1], fapl_id, filename, sizeof filename); + H5File file_b(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); + + // Create groups in first file + Group grp_1(file_a.createGroup(GROUP1NAME)); + Group grp_2(file_a.createGroup(GROUP2NAME)); + Group grp_move(grp_1.createGroup("group_move")); + + // Create hard and soft links + grp_1.link(H5L_TYPE_HARD, "group_move", "hard"); + grp_2.link(H5L_TYPE_SOFT, "/First_group/group_copy", "soft"); + + // Move a group across files, should fail + try { + grp_1.moveLink("group_move", file_b, "group_new_name"); + + // Should throw an exception but didn't + H5_FAILED(); + cerr << " Group group_move should not be moved across files" << endl; + } catch (Exception& E) { + // expected + } + + // Move a soft link across files, should succeed + grp_2.moveLink("soft", file_b, "soft_new_name"); + if(file_b.nameExists("soft_new_name") != TRUE) + throw InvalidActionException("H5File::nameExists", "grp1/soft doesn't exist"); + + // Move a group across groups in the same file while renaming it + grp_1.moveLink("group_move", grp_2, "group_new_name"); + + // Open the group just moved to the new location. */ + Group moved_grp = grp_2.openGroup("group_new_name"); + moved_grp.close(); + + // Verify that the group is no longer in the original location + try { + moved_grp = grp_1.openGroup("group_move"); + + // Should throw an exception but didn't + H5_FAILED(); + cerr << " Group group_move should not be in original location" << endl; + } catch (Exception& E) { + // expected + } + + // Use H5Lmove to rename a group without moving it + H5std_string new_name("group_new_name"); + H5std_string newer_name("group_newer_name"); + grp_2.moveLink(new_name, newer_name); + + // Open the group + moved_grp = grp_2.openGroup("group_newer_name"); + moved_grp.close(); + + // Use H5Lmove to move a group without renaming it + grp_2.moveLink(newer_name, grp_1, newer_name); + + // Open the group + moved_grp = grp_1.openGroup("group_newer_name"); + moved_grp.close(); + + // Move the group while giving long paths + file_a.moveLink("/First_group/group_newer_name", grp_2, "/Second_group/group_newest_name"); + + // Open the group just moved to the new location + moved_grp = grp_2.openGroup("group_newest_name"); + moved_grp.close(); + + // Verify that the groups are not in previous locations + try { + moved_grp = grp_1.openGroup("group_newer_name"); + moved_grp.close(); + + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_newer_name should not be in GROUP1NAME" << endl; + } catch (Exception& E) { + // expected + } + try { + moved_grp = grp_2.openGroup("group_newer_name"); + moved_grp.close(); + + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_newer_name should not be in GROUP2NAME" << endl; + } catch (Exception& E) { + // expected + } + try { + moved_grp = grp_2.openGroup("group_new_name"); + moved_grp.close(); + + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_new_name should not be in GROUP2NAME" << endl; + } catch (Exception& E) { + // expected + } + try { + moved_grp = grp_1.openGroup("group_copy"); + moved_grp.close(); + + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_copy should not be in GROUP1NAME" << endl; + } catch (Exception& E) { + // expected + } + PASSED(); + } // end of try block + catch (Exception& E) + { + issue_fail_msg("test_move()", __LINE__, __FILE__, E.getCDetailMsg()); + } +} // test_move + +/*------------------------------------------------------------------------- + * Function: test_copy + * + * Purpose: Tests wrappers of H5Lcopy() and H5Ldelete() + * + * Return: Success: 0 + * Failure: number of errors + * May 2018 + *------------------------------------------------------------------------- + */ +static void test_copy(hid_t fapl_id, hbool_t new_format) +{ + char filename[1024]; + + if(new_format) + SUBTEST("Group::copyLink (w/new group format)") + else + SUBTEST("Group::copyLink") + + try + { + // Create two new files + h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename); + H5File file_a(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl_id); + h5_fixname(FILENAME[1], fapl_id, filename, sizeof filename); + H5File file_b(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl_id); + + // Create groups in first file + Group grp_1(file_a.createGroup(GROUP1NAME)); + Group grp_2(file_a.createGroup(GROUP2NAME)); + Group grp_move(grp_1.createGroup("group_copy")); + + // Create hard and soft links + grp_1.link("group_copy", H5L_SAME_LOC, "hard"); + grp_2.link("/First_group/group_copy", "soft"); + + // Copy a group across files, should fail + try { + grp_1.copyLink("group_copy", file_b, "group_new_name"); + } catch (Exception& E) { + // expected + } + + // Copy a soft link across files, should succeed + grp_2.copyLink("soft", file_b, "soft_new_name"); + if (file_b.nameExists("soft_new_name") != TRUE) + throw InvalidActionException("H5File::nameExists", "soft_new_name doesn't exist"); + + // Move a group across groups in the same file while renaming it + H5std_string copy_name("group_copy"); + H5std_string new_name("group_new_name"); + grp_1.copyLink(copy_name, grp_2, new_name); + + // Open the group just moved to the new location. + Group moved_grp(grp_2.openGroup("group_new_name")); + moved_grp.close(); + + // Verify that the group is also in the original location + moved_grp = grp_1.openGroup("group_copy"); + moved_grp.close(); + + // Create a group in the same location with a different name + grp_2.copyLink("group_new_name", "group_newer_name"); + + // Open the group + moved_grp = grp_2.openGroup("group_newer_name"); + moved_grp.close(); + + // Verify that the group is also in the original location + moved_grp = grp_2.openGroup("group_new_name"); + moved_grp.close(); + + // Use H5Lcopy to copy to a different location with the same name + grp_2.copyLink("group_newer_name", grp_1, "group_newer_name"); + + // Open the group + moved_grp = grp_1.openGroup("group_newer_name"); + moved_grp.close(); + + // Verify that the group is still in the previous location + moved_grp = grp_2.openGroup("group_new_name"); + moved_grp.close(); + + // Copy the group while giving long paths + file_a.copyLink("/First_group/group_newer_name", grp_2, "/Second_group/group_newest_name"); + + // Open the newest group just moved to the new location + moved_grp = grp_2.openGroup("group_newest_name"); + moved_grp.close(); + + // Verify that the group is still in all previous original locations + moved_grp = grp_1.openGroup("group_newer_name"); + moved_grp.close(); + + moved_grp = grp_2.openGroup("group_newer_name"); + moved_grp.close(); + + moved_grp = grp_2.openGroup("group_new_name"); + moved_grp.close(); + + moved_grp = grp_1.openGroup("group_copy"); + moved_grp.close(); + + // Delete "group_newer_name" from group 2, then try to open it. + grp_2.unlink("group_newer_name"); + try { + moved_grp = grp_2.openGroup("group_newer_name"); + moved_grp.close(); + + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_newer_name should not be in GROUP2NAME" << endl; + } catch (Exception& E) { + // expected + } + + // Delete "group_copy" from group 1, then try to open it. + grp_1.unlink("group_copy"); + try { + moved_grp = grp_1.openGroup("group_copy"); + moved_grp.close(); + + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_copy should not be in GROUP1NAME" << endl; + } catch (Exception& E) { + // expected + } + + PASSED(); + } // end of try block + catch (Exception& E) + { + issue_fail_msg("test_copy()", __LINE__, __FILE__, E.getCDetailMsg()); + } +} // test_copy + +/*------------------------------------------------------------------------- * Function: test_num_links * * Purpose: Test setting and getting limit of number of links @@ -528,13 +888,13 @@ void test_links() // FileAccPropList may be passed in instead of fapl id test_basic_links(my_fapl_id, new_format); test_num_links(my_fapl_id, new_format); + test_lcpl(my_fapl_id, new_format); + test_move(my_fapl_id, new_format); + test_copy(my_fapl_id, new_format); #if 0 // these tests are from the C test links.c and left here for future // implementation of H5L API - test_move(my_fapl_id, new_format); - test_copy(my_fapl_id, new_format); - test_lcpl(my_fapl_id, new_format); nerrors += cklinks(my_fapl, new_format) < 0 ? 1 : 0; nerrors += new_links(my_fapl, new_format) < 0 ? 1 : 0; nerrors += ck_new_links(my_fapl, new_format) < 0 ? 1 : 0; diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 7b3e556..fb3fa12 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -4,11 +4,9 @@ HDF5 version 1.8.21-pre1 currently under development INTRODUCTION ============ -This document describes the differences between HDF5-1.8.20 and -HDF5-1.8.21, and contains information on the platforms tested and -known problems in HDF5-1.8.21. -For more details, see the files HISTORY-1_0-1_8_0_rc3.txt -and HISTORY-1_8.txt in the release_docs/ directory of the HDF5 source. +This document describes the differences between HDF5-1.8.21 and HDF5 1.10.22, and +contains information on the platforms tested and known problems in HDF5-1.10.21. +For more details check the HISTORY*.txt files in the HDF5 source. Links to the HDF5 1.8.21 source code, documentation, and additional materials can be found on the HDF5 web page at: @@ -19,7 +17,7 @@ The HDF5 1.8.21 release can be obtained from: https://support.hdfgroup.org/HDF5/release/obtain518.html -User documentation for 1.8.21 can be accessed directly at this location: +User documentation for the snapshot can be accessed directly at this location: https://support.hdfgroup.org/HDF5/doc1.8/ @@ -30,8 +28,8 @@ in 1.8.0?" document: https://support.hdfgroup.org/HDF5/doc/ADGuide/WhatsNew180.html All new and modified APIs are listed in detail in the "HDF5 Software Changes -from Release to Release" document, in the section "Release 1.8.21 (current -release) versus Release 1.8.20 +from Release to Release" document, in the section "Release 1.8.22 (current +release) versus Release 1.8.21 https://support.hdfgroup.org/HDF5/doc1.8/ADGuide/Changes.html @@ -57,36 +55,6 @@ New Features Configuration ------------- - - CMake - - Change minimum version to 3.10. - - This change removes the need to support a copy of the FindMPI.cmake module, - which has been removed, along with its subfolder in the config/cmake_ext_mod - location. - - (ADB - 2018/03/09) - - - CMake - - Add pkg-config file generation - - Added pkg-config file generation for the C, C++, HL, and HL C++ libraries. - In addition, builds on linux will create h5cXXX scripts that use the pkg-config - files. This is a limited implementation of a script like autotools h5cc. - - (ADB - 2018/03/08, HDFFV-4359) - - - CMake - - Refactor use of CMAKE_BUILD_TYPE for new variable, which understands - the type of generator in use. - - Added new configuration macros to use new HDF_BUILD_TYPE variable. This - variable is set correctly for the type of generator being used for the build. - - (ADB - 2018/01/08, HDFFV-10385, HDFFV-10296) - - None @@ -132,143 +100,14 @@ Support for New Platforms, Languages, and Compilers Bug Fixes since HDF5-1.8.20 =========================== - - If an HDF5 file contains a filter pipeline message with a 'number of - filters' field that exceeds the maximum number of allowed filters, - the error handling code will attempt to dereference a NULL pointer. - - This issue was reported to The HDF Group as issue #CVE-2017-17505. - - NOTE: The HDF5 C library cannot produce such a file. This condition - should only occur in a corrupt (or deliberately altered) file - or a file created by third-party software. - - This problem arose because the error handling code assumed that - the 'number of filters' field implied that a dynamic array of that - size had already been created and that the cleanup code should - iterate over that array and clean up each element's resources. If - an error occurred before the array has been allocated, this will - not be true. - - This has been changed so that the number of filters is set to - zero on errors. Additionally, the filter array traversal in the - error handling code now requires that the filter array not be NULL. - - (DER - 2018/02/06, HDFFV-10354) - - - If an HDF5 file contains a filter pipeline message which contains - a 'number of filters' field that exceeds the actual number of - filters in the message, the HDF5 C library will read off the end of - the read buffer. - - This issue was reported to The HDF Group as issue #CVE-2017-17506. - - NOTE: The HDF5 C library cannot produce such a file. This condition - should only occur in a corrupt (or deliberately altered) file - or a file created by third-party software. - - The problem was fixed by passing the buffer size with the buffer - and ensuring that the pointer cannot be incremented off the end - of the buffer. A mismatch between the number of filters declared - and the actual number of filters will now invoke normal HDF5 - error handling. - - (DER - 2018/02/26, HDFFV-10355) - - - If an HDF5 file contains a malformed compound datatype with a - suitably large offset, the type conversion code can run off - the end of the type conversion buffer, causing a segmentation - fault. - - This issue was reported to The HDF Group as issue #CVE-2017-17507. - - NOTE: The HDF5 C library cannot produce such a file. This condition - should only occur in a corrupt (or deliberately altered) file - or a file created by third-party software. - - THE HDF GROUP WILL NOT FIX THIS BUG AT THIS TIME - - Fixing this problem would involve updating the publicly visible - H5T_conv_t function pointer typedef and versioning the API calls - which use it. We normally only modify the public API during - major releases, so this bug will not be fixed at this time. - - (DER - 2018/02/26, HDFFV-10356) - - - If an HDF5 file contains a malformed compound type which contains - a member of size zero, a division by zero error will occur while - processing the type. - - This issue was reported to The HDF Group as issue #CVE-2017-17508. - - NOTE: The HDF5 C library cannot produce such a file. This condition - should only occur in a corrupt (or deliberately altered) file - or a file created by third-party software. - - Checking for zero before dividing fixes the problem. Instead of the - division by zero, the normal HDF5 error handling is invoked. - - (DER - 2018/02/26, HDFFV-10357) - - - If an HDF5 file contains a malformed symbol table node that declares - it contains more symbols than it actually contains, the library - can run off the end of the metadata cache buffer while processing - the symbol table node. - - This issue was reported to The HDF Group as issue #CVE-2017-17509. - - NOTE: The HDF5 C library cannot produce such a file. This condition - should only occur in a corrupt (or deliberately altered) file - or a file created by third-party software. - - Performing bounds checks on the buffer while processing fixes the - problem. Instead of the segmentation fault, the normal HDF5 error - handling is invoked. - - (DER - 2018/03/12, HDFFV-10358) - Configuration ------------- - - CMake - - Update CMake commands configuration. - - A number of improvements were made to the CMake commands. Most - changes simplify usage or eliminate unused constructs. Also, - some changes support better cross-platform support. - - (ADB - 2018/02/01, HDFFV-10398) - - - CMake - - Correct usage of CMAKE_BUILD_TYPE variable. - - The use of the CMAKE_BUILD_TYPE is incorrect for multi-config - generators (Visual Studio and XCode) and is optional for single - config generators. Created a new macro to check - GLOBAL PROPERTY -> GENERATOR_IS_MULTI_CONFIG - Created two new HDF variable, HDF_BUILD_TYPE and HDF_CFG_BUILD_TYPE. - Defaults for these variables is "Release". - - (ADB - 2018/01/10, HDFFV-10385) - - - CMake - - Add replacement of fortran flags if using static CRT. - - Added TARGET_STATIC_CRT_FLAGS call to HDFUseFortran.cmake file in - config/cmake_ext_mod folder. - - (ADB - 2018/01/08, HDFFV-10334) + - None Library ------- - - Utility function can not handle lowercase Windows drive letters - - Added call to toupper function for drive letter. - - (ADB - 2017/12/18, HDFFV-10307) - + - None Parallel Library @@ -283,81 +122,7 @@ Bug Fixes since HDF5-1.8.20 Tools ----- - - h5repack - - h5repack changes the chunk parameters when a change of layout is not - specified and a filter is applied. - - HDFFV-10297, HDFFV-10319 reworked code for h5repack and h5diff code - in the tools library. The check for an existing layout was incorrectly - placed into an if block and not executed. The check was moved into - the normal path of the function. - - (ADB - 2018/02/21, HDFFV-10412) - - - h5dump - - the tools library will hide the error stack during file open. - - While this is preferable almost always, there are reasons to enable - display of the error stack when a tool will not open a file. Adding an - optional argument to the --enable-error-stack will provide this use case. - As an optional argument it will not affect the operation of the - --enable-error-stack. h5dump is the only tool to implement this change. - - (ADB - 2018/02/15, HDFFV-10384) - - - h5dump - - h5dump would output an indented blank line in the filters section. - - h5dump overused the h5tools_simple_prefix function, which is a - function intended to account for the data index (x,y,z) option. - Removed the function call for header information. - - (ADB - 2018/01/25, HDFFV-10396) - - - h5repack - - h5repack incorrectly searched internal object table for name. - - h5repack would search the table of objects for a name, if the - name did not match it tried to determine if the name without a - leading slash would match. The logic was flawed! The table - stored names(paths) without a leading slash and did a strstr - of the table path to the name. - The assumption was that if there was a difference of one then - it was a match, however "pressure" would match "/pressure" as - well as "/pressure1", "/pressure2", etc. Changed logic to remove - any leading slash and then do a full compare of the name. - - (ADB - 2018/01/18, HDFFV-10393) - - - h5repack - - h5repack failed to handle more then 9 chars for int conversion. - - User defined filter parameter conversions would fail for integers - larger then 9 characters. Increased local variable array for storing - the current command line parameter to prevent buffer overflows. - - (ADB - 2018/01/17, HDFFV-10392) - - - h5diff - - h5diff seg-faulted if comparing VL strings against fixed strings. - - Reworked solution for HDFFV-8625 and HDFFV-8639. Implemented the check - for string objects of same type in the diff_can_type function by - adding an if(tclass1 == H5T_STRING) block. This if block moves the - same check that was added for attributes to this function, which is - used by all object types. This function also handles complex type - structures. - Also added a new test file in h5diffgenttest for testing this issue - and removed the temporary files used in the test scripts. - - (ADB - 2018/01/04, HDFFV-8745) - + - None Fortran API diff --git a/tools/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl b/tools/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl index e8ac9a4..08fd4aa 100644 --- a/tools/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl +++ b/tools/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl @@ -11,7 +11,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 8 21 } + PARAMS { 9 1 8 22 } } } FILLVALUE { @@ -33,7 +33,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 8 21 } + PARAMS { 9 1 8 22 } } } FILLVALUE { @@ -55,7 +55,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 8 21 } + PARAMS { 9 1 8 22 } } } FILLVALUE { @@ -77,7 +77,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 8 21 } + PARAMS { 9 1 8 22 } } } FILLVALUE { @@ -99,7 +99,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 8 21 } + PARAMS { 9 1 8 22 } } } FILLVALUE { @@ -121,7 +121,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 8 21 } + PARAMS { 9 1 8 22 } } } FILLVALUE { @@ -143,7 +143,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 8 21 } + PARAMS { 9 1 8 22 } } } FILLVALUE { |