summaryrefslogtreecommitdiffstats
path: root/c++/src/H5PropList.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c++/src/H5PropList.cpp')
-rw-r--r--c++/src/H5PropList.cpp270
1 files changed, 141 insertions, 129 deletions
diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp
index 13be182..da24904 100644
--- a/c++/src/H5PropList.cpp
+++ b/c++/src/H5PropList.cpp
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -19,18 +19,17 @@
#include <string>
-#include "H5private.h" // for HDmemset
+#include "H5private.h" // for HDmemset
#include "H5Include.h"
#include "H5Exception.h"
#include "H5IdComponent.h"
#include "H5PropList.h"
-
-namespace H5{
+namespace H5 {
#ifndef H5_NO_STD
- using std::cerr;
- using std::endl;
-#endif // H5_NO_STD
+using std::cerr;
+using std::endl;
+#endif // H5_NO_STD
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// This DOXYGEN_SHOULD_SKIP_THIS block is a work-around approach to control
@@ -38,7 +37,7 @@ namespace H5{
// in "H5PredType.cpp" for information.
// Initialize a pointer for the constant
-PropList* PropList::DEFAULT_ = 0;
+PropList *PropList::DEFAULT_ = 0;
//--------------------------------------------------------------------------
// Function: PropList::getConstant
@@ -50,13 +49,13 @@ PropList* PropList::DEFAULT_ = 0;
// throw a PropListIException. This scenario should not happen.
// Programmer Binh-Minh Ribler - 2015
//--------------------------------------------------------------------------
-PropList* PropList::getConstant()
+PropList *
+PropList::getConstant()
{
// Tell the C library not to clean up, H5Library::termH5cpp will call
// H5close - more dependency if use H5Library::dontAtExit()
- if (!IdComponent::H5dontAtexit_called)
- {
- (void) H5dont_atexit();
+ if (!IdComponent::H5dontAtexit_called) {
+ (void)H5dont_atexit();
IdComponent::H5dontAtexit_called = true;
}
@@ -65,8 +64,9 @@ PropList* PropList::getConstant()
if (DEFAULT_ == 0)
DEFAULT_ = new PropList(H5P_DEFAULT);
else
- throw PropListIException("PropList::getConstant", "PropList::getConstant is being invoked on an allocated DEFAULT_");
- return(DEFAULT_);
+ throw PropListIException("PropList::getConstant",
+ "PropList::getConstant is being invoked on an allocated DEFAULT_");
+ return (DEFAULT_);
}
//--------------------------------------------------------------------------
@@ -74,7 +74,8 @@ PropList* PropList::getConstant()
// Purpose: Deletes the constant object that PropList::DEFAULT_ points to.
// Programmer Binh-Minh Ribler - 2015
//--------------------------------------------------------------------------
-void PropList::deleteConstants()
+void
+PropList::deleteConstants()
{
if (DEFAULT_ != 0)
delete DEFAULT_;
@@ -83,7 +84,7 @@ void PropList::deleteConstants()
//--------------------------------------------------------------------------
// Purpose Constant for default property.
//--------------------------------------------------------------------------
-const PropList& PropList::DEFAULT = *getConstant();
+const PropList &PropList::DEFAULT = *getConstant();
#endif // DOXYGEN_SHOULD_SKIP_THIS
@@ -100,7 +101,7 @@ PropList::PropList() : IdComponent(), id(H5P_DEFAULT) {}
///\param original - IN: The original property list to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-PropList::PropList(const PropList& original) : IdComponent(), id(original.id)
+PropList::PropList(const PropList &original) : IdComponent(), id(original.id)
{
incRefCount(); // increment number of references to this id
}
@@ -125,24 +126,22 @@ PropList::PropList(const hid_t plist_id) : IdComponent()
H5I_type_t id_type = H5Iget_type(plist_id);
switch (id_type) {
case H5I_GENPROP_CLS:
- // call C routine to create a new property from the given prop class
- id = H5Pcreate(plist_id);
- if(id < 0)
- {
- throw PropListIException("PropList constructor", "H5Pcreate failed");
- }
- break;
+ // call C routine to create a new property from the given prop class
+ id = H5Pcreate(plist_id);
+ if (id < 0) {
+ throw PropListIException("PropList constructor", "H5Pcreate failed");
+ }
+ break;
case H5I_GENPROP_LST:
- // call C routine to make a copy of the given property list
- id = H5Pcopy(plist_id);
- if(id < 0)
- {
- throw PropListIException("PropList constructor", "H5Pcopy failed");
- }
- break;
+ // call C routine to make a copy of the given property list
+ id = H5Pcopy(plist_id);
+ if (id < 0) {
+ throw PropListIException("PropList constructor", "H5Pcopy failed");
+ }
+ break;
default:
- id = H5P_DEFAULT;
- break;
+ id = H5P_DEFAULT;
+ break;
}
}
@@ -158,20 +157,21 @@ PropList::PropList(const hid_t plist_id) : IdComponent()
// - Replaced decRefCount with close() to let the C library
// handle the reference counting - BMR, Jun 1, 2006
//--------------------------------------------------------------------------
-void PropList::copy(const PropList& like_plist)
+void
+PropList::copy(const PropList &like_plist)
{
// If this object is representing an hdf5 object, close it before
// copying like_plist to it
try {
close();
}
- catch (Exception& close_error) {
+ catch (Exception &close_error) {
throw PropListIException(inMemFunc("copy"), close_error.getDetailMsg());
}
// call C routine to copy the property list
id = H5Pcopy(like_plist.getId());
- if(id < 0)
+ if (id < 0)
throw PropListIException(inMemFunc("copy"), "H5Pcopy failed");
}
@@ -186,11 +186,12 @@ void PropList::copy(const PropList& like_plist)
// and stores the new id in the left hand side object.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-PropList& PropList::operator=(const PropList& rhs)
+PropList &
+PropList::operator=(const PropList &rhs)
{
if (this != &rhs)
copy(rhs);
- return(*this);
+ return (*this);
}
//--------------------------------------------------------------------------
@@ -201,12 +202,12 @@ PropList& PropList::operator=(const PropList& rhs)
///\exception H5::PropListIException
// Programmer Binh-Minh Ribler - Jul, 2005
//--------------------------------------------------------------------------
-void PropList::copyProp(PropList& dest, const char *name) const
+void
+PropList::copyProp(PropList &dest, const char *name) const
{
- hid_t dst_id = dest.getId();
+ hid_t dst_id = dest.getId();
herr_t ret_value = H5Pcopy_prop(dst_id, id, name);
- if(ret_value < 0)
- {
+ if (ret_value < 0) {
throw PropListIException(inMemFunc("copyProp"), "H5Pcopy_prop failed");
}
}
@@ -220,9 +221,10 @@ void PropList::copyProp(PropList& dest, const char *name) const
///\param name - IN: Name of the property to copy - \c H5std_string
// Programmer Binh-Minh Ribler - Jul, 2005
//--------------------------------------------------------------------------
-void PropList::copyProp(PropList& dest, const H5std_string& name) const
+void
+PropList::copyProp(PropList &dest, const H5std_string &name) const
{
- copyProp(dest, name.c_str());
+ copyProp(dest, name.c_str());
}
//--------------------------------------------------------------------------
@@ -235,16 +237,15 @@ void PropList::copyProp(PropList& dest, const H5std_string& name) const
///\exception H5::PropListIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-void PropList::copyProp(PropList& dest, PropList& src, const char *name) const
+void
+PropList::copyProp(PropList &dest, PropList &src, const char *name) const
{
- hid_t dst_id = dest.getId();
- hid_t src_id = src.getId();
+ hid_t dst_id = dest.getId();
+ hid_t src_id = src.getId();
herr_t ret_value = H5Pcopy_prop(dst_id, src_id, name);
- if(ret_value < 0)
- {
+ if (ret_value < 0) {
throw PropListIException(inMemFunc("copyProp"), "H5Pcopy_prop failed");
}
-
}
//--------------------------------------------------------------------------
@@ -257,7 +258,8 @@ void PropList::copyProp(PropList& dest, PropList& src, const char *name) const
///\param name - IN: Name of the property to copy - \c H5std_string
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-void PropList::copyProp(PropList& dest, PropList& src, const H5std_string& name) const
+void
+PropList::copyProp(PropList &dest, PropList &src, const H5std_string &name) const
{
copyProp(dest, src, name.c_str());
}
@@ -273,9 +275,10 @@ void PropList::copyProp(PropList& dest, PropList& src, const H5std_string& name)
// IdComponent::getId now becomes pure virtual function.
// Programmer Binh-Minh Ribler - May, 2008
//--------------------------------------------------------------------------
-hid_t PropList::getId() const
+hid_t
+PropList::getId() const
{
- return(id);
+ return (id);
}
#ifndef DOXYGEN_SHOULD_SKIP_THIS
@@ -291,13 +294,14 @@ hid_t PropList::getId() const
// Then the object's id is reset to the new id.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-void PropList::p_setId(const hid_t new_id)
+void
+PropList::p_setId(const hid_t new_id)
{
// handling references to this old id
try {
close();
}
- catch (Exception& close_error) {
+ catch (Exception &close_error) {
throw PropListIException(inMemFunc("p_setId"), close_error.getDetailMsg());
}
// reset object's id to the given id
@@ -313,13 +317,12 @@ void PropList::p_setId(const hid_t new_id)
///\exception H5::PropListIException
// Programmer Binh-Minh Ribler - Mar 9, 2005
//--------------------------------------------------------------------------
-void PropList::close()
+void
+PropList::close()
{
- if (p_valid_id(id))
- {
+ if (p_valid_id(id)) {
herr_t ret_value = H5Pclose(id);
- if(ret_value < 0)
- {
+ if (ret_value < 0) {
throw PropListIException(inMemFunc("close"), "H5Pclose failed");
}
// reset the id
@@ -334,15 +337,14 @@ void PropList::close()
///\exception H5::PropListIException
// Programmer Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-hid_t PropList::getClass() const
+hid_t
+PropList::getClass() const
{
hid_t plist_class = H5Pget_class(id);
- if(plist_class == H5P_ROOT)
- {
- throw PropListIException(inMemFunc("getClass"),
- "H5Pget_class failed - returned H5P_ROOT");
+ if (plist_class == H5P_ROOT) {
+ throw PropListIException(inMemFunc("getClass"), "H5Pget_class failed - returned H5P_ROOT");
}
- return(plist_class);
+ return (plist_class);
}
//--------------------------------------------------------------------------
@@ -357,15 +359,16 @@ hid_t PropList::getClass() const
/// list or class.
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-bool PropList::propExist(const char* name) const
+bool
+PropList::propExist(const char *name) const
{
// Calls C routine H5Pexist to determine whether a property exists
// within a property list or class. It returns a positive value, 0,
// or a negative value
htri_t ret_value = H5Pexist(id, name);
- if(ret_value > 0)
+ if (ret_value > 0)
return true;
- else if(ret_value == 0)
+ else if (ret_value == 0)
return false;
else // Raise exception when H5Pexist returns a negative value
{
@@ -380,9 +383,10 @@ bool PropList::propExist(const char* name) const
///\param name - IN: Name of property to check for - \c H5std_string
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-bool PropList::propExist(const H5std_string& name) const
+bool
+PropList::propExist(const H5std_string &name) const
{
- return(propExist(name.c_str()));
+ return (propExist(name.c_str()));
}
//--------------------------------------------------------------------------
@@ -395,11 +399,11 @@ bool PropList::propExist(const H5std_string& name) const
/// list class hierarchy.
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-void PropList::closeClass() const
+void
+PropList::closeClass() const
{
herr_t ret_value = H5Pclose_class(id);
- if(ret_value < 0)
- {
+ if (ret_value < 0) {
throw PropListIException(inMemFunc("closeClass"), "H5Pclose_class failed");
}
}
@@ -416,11 +420,11 @@ void PropList::closeClass() const
/// throw an exception.
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-void PropList::getProperty(const char* name, void* value) const
+void
+PropList::getProperty(const char *name, void *value) const
{
herr_t ret_value = H5Pget(id, name, value);
- if (ret_value < 0)
- {
+ if (ret_value < 0) {
throw PropListIException(inMemFunc("getProperty"), "H5Pget failed");
}
}
@@ -434,27 +438,27 @@ void PropList::getProperty(const char* name, void* value) const
///\exception H5::PropListIException
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-H5std_string PropList::getProperty(const char* name) const
+H5std_string
+PropList::getProperty(const char *name) const
{
// Get property size first
size_t size = getPropSize(name);
// Allocate buffer then get the property
- char* prop_strg_C = new char[size+1]; // temporary C-string for C API
- HDmemset(prop_strg_C, 0, size+1); // clear buffer
+ char *prop_strg_C = new char[size + 1]; // temporary C-string for C API
+ HDmemset(prop_strg_C, 0, size + 1); // clear buffer
herr_t ret_value = H5Pget(id, name, prop_strg_C); // call C API
// Throw exception if H5Pget returns failure
- if (ret_value < 0)
- {
- delete []prop_strg_C;
+ if (ret_value < 0) {
+ delete[] prop_strg_C;
throw PropListIException(inMemFunc("getProperty"), "H5Pget failed");
}
// Return propety value as a string after deleting temp C-string
H5std_string prop_strg(prop_strg_C);
- delete []prop_strg_C;
+ delete[] prop_strg_C;
return (prop_strg);
}
//--------------------------------------------------------------------------
@@ -466,7 +470,8 @@ H5std_string PropList::getProperty(const char* name) const
///\param value - OUT: Pointer to the buffer for the property value
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-void PropList::getProperty(const H5std_string& name, void* value) const
+void
+PropList::getProperty(const H5std_string &name, void *value) const
{
getProperty(name.c_str(), value);
}
@@ -479,7 +484,8 @@ void PropList::getProperty(const H5std_string& name, void* value) const
///\return The property that is a \c H5std_string.
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-H5std_string PropList::getProperty(const H5std_string& name) const
+H5std_string
+PropList::getProperty(const H5std_string &name) const
{
return (getProperty(name.c_str()));
}
@@ -497,15 +503,15 @@ H5std_string PropList::getProperty(const H5std_string& name) const
/// lists and classes.
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-size_t PropList::getPropSize(const char *name) const
+size_t
+PropList::getPropSize(const char *name) const
{
size_t prop_size;
herr_t ret_value = H5Pget_size(id, name, &prop_size);
- if (ret_value < 0)
- {
+ if (ret_value < 0) {
throw PropListIException(inMemFunc("getPropSize"), "H5Pget_size failed");
}
- return(prop_size);
+ return (prop_size);
}
//--------------------------------------------------------------------------
// Function: PropList::getPropSize
@@ -516,7 +522,8 @@ size_t PropList::getPropSize(const char *name) const
///
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-size_t PropList::getPropSize(const H5std_string& name) const
+size_t
+PropList::getPropSize(const H5std_string &name) const
{
return (getPropSize(name.c_str()));
}
@@ -528,17 +535,17 @@ size_t PropList::getPropSize(const H5std_string& name) const
/// a NULL string.
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-H5std_string PropList::getClassName() const
+H5std_string
+PropList::getClassName() const
{
- char* temp_str;
+ char *temp_str;
temp_str = H5Pget_class_name(id); // this API specified that temp_str must
- // be freed.
+ // be freed.
- if (temp_str != NULL)
- {
+ if (temp_str != NULL) {
H5std_string class_name(temp_str);
H5free_memory(temp_str);
- return(class_name);
+ return (class_name);
}
else
return 0;
@@ -550,12 +557,12 @@ H5std_string PropList::getClassName() const
///\exception H5::PropListIException
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-size_t PropList::getNumProps() const
+size_t
+PropList::getNumProps() const
{
size_t nprops;
- herr_t ret_value = H5Pget_nprops (id, &nprops);
- if (ret_value < 0)
- {
+ herr_t ret_value = H5Pget_nprops(id, &nprops);
+ if (ret_value < 0) {
throw PropListIException(inMemFunc("getNumProps"), "H5Pget_nprops failed");
}
return (nprops);
@@ -569,11 +576,11 @@ size_t PropList::getNumProps() const
///\exception H5::PropListIException
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-void PropList::setProperty(const char* name, void* value) const
+void
+PropList::setProperty(const char *name, void *value) const
{
herr_t ret_value = H5Pset(id, name, value);
- if (ret_value < 0)
- {
+ if (ret_value < 0) {
throw PropListIException(inMemFunc("setProperty"), "H5Pset failed");
}
}
@@ -586,11 +593,11 @@ void PropList::setProperty(const char* name, void* value) const
///\param charptr - IN: Char pointer to the value for the property
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-void PropList::setProperty(const char* name, const char* charptr) const
+void
+PropList::setProperty(const char *name, const char *charptr) const
{
- herr_t ret_value = H5Pset(id, name, (void*)charptr);
- if (ret_value < 0)
- {
+ herr_t ret_value = H5Pset(id, name, (void *)charptr);
+ if (ret_value < 0) {
throw PropListIException(inMemFunc("setProperty"), "H5Pset failed");
}
}
@@ -603,7 +610,8 @@ void PropList::setProperty(const char* name, const char* charptr) const
///\param strg - IN: Value for the property is a \c H5std_string
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-void PropList::setProperty(const char* name, H5std_string& strg) const
+void
+PropList::setProperty(const char *name, H5std_string &strg) const
{
setProperty(name, strg.c_str());
}
@@ -617,7 +625,8 @@ void PropList::setProperty(const char* name, H5std_string& strg) const
///\param value - IN: Void pointer to the value for the property
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-void PropList::setProperty(const H5std_string& name, void* value) const
+void
+PropList::setProperty(const H5std_string &name, void *value) const
{
setProperty(name.c_str(), value);
}
@@ -631,7 +640,8 @@ void PropList::setProperty(const H5std_string& name, void* value) const
///\param strg - IN: Value for the property is a \c H5std_string
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-void PropList::setProperty(const H5std_string& name, H5std_string& strg) const
+void
+PropList::setProperty(const H5std_string &name, H5std_string &strg) const
{
setProperty(name.c_str(), strg.c_str());
}
@@ -645,18 +655,18 @@ void PropList::setProperty(const H5std_string& name, H5std_string& strg) const
///\exception H5::PropListIException
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-bool PropList::isAClass(const PropList& prop_class) const
+bool
+PropList::isAClass(const PropList &prop_class) const
{
htri_t ret_value = H5Pisa_class(id, prop_class.getId());
- if(ret_value > 0)
+ if (ret_value > 0)
return true;
- else if(ret_value == 0)
+ else if (ret_value == 0)
return false;
else // Raise exception when H5Pisa_class returns a negative value
{
throw PropListIException(inMemFunc("isAClass"), "H5Pisa_class failed");
}
-
}
//--------------------------------------------------------------------------
@@ -666,11 +676,11 @@ bool PropList::isAClass(const PropList& prop_class) const
///\exception H5::PropListIException
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-void PropList::removeProp(const char *name) const
+void
+PropList::removeProp(const char *name) const
{
herr_t ret_value = H5Premove(id, name);
- if (ret_value < 0)
- {
+ if (ret_value < 0) {
throw PropListIException(inMemFunc("removeProp"), "H5Premove failed");
}
}
@@ -683,7 +693,8 @@ void PropList::removeProp(const char *name) const
///\param name - IN: Name of property to remove - \c H5std_string
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-void PropList::removeProp(const H5std_string& name) const
+void
+PropList::removeProp(const H5std_string &name) const
{
removeProp(name.c_str());
}
@@ -697,12 +708,13 @@ void PropList::removeProp(const H5std_string& name) const
///\exception H5::PropListIException
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-bool PropList::operator==(const PropList& rhs) const
+bool
+PropList::operator==(const PropList &rhs) const
{
htri_t ret_value = H5Pequal(id, rhs.getId());
- if(ret_value > 0)
+ if (ret_value > 0)
return true;
- else if(ret_value == 0)
+ else if (ret_value == 0)
return false;
else // Raise exception when H5Pequal returns a negative value
{
@@ -717,15 +729,15 @@ bool PropList::operator==(const PropList& rhs) const
///\exception H5::PropListIException
// Programmer: Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
-PropList PropList::getClassParent() const
+PropList
+PropList::getClassParent() const
{
hid_t class_id = H5Pget_class_parent(id);
- if (class_id < 0)
- {
+ if (class_id < 0) {
throw PropListIException(inMemFunc("getClassParent"), "H5Pget_class_parent failed");
}
- PropList pclass(class_id);
- return(pclass);
+ PropList pclass(class_id);
+ return (pclass);
}
//--------------------------------------------------------------------------
@@ -743,8 +755,8 @@ PropList::~PropList()
try {
close();
}
- catch (Exception& close_error) {
+ catch (Exception &close_error) {
cerr << "PropList::~PropList - " << close_error.getDetailMsg() << endl;
}
}
-} // end namespace
+} // namespace H5