To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

The primary repository for this project is hosted at https://github.com/sonic-visualiser/sv-dependency-builds .
This repository is a read-only copy which is updated automatically every hour.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / src / portaudio_20161030_catalina_patch / bindings / cpp / include / portaudiocpp / Exception.hxx @ 164:9fa11135915a

History | View | Annotate | Download (3.02 KB)

1
#ifndef INCLUDED_PORTAUDIO_EXCEPTION_HXX
2
#define INCLUDED_PORTAUDIO_EXCEPTION_HXX
3

    
4
// ---------------------------------------------------------------------------------------
5

    
6
#include <exception>
7

    
8
#include "portaudio.h"
9

    
10
// ---------------------------------------------------------------------------------------
11

    
12
namespace portaudio
13
{
14

    
15
	//////
16
	/// @brief Base class for all exceptions PortAudioCpp can throw.
17
	///
18
	/// Class is derived from std::exception.
19
	//////
20
	class Exception : public std::exception
21
	{
22
	public:
23
		virtual ~Exception() throw() {}
24

    
25
		virtual const char *what() const throw() = 0;
26
	};
27
	
28
	// -----------------------------------------------------------------------------------
29

    
30
	//////
31
	/// @brief Wrapper for PortAudio error codes to C++ exceptions.
32
	///
33
	/// It wraps up PortAudio's error handling mechanism using 
34
	/// C++ exceptions and is derived from std::exception for 
35
	/// easy exception handling and to ease integration with 
36
	/// other code.
37
	///
38
	/// To know what exceptions each function may throw, look up 
39
	/// the errors that can occure in the PortAudio documentation 
40
	/// for the equivalent functions.
41
	///
42
	/// Some functions are likely to throw an exception (such as 
43
	/// Stream::open(), etc) and these should always be called in 
44
	/// try{} catch{} blocks and the thrown exceptions should be 
45
	/// handled properly (ie. the application shouldn't just abort, 
46
	/// but merely display a warning dialog to the user or something).
47
	/// However nearly all functions in PortAudioCpp are capable 
48
	/// of throwing exceptions. When a function like Stream::isStopped() 
49
	/// throws an exception, it's such an exceptional state that it's 
50
	/// not likely that it can be recovered. PaExceptions such as these 
51
	/// can ``safely'' be left to be handled by some outer catch-all-like 
52
	/// mechanism for unrecoverable errors.
53
	//////
54
	class PaException : public Exception
55
	{
56
	public:
57
		explicit PaException(PaError error);
58

    
59
		const char *what() const throw();
60

    
61
		PaError paError() const;
62
		const char *paErrorText() const;
63

    
64
		bool isHostApiError() const; // extended
65
		long lastHostApiError() const;
66
		const char *lastHostApiErrorText() const;
67

    
68
		bool operator==(const PaException &rhs) const;
69
		bool operator!=(const PaException &rhs) const;
70

    
71
	private:
72
		PaError error_;
73
 	};
74

    
75
	// -----------------------------------------------------------------------------------
76

    
77
	//////
78
	/// @brief Exceptions specific to PortAudioCpp (ie. exceptions which do not have an 
79
	/// equivalent PortAudio error code).
80
	//////
81
	class PaCppException : public Exception
82
	{
83
	public:
84
		enum ExceptionSpecifier
85
		{
86
			UNABLE_TO_ADAPT_DEVICE
87
		};
88

    
89
		PaCppException(ExceptionSpecifier specifier);
90

    
91
		const char *what() const throw();
92

    
93
		ExceptionSpecifier specifier() const;
94

    
95
		bool operator==(const PaCppException &rhs) const;
96
		bool operator!=(const PaCppException &rhs) const;
97

    
98
	private:
99
		ExceptionSpecifier specifier_;
100
	};
101

    
102

    
103
} // namespace portaudio
104

    
105
// ---------------------------------------------------------------------------------------
106

    
107
#endif // INCLUDED_PORTAUDIO_EXCEPTION_HXX
108