svcore  1.9
Exceptions.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef _EXCEPTIONS_H_
17 #define _EXCEPTIONS_H_
18 
19 #include <exception>
20 
21 #include <QString>
22 
23 #include "Debug.h"
24 
25 class FileNotFound : virtual public std::exception
26 {
27 public:
28  FileNotFound(QString file) throw();
29  virtual ~FileNotFound() throw() { }
30  virtual const char *what() const throw();
31 
32 protected:
33  QString m_file;
34 };
35 
36 class FailedToOpenFile : virtual public std::exception
37 {
38 public:
39  FailedToOpenFile(QString file) throw();
40  virtual ~FailedToOpenFile() throw() { }
41  virtual const char *what() const throw();
42 
43 protected:
44  QString m_file;
45 };
46 
47 class DirectoryCreationFailed : virtual public std::exception
48 {
49 public:
50  DirectoryCreationFailed(QString directory) throw();
51  virtual ~DirectoryCreationFailed() throw() { }
52  virtual const char *what() const throw();
53 
54 protected:
55  QString m_directory;
56 };
57 
58 class FileReadFailed : virtual public std::exception
59 {
60 public:
61  FileReadFailed(QString file) throw();
62  virtual ~FileReadFailed() throw() { }
63  virtual const char *what() const throw();
64 
65 protected:
66  QString m_file;
67 };
68 
69 class FileOperationFailed : virtual public std::exception
70 {
71 public:
72  FileOperationFailed(QString file, QString operation) throw();
73  virtual ~FileOperationFailed() throw() { }
74  virtual const char *what() const throw();
75 
76 protected:
77  QString m_file;
78  QString m_operation;
79 };
80 
81 class InsufficientDiscSpace : virtual public std::exception
82 {
83 public:
84  InsufficientDiscSpace(QString directory,
85  int required, int available) throw();
86  InsufficientDiscSpace(QString directory) throw();
87  virtual ~InsufficientDiscSpace() throw() { }
88  virtual const char *what() const throw();
89 
90  QString getDirectory() const { return m_directory; }
91  int getRequired() const { return m_required; }
92  int getAvailable() const { return m_available; }
93 
94 protected:
95  QString m_directory;
98 };
99 
100 class AllocationFailed : virtual public std::exception
101 {
102 public:
103  AllocationFailed(QString purpose) throw();
104  virtual ~AllocationFailed() throw() { }
105  virtual const char *what() const throw();
106 
107 protected:
108  QString m_purpose;
109 };
110 
111 #endif
virtual ~DirectoryCreationFailed()
Definition: Exceptions.h:51
FileNotFound(QString file)
Definition: Exceptions.cpp:22
virtual ~FileOperationFailed()
Definition: Exceptions.h:73
int getRequired() const
Definition: Exceptions.h:91
virtual ~FileNotFound()
Definition: Exceptions.h:29
virtual ~FailedToOpenFile()
Definition: Exceptions.h:40
virtual ~FileReadFailed()
Definition: Exceptions.h:62
QString m_file
Definition: Exceptions.h:33
virtual ~InsufficientDiscSpace()
Definition: Exceptions.h:87
virtual ~AllocationFailed()
Definition: Exceptions.h:104
int getAvailable() const
Definition: Exceptions.h:92
virtual const char * what() const
Definition: Exceptions.cpp:30