]> git.mxchange.org Git - flightgear.git/blob - 3rdparty/iaxclient/lib/portaudio/bindings/cpp/include/portaudiocpp/Exception.hxx
Move IAXClient library into 3rdparty directory
[flightgear.git] / 3rdparty / iaxclient / lib / portaudio / bindings / cpp / include / portaudiocpp / Exception.hxx
1 #ifndef INCLUDED_PORTAUDIO_EXCEPTION_HXX\r
2 #define INCLUDED_PORTAUDIO_EXCEPTION_HXX\r
3 \r
4 // ---------------------------------------------------------------------------------------\r
5 \r
6 #include <exception>\r
7 \r
8 #include "portaudio.h"\r
9 \r
10 // ---------------------------------------------------------------------------------------\r
11 \r
12 namespace portaudio\r
13 {\r
14 \r
15         //////\r
16         /// @brief Base class for all exceptions PortAudioCpp can throw.\r
17         ///\r
18         /// Class is derived from std::exception.\r
19         //////\r
20         class Exception : public std::exception\r
21         {\r
22         public:\r
23                 virtual ~Exception() throw() {}\r
24 \r
25                 virtual const char *what() const throw() = 0;\r
26         };\r
27         \r
28         // -----------------------------------------------------------------------------------\r
29 \r
30         //////\r
31         /// @brief Wrapper for PortAudio error codes to C++ exceptions.\r
32         ///\r
33         /// It wraps up PortAudio's error handling mechanism using \r
34         /// C++ exceptions and is derived from std::exception for \r
35         /// easy exception handling and to ease integration with \r
36         /// other code.\r
37         ///\r
38         /// To know what exceptions each function may throw, look up \r
39         /// the errors that can occure in the PortAudio documentation \r
40         /// for the equivalent functions.\r
41         ///\r
42         /// Some functions are likely to throw an exception (such as \r
43         /// Stream::open(), etc) and these should always be called in \r
44         /// try{} catch{} blocks and the thrown exceptions should be \r
45         /// handled properly (ie. the application shouldn't just abort, \r
46         /// but merely display a warning dialog to the user or something).\r
47         /// However nearly all functions in PortAudioCpp are capable \r
48         /// of throwing exceptions. When a function like Stream::isStopped() \r
49         /// throws an exception, it's such an exceptional state that it's \r
50         /// not likely that it can be recovered. PaExceptions such as these \r
51         /// can ``safely'' be left to be handled by some outer catch-all-like \r
52         /// mechanism for unrecoverable errors.\r
53         //////\r
54         class PaException : public Exception\r
55         {\r
56         public:\r
57                 explicit PaException(PaError error);\r
58 \r
59                 const char *what() const throw();\r
60 \r
61                 PaError paError() const;\r
62                 const char *paErrorText() const;\r
63 \r
64                 bool isHostApiError() const; // extended\r
65                 long lastHostApiError() const;\r
66                 const char *lastHostApiErrorText() const;\r
67 \r
68                 bool operator==(const PaException &rhs) const;\r
69                 bool operator!=(const PaException &rhs) const;\r
70 \r
71         private:\r
72                 PaError error_;\r
73         };\r
74 \r
75         // -----------------------------------------------------------------------------------\r
76 \r
77         //////\r
78         /// @brief Exceptions specific to PortAudioCpp (ie. exceptions which do not have an \r
79         /// equivalent PortAudio error code).\r
80         //////\r
81         class PaCppException : public Exception\r
82         {\r
83         public:\r
84                 enum ExceptionSpecifier\r
85                 {\r
86                         UNABLE_TO_ADAPT_DEVICE\r
87                 };\r
88 \r
89                 PaCppException(ExceptionSpecifier specifier);\r
90 \r
91                 const char *what() const throw();\r
92 \r
93                 ExceptionSpecifier specifier() const;\r
94 \r
95                 bool operator==(const PaCppException &rhs) const;\r
96                 bool operator!=(const PaCppException &rhs) const;\r
97 \r
98         private:\r
99                 ExceptionSpecifier specifier_;\r
100         };\r
101 \r
102 \r
103 } // namespace portaudio\r
104 \r
105 // ---------------------------------------------------------------------------------------\r
106 \r
107 #endif // INCLUDED_PORTAUDIO_EXCEPTION_HXX\r
108 \r