OIS  1.5
Object-oriented Input System
OISException.h
Go to the documentation of this file.
1 /*
2 The zlib/libpng License
3 
4 Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
5 
6 This software is provided 'as-is', without any express or implied warranty. In no event will
7 the authors be held liable for any damages arising from the use of this software.
8 
9 Permission is granted to anyone to use this software for any purpose, including commercial
10 applications, and to alter it and redistribute it freely, subject to the following
11 restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not claim that
14  you wrote the original software. If you use this software in a product,
15  an acknowledgment in the product documentation would be appreciated but is
16  not required.
17 
18  2. Altered source versions must be plainly marked as such, and must not be
19  misrepresented as being the original software.
20 
21  3. This notice may not be removed or altered from any source distribution.
22 */
23 #ifndef _OIS_EXCEPTION_HEADER_
24 #define _OIS_EXCEPTION_HEADER_
25 #include "OISPrereqs.h"
26 #include <exception>
27 
28 #ifdef OIS_WIN32_PLATFORM
29 #pragma warning(push)
30 #pragma warning(disable : 4275) //Silence warning from MSVC when using std::exception as the base class of a dll-interface class (OIS::Exception)
31 #endif
32 
33 namespace OIS
34 {
36  enum OIS_ERROR {
46  };
47 
55  class _OISExport Exception : public std::exception
56  {
57  public:
59  Exception(OIS_ERROR err, const char* str, int line, const char* file) :
60  eType(err), eLine(line), eFile(file), eText(str) {}
61 
62  Exception(const Exception& other) :
63  eType(other.eType), eLine(other.eLine), eFile(other.eFile), eText(other.eText) {}
64 
65  ~Exception() throw() {}
66 
67  virtual const char* what() const throw();
68 
70  const OIS_ERROR eType;
72  const int eLine;
74  const char* eFile;
76  const char* eText;
77 
78  private:
79  // Unimplemented and unaccessible due to const members.
80  Exception& operator=(Exception);
81  };
82 }
83 
85 #define OIS_EXCEPT(err, str) throw(OIS::Exception(err, str, __LINE__, __FILE__))
86 
87 //TODO choose what to do with this...
88 //#define OIS_WARN( err, str ) throw( OIS::Exception(err, str, __LINE__, __FILE__) )
89 #define OIS_WARN(err, str) \
90  do \
91  { \
92  } while(0)
93 
94 #ifdef OIS_WIN32_PLATFORM
95 #pragma warning(pop)
96 #endif
97 
98 #endif //_OIS_EXCEPTION_HEADER_
#define _OISExport
Definition: OISPrereqs.h:40
Definition: OISException.h:41
Exception(OIS_ERROR err, const char *str, int line, const char *file)
Creates exception object.
Definition: OISException.h:59
Exception(const Exception &other)
Definition: OISException.h:62
Definition: OISException.h:40
Definition: OISException.h:55
Definition: OISException.h:45
Definition: OISException.h:42
OIS_ERROR
Simple enum&#39;s for dealing with exceptions.
Definition: OISException.h:36
~Exception()
Definition: OISException.h:65
Definition: OISException.h:37
Definition: OISException.h:38
Definition: OISEffect.h:28
Definition: OISException.h:44
Definition: OISException.h:39
Definition: OISException.h:43