summaryrefslogtreecommitdiffstats
path: root/c++/src
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2013-03-29 23:13:05 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2013-03-29 23:13:05 (GMT)
commit6c974c824db0c4b97a5ec5e03726ebe4a2198ad9 (patch)
treea89f756228cc72486ff1e71fbc68fd29baa01ba3 /c++/src
parented621aae38837e90c7273087de22f1752eee7cc7 (diff)
downloadhdf5-6c974c824db0c4b97a5ec5e03726ebe4a2198ad9.zip
hdf5-6c974c824db0c4b97a5ec5e03726ebe4a2198ad9.tar.gz
hdf5-6c974c824db0c4b97a5ec5e03726ebe4a2198ad9.tar.bz2
[svn-r23495] ported revisions 23433:23494 from the trunk
Diffstat (limited to 'c++/src')
-rw-r--r--c++/src/H5Location.cpp33
-rw-r--r--c++/src/H5Location.h10
2 files changed, 40 insertions, 3 deletions
diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp
index b93cd86..98878d7 100644
--- a/c++/src/H5Location.cpp
+++ b/c++/src/H5Location.cpp
@@ -250,6 +250,39 @@ int H5Location::getNumAttrs() const
}
//--------------------------------------------------------------------------
+// Function: H5Location::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
+//--------------------------------------------------------------------------
+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 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
+//--------------------------------------------------------------------------
+bool H5Location::attrExists(const H5std_string& name) const
+{
+ return(attrExists(name.c_str()));
+}
+
+//--------------------------------------------------------------------------
// Function: H5Location::removeAttr
///\brief Removes the named attribute from this object.
///\param name - IN: Name of the attribute to be removed
diff --git a/c++/src/H5Location.h b/c++/src/H5Location.h
index d1dd892..8eae454 100644
--- a/c++/src/H5Location.h
+++ b/c++/src/H5Location.h
@@ -79,11 +79,15 @@ class H5_DLLCPP H5Location : public IdComponent {
// misleading, so getRefObjType is used in the new function instead.
// Iterate user's function over the attributes at this location.
- int iterateAttrs( attr_operator_t user_op, unsigned* idx = NULL, void* op_data = NULL );
+ int iterateAttrs(attr_operator_t user_op, unsigned* idx = NULL, void* op_data = NULL);
+
+ // Checks whether the named attribute exists at this location.
+ bool attrExists(const char* name) const;
+ bool attrExists(const H5std_string& name) const;
// Removes the named attribute from this location.
- void removeAttr( const char* name ) const;
- void removeAttr( const H5std_string& name ) const;
+ void removeAttr(const char* name) const;
+ void removeAttr(const H5std_string& name) const;
// Renames the named attribute to a new name.
void renameAttr(const char* oldname, const char* newname) const;