Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Exceptions.h
Go to the documentation of this file.
1 //
2 // C++ Interface: Audio::Codec
3 //
4 #ifndef __AUDIO_EXCEPTIONS_H__INCLUDED__
5 #define __AUDIO_EXCEPTIONS_H__INCLUDED__
6 
7 #include <string>
8 #include <exception>
9 #include "Format.h"
10 
11 namespace Audio {
12 
19  class Exception : public std::exception
20  {
21  private:
22  std::string _message;
23 
24  public:
25  Exception() {};
26  Exception(const Exception &other) : _message(other._message) {}
27  explicit Exception(const std::string &message) : _message(message) {}
28  virtual ~Exception() throw() {}
29  virtual const char* what() const throw() { return _message.c_str(); }
30  };
31 
36  class FileOpenException : public Exception {
37  public:
39  FileOpenException(const FileOpenException &other) : Exception(other) {}
40  explicit FileOpenException(const std::string &message) : Exception(message) {}
41  };
42 
49  public:
52  explicit CodecNotFoundException(const std::string &message) : Exception(message) {}
53  };
54 
59  class FileFormatException : public Exception {
60  public:
63  explicit FileFormatException(const std::string &message) : Exception(message) {}
64  };
65 
71  public:
74  explicit EndOfStreamException(const std::string &message) : Exception(message) {}
75  };
76 
86  bool fatal;
87  public:
89  explicit CorruptStreamException(bool _fatal)
90  : Exception(fatal ? "Fatal corruption on stream" : "Recoverable corruption on stream"),
91  fatal(_fatal)
92  {}
93 
94  bool isFatal() const { return fatal; }
95  };
96 
103  public:
106  explicit ResourceNotLoadedException(const std::string &message) : Exception(message) {}
107  };
108 
116  public:
119  explicit ResourceAlreadyLoadedException(const std::string &message) : Exception(message) {}
120  };
121 
127  public:
130  explicit InvalidParametersException(const std::string &message) : Exception(message) {}
131  };
132 
137  public:
138  explicit DuplicateObjectException(const std::string &name) :
139  Exception(std::string("Object with name \"") + name + "\" already existed") {}
140  };
141 
145  class NotFoundException : public Exception {
146  public:
147  explicit NotFoundException(const std::string &name) :
148  Exception(std::string("Object with name \"") + name + "\" does not exist") {}
149  };
150 
155  public:
156  explicit NotImplementedException(const std::string &name) :
157  Exception(name + " has not been implemented yet") {}
158  };
159 
164  Format format;
165  public:
166  explicit UnsupportedFormatException(const std::string &where, const Format &fmt) :
167  Exception(std::string("Unsupported format (" + where + ")")),
168  format(fmt)
169  {}
170 
171  const Format& getFormat() const throw() { return format; }
172  };
173 
178  public:
180  };
181 
182 };
183 
184 #endif//__AUDIO_EXCEPTIONS_H__INCLUDED__