summaryrefslogtreecommitdiffstats
path: root/c++/src/H5IdComponent.cpp
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
commitb2d661b508a7fc7a2592c13bc6bdc175551f075d (patch)
tree13baeb0d83a7c2a4c6299993c182b1227c2f6114 /c++/src/H5IdComponent.cpp
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'c++/src/H5IdComponent.cpp')
-rw-r--r--c++/src/H5IdComponent.cpp101
1 files changed, 55 insertions, 46 deletions
diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp
index 40520aa..ca54551 100644
--- a/c++/src/H5IdComponent.cpp
+++ b/c++/src/H5IdComponent.cpp
@@ -13,7 +13,7 @@
#include <string>
-#include "H5private.h" // for HDmemset
+#include "H5private.h" // for HDmemset
#include "H5Include.h"
#include "H5Exception.h"
#include "H5Library.h"
@@ -38,7 +38,8 @@ bool IdComponent::H5dontAtexit_called = false;
///\brief Increment reference counter for a given id.
// Programmer Binh-Minh Ribler - May 2005
//--------------------------------------------------------------------------
-void IdComponent::incRefCount(const hid_t obj_id) const
+void
+IdComponent::incRefCount(const hid_t obj_id) const
{
if (p_valid_id(obj_id))
if (H5Iinc_ref(obj_id) < 0)
@@ -50,7 +51,8 @@ void IdComponent::incRefCount(const hid_t obj_id) const
///\brief Increment reference counter for the id of this object.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-void IdComponent::incRefCount() const
+void
+IdComponent::incRefCount() const
{
incRefCount(getId());
}
@@ -63,17 +65,15 @@ void IdComponent::incRefCount() const
// Added the check for ref counter to give a little more info
// on why H5Idec_ref fails in some cases - BMR 5/19/2005
//--------------------------------------------------------------------------
-void IdComponent::decRefCount(const hid_t obj_id) const
+void
+IdComponent::decRefCount(const hid_t obj_id) const
{
if (p_valid_id(obj_id))
- if (H5Idec_ref(obj_id) < 0)
- {
+ if (H5Idec_ref(obj_id) < 0) {
if (H5Iget_ref(obj_id) <= 0)
- throw IdComponentException(inMemFunc("decRefCount"),
- "object ref count is 0 or negative");
+ throw IdComponentException(inMemFunc("decRefCount"), "object ref count is 0 or negative");
else
- throw IdComponentException(inMemFunc("decRefCount"),
- "decrementing object ref count failed");
+ throw IdComponentException(inMemFunc("decRefCount"), "decrementing object ref count failed");
}
}
@@ -82,7 +82,8 @@ void IdComponent::decRefCount(const hid_t obj_id) const
///\brief Decrement reference counter for the id of this object.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-void IdComponent::decRefCount() const
+void
+IdComponent::decRefCount() const
{
decRefCount(getId());
}
@@ -93,14 +94,15 @@ void IdComponent::decRefCount() const
///\return Reference count
// Programmer Binh-Minh Ribler - May 2005
//--------------------------------------------------------------------------
-int IdComponent::getCounter(const hid_t obj_id) const
+int
+IdComponent::getCounter(const hid_t obj_id) const
{
int counter = 0;
- if (p_valid_id(obj_id))
- {
+ if (p_valid_id(obj_id)) {
counter = H5Iget_ref(obj_id);
if (counter < 0)
- throw IdComponentException(inMemFunc("incRefCount"), "getting object ref count failed - negative");
+ throw IdComponentException(inMemFunc("incRefCount"),
+ "getting object ref count failed - negative");
}
return (counter);
}
@@ -111,7 +113,8 @@ int IdComponent::getCounter(const hid_t obj_id) const
///\return Reference count
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-int IdComponent::getCounter() const
+int
+IdComponent::getCounter() const
{
return (getCounter(getId()));
}
@@ -130,7 +133,8 @@ int IdComponent::getCounter() const
/// input object id is invalid.
// Programmer Binh-Minh Ribler - Jul, 2005
//--------------------------------------------------------------------------
-H5I_type_t IdComponent::getHDFObjType(const hid_t obj_id)
+H5I_type_t
+IdComponent::getHDFObjType(const hid_t obj_id)
{
if (obj_id <= 0)
return H5I_BADID; // invalid
@@ -156,9 +160,10 @@ H5I_type_t IdComponent::getHDFObjType(const hid_t obj_id)
/// input object id is invalid.
// Programmer Binh-Minh Ribler - Mar, 2014
//--------------------------------------------------------------------------
-H5I_type_t IdComponent::getHDFObjType() const
+H5I_type_t
+IdComponent::getHDFObjType() const
{
- return(getHDFObjType(getId()));
+ return (getHDFObjType(getId()));
}
//--------------------------------------------------------------------------
@@ -183,14 +188,15 @@ H5I_type_t IdComponent::getHDFObjType() const
/// \li \c H5I_ERROR_STACK
// Programmer Binh-Minh Ribler - Feb, 2017
//--------------------------------------------------------------------------
-hsize_t IdComponent::getNumMembers(H5I_type_t type)
+hsize_t
+IdComponent::getNumMembers(H5I_type_t type)
{
- hsize_t nmembers = 0;
- herr_t ret_value = H5Inmembers(type, &nmembers);
+ hsize_t nmembers = 0;
+ herr_t ret_value = H5Inmembers(type, &nmembers);
if (ret_value < 0)
throw IdComponentException("getNumMembers", "H5Inmembers failed");
else
- return(nmembers);
+ return (nmembers);
}
//--------------------------------------------------------------------------
@@ -202,7 +208,8 @@ hsize_t IdComponent::getNumMembers(H5I_type_t type)
/// reference count of at least 1.
// Programmer Binh-Minh Ribler - Mar 1, 2017
//--------------------------------------------------------------------------
-bool IdComponent::isValid(hid_t an_id)
+bool
+IdComponent::isValid(hid_t an_id)
{
// Call C function
htri_t ret_value = H5Iis_valid(an_id);
@@ -236,7 +243,8 @@ bool IdComponent::isValid(hid_t an_id)
/// \li \c H5I_ERROR_STACK
// Programmer Binh-Minh Ribler - Feb, 2017
//--------------------------------------------------------------------------
-bool IdComponent::typeExists(H5I_type_t type)
+bool
+IdComponent::typeExists(H5I_type_t type)
{
// Call C function
htri_t ret_value = H5Itype_exists(type);
@@ -266,17 +274,17 @@ bool IdComponent::typeExists(H5I_type_t type)
// care of close() and setId takes care incRefCount().
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-IdComponent& IdComponent::operator=(const IdComponent& rhs)
+IdComponent &
+IdComponent::operator=(const IdComponent &rhs)
{
- if (this != &rhs)
- {
+ if (this != &rhs) {
// handling references to this id
try {
setId(rhs.getId());
// Note: a = b, so there are two objects with the same hdf5 id
// that's why incRefCount is needed, and it is called by setId
}
- catch (Exception& close_error) {
+ catch (Exception &close_error) {
throw FileIException(inMemFunc("operator="), close_error.getDetailMsg());
}
}
@@ -304,7 +312,8 @@ IdComponent& IdComponent::operator=(const IdComponent& rhs)
// the id passed to setId is that of another C++ API object, so
// setId must call incRefCount.
//--------------------------------------------------------------------------
-void IdComponent::setId(const hid_t new_id)
+void
+IdComponent::setId(const hid_t new_id)
{
// set to new_id
p_setId(new_id);
@@ -338,7 +347,8 @@ IdComponent::~IdComponent() {}
/// an exception is thrown.
// Programmer Binh-Minh Ribler - Aug 6, 2005
//--------------------------------------------------------------------------
-H5std_string IdComponent::inMemFunc(const char* func_name) const
+H5std_string
+IdComponent::inMemFunc(const char *func_name) const
{
H5std_string full_name = func_name;
full_name.insert(0, "::");
@@ -355,8 +365,7 @@ IdComponent::IdComponent()
{
// initH5cpp will register the terminating functions with atexit().
// This should only be done once.
- if (!H5cppinit)
- {
+ if (!H5cppinit) {
H5Library::initH5cpp();
H5cppinit = true;
}
@@ -374,7 +383,8 @@ IdComponent::IdComponent()
// inherits from H5Location.
// Programmer Binh-Minh Ribler - Jul, 2004
//--------------------------------------------------------------------------
-H5std_string IdComponent::p_get_file_name() const
+H5std_string
+IdComponent::p_get_file_name() const
{
hid_t temp_id = getId();
@@ -382,28 +392,26 @@ H5std_string IdComponent::p_get_file_name() const
ssize_t name_size = H5Fget_name(temp_id, NULL, 0);
// If H5Aget_name returns a negative value, raise an exception,
- if (name_size < 0)
- {
+ if (name_size < 0) {
throw IdComponentException("", "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
- HDmemset(name_C, 0, name_size+1); // clear buffer
+ char *name_C = new char[name_size + 1]; // temporary C-string for C API
+ HDmemset(name_C, 0, name_size + 1); // clear buffer
- name_size = H5Fget_name(temp_id, name_C, name_size+1);
+ name_size = H5Fget_name(temp_id, name_C, name_size + 1);
// Check for failure again
- if (name_size < 0)
- {
- delete []name_C;
+ if (name_size < 0) {
+ delete[] name_C;
throw IdComponentException("", "H5Fget_name failed");
}
// Convert the C file name and return
H5std_string file_name(name_C);
- delete []name_C;
- return(file_name);
+ delete[] name_C;
+ return (file_name);
}
//
@@ -417,7 +425,8 @@ H5std_string IdComponent::p_get_file_name() const
// Return true if id is valid, false, otherwise
// Programmer Binh-Minh Ribler - May, 2005
//--------------------------------------------------------------------------
-bool IdComponent::p_valid_id(const hid_t obj_id)
+bool
+IdComponent::p_valid_id(const hid_t obj_id)
{
if (obj_id <= 0)
return false;
@@ -439,4 +448,4 @@ bool IdComponent::p_valid_id(const hid_t obj_id)
#endif // DOXYGEN_SHOULD_SKIP_THIS
-}
+} // namespace H5