From b142a4144862b22c37c27aa11e2ee519a08ede2f Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Thu, 19 Aug 2004 23:30:45 -0500 Subject: [svn-r9128] Purpose: Code updating Description: Renamed some private members and member functions appropriately. Platforms tested: SunOS 5.7 (arabica) Linux 2.4 (eirene) --- c++/src/H5Exception.cpp | 169 +++++++++++++++++++++++------------------------- c++/src/H5Exception.h | 44 ++++++------- 2 files changed, 104 insertions(+), 109 deletions(-) diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index 0c9c4d7..b94751b 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -1,7 +1,7 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * - * * + * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * @@ -29,18 +29,17 @@ const string Exception::DEFAULT_MSG("No detailed information provided"); ///\brief Default constructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Exception::Exception() : detailMessage(""), funcName("") {} +Exception::Exception() : detail_message(""), func_name("") {} //-------------------------------------------------------------------------- // Function: Exception overloaded constructor -///\brief Creates an exception with a function name where the failure -/// occurs and an optional detailed message +///\brief Creates an exception with the name of the function, +/// in which the failure occurs, and an optional detailed message. ///\param func_name - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure -///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Exception::Exception(const string func_name, const string message) : detailMessage(message), funcName(func_name) {} +Exception::Exception(const string func_name, const string message) : detail_message(message), func_name(func_name) {} //-------------------------------------------------------------------------- // Function: Exception copy constructor @@ -50,17 +49,18 @@ Exception::Exception(const string func_name, const string message) : detailMessa //-------------------------------------------------------------------------- Exception::Exception( const Exception& orig ) { - detailMessage = orig.detailMessage; - funcName = orig.funcName; + detail_message = orig.detail_message; + func_name = orig.func_name; } //-------------------------------------------------------------------------- // Function: Exception::getMajorString -///\brief Returns the text string that describes an error +///\brief Returns a text string that describes the error /// specified by a major error number. ///\param err_major - IN: Major error number +///\return Major error string ///\par Description -/// In the failure case, the string "Invalid major error number" +/// In the failure case, the string "Invalid major error number" /// will be returned. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- @@ -75,11 +75,12 @@ string Exception::getMajorString( hid_t err_major ) const //-------------------------------------------------------------------------- // Function: Exception::getMinorString -///\brief Returns the text string that describes an error +///\brief Returns a text string that describes the error /// specified by a minor error number. ///\param err_minor - IN: Minor error number +///\return Minor error string ///\par Description -/// In the failure case, the string "Invalid minor error number" +/// In the failure case, the string "Invalid minor error number" /// will be returned. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- @@ -98,12 +99,13 @@ string Exception::getMinorString( hid_t err_minor ) const ///\param func - IN: Function to be called upon an error condition ///\param client_data - IN: Data passed to the error function ///\par Description -/// When the library is first initialized the auto printing -/// function is set to the C API \c H5Eprint and \a client_data is -/// the standard error stream pointer, \c stderr. Automatic stack -/// traversal is always in the \c H5E_WALK_DOWNWARD direction. +/// When the library is first initialized the auto printing +/// function, \a func, is set to the C API \c H5Eprint and +/// \a client_data is the standard error stream pointer, \c stderr. +/// Automatic stack traversal is always in the \c H5E_WALK_DOWNWARD +/// direction. ///\par -/// Users are encouraged to write their own more specific error +/// Users are encouraged to write their own more specific error /// handlers // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- @@ -118,7 +120,7 @@ void Exception::setAutoPrint( H5E_auto_t& func, void* client_data ) //-------------------------------------------------------------------------- // Function: Exception::dontPrint -///\brief Turns off the automatic error printing. +///\brief Turns off the automatic error printing from the C library. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void Exception::dontPrint() @@ -132,18 +134,12 @@ void Exception::dontPrint() //-------------------------------------------------------------------------- // Function: Exception::getAutoPrint -///\brief Retrieves the current settings for the automatic error +///\brief Retrieves the current settings for the automatic error /// stack traversal function and its data. -///\param func - IN: Function to be called upon an error condition -///\param client_data - IN: Data passed to the error function -///\par Description -/// When the library is first initialized the auto printing -/// function is set to the C API \c H5Eprint and \a client_data is -/// the standard error stream pointer, \c stderr. Automatic stack -/// traversal is always in the \c H5E_WALK_DOWNWARD direction. -///\par -/// Users are encouraged to write their own more specific error -/// handlers +///\param func - OUT: Current setting for the function to be +/// called upon an error condition +///\param client_data - OUT: Current setting for the data passed to +/// the error function // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void Exception::getAutoPrint( H5E_auto_t& func, void** client_data ) @@ -159,8 +155,8 @@ void Exception::getAutoPrint( H5E_auto_t& func, void** client_data ) // Function: Exception::clearErrorStack ///\brief Clears the error stack for the current thread. ///\par Description -/// The stack is also cleared whenever a C API function is -/// called, with certain exceptions (for instance, H5Eprint). +/// The stack is also cleared whenever a C API function is +/// called, with certain exceptions (for instance, \c H5Eprint). // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void Exception::clearErrorStack() @@ -173,41 +169,41 @@ void Exception::clearErrorStack() //-------------------------------------------------------------------------- // Function: Exception::walkErrorStack -///\brief Walks the error stack for the current thread, calling the +///\brief Walks the error stack for the current thread, calling the /// specified function. ///\param direction - IN: Direction in which the error stack is to be walked ///\param func - IN: Function to be called for each error encountered ///\param client_data - IN: Data passed to the error function ///\par Description /// Valid values for \a direction include: -/// \li \c H5E_WALK_UPWARD - begin with the most specific error -/// and end at the API -/// \li \c H5E_WALK_DOWNWARD - begin at the API and end at the -/// inner-most function where the error was first detected +/// \li \c H5E_WALK_UPWARD - begin with the most specific error +/// and end at the API +/// \li \c H5E_WALK_DOWNWARD - begin at the API and end at the +/// inner-most function where the error was first detected ///\par -/// The function specified by \a func will be called for each -/// error in the error stack. The \c H5E_walk_t prototype is as -/// follows: +/// The function specified by \a func will be called for each +/// error in the error stack. The \c H5E_walk_t prototype is as +/// follows: ///\code -/// typedef herr_t (*H5E_walk_t)(int n, H5E_error_t *err_desc, void *client_data) -/// int n - Indexed position of the error in the stack; it begins at zero +/// typedef herr_t (*H5E_walk_t)(int n, H5E_error_t *err_desc, void *client_data) +/// int n - Indexed position of the error in the stack; it begins at zero /// regardless of stack traversal direction -/// H5E_error_t *err_desc - Pointer to a data structure describing the +/// H5E_error_t *err_desc - Pointer to a data structure describing the /// error. This structure is listed below. -/// void *client_data - Pointer to client data in the format expected by +/// void *client_data - Pointer to client data in the format expected by /// the user-defined function. ///\endcode ///\par -/// Data structure to describe the error: +/// Data structure to describe the error: ///\code /// typedef struct H5E_error_t { -/// hid_t cls_id; //class ID -/// hid_t maj_num; //major error ID -/// hid_t min_num; //minor error number +/// hid_t cls_id; //class ID +/// hid_t maj_num; //major error ID +/// hid_t min_num; //minor error number /// const char *func_name; //function in which error occurred -/// const char *file_name; //file in which error occurred +/// const char *file_name; //file in which error occurred /// unsigned line; //line in file where error occurs -/// const char *desc; //optional supplied description +/// const char *desc; //optional supplied description /// } H5E_error_t; ///\endcode // Programmer Binh-Minh Ribler - 2000 @@ -222,26 +218,26 @@ void Exception::walkErrorStack( H5E_direction_t direction, H5E_walk_t func, void //-------------------------------------------------------------------------- // Function: Exception::getDetailMsg -///\brief Returns the detailed message set at the time the exception +///\brief Returns the detailed message set at the time the exception /// is thrown. ///\return Text message - \c std::string // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- string Exception::getDetailMsg() const { - return(detailMessage); + return(detail_message); } //-------------------------------------------------------------------------- // Function: Exception::getCDetailMsg -///\brief Returns the detailed message set at the time the exception +///\brief Returns the detailed message set at the time the exception /// is thrown. ///\return Text message - \c char pointer // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- const char* Exception::getCDetailMsg() const { - return(detailMessage.c_str()); + return(detail_message.c_str()); } //-------------------------------------------------------------------------- @@ -252,7 +248,7 @@ const char* Exception::getCDetailMsg() const //-------------------------------------------------------------------------- string Exception::getFuncName() const { - return(funcName); + return(func_name); } //-------------------------------------------------------------------------- @@ -263,11 +259,11 @@ string Exception::getFuncName() const //-------------------------------------------------------------------------- const char* Exception::getCFuncName() const { - return(funcName.c_str()); + return(func_name.c_str()); } //-------------------------------------------------------------------------- -// Function: Exception::getCDetailMsg +// Function: Exception::printError ///\brief Prints the error stack in a default manner. ///\param stream - IN: File pointer // Programmer Binh-Minh Ribler - 2000 @@ -287,7 +283,7 @@ void Exception::printError( FILE* stream ) const Exception::~Exception() {} //-------------------------------------------------------------------------- -// Subclasses: FileIException +// Subclass: FileIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- @@ -297,8 +293,8 @@ Exception::~Exception() {} FileIException::FileIException():Exception(){} //-------------------------------------------------------------------------- // Function: FileIException overloaded constructor -///\brief Creates a FileIException with a function name where the failure -/// occurs and an optional detailed message. +///\brief Creates a FileIException with the name of the function, +/// in which the failure occurs, and an optional detailed message. ///\param func_name - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- @@ -310,7 +306,7 @@ FileIException::FileIException(const string func_name, const string message) : E FileIException::~FileIException() {} //-------------------------------------------------------------------------- -// Subclasses: GroupIException +// Subclass: GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- @@ -320,8 +316,8 @@ FileIException::~FileIException() {} GroupIException::GroupIException():Exception(){} //-------------------------------------------------------------------------- // Function: GroupIException overloaded constructor -///\brief Creates a GroupIException with a function name where the -/// failure occurs and an optional detailed message. +///\brief Creates a GroupIException with the name of the function, +/// in which the failure occurs, and an optional detailed message. ///\param func_name - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- @@ -333,7 +329,7 @@ GroupIException::GroupIException(const string func_name, const string message) : GroupIException::~GroupIException() {} //-------------------------------------------------------------------------- -// Subclasses: DataSpaceIException +// Subclass: DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- @@ -343,8 +339,8 @@ GroupIException::~GroupIException() {} DataSpaceIException::DataSpaceIException():Exception(){} //-------------------------------------------------------------------------- // Function: DataSpaceIException overloaded constructor -///\brief Creates a DataSpaceIException with a function name where -/// the failure occurs and an optional detailed message. +///\brief Creates a DataSpaceIException with the name of the function, +/// in which the failure occurs, and an optional detailed message. ///\param func_name - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- @@ -356,7 +352,7 @@ DataSpaceIException::DataSpaceIException(const string func_name, const string me DataSpaceIException::~DataSpaceIException() {} //-------------------------------------------------------------------------- -// Subclasses: DataTypeIException +// Subclass: DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- @@ -366,8 +362,8 @@ DataSpaceIException::~DataSpaceIException() {} DataTypeIException::DataTypeIException():Exception(){} //-------------------------------------------------------------------------- // Function: DataTypeIException overloaded constructor -///\brief Creates a DataTypeIException with a function name where the -/// failure occurs and an optional detailed message. +///\brief Creates a DataTypeIException with the name of the function, +/// in which the failure occurs, and an optional detailed message. ///\param func_name - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- @@ -379,7 +375,7 @@ DataTypeIException::DataTypeIException(const string func_name, const string mess DataTypeIException::~DataTypeIException() {} //-------------------------------------------------------------------------- -// Subclasses: PropListIException +// Subclass: PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- @@ -389,8 +385,8 @@ DataTypeIException::~DataTypeIException() {} PropListIException::PropListIException():Exception(){} //-------------------------------------------------------------------------- // Function: PropListIException overloaded constructor -///\brief Creates a PropListIException with a function name where -/// the failure occurs and an optional detailed message. +///\brief Creates a PropListIException with the name of the function, +/// in which the failure occurs, and an optional detailed message. ///\param func_name - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- @@ -402,7 +398,7 @@ PropListIException::PropListIException(const string func_name, const string mess PropListIException::~PropListIException() {} //-------------------------------------------------------------------------- -// Subclasses: DataSetIException +// Subclass: DataSetIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- @@ -412,8 +408,8 @@ PropListIException::~PropListIException() {} DataSetIException::DataSetIException():Exception(){} //-------------------------------------------------------------------------- // Function: DataSetIException overloaded constructor -///\brief Creates a DataSetIException with a function name where -/// the failure occurs and an optional detailed message. +///\brief Creates a DataSetIException with the name of the function, +/// in which the failure occurs, and an optional detailed message. ///\param func_name - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- @@ -425,7 +421,7 @@ DataSetIException::DataSetIException(const string func_name, const string messag DataSetIException::~DataSetIException() {} //-------------------------------------------------------------------------- -// Subclasses: AttributeIException +// Subclass: AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- @@ -435,8 +431,8 @@ DataSetIException::~DataSetIException() {} AttributeIException::AttributeIException():Exception(){} //-------------------------------------------------------------------------- // Function: AttributeIException overloaded constructor -///\brief Creates a AttributeIException with a function name where -/// the failure occurs and an optional detailed message. +///\brief Creates an AttributeIException with the name of the function, +/// in which the failure occurs, and an optional detailed message. ///\param func_name - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- @@ -448,7 +444,7 @@ AttributeIException::AttributeIException(const string func_name, const string me AttributeIException::~AttributeIException() {} //-------------------------------------------------------------------------- -// Subclasses: ReferenceException +// Subclass: ReferenceException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- @@ -458,8 +454,8 @@ AttributeIException::~AttributeIException() {} ReferenceException::ReferenceException():Exception(){} //-------------------------------------------------------------------------- // Function: ReferenceException overloaded constructor -///\brief Creates a ReferenceException with a function name where -/// the failure occurs and an optional detailed message. +///\brief Creates a ReferenceException with the name of the function, +/// in which the failure occurs, and an optional detailed message. ///\param func_name - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- @@ -471,7 +467,7 @@ ReferenceException::ReferenceException(const string func_name, const string mess ReferenceException::~ReferenceException() {} //-------------------------------------------------------------------------- -// Subclasses: LibraryIException +// Subclass: LibraryIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- @@ -481,8 +477,8 @@ ReferenceException::~ReferenceException() {} LibraryIException::LibraryIException():Exception(){} //-------------------------------------------------------------------------- // Function: LibraryIException overloaded constructor -///\brief Creates a LibraryIException with a function name where -/// the failure occurs and an optional detailed message. +///\brief Creates a LibraryIException with the name of the function, +/// in which the failure occurs, and an optional detailed message. ///\param func_name - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- @@ -494,7 +490,7 @@ LibraryIException::LibraryIException(const string func_name, const string messag LibraryIException::~LibraryIException() {} //-------------------------------------------------------------------------- -// Subclasses: IdComponentException +// Subclass: IdComponentException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- @@ -504,8 +500,8 @@ LibraryIException::~LibraryIException() {} IdComponentException::IdComponentException(): Exception() {} //-------------------------------------------------------------------------- // Function: IdComponentException overloaded constructor -///\brief Creates a IdComponentException with a function name where -/// the failure occurs and an optional detailed message. +///\brief Creates a IdComponentException with the name of the function, +/// in which the failure occurs, and an optional detailed message. ///\param func_name - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- @@ -515,7 +511,6 @@ IdComponentException::IdComponentException(const string func_name, const string ///\brief Noop destructor. //-------------------------------------------------------------------------- IdComponentException::~IdComponentException() {} - #ifndef H5_NO_NAMESPACE } // end namespace #endif diff --git a/c++/src/H5Exception.h b/c++/src/H5Exception.h index 073827e..c67ca3f 100644 --- a/c++/src/H5Exception.h +++ b/c++/src/H5Exception.h @@ -27,21 +27,15 @@ namespace H5 { class H5_DLLCPP Exception { public: - // Default constructor - Exception(); - // Creates an exception with a function name where the failure occurs // and an optional detailed message Exception(const string func_name, const string message = DEFAULT_MSG); - // copy constructor - Exception( const Exception& orig); - - // Returns the character string that describes an error specified by + // Returns a character string that describes the error specified by // a major error number. string getMajorString( hid_t err_major_id ) const; - // Returns the character string that describes an error specified by + // Returns a character string that describes the error specified by // a minor error number. string getMinorString( hid_t err_minor_id ) const; @@ -72,6 +66,12 @@ class H5_DLLCPP Exception { // Prints the error stack in a default manner. virtual void printError( FILE* stream = NULL ) const; + // Default constructor + Exception(); + + // copy constructor + Exception( const Exception& orig); + // virtual Destructor virtual ~Exception(); @@ -82,81 +82,81 @@ class H5_DLLCPP Exception { #if defined(WIN32) #pragma warning(disable: 4251) #endif - string detailMessage; - string funcName; + string detail_message; + string func_name; + protected: - // Default value for detailMessage + // Default value for detail_message static const string DEFAULT_MSG; - }; class H5_DLLCPP FileIException : public Exception { public: + FileIException( const string func_name, const string message = DEFAULT_MSG); FileIException(); - FileIException(const string func_name, const string message = DEFAULT_MSG); virtual ~FileIException(); }; class H5_DLLCPP GroupIException : public Exception { public: + GroupIException( const string func_name, const string message = DEFAULT_MSG); GroupIException(); - GroupIException(const string func_name, const string message = DEFAULT_MSG); virtual ~GroupIException(); }; class H5_DLLCPP DataSpaceIException : public Exception { public: - DataSpaceIException(); DataSpaceIException(const string func_name, const string message = DEFAULT_MSG); + DataSpaceIException(); virtual ~DataSpaceIException(); }; class H5_DLLCPP DataTypeIException : public Exception { public: - DataTypeIException(); DataTypeIException(const string func_name, const string message = DEFAULT_MSG); + DataTypeIException(); virtual ~DataTypeIException(); }; class H5_DLLCPP PropListIException : public Exception { public: - PropListIException(); PropListIException(const string func_name, const string message = DEFAULT_MSG); + PropListIException(); virtual ~PropListIException(); }; class H5_DLLCPP DataSetIException : public Exception { public: - DataSetIException(); DataSetIException(const string func_name, const string message = DEFAULT_MSG); + DataSetIException(); virtual ~DataSetIException(); }; class H5_DLLCPP AttributeIException : public Exception { public: - AttributeIException(); AttributeIException(const string func_name, const string message = DEFAULT_MSG); + AttributeIException(); virtual ~AttributeIException(); }; class H5_DLLCPP ReferenceException : public Exception { public: + ReferenceException(const string func_name, const string message = DEFAULT_MSG); ReferenceException(); - ReferenceException(const string func_name, const string message=DEFAULT_MSG); virtual ~ReferenceException(); }; class H5_DLLCPP LibraryIException : public Exception { public: + LibraryIException(const string func_name, const string message = DEFAULT_MSG); LibraryIException(); - LibraryIException(const string func_name, const string message=DEFAULT_MSG); virtual ~LibraryIException(); }; class H5_DLLCPP IdComponentException : public Exception { public: + IdComponentException(const string func_name, const string message = DEFAULT_MSG); IdComponentException(); - IdComponentException(const string func_name, const string message=DEFAULT_MSG); virtual ~IdComponentException(); }; -- cgit v0.12