1.8.5: No method in H5::H5Object to test for attribute existence.

VERSION:
          HDF5-1.8.5-post2

       USER:
              Kent Williams, 319-353-8553, University of Iowa Hospitals
W278 GH 200 Hawkins Dr Iowa City, IA 52242
       SYNOPSIS:
              C++ API missing method to test if an attribute exists

       MACHINE / OPERATING SYSTEM:
              All platforms
       COMPILER:
              All Compilers

       DESCRIPTION:
       While the base C API has the H5Aexists function, there's no
equivalent in the C++ H5::H5Object
       REPEAT BUG BY:
       Reading documentation and header files :wink:
       SAMPLE FIX:
              The patch below adds two methods to allow for testing
attribute existence. I wasn't sure how to

              name it in a way consistent with the rest of the class
methods, and settled on doesAttrExist

diff --git a/Modules/ThirdParty/HDF5/src/itkhdf5/c++/src/H5Object.cpp
b/Modules/ThirdParty/HDF5/src/itkhdf5/c++/src/H5Object.cpp
index d5fa62d..7f41408 100644
--- a/Modules/ThirdParty/HDF5/src/itkhdf5/c++/src/H5Object.cpp
+++ b/Modules/ThirdParty/HDF5/src/itkhdf5/c++/src/H5Object.cpp
@@ -154,6 +154,8 @@ Attribute H5Object::openAttribute( const char* name )
const
    }
}

···

+
+
//------------------------------------------------------------------------
--
// Function: H5Object::openAttribute
///\brief This is an overloaded member function, provided for convenience.
@@ -167,6 +169,31 @@ Attribute H5Object::openAttribute( const
H5std_string& name ) const
}

//------------------------------------------------------------------------
--
+// Function: H5Object::doesAttrExist
+///\brief test for existence of attribut
+///\param name - IN: Name of the attribute
+///\return true if attribute exists, false otherwise
+///\exception none
+// Programmer Kent Williams 2011
+//------------------------------------------------------------------------
--
+bool H5Object::doesAttrExist( const char* name ) const
+{
+ return( H5Aexists(getId(), name) > 0 ? true : false );
+}
+
+//------------------------------------------------------------------------
--
+// Function: H5Object::doesAttrExist
+///\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 Kent Williams 2011
+//------------------------------------------------------------------------
--
+bool H5Object::doesAttrExist( const H5std_string &name ) const
+{
+ return( doesAttrExist( name.c_str()) );
+}
+
+//------------------------------------------------------------------------
--
// Function: H5Object::openAttribute
///\brief Opens an attribute given its index.
///\param idx - IN: Index of the attribute, a 0-based, non-negative
integer
diff --git a/Modules/ThirdParty/HDF5/src/itkhdf5/c++/src/H5Object.h
b/Modules/ThirdParty/HDF5/src/itkhdf5/c++/src/H5Object.h
index 4ac417b..2358985 100644
--- a/Modules/ThirdParty/HDF5/src/itkhdf5/c++/src/H5Object.h
+++ b/Modules/ThirdParty/HDF5/src/itkhdf5/c++/src/H5Object.h
@@ -62,6 +62,10 @@ class H5_DLLCPP H5Object : public IdComponent {
  // Flushes all buffers associated with this object to disk
  void flush( H5F_scope_t scope ) const;

+ // test the existence of an attribute
+ bool doesAttrExist( const char *name ) const;
+ bool doesAttrExist( const H5std_string &name ) const;
+
  // Gets the name of the file, in which this HDF5 object belongs.
  H5std_string getFileName() const;

________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error, then delete it. Thank you.
________________________________