Crazy Eddie's GUI System  0.8.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Exceptions.h
1 /***********************************************************************
2  filename: CEGUIExceptions.h
3  created: 20/2/2004
4  author: Paul D Turner, Frederico Jeronimo (fjeronimo)
5 
6  purpose: Defines exceptions used within the system
7 *************************************************************************/
8 /***************************************************************************
9 * Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining
12 * a copy of this software and associated documentation files (the
13 * "Software"), to deal in the Software without restriction, including
14 * without limitation the rights to use, copy, modify, merge, publish,
15 * distribute, sublicense, and/or sell copies of the Software, and to
16 * permit persons to whom the Software is furnished to do so, subject to
17 * the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be
20 * included in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
29 ***************************************************************************/
30 #ifndef _CEGUIExceptions_h_
31 #define _CEGUIExceptions_h_
32 
33 #include "CEGUI/Base.h"
34 #include "CEGUI/String.h"
35 #include <exception>
36 
37 // Start of CEGUI namespace section
38 namespace CEGUI
39 {
41 class CEGUIEXPORT Exception :
42  public std::exception,
43  public AllocatedObject<Exception>
44 {
45 public:
47  virtual ~Exception(void) throw();
48 
58  const String& getMessage(void) const
59  { return d_message; }
60 
69  const String& getName() const
70  { return d_name; }
71 
81  const String& getFileName(void) const
82  { return d_filename; }
83 
91  int getLine(void) const
92  { return d_line; }
93 
103  const String& getFunctionName(void) const
104  { return d_function; }
105 
106  // override from std::exception.
107  const char* what() const throw();
108 
121  static void setStdErrEnabled(bool enabled);
122 
130  static bool isStdErrEnabled();
131 
132 protected:
134  static bool d_stdErrEnabled;
135 
160  Exception(const String& message = "",
161  const String& name = "CEGUI::Exception",
162  const String& filename = "",
163  int line = 0,
164  const String& function = "");
165 
167  String d_message;
169  String d_name;
171  String d_filename;
173  int d_line;
175  String d_function;
177  String d_what;
178 };
179 
180 //----------------------------------------------------------------------------//
181 
183 class CEGUIEXPORT GenericException : public Exception
184 {
185 public:
211  GenericException(const String& message,
212  const String& file = "unknown", int line = 0,
213  const String& function = "unknown") :
214  Exception(message, "CEGUI::GenericException", file, line, function)
215  {}
216 };
217 
235 #define GenericException(message) \
236  GenericException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
237 
238 //----------------------------------------------------------------------------//
239 
241 class CEGUIEXPORT UnknownObjectException : public Exception
242 {
243 public:
270  const String& file = "unknown", int line = 0,
271  const String& function = "unknown") :
272  Exception(message, "CEGUI::UnknownObjectException", file, line, function)
273  {}
274 };
275 
293 #define UnknownObjectException(message) \
294  UnknownObjectException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
295 
296 //----------------------------------------------------------------------------//
297 
299 class CEGUIEXPORT InvalidRequestException : public Exception
300 {
301 public:
328  const String& file = "unknown", int line = 0,
329  const String& function = "unknown") :
330  Exception(message, "CEGUI::InvalidRequestException", file, line, function)
331  {}
332 };
333 
351 #define InvalidRequestException(message) \
352  InvalidRequestException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
353 
354 //----------------------------------------------------------------------------//
355 
357 class CEGUIEXPORT FileIOException : public Exception
358 {
359 public:
385  FileIOException(const String& message,
386  const String& file = "unknown", int line = 0,
387  const String& function = "unknown") :
388  Exception(message, "CEGUI::FileIOException", file, line, function)
389  {}
390 };
391 
409 #define FileIOException(message) \
410  FileIOException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
411 
412 //----------------------------------------------------------------------------//
413 
415 class CEGUIEXPORT RendererException : public Exception
416 {
417 public:
443  RendererException(const String& message,
444  const String& file = "unknown", int line = 0,
445  const String& function = "unknown") :
446  Exception(message, "CEGUI::RendererException", file, line, function)
447  {}
448 };
449 
467 #define RendererException(message) \
468  RendererException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
469 
470 //----------------------------------------------------------------------------//
471 
478 class CEGUIEXPORT AlreadyExistsException : public Exception
479 {
480 public:
507  const String& file = "unknown", int line = 0,
508  const String& function = "unknown") :
509  Exception(message, "CEGUI::AlreadyExistsException", file, line, function)
510  {}
511 };
512 
530 #define AlreadyExistsException(message) \
531  AlreadyExistsException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
532 
533 //----------------------------------------------------------------------------//
534 
536 class CEGUIEXPORT MemoryException : public Exception
537 {
538 public:
564  MemoryException(const String& message,
565  const String& file = "unknown", int line = 0,
566  const String& function = "unknown") :
567  Exception(message, "CEGUI::MemoryException", file, line, function)
568  {}
569 };
570 
588 #define MemoryException(message) \
589  MemoryException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
590 
591 //----------------------------------------------------------------------------//
592 
594 class CEGUIEXPORT NullObjectException : public Exception
595 {
596 public:
622  NullObjectException(const String& message,
623  const String& file = "unknown", int line = 0,
624  const String& function = "unknown") :
625  Exception(message, "CEGUI::NullObjectException", file, line, function)
626  {}
627 };
628 
646 #define NullObjectException(message) \
647  NullObjectException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
648 
649 //----------------------------------------------------------------------------//
650 
656 class CEGUIEXPORT ObjectInUseException : public Exception
657 {
658 public:
684  ObjectInUseException(const String& message,
685  const String& file = "unknown", int line = 0,
686  const String& function = "unknown") :
687  Exception(message, "CEGUI::ObjectInUseException", file, line, function)
688  {}
689 };
690 
708 #define ObjectInUseException(message) \
709  ObjectInUseException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
710 
711 //----------------------------------------------------------------------------//
712 
714 class CEGUIEXPORT ScriptException : public Exception
715 {
716 public:
742  ScriptException(const String& message,
743  const String& file = "unknown", int line = 0,
744  const String& function = "unknown") :
745  Exception(message, "CEGUI::ScriptException", file, line, function)
746  {}
747 };
748 
766 #define ScriptException(message) \
767  ScriptException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
768 
769 
770 //----------------------------------------------------------------------------//
771 
772 } // End of CEGUI namespace section
773 
774 
775 #endif // end of guard _CEGUIExceptions_h_