ROLAND  0.70
Amstrad Emulator based on Caprice Source rewritten in C++.
exception.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) by Fred Klaus *
3  * development@fkweb.de *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 #ifndef SDLGUIEXCEPTION_H
21 #define SDLGUIEXCEPTION_H
22 
23 #include "types.h"
24 
25 #include <string>
26 #include <cerrno>
27 #include "SDL.h"
28 #include "SDL_opengl.h"
29 
30 #define SDLGUIERROR(error,details) sdltk::Exception ((details), __FILE__, __LINE__)
31 #define SDLGUICERROR(eno,error,details) sdltk::Exception (eno, (details), __FILE__, __LINE__)
32 #define EXCLF __FILE__, __LINE__
33 #define EXCSDL(error) sdltk::ExcSDL((error), SDL_GetError(), EXCLF);
34 #define EXCGL(error) sdltk::ExcGL((error), oglGetError(), EXCLF);
35 
36 namespace sdltk
37 {
38 
40 
45  class Exception
46  {
47 
48  public:
49  Exception(const char* details=0, const char* file=0, int line=0);
50  Exception(const char* message, const char* details=0, const char* file=0, int line=0, bool eno=false);
51  Exception(const char* section, const char* message, const char* details=0, const char* file=0, int line=0);
52  Exception(const char* section, const char* message, GLenum glerr, const char* file=0, int line=0);
53  virtual ~Exception() {}
54 
55  void init(bool eno, const char* details, const char* file, int line);
56 
57  int getLine() const {return mLine;}
58  const char* getFile() const {return mFile.c_str();}
59  const char* getMessage() const {return mMsg.c_str();}
60  const char* getDetails() const {return mDetails.c_str();}
61 
62  virtual void printError();
63 
64  protected:
65  int mError;
66  int mLine;
72 
73  private:
74  void init(bool eno, const char* message, const char* details, const char* file, int line);
75  };
76 
77 
78  class ExcSDL : public Exception
79  {
80  public:
81  ExcSDL(const char* message=0, const char* details=0, const char* file=0, int line=0)
82  : Exception("[SDL]", message, details, file, line) {}
83 
84  ~ExcSDL() {}
85  };
86 
87 
88  class ExcGL : public Exception
89  {
90  public:
91  ExcGL(const char* message=0, GLenum glerr=0, const char* file=0, int line=0)
92  : Exception("[OpenGL]", message, glerr, file, line) {}
93 
94  ~ExcGL() {}
95 
96  GLenum getEnum() const {return mGLErr;}
97  };
98 
99  /*
100  class ExcMemory : public Exception
101  {
102  public:
103  ExcMemory(const char* details=0, const char* file=0, int line=0, bool eno=false)
104  : Exception("Out of Memory", details, file, line) {}
105 
106  ~ExcMemory() {}
107  };
108 
109 
110  class ExcIO : public Exception
111  {
112  public:
113  ExcIO(const char* details=0, const char* file=0, int line=0, bool eno=false)
114  : Exception("IO-Error", details, file, line) {}
115 
116  ~ExcIO() {}
117  };
118  */
119 
120 } //namespace sdltk
121 
122 #endif
String mFile
Definition: exception.h:69
~ExcSDL()
Definition: exception.h:84
String mDetails
Definition: exception.h:70
String mMsg
Definition: exception.h:68
Definition: exception.h:78
Handles all Exceptions.
Definition: exception.h:45
virtual void printError()
Definition: exception.cpp:109
GLenum
Definition: glfunclist.h:7
const char * getDetails() const
Definition: exception.h:60
GLenum mGLErr
Definition: exception.h:71
Definition: exception.h:88
ExcGL(const char *message=0, GLenum glerr=0, const char *file=0, int line=0)
Definition: exception.h:91
int mError
Definition: exception.h:65
int mLine
Definition: exception.h:66
~ExcGL()
Definition: exception.h:94
Exception(const char *details=0, const char *file=0, int line=0)
Definition: exception.cpp:27
ExcSDL(const char *message=0, const char *details=0, const char *file=0, int line=0)
Definition: exception.h:81
int getLine() const
Definition: exception.h:57
virtual ~Exception()
Definition: exception.h:53
String mSection
Definition: exception.h:67
const char * getFile() const
Definition: exception.h:58
GLenum getEnum() const
Definition: exception.h:96
std::string String
Definition: types.h:29
the SDL based Stuff
Definition: audio.cpp:22
const char * getMessage() const
Definition: exception.h:59
void init(bool eno, const char *details, const char *file, int line)
Definition: exception.cpp:91