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