Crazy Eddie's GUI System  0.8.4
Exceptions.h
00001 /***********************************************************************
00002     created:    20/2/2004
00003     author:     Paul D Turner, Frederico Jeronimo (fjeronimo)
00004 
00005     purpose:    Defines exceptions used within the system
00006 *************************************************************************/
00007 /***************************************************************************
00008 *   Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
00009 *
00010 *   Permission is hereby granted, free of charge, to any person obtaining
00011 *   a copy of this software and associated documentation files (the
00012 *   "Software"), to deal in the Software without restriction, including
00013 *   without limitation the rights to use, copy, modify, merge, publish,
00014 *   distribute, sublicense, and/or sell copies of the Software, and to
00015 *   permit persons to whom the Software is furnished to do so, subject to
00016 *   the following conditions:
00017 *
00018 *   The above copyright notice and this permission notice shall be
00019 *   included in all copies or substantial portions of the Software.
00020 *
00021 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00022 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00023 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00024 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00025 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00026 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00027 *   OTHER DEALINGS IN THE SOFTWARE.
00028 ***************************************************************************/
00029 #ifndef _CEGUIExceptions_h_
00030 #define _CEGUIExceptions_h_
00031 
00032 #include "CEGUI/Base.h"
00033 #include "CEGUI/String.h"
00034 #include <exception>
00035 
00036 // Start of CEGUI namespace section
00037 namespace CEGUI
00038 {
00040 class  CEGUIEXPORT Exception :
00041     public std::exception,
00042     public AllocatedObject<Exception>
00043 {
00044 public:
00046     virtual ~Exception(void) throw();
00047 
00057     const String& getMessage(void) const
00058         { return d_message; }
00059 
00068     const String& getName() const
00069         { return d_name; }
00070 
00080     const String& getFileName(void) const
00081         { return d_filename; }
00082 
00090     int getLine(void) const
00091         { return d_line; }
00092 
00102     const String& getFunctionName(void) const
00103         { return d_function; }
00104 
00105     // override from std::exception.
00106     const char* what() const throw();
00107 
00120     static void setStdErrEnabled(bool enabled);
00121 
00129     static bool isStdErrEnabled();
00130 
00131 protected:
00133     static bool d_stdErrEnabled;
00134 
00159     Exception(const String& message = "",
00160               const String& name = "CEGUI::Exception",
00161               const String& filename = "",
00162               int line = 0,
00163               const String& function = "");
00164 
00166     String d_message;
00168     String d_name;
00170     String d_filename;
00172     int d_line;
00174     String d_function;
00176     String d_what;
00177 };
00178 
00179 //----------------------------------------------------------------------------//
00180 
00182 class CEGUIEXPORT GenericException : public Exception
00183 {
00184 public:
00210     GenericException(const String& message,
00211                      const String& file = "unknown", int line = 0,
00212                      const String& function = "unknown") :
00213         Exception(message, "CEGUI::GenericException", file, line, function)
00214     {}
00215 };
00216 
00234 #define GenericException(message)  \
00235     GenericException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
00236 
00237 //----------------------------------------------------------------------------//
00238 
00240 class CEGUIEXPORT UnknownObjectException : public Exception
00241 {
00242 public:
00268     UnknownObjectException(const String& message,
00269                            const String& file = "unknown", int line = 0,
00270                            const String& function = "unknown") :
00271         Exception(message, "CEGUI::UnknownObjectException", file, line, function)
00272     {}
00273 };
00274 
00292 #define UnknownObjectException(message)  \
00293     UnknownObjectException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
00294 
00295 //----------------------------------------------------------------------------//
00296 
00298 class CEGUIEXPORT InvalidRequestException : public Exception
00299 {
00300 public:
00326     InvalidRequestException(const String& message,
00327                             const String& file = "unknown", int line = 0,
00328                             const String& function = "unknown") :
00329         Exception(message, "CEGUI::InvalidRequestException", file, line, function)
00330     {}
00331 };
00332 
00350 #define InvalidRequestException(message)  \
00351     InvalidRequestException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
00352 
00353 //----------------------------------------------------------------------------//
00354 
00356 class CEGUIEXPORT FileIOException : public Exception
00357 {
00358 public:
00384     FileIOException(const String& message,
00385                     const String& file = "unknown", int line = 0,
00386                     const String& function = "unknown") :
00387         Exception(message, "CEGUI::FileIOException", file, line, function)
00388     {}
00389 };
00390 
00408 #define FileIOException(message)  \
00409     FileIOException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
00410 
00411 //----------------------------------------------------------------------------//
00412 
00414 class CEGUIEXPORT RendererException : public Exception
00415 {
00416 public:
00442     RendererException(const String& message,
00443                       const String& file = "unknown", int line = 0,
00444                       const String& function = "unknown") :
00445         Exception(message, "CEGUI::RendererException", file, line, function)
00446     {}
00447 };
00448 
00466 #define RendererException(message)  \
00467     RendererException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
00468 
00469 //----------------------------------------------------------------------------//
00470 
00477 class CEGUIEXPORT AlreadyExistsException : public Exception
00478 {
00479 public:
00505     AlreadyExistsException(const String& message,
00506                            const String& file = "unknown", int line = 0,
00507                            const String& function = "unknown") :
00508         Exception(message, "CEGUI::AlreadyExistsException", file, line, function)
00509     {}
00510 };
00511 
00529 #define AlreadyExistsException(message)  \
00530     AlreadyExistsException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
00531 
00532 //----------------------------------------------------------------------------//
00533 
00535 class CEGUIEXPORT MemoryException : public Exception
00536 {
00537 public:
00563     MemoryException(const String& message,
00564                     const String& file = "unknown", int line = 0,
00565                     const String& function = "unknown") :
00566         Exception(message, "CEGUI::MemoryException", file, line, function)
00567     {}
00568 };
00569 
00587 #define MemoryException(message)  \
00588     MemoryException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
00589 
00590 //----------------------------------------------------------------------------//
00591 
00593 class CEGUIEXPORT NullObjectException : public Exception
00594 {
00595 public:
00621     NullObjectException(const String& message,
00622                         const String& file = "unknown", int line = 0,
00623                         const String& function = "unknown") :
00624         Exception(message, "CEGUI::NullObjectException", file, line, function)
00625     {}
00626 };
00627 
00645 #define NullObjectException(message)  \
00646     NullObjectException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
00647 
00648 //----------------------------------------------------------------------------//
00649 
00655 class CEGUIEXPORT ObjectInUseException : public Exception
00656 {
00657 public:
00683     ObjectInUseException(const String& message,
00684                          const String& file = "unknown", int line = 0,
00685                          const String& function = "unknown") :
00686         Exception(message, "CEGUI::ObjectInUseException", file, line, function)
00687     {}
00688 };
00689 
00707 #define ObjectInUseException(message)  \
00708     ObjectInUseException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
00709 
00710 //----------------------------------------------------------------------------//
00711 
00713 class CEGUIEXPORT ScriptException : public Exception
00714 {
00715 public:
00741     ScriptException(const String& message,
00742                     const String& file = "unknown", int line = 0,
00743                     const String& function = "unknown") :
00744         Exception(message, "CEGUI::ScriptException", file, line, function)
00745     {}
00746 };
00747 
00765 #define ScriptException(message)  \
00766     ScriptException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
00767 
00768 
00769 //----------------------------------------------------------------------------//
00770 
00771 } // End of  CEGUI namespace section
00772 
00773 
00774 #endif // end of guard _CEGUIExceptions_h_
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends