summaryrefslogtreecommitdiffstats
path: root/c++
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2004-07-14 05:06:33 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2004-07-14 05:06:33 (GMT)
commit2eaa20781d8ba99ef027704dfabef306de4fed8b (patch)
tree10b885d807bb66c5da843bbf468c5c7b967c80e9 /c++
parentfa3be978e5954c2ea1013afbb88f9e0c245cd029 (diff)
downloadhdf5-2eaa20781d8ba99ef027704dfabef306de4fed8b.zip
hdf5-2eaa20781d8ba99ef027704dfabef306de4fed8b.tar.gz
hdf5-2eaa20781d8ba99ef027704dfabef306de4fed8b.tar.bz2
[svn-r8871] Purpose: Adding wrapper for new C API
Description: Added wrappers for H5Fget_name: H5File::getFileName H5Object::getFileName Platforms tested: SunOS 5.7 (arabica) Linux 2.4 (eirene) Windows XP
Diffstat (limited to 'c++')
-rw-r--r--c++/src/H5File.cpp12
-rw-r--r--c++/src/H5File.h3
-rw-r--r--c++/src/H5IdComponent.cpp39
-rw-r--r--c++/src/H5IdComponent.h3
-rw-r--r--c++/src/H5Object.cpp14
-rw-r--r--c++/src/H5Object.h3
6 files changed, 74 insertions, 0 deletions
diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp
index e3c98ff..3962fc3 100644
--- a/c++/src/H5File.cpp
+++ b/c++/src/H5File.cpp
@@ -401,6 +401,18 @@ void H5File::getVFDHandle(void **file_handle) const
}
//--------------------------------------------------------------------------
+// Function: H5File::getFileName
+///\brief Gets the name of this file.
+///\return File name
+///\exception H5::IdComponentException
+// Programmer Binh-Minh Ribler - Jul, 2004
+//--------------------------------------------------------------------------
+string H5File::getFileName() const
+{
+ return(p_get_file_name());
+}
+
+//--------------------------------------------------------------------------
// Function: H5File::Reference
///\brief Creates a reference to an Hdf5 object or a dataset region.
///\param name - IN: Name of the object to be referenced
diff --git a/c++/src/H5File.h b/c++/src/H5File.h
index 900681e..2e0eeec 100644
--- a/c++/src/H5File.h
+++ b/c++/src/H5File.h
@@ -59,6 +59,9 @@ class H5_DLLCPP H5File : public IdComponent, public CommonFG {
static bool isHdf5(const string& name );
static bool isHdf5(const char* name );
+ // Gets the name of this file.
+ string getFileName() const;
+
// Creates a reference to a named Hdf5 object in this object.
void* Reference(const char* name) const;
diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp
index ee83acc..e8b85c0 100644
--- a/c++/src/H5IdComponent.cpp
+++ b/c++/src/H5IdComponent.cpp
@@ -173,6 +173,45 @@ void IdComponent::reset ()
}
//--------------------------------------------------------------------------
+// Function: IdComponent::p_get_file_name
+// Purpose: Gets the name of the file, in which this object belongs.
+// Exception: H5::IdComponentException
+// Description:
+// This function is protected so that the user applications can
+// only have access to its code via allowable classes, namely,
+// H5File and H5Object subclasses.
+// Programmer Binh-Minh Ribler - Jul, 2004
+//--------------------------------------------------------------------------
+string IdComponent::p_get_file_name() const
+{
+ // Preliminary call to H5Fget_name to get the length of the file name
+ ssize_t name_size = H5Fget_name(id, NULL, 0);
+
+ // If H5Aget_name returns a negative value, raise an exception,
+ if( name_size < 0 )
+ {
+ throw IdComponentException("IdComponent::p_get_file_name",
+ "H5Fget_name failed");
+ }
+
+ // Call H5Fget_name again to get the actual file name
+ char* name_C = new char[name_size+1]; // temporary C-string for C API
+ name_size = H5Fget_name(id, name_C, name_size+1);
+
+ // Check for failure again
+ if( name_size < 0 )
+ {
+ throw IdComponentException("IdComponent::p_get_file_name",
+ "H5Fget_name failed");
+ }
+
+ // Convert the C file name and return
+ string file_name(name_C);
+ delete name_C;
+ return(file_name);
+}
+
+//--------------------------------------------------------------------------
// Function: IdComponent destructor
///\brief Noop destructor.
// Programmer Binh-Minh Ribler - 2000
diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h
index fedca0e..73305ef 100644
--- a/c++/src/H5IdComponent.h
+++ b/c++/src/H5IdComponent.h
@@ -72,6 +72,9 @@ class H5_DLLCPP IdComponent {
// Default constructor
IdComponent();
+ // Gets the name of the file, in which an HDF5 object belongs.
+ std::string p_get_file_name() const;
+
// Gets the id of the H5 file in which the given object is located.
hid_t p_get_file_id();
diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp
index e3dc2bb..76d9b6c 100644
--- a/c++/src/H5Object.cpp
+++ b/c++/src/H5Object.cpp
@@ -21,6 +21,8 @@
#include "H5Idtemplates.h"
#include "H5PropList.h"
#include "H5Object.h"
+#include "H5DcreatProp.h"
+#include "H5CommonFG.h"
#include "H5DataType.h"
#include "H5DataSpace.h"
#include "H5AbstractDs.h"
@@ -287,6 +289,18 @@ void H5Object::flush(H5F_scope_t scope ) const
}
//--------------------------------------------------------------------------
+// Function: H5Object::getFileName
+///\brief Gets the name of the file, in which this HDF5 object belongs.
+///\return File name
+///\exception H5::IdComponentException
+// Programmer Binh-Minh Ribler - Jul, 2004
+//--------------------------------------------------------------------------
+string H5Object::getFileName() const
+{
+ return(p_get_file_name());
+}
+
+//--------------------------------------------------------------------------
// Function: H5Object destructor
///\brief Noop destructor.
// Programmer Binh-Minh Ribler - 2000
diff --git a/c++/src/H5Object.h b/c++/src/H5Object.h
index 10d6d61..1ba8929 100644
--- a/c++/src/H5Object.h
+++ b/c++/src/H5Object.h
@@ -74,6 +74,9 @@ class H5_DLLCPP H5Object : public IdComponent {
void removeAttr( const char* name ) const;
void removeAttr( const string& name ) const;
+ // Gets the name of the file, in which this HDF5 object belongs.
+ string getFileName() const;
+
// Noop destructor
virtual ~H5Object();