diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-05-05 17:18:50 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-05-05 17:18:50 (GMT) |
commit | ca7fc8e96a70b06b08e1db21040056ae17a51906 (patch) | |
tree | 3d665b7a3119174158fc91a05fd8055f6ca7074b /c++/src | |
parent | b24e2d4dd861b67a61fcf56be5975bcd4d37203b (diff) | |
download | hdf5-ca7fc8e96a70b06b08e1db21040056ae17a51906.zip hdf5-ca7fc8e96a70b06b08e1db21040056ae17a51906.tar.gz hdf5-ca7fc8e96a70b06b08e1db21040056ae17a51906.tar.bz2 |
[svn-r18708] Description:
Bring r18638:18704 from trunk to revise_chunks branch.
Tested on:
Mac OS X/32 10.6.3 (amazon) w/debug & production
(h5committest not required on this branch)
Diffstat (limited to 'c++/src')
-rw-r--r-- | c++/src/H5Attribute.cpp | 7 | ||||
-rw-r--r-- | c++/src/H5CommonFG.cpp | 50 | ||||
-rw-r--r-- | c++/src/H5CommonFG.h | 4 | ||||
-rw-r--r-- | c++/src/Makefile.in | 2 |
4 files changed, 54 insertions, 9 deletions
diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index 5f04865..a2445d6 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -423,18 +423,15 @@ void Attribute::p_read_fixed_len(const DataType& mem_type, H5std_string& strg) c // If there is data, allocate buffer and read it. if (attr_size > 0) { - char *strg_C = NULL; - - strg_C = new char [(size_t)attr_size+1]; + char *strg_C = new char[(size_t)attr_size+1]; herr_t ret_value = H5Aread(id, mem_type.getId(), strg_C); - if( ret_value < 0 ) { delete []strg_C; // de-allocate for fixed-len string throw AttributeIException("Attribute::read", "H5Aread failed"); } - // Get string from the C char* and release resource allocated locally + strg_C[attr_size] = '\0'; strg = strg_C; delete []strg_C; } diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp index 8c1237d..5b93bd5 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -31,6 +31,7 @@ #include "H5DataSet.h" #include "H5File.h" #include "H5Alltypes.h" +#include "H5private.h" // for HDstrcpy // There are a few comments that are common to most of the functions // defined in this file so they are listed here. @@ -1058,10 +1059,27 @@ H5std_string CommonFG::getObjnameByIdx(hsize_t idx) const /// each time the group is opened. // Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- +ssize_t CommonFG::getObjnameByIdx(hsize_t idx, char* name, size_t size) const +{ + ssize_t name_len = H5Lget_name_by_idx(getLocId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name, size, H5P_DEFAULT); + if(name_len < 0) + { + throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); + } + return (name_len); +} + +//-------------------------------------------------------------------------- +// Function: CommonFG::getObjnameByIdx +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c std::string for \a name. +// Programmer Binh-Minh Ribler - January, 2003 +//-------------------------------------------------------------------------- ssize_t CommonFG::getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size) const { char* name_C = new char[size]; - ssize_t name_len = H5Lget_name_by_idx(getLocId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name_C, size, H5P_DEFAULT); + ssize_t name_len = getObjnameByIdx(idx, name_C, size); if(name_len < 0) { throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); @@ -1095,7 +1113,35 @@ H5G_obj_t CommonFG::getObjTypeByIdx(hsize_t idx) const // Function: CommonFG::getObjTypeByIdx ///\brief This is an overloaded member function, provided for convenience. /// It differs from the above function because it also provides -/// the returned object type in text. +/// the returned object type in text (char*) +///\param idx - IN: Transient index of the object +///\param type_name - IN: Object type in text +///\return Object type +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - May, 2010 +//-------------------------------------------------------------------------- +H5G_obj_t CommonFG::getObjTypeByIdx(hsize_t idx, char* type_name) const +{ + H5G_obj_t obj_type = H5Gget_objtype_by_idx(getLocId(), idx); + switch (obj_type) + { + case H5G_LINK: HDstrcpy(type_name, "symbolic link"); break; + case H5G_GROUP: HDstrcpy(type_name, "group"); break; + case H5G_DATASET: HDstrcpy(type_name, "dataset"); break; + case H5G_TYPE: HDstrcpy(type_name, "datatype"); break; + case H5G_UNKNOWN: + default: + { + throwException("getObjTypeByIdx", "H5Gget_objtype_by_idx failed"); + } + } + return (obj_type); +} +//-------------------------------------------------------------------------- +// Function: CommonFG::getObjTypeByIdx +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function because it also provides +/// the returned object type in text (H5std_string&) ///\param idx - IN: Transient index of the object ///\param type_name - IN: Object type in text ///\return Object type diff --git a/c++/src/H5CommonFG.h b/c++/src/H5CommonFG.h index d472d42..4f32d21 100644 --- a/c++/src/H5CommonFG.h +++ b/c++/src/H5CommonFG.h @@ -70,13 +70,15 @@ class H5_DLLCPP CommonFG { // Retrieves the name of an object in this group, given the // object's index. - ssize_t getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size) const; H5std_string getObjnameByIdx(hsize_t idx) const; + ssize_t getObjnameByIdx(hsize_t idx, char* name, size_t size) const; + ssize_t getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size) const; #ifndef H5_NO_DEPRECATED_SYMBOLS // Returns the type of an object in this group, given the // object's index. H5G_obj_t getObjTypeByIdx(hsize_t idx) const; + H5G_obj_t getObjTypeByIdx(hsize_t idx, char* type_name) const; H5G_obj_t getObjTypeByIdx(hsize_t idx, H5std_string& type_name) const; // Returns information about an HDF5 object, given by its name, diff --git a/c++/src/Makefile.in b/c++/src/Makefile.in index 94fb618..2c595fc 100644 --- a/c++/src/Makefile.in +++ b/c++/src/Makefile.in @@ -390,7 +390,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 58 +LT_VERS_REVISION = 59 LT_VERS_AGE = 0 # Include src directory |