Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Purpose: Declaration of the PCIDSKException class. All exceptions thrown 4 : * by the PCIDSK library will be of this type. 5 : * 6 : ****************************************************************************** 7 : * Copyright (c) 2009 8 : * PCI Geomatics, 90 Allstate Parkway, Markham, Ontario, Canada. 9 : * 10 : * Permission is hereby granted, free of charge, to any person obtaining a 11 : * copy of this software and associated documentation files (the "Software"), 12 : * to deal in the Software without restriction, including without limitation 13 : * the rights to use, copy, modify, merge, publish, distribute, sublicense, 14 : * and/or sell copies of the Software, and to permit persons to whom the 15 : * Software is furnished to do so, subject to the following conditions: 16 : * 17 : * The above copyright notice and this permission notice shall be included 18 : * in all copies or substantial portions of the Software. 19 : * 20 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 23 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26 : * DEALINGS IN THE SOFTWARE. 27 : ****************************************************************************/ 28 : #ifndef INCLUDE_PCIDSK_EXCEPTION_H 29 : #define INCLUDE_PCIDSK_EXCEPTION_H 30 : 31 : #include "pcidsk_config.h" 32 : 33 : #include <string> 34 : #include <cstdarg> 35 : #include <stdexcept> 36 : 37 : namespace PCIDSK 38 : { 39 : /************************************************************************/ 40 : /* Exception */ 41 : /************************************************************************/ 42 : 43 : class PCIDSK_DLL PCIDSKException : public std::exception 44 : { 45 : friend void PCIDSK_DLL ThrowPCIDSKException( const char *fmt, ... ) PCIDSK_PRINT_FUNC_FORMAT(1,2); 46 : friend int PCIDSK_DLL ThrowPCIDSKException( int ret_unused, const char *fmt, ... ) PCIDSK_PRINT_FUNC_FORMAT(2,3); 47 : friend void PCIDSK_DLL * ThrowPCIDSKExceptionPtr( const char *fmt, ... ) PCIDSK_PRINT_FUNC_FORMAT(1,2); 48 56 : PCIDSKException() {} 49 : public: 50 : PCIDSKException(const char *fmt, ... ) PCIDSK_PRINT_FUNC_FORMAT(2,3); 51 : virtual ~PCIDSKException() throw(); 52 : 53 : void vPrintf( const char *fmt, std::va_list list ); 54 53 : virtual const char *what() const throw() override { return message.c_str(); } 55 : private: 56 : std::string message; 57 : }; 58 : 59 : void PCIDSK_DLL ThrowPCIDSKException( const char *fmt, ... ) PCIDSK_PRINT_FUNC_FORMAT(1,2); 60 : int PCIDSK_DLL ThrowPCIDSKException( int ret_unused, const char *fmt, ... ) PCIDSK_PRINT_FUNC_FORMAT(2,3); 61 : void PCIDSK_DLL * ThrowPCIDSKExceptionPtr( const char *fmt, ... ) PCIDSK_PRINT_FUNC_FORMAT(1,2); 62 : 63 : } // end namespace PCIDSK 64 : 65 : #endif // INCLUDE_PCIDSK_EXCEPTION_H