summaryrefslogtreecommitdiffstats
path: root/c++/src/H5Exception.cpp
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2004-03-22 02:56:59 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2004-03-22 02:56:59 (GMT)
commit9e3178fedfab5caa9eed7395ac2d2a9b9a8a7130 (patch)
tree8003f306aaef942d32adc30235aa818772a052dd /c++/src/H5Exception.cpp
parent7fb0362eeda413222426613058a51282d25d0235 (diff)
downloadhdf5-9e3178fedfab5caa9eed7395ac2d2a9b9a8a7130.zip
hdf5-9e3178fedfab5caa9eed7395ac2d2a9b9a8a7130.tar.gz
hdf5-9e3178fedfab5caa9eed7395ac2d2a9b9a8a7130.tar.bz2
[svn-r8269] Purpose:
Cleaning up warnings Description: Many exception constructors have warnings about reference to temporary location because of the parameter initialization, for example, "const string& var = 0." Solution: Changed "string&" parameters to pass by value for these constructors. Consequently, passing string by value also takes care of char pointers so the overloaded constructors for char pointers are then removed. Also, instead of setting Exception::detailMessage to null string, I set it to DEFAULT_MSG ("No detailed information provided") by default. Platforms: SunOS 5.7 (arabica) Linux 2.4 (eirene) IA-64 (titan)
Diffstat (limited to 'c++/src/H5Exception.cpp')
-rw-r--r--c++/src/H5Exception.cpp57
1 files changed, 14 insertions, 43 deletions
diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp
index 7d6218c..04dca00 100644
--- a/c++/src/H5Exception.cpp
+++ b/c++/src/H5Exception.cpp
@@ -22,32 +22,13 @@ namespace H5 {
#endif // H5_NO_STD
#endif
+const string Exception::DEFAULT_MSG("No detailed information provided");
+
// Default constructor
Exception::Exception() : detailMessage(""), funcName("") {}
-// Constructor taking only a detailed message as string object
-//Exception::Exception(const string& message) : detailMessage(message) {}
-
// Constructor taking a function name and a detailed message as string objects
-Exception::Exception(const string& func_name, const string& message) : detailMessage(message), funcName(func_name) {}
-
-// Constructor taking a detailed message as character string
-// digital alpha (gondolin) produces compilation error at static_cast<string>
-// so I replaced this constructor by the one below it
-//Exception::Exception( const char* message) : detailMessage(static_cast<string>(message)) {}
-//Exception::Exception(const char* message)
-//{
- //detailMessage = string(message);
-//}
-
-// Constructor taking a function name and a detailed message as character
-// strings
-Exception::Exception(const char* func_name, const char* message)
-{
- detailMessage = string(message);
- if (func_name != NULL)
- funcName = string(func_name);
-}
+Exception::Exception(const string func_name, const string message) : detailMessage(message), funcName(func_name) {}
// copy constructor
Exception::Exception( const Exception& orig )
@@ -153,7 +134,7 @@ const char* Exception::getCFuncName() const
// Prints the error stack in a default manner.
void Exception::printError( FILE* stream ) const
{
- herr_t ret_value = H5Eprint( H5E_DEFAULT, NULL ); // print to stderr
+ herr_t ret_value = H5Eprint( H5E_DEFAULT, stream ); // print to stderr
if( ret_value < 0 )
throw Exception( "Exception::printError", "H5Eprint failed" );
}
@@ -161,53 +142,43 @@ void Exception::printError( FILE* stream ) const
Exception::~Exception() {}
FileIException::FileIException():Exception(){}
-FileIException::FileIException(const string& func_name, const string& message) : Exception(func_name, message) {}
-FileIException::FileIException(const char* func_name, const char* message) : Exception(func_name, message) {}
+FileIException::FileIException(const string func_name, const string message) : Exception(func_name, message) {}
FileIException::~FileIException() {}
GroupIException::GroupIException():Exception(){}
-GroupIException::GroupIException(const string& func_name, const string& message) : Exception(func_name, message) {}
-GroupIException::GroupIException(const char* func_name, const char* message) : Exception(func_name, message) {}
+GroupIException::GroupIException(const string func_name, const string message) : Exception(func_name, message) {}
GroupIException::~GroupIException() {}
DataSpaceIException::DataSpaceIException():Exception(){}
-DataSpaceIException::DataSpaceIException(const string& func_name, const string& message) : Exception(func_name, message) {}
-DataSpaceIException::DataSpaceIException(const char* func_name, const char* message) : Exception(func_name, message) {}
+DataSpaceIException::DataSpaceIException(const string func_name, const string message) : Exception(func_name, message) {}
DataSpaceIException::~DataSpaceIException() {}
DataTypeIException::DataTypeIException():Exception(){}
-DataTypeIException::DataTypeIException(const string& func_name, const string& message) : Exception(func_name, message) {}
-DataTypeIException::DataTypeIException(const char* func_name, const char* message) : Exception(func_name, message) {}
+DataTypeIException::DataTypeIException(const string func_name, const string message) : Exception(func_name, message) {}
DataTypeIException::~DataTypeIException() {}
PropListIException::PropListIException():Exception(){}
-PropListIException::PropListIException(const string& func_name, const string& message) : Exception(func_name, message) {}
-PropListIException::PropListIException(const char* func_name, const char* message) : Exception(func_name, message) {}
+PropListIException::PropListIException(const string func_name, const string message) : Exception(func_name, message) {}
PropListIException::~PropListIException() {}
DataSetIException::DataSetIException():Exception(){}
-DataSetIException::DataSetIException(const string& func_name, const string& message) : Exception(func_name, message) {}
-DataSetIException::DataSetIException(const char* func_name, const char* message) : Exception(func_name, message) {}
+DataSetIException::DataSetIException(const string func_name, const string message) : Exception(func_name, message) {}
DataSetIException::~DataSetIException() {}
AttributeIException::AttributeIException():Exception(){}
-AttributeIException::AttributeIException(const string& func_name, const string& message) : Exception(func_name, message) {}
-AttributeIException::AttributeIException(const char* func_name, const char* message) : Exception(func_name, message) {}
+AttributeIException::AttributeIException(const string func_name, const string message) : Exception(func_name, message) {}
AttributeIException::~AttributeIException() {}
ReferenceException::ReferenceException():Exception(){}
-ReferenceException::ReferenceException(const string& func_name, const string& message) : Exception(func_name, message) {}
-ReferenceException::ReferenceException(const char* func_name, const char* message) : Exception(func_name, message) {}
+ReferenceException::ReferenceException(const string func_name, const string message) : Exception(func_name, message) {}
ReferenceException::~ReferenceException() {}
LibraryIException::LibraryIException():Exception(){}
-LibraryIException::LibraryIException(const string& func_name, const string& message) : Exception(func_name, message) {}
-LibraryIException::LibraryIException(const char* func_name, const char* message) : Exception(func_name, message) {}
+LibraryIException::LibraryIException(const string func_name, const string message) : Exception(func_name, message) {}
LibraryIException::~LibraryIException() {}
IdComponentException::IdComponentException(): Exception() {}
-IdComponentException::IdComponentException(const string& func_name, const string& message) : Exception(func_name, message) {}
-IdComponentException::IdComponentException(const char* func_name, const char* message) : Exception(func_name, message) {}
+IdComponentException::IdComponentException(const string func_name, const string message) : Exception(func_name, message) {}
IdComponentException::~IdComponentException() {}
#ifndef H5_NO_NAMESPACE