[cig-commits] r13827 - cs/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Mon Jan 12 14:09:50 PST 2009
Author: luis
Date: 2009-01-12 14:09:50 -0800 (Mon, 12 Jan 2009)
New Revision: 13827
Modified:
cs/cigma/trunk/src/h5attr.cpp
Log:
Check for older versions of HDF5 (lower than 1.8.2)
Modified: cs/cigma/trunk/src/h5attr.cpp
===================================================================
--- cs/cigma/trunk/src/h5attr.cpp 2009-01-12 22:09:48 UTC (rev 13826)
+++ cs/cigma/trunk/src/h5attr.cpp 2009-01-12 22:09:50 UTC (rev 13827)
@@ -14,6 +14,9 @@
#include "H5Cpp.h"
#include "hdf5.h"
+#if ((H5_VERS_MAJOR >= 1) && (H5_VERS_MINOR >= 8) && (H5_VERS_RELEASE >= 2))
+#define HAVE_HDF5_1_8_2
+#endif
using namespace std;
using namespace boost;
@@ -257,26 +260,26 @@
return 0;
}
-/*
-void listAttrOp(H5::H5Object& loc, const string name, void *data)
+void listAttrOp0(H5::H5Object& loc, const string name, void *data)
{
TRI_LOG_STR("listAttrOp()");
string dtype, value;
getattr(&loc, name, dtype, value);
- cout << name << " = " << value << endl;
-} */
+ cout << "\t" << name << " = " << value << endl;
+}
+#ifdef HAVE_HDF5_1_8_2
herr_t listAttrOp(hid_t loc_id, const char *attr_name, const H5A_info_t *ainfo, void *op_data)
{
//TRI_LOG_STR("listAttrOp()");
string name(attr_name);
string dtype, value;
- cout << "\t" << name << " = ";
if (op_data != 0)
{
H5::H5Object *obj = (H5::H5Object *)op_data;
getattr(obj, name, dtype, value);
+ cout << "\t" << name << " = ";
if (dtype != "string")
{
cout << value;
@@ -290,8 +293,8 @@
boost::algorithm::replace_all(value, "'", "\\'");
cout << "'" << value << "'";
}
+ cout << endl;
}
- cout << endl;
}
herr_t listGroupOp(hid_t group, const char *name, void *data)
@@ -299,6 +302,7 @@
//TRI_LOG_STR("listOp()");
cout << "\t" << name << endl;
}
+#endif
// ----------------------------------------------------------------------------
@@ -358,11 +362,8 @@
}
cout << endl;
- cout << "The attribute types can be one of the following" << endl;
- cout << " - string (default)" << endl;
- cout << " - integer" << endl;
- cout << " - float" << endl;
- cout << " - double" << endl;
+ cout << "The attribute types can be one of the following:" << endl << endl;
+ cout << " string (default), integer, float, double" << endl << endl;
return 1;
}
@@ -451,29 +452,13 @@
int idx;
int status;
- /*
- hobj_ref_t ref;
- obj->reference(&ref, location.c_str());
- H5G_obj_t objtype = file->getObjType(&ref);
- */
-
+ // require hdf5-1.8.2
+ #ifdef HAVE_HDF5_1_8_2
H5I_type_t objtype = H5::IdComponent::getHDFObjType(obj->getId());
TRI_LOG(obj->getId());
TRI_LOG(objtype);
if (objtype == H5I_GROUP)
{
- /*
- // NOTE: This requires HDF5 1.8.1
- H5G_info_t ginfo;
- herr_t ret = H5Gget_info(obj->getId(), &ginfo);
- if (ret < 0)
- {
- throw H5::Exception("main", "H5Gget_info failed");
- }
- TRI_LOG(ginfo.nlinks);
- cout << "Found " << ginfo.nlinks << " groups under " << location << endl;
- */
-
const char *prefix = location.c_str();
cout << indent << "Groups" << endl;
try
@@ -508,13 +493,23 @@
hsize_t _idx = 0;
while ((status = H5Aiterate2(oid, H5_INDEX_NAME, H5_ITER_INC, &_idx, listAttrOp, obj)) > 0)
{
- TRI_LOG(status);
+ //TRI_LOG(status);
}
}
else
{
cout << "\t" << "No attributes found" << endl;
}
+ #else
+ if (obj->getNumAttrs() > 0)
+ {
+ obj->iterateAttrs(listAttrOp0);
+ }
+ else
+ {
+ cout << "\t" << "No attributes found" << endl;
+ }
+ #endif
}
}
catch (H5::Exception error)
More information about the CIG-COMMITS
mailing list