1 /* 2 * Copyright (C) 2004-2006 Marc Boris Duerner 3 * Copyright (C) 2005 Aloysius Indrayanto 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * As a special exception, you may use this file as part of a free 11 * software library without restriction. Specifically, if other files 12 * instantiate templates or use macros or inline functions from this 13 * file, or you compile this file and link it with other files to 14 * produce an executable, this file does not by itself cause the 15 * resulting executable to be covered by the GNU General Public 16 * License. This exception does not however invalidate any other 17 * reasons why the executable file might be covered by the GNU Library 18 * General Public License. 19 * 20 * This library is distributed in the hope that it will be useful, 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 * Lesser General Public License for more details. 24 * 25 * You should have received a copy of the GNU Lesser General Public 26 * License along with this library; if not, write to the Free Software 27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 28 */ 29 #ifndef CXXTOOLS_IOERROR_H 30 #define CXXTOOLS_IOERROR_H 31 32 #include <cxxtools/api.h> 33 #include <ios> 34 #include <stdexcept> 35 36 namespace cxxtools 37 { 38 39 class CXXTOOLS_API IOError : public std::ios::failure 40 { 41 public: 42 explicit IOError(const std::string& what); 43 throw()44 ~IOError() throw() 45 {} 46 }; 47 48 class CXXTOOLS_API IOTimeout : public IOError 49 { 50 public: 51 IOTimeout(); 52 throw()53 ~IOTimeout() throw() 54 {} 55 }; 56 57 class CXXTOOLS_API AccessFailed : public IOError 58 { 59 public: 60 explicit AccessFailed(const std::string& what); 61 throw()62 ~AccessFailed() throw() 63 {} 64 }; 65 66 class CXXTOOLS_API PermissionDenied : public AccessFailed 67 { 68 public: 69 explicit PermissionDenied(const std::string& resource); 70 throw()71 ~PermissionDenied() throw() 72 {} 73 }; 74 75 class CXXTOOLS_API DeviceNotFound : public AccessFailed 76 { 77 public: 78 explicit DeviceNotFound(const std::string& device); 79 throw()80 ~DeviceNotFound() throw() 81 {} 82 }; 83 84 class CXXTOOLS_API FileNotFound : public AccessFailed 85 { 86 public: 87 explicit FileNotFound(const std::string& path); 88 throw()89 ~FileNotFound() throw() 90 {} 91 }; 92 93 /** @brief A directory could not be found at a given path 94 */ 95 class CXXTOOLS_API DirectoryNotFound : public AccessFailed 96 { 97 public: 98 /** @brief Construct from path and source info 99 100 Constructs the exception from the path where the directory 101 could not be found and the location in the source code where 102 he exception was thrown. 103 */ 104 explicit DirectoryNotFound(const std::string& path); 105 106 //! @brief Destructor throw()107 ~DirectoryNotFound() throw() 108 {} 109 }; 110 111 class CXXTOOLS_API IOPending : public IOError 112 { 113 public: 114 explicit IOPending(const std::string& what); 115 throw()116 ~IOPending() throw() 117 {} 118 }; 119 120 class CXXTOOLS_API DeviceClosed : public IOError 121 { 122 public: 123 explicit DeviceClosed(const std::string& what); 124 125 DeviceClosed(const char* what); 126 throw()127 ~DeviceClosed() throw() 128 {} 129 }; 130 131 } // namespace cxxtools 132 133 #endif 134