summaryrefslogtreecommitdiffstats
path: root/c++/src/H5Exception.C
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2000-11-14 21:30:12 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2000-11-14 21:30:12 (GMT)
commit92041a68656c59813619ae1f26ed211b7f028e86 (patch)
treeaaa3256c9a9f0adde21570eac9254f7ce00450b1 /c++/src/H5Exception.C
parent36acd5381e3977164e0d6d666f8ce97cc53f9387 (diff)
downloadhdf5-92041a68656c59813619ae1f26ed211b7f028e86.zip
hdf5-92041a68656c59813619ae1f26ed211b7f028e86.tar.gz
hdf5-92041a68656c59813619ae1f26ed211b7f028e86.tar.bz2
[svn-r2897] Purpose:
C++ API for 1.3.x branch Description: The *.C and *.h files named different than those in 1.2.x. They are in the form: 'H5' + classname, or just classname if the classname is already prefixed with 'H5' to avoid ambiguity in documentation context. This version has several hidden bugs fixed and an improvement on the reference counting approach. The classes and their inheritance structure are listed below: --------------------------------------- H5Library Exception RefCounter IdComponent H5File DataSpace H5Object Group AbstractDs DataSet Attribute DataType PredType EnumType CompType AtomType StrType IntType FloatType PropList FileCreatPropList FileAccPropList DSetCreatPropList DSetMemXferPropList --------------------------------------- IdComponent uses RefCounter to keep track of opened objects so proper termination of HDF5 objects can be maintained. Each class has a .h file containing the class declaration and a .C file containing its definition. In addition to the classes files, the following files do not have class information: - H5Cpp.h: header file to be included in user's application - H5Idtemplates.h: contains a template function used by several classes - H5Classes.h: contains forward class declarations - H5CommonFG.*: contains common code used by classes H5File and Group - H5Include.h: contains the hdf5.h header file and the #undef RCSID to work around the problem: multiple defined RcsId - H5Alltypes.h: simply serves as a container to hold the header files of all datatypes to simplify the header file inclusion Platforms: Solaris (arabica) and Linux
Diffstat (limited to 'c++/src/H5Exception.C')
-rw-r--r--c++/src/H5Exception.C188
1 files changed, 188 insertions, 0 deletions
diff --git a/c++/src/H5Exception.C b/c++/src/H5Exception.C
new file mode 100644
index 0000000..6302fe5
--- /dev/null
+++ b/c++/src/H5Exception.C
@@ -0,0 +1,188 @@
+#ifdef OLD_HEADER_FILENAME
+#include <iostream.h>
+#else
+#include <iostream>
+#endif
+
+#include "H5Include.h"
+#include <string>
+
+// Added this line for CC to work at this time. Will remove it when
+// the problem is fixed. BMR - 10/30/00
+
+#include "H5Exception.h"
+
+#ifndef H5_NO_NAMESPACE
+namespace H5 {
+#endif
+
+Exception::Exception() : detailMessage("") {}
+
+Exception::Exception( const char* message) : detailMessage(static_cast<string>(message)) {}
+
+Exception::Exception( const string& message ) : detailMessage( message ) {}
+
+// copy constructor
+Exception::Exception( const Exception& orig )
+{
+ detailMessage = orig.detailMessage;
+}
+
+// Returns the character string that describes an error specified by
+// a major error number.
+string Exception::getMajorString( H5E_major_t major_num ) const
+{
+ // calls the C API routine to get the major string - Note: in the
+ // failure case, the string "Invalid major error number" will be returned.
+ string major_str( H5Eget_major( major_num ));
+ return( major_str );
+}
+
+// Returns the character string that describes an error specified by
+// a minor error number.
+string Exception::getMinorString( H5E_minor_t minor_num ) const
+{
+ // calls the C API routine to get the minor string - Note: in the
+ // failure case, the string "Invalid minor error number" will be returned.
+ string minor_str( H5Eget_minor( minor_num ));
+ return( minor_str );
+}
+
+// Turns on the automatic error printing.
+void Exception::setAutoPrint( H5E_auto_t func, void* client_data ) const
+{
+ // calls the C API routine H5Eset_auto to set the auto printing to
+ // the specified function.
+ herr_t ret_value = H5Eset_auto( func, client_data );
+ if( ret_value < 0 )
+ throw Exception( "setAutoPrint: H5Eset_auto fails" );
+}
+
+// Turns off the automatic error printing.
+void Exception::dontPrint()
+{
+ // calls the C API routine H5Eset_auto with NULL parameters to turn
+ // off the automatic error printing.
+ herr_t ret_value = H5Eset_auto( NULL, NULL );
+ if( ret_value < 0 )
+ throw Exception( "dontPrint: H5Eset_auto fails" );
+}
+
+// Retrieves the current settings for the automatic error stack traversal
+// function and its data.
+void Exception::getAutoPrint( H5E_auto_t& func, void** client_data ) const
+{
+ // calls the C API routine H5Eget_auto to get the current setting of
+ // the automatic error printing
+ herr_t ret_value = H5Eget_auto( &func, client_data );
+ if( ret_value < 0 )
+ throw Exception( "getAutoPrint: H5Eget_auto fails" );
+}
+
+// Clears the error stack for the current thread.
+void Exception::clearErrorStack() const
+{
+ // calls the C API routine H5Eclear to clear the error stack
+ herr_t ret_value = H5Eclear();
+ if( ret_value < 0 )
+ throw Exception( "clearErrorStack: H5Eclear fails" );
+}
+
+// Walks the error stack for the current thread, calling the specified function.
+void Exception::walkErrorStack( H5E_direction_t direction, H5E_walk_t func, void* client_data ) const
+{
+ // calls the C API routine H5Ewalk to walk the error stack
+ herr_t ret_value = H5Ewalk( direction, func, client_data );
+ if( ret_value < 0 )
+ throw Exception( "walkErrorStack: H5Ewalk fails" );
+}
+
+// Default error stack traversal callback function that prints error
+// messages to the specified output stream.
+void Exception::walkDefErrorStack( int n, H5E_error_t& err_desc, void* client_data ) const
+{
+ // calls the C API routine H5Ewalk_cb to walk the error stack
+ herr_t ret_value = H5Ewalk_cb( n, &err_desc, client_data );
+ if( ret_value < 0 )
+ throw Exception( "walkDefErrorStack: H5Ewalk_cb fails" );
+}
+
+// Returns the detailed message set at the time the exception is thrown
+string Exception::getDetailMesg() const
+{
+ return( detailMessage );
+}
+
+// Prints the error stack in a default manner.
+void Exception::printError( FILE* stream ) const
+{
+ herr_t ret_value = H5Eprint( NULL ); // print to stderr
+ if( ret_value < 0 )
+ throw Exception( "printError: H5Eprint fails" );
+}
+
+FileIException::FileIException():Exception(){};
+FileIException::FileIException( string message ):
+Exception( message ){};
+
+GroupIException::GroupIException():Exception(){};
+GroupIException::GroupIException( string message ):
+Exception( message ){};
+
+ObjectHeaderException::ObjectHeaderException():Exception(){};
+ObjectHeaderException::ObjectHeaderException( string message ): Exception( message ) {};
+
+DataSpaceIException::DataSpaceIException():Exception(){};
+DataSpaceIException::DataSpaceIException( string message ): Exception( message ) {};
+
+DataTypeIException::DataTypeIException():Exception(){};
+DataTypeIException::DataTypeIException( string message ): Exception( message ) {};
+
+PropListIException::PropListIException():Exception(){};
+PropListIException::PropListIException( string message ): Exception( message ) {};
+
+DataSetIException::DataSetIException():Exception(){};
+DataSetIException::DataSetIException( string message ): Exception( message ) {};
+
+AttributeIException::AttributeIException():Exception(){};
+AttributeIException::AttributeIException( string message ): Exception( message ) {};
+
+FunctionArgumentException::FunctionArgumentException():Exception(){};
+FunctionArgumentException::FunctionArgumentException( string message ): Exception( message ) {};
+
+ReferenceException::ReferenceException():Exception(){};
+ReferenceException::ReferenceException( string message ):
+Exception( message ) {};
+
+DataStorageException::DataStorageException():Exception(){};
+DataStorageException::DataStorageException( string message ):
+Exception( message ) {};
+
+LibraryIException::LibraryIException():Exception(){};
+LibraryIException::LibraryIException( string message ):
+Exception( message ) {};
+
+IdComponentException::IdComponentException(): Exception() {};
+IdComponentException::IdComponentException( string message ): Exception( message ) {};
+
+// The following are from Java API but not done here:
+// AtomException, BtreeException, DataFiltersException,
+// ExternalFileListException, FunctionEntryExitException,
+// HeapException, InternalErrorException, LowLevelIOException,
+// MetaDataCacheException, ResourceUnavailableException,
+// SymbolTableException
+
+File_GroupException::File_GroupException()
+{
+ // for now, do nothing
+}
+
+File_GroupException::File_GroupException( string message )
+{
+ // for now, do nothing
+}
+
+
+#ifndef H5_NO_NAMESPACE
+} // end namespace
+#endif