annotate src/portaudio_20161030/bindings/cpp/source/portaudiocpp/Exception.cxx @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents 59a8758c56b1
children
rev   line source
cannam@140 1 #include "portaudiocpp/Exception.hxx"
cannam@140 2
cannam@140 3 namespace portaudio
cannam@140 4 {
cannam@140 5 // -----------------------------------------------------------------------------------
cannam@140 6 // PaException:
cannam@140 7 // -----------------------------------------------------------------------------------
cannam@140 8
cannam@140 9 //////
cannam@140 10 /// Wraps a PortAudio error into a PortAudioCpp PaException.
cannam@140 11 //////
cannam@140 12 PaException::PaException(PaError error) : error_(error)
cannam@140 13 {
cannam@140 14 }
cannam@140 15
cannam@140 16 // -----------------------------------------------------------------------------------
cannam@140 17
cannam@140 18 //////
cannam@140 19 /// Alias for paErrorText(), to have std::exception compliance.
cannam@140 20 //////
cannam@140 21 const char *PaException::what() const throw()
cannam@140 22 {
cannam@140 23 return paErrorText();
cannam@140 24 }
cannam@140 25
cannam@140 26 // -----------------------------------------------------------------------------------
cannam@140 27
cannam@140 28 //////
cannam@140 29 /// Returns the PortAudio error code (PaError).
cannam@140 30 //////
cannam@140 31 PaError PaException::paError() const
cannam@140 32 {
cannam@140 33 return error_;
cannam@140 34 }
cannam@140 35
cannam@140 36 //////
cannam@140 37 /// Returns the error as a (zero-terminated) text string.
cannam@140 38 //////
cannam@140 39 const char *PaException::paErrorText() const
cannam@140 40 {
cannam@140 41 return Pa_GetErrorText(error_);
cannam@140 42 }
cannam@140 43
cannam@140 44 //////
cannam@140 45 /// Returns true is the error is a HostApi error.
cannam@140 46 //////
cannam@140 47 bool PaException::isHostApiError() const
cannam@140 48 {
cannam@140 49 return (error_ == paUnanticipatedHostError);
cannam@140 50 }
cannam@140 51
cannam@140 52 //////
cannam@140 53 /// Returns the last HostApi error (which is the current one if
cannam@140 54 /// isHostApiError() returns true) as an error code.
cannam@140 55 //////
cannam@140 56 long PaException::lastHostApiError() const
cannam@140 57 {
cannam@140 58 return Pa_GetLastHostErrorInfo()->errorCode;
cannam@140 59 }
cannam@140 60
cannam@140 61 //////
cannam@140 62 /// Returns the last HostApi error (which is the current one if
cannam@140 63 /// isHostApiError() returns true) as a (zero-terminated) text
cannam@140 64 /// string, if it's available.
cannam@140 65 //////
cannam@140 66 const char *PaException::lastHostApiErrorText() const
cannam@140 67 {
cannam@140 68 return Pa_GetLastHostErrorInfo()->errorText;
cannam@140 69 }
cannam@140 70
cannam@140 71 // -----------------------------------------------------------------------------------
cannam@140 72
cannam@140 73 bool PaException::operator==(const PaException &rhs) const
cannam@140 74 {
cannam@140 75 return (error_ == rhs.error_);
cannam@140 76 }
cannam@140 77
cannam@140 78 bool PaException::operator!=(const PaException &rhs) const
cannam@140 79 {
cannam@140 80 return !(*this == rhs);
cannam@140 81 }
cannam@140 82
cannam@140 83 // -----------------------------------------------------------------------------------
cannam@140 84 // PaCppException:
cannam@140 85 // -----------------------------------------------------------------------------------
cannam@140 86
cannam@140 87 PaCppException::PaCppException(ExceptionSpecifier specifier) : specifier_(specifier)
cannam@140 88 {
cannam@140 89 }
cannam@140 90
cannam@140 91 const char *PaCppException::what() const throw()
cannam@140 92 {
cannam@140 93 switch (specifier_)
cannam@140 94 {
cannam@140 95 case UNABLE_TO_ADAPT_DEVICE:
cannam@140 96 {
cannam@140 97 return "Unable to adapt the given device to the specified host api specific device extension";
cannam@140 98 }
cannam@140 99 }
cannam@140 100
cannam@140 101 return "Unknown exception";
cannam@140 102 }
cannam@140 103
cannam@140 104 PaCppException::ExceptionSpecifier PaCppException::specifier() const
cannam@140 105 {
cannam@140 106 return specifier_;
cannam@140 107 }
cannam@140 108
cannam@140 109 bool PaCppException::operator==(const PaCppException &rhs) const
cannam@140 110 {
cannam@140 111 return (specifier_ == rhs.specifier_);
cannam@140 112 }
cannam@140 113
cannam@140 114 bool PaCppException::operator!=(const PaCppException &rhs) const
cannam@140 115 {
cannam@140 116 return !(*this == rhs);
cannam@140 117 }
cannam@140 118
cannam@140 119 // -----------------------------------------------------------------------------------
cannam@140 120
cannam@140 121 } // namespace portaudio
cannam@140 122
cannam@140 123