H5Exception.h

00001 // C++ informative line for the emacs editor: -*- C++ -*-
00002 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00003  * Copyright by The HDF Group.                                               *
00004  * Copyright by the Board of Trustees of the University of Illinois.         *
00005  * All rights reserved.                                                      *
00006  *                                                                           *
00007  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
00008  * terms governing use, modification, and redistribution, is contained in    *
00009  * the files COPYING and Copyright.html.  COPYING can be found at the root   *
00010  * of the source code distribution tree; Copyright.html can be found at the  *
00011  * root level of an installed copy of the electronic HDF5 document set and   *
00012  * is linked from the top-level documents page.  It can also be found at     *
00013  * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
00014  * access to either file, you may request a copy from help@hdfgroup.org.     *
00015  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00016 
00017 #ifndef _H5Exception_H
00018 #define _H5Exception_H
00019 
00020 #include <string>
00021 
00022 #ifndef H5_NO_NAMESPACE
00023 namespace H5 {
00024 #ifdef H5_NO_STD
00025     #define H5std_string ::string
00026 #else
00027     #define H5std_string std::string
00028 #endif
00029 #endif
00030 
00031 class H5_DLLCPP Exception {
00032    public:
00033         // Creates an exception with a function name where the failure occurs
00034         // and an optional detailed message
00035         Exception(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
00036 
00037         // Returns a character string that describes the error specified by
00038         // a major error number.
00039         H5std_string getMajorString( hid_t err_major_id ) const;
00040 
00041         // Returns a character string that describes the error specified by
00042         // a minor error number.
00043         H5std_string getMinorString( hid_t err_minor_id ) const;
00044 
00045         // Returns the detailed message set at the time the exception is thrown
00046         H5std_string getDetailMsg() const;
00047         const char* getCDetailMsg() const;      // C string of detailed message
00048         H5std_string getFuncName() const;       // function name as a string object
00049         const char* getCFuncName() const;       // function name as a char string
00050 
00051         // Turns on the automatic error printing.
00052         static void setAutoPrint( H5E_auto2_t& func, void* client_data);
00053 
00054         // Turns off the automatic error printing.
00055         static void dontPrint();
00056 
00057         // Retrieves the current settings for the automatic error stack
00058         // traversal function and its data.
00059         static void getAutoPrint( H5E_auto2_t& func, void** client_data);
00060 
00061         // Clears the error stack for the current thread.
00062         static void clearErrorStack();
00063 
00064         // Walks the error stack for the current thread, calling the
00065         // specified function.
00066         static void walkErrorStack( H5E_direction_t direction,
00067                                 H5E_walk2_t func, void* client_data);
00068 
00069         // Prints the error stack in a default manner.
00070         virtual void printError( FILE* stream = NULL ) const;
00071 
00072         // Default constructor
00073         Exception();
00074 
00075         // copy constructor
00076         Exception( const Exception& orig);
00077 
00078         // virtual Destructor
00079         virtual ~Exception();
00080 
00081    private:
00082         H5std_string detail_message;
00083         H5std_string func_name;
00084 
00085    protected:
00086         // Default value for detail_message
00087         static const H5std_string DEFAULT_MSG;
00088 };
00089 
00090 class H5_DLLCPP FileIException : public Exception {
00091    public:
00092         FileIException( const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
00093         FileIException();
00094         virtual ~FileIException();
00095 };
00096 
00097 class H5_DLLCPP GroupIException : public Exception {
00098    public:
00099         GroupIException( const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
00100         GroupIException();
00101         virtual ~GroupIException();
00102 };
00103 
00104 class H5_DLLCPP DataSpaceIException : public Exception {
00105    public:
00106         DataSpaceIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
00107         DataSpaceIException();
00108         virtual ~DataSpaceIException();
00109 };
00110 
00111 class H5_DLLCPP DataTypeIException : public Exception {
00112    public:
00113         DataTypeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
00114         DataTypeIException();
00115         virtual ~DataTypeIException();
00116 };
00117 
00118 class H5_DLLCPP PropListIException : public Exception {
00119    public:
00120         PropListIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
00121         PropListIException();
00122         virtual ~PropListIException();
00123 };
00124 
00125 class H5_DLLCPP DataSetIException : public Exception {
00126    public:
00127         DataSetIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
00128         DataSetIException();
00129         virtual ~DataSetIException();
00130 };
00131 
00132 class H5_DLLCPP AttributeIException : public Exception {
00133    public:
00134         AttributeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
00135         AttributeIException();
00136         virtual ~AttributeIException();
00137 };
00138 
00139 class H5_DLLCPP ReferenceException : public Exception {
00140    public:
00141         ReferenceException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
00142         ReferenceException();
00143         virtual ~ReferenceException();
00144 };
00145 
00146 class H5_DLLCPP LibraryIException : public Exception {
00147    public:
00148         LibraryIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
00149         LibraryIException();
00150         virtual ~LibraryIException();
00151 };
00152 
00153 class H5_DLLCPP IdComponentException : public Exception {
00154    public:
00155         IdComponentException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
00156         IdComponentException();
00157         virtual ~IdComponentException();
00158 };
00159 
00160 #ifndef H5_NO_NAMESPACE
00161 }
00162 #endif
00163 
00164 #endif // _H5Exception_H