2 Copyright 2005-2007 Adobe Systems Incorporated
4 Use, modification and distribution are subject to the Boost Software License,
5 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt).
8 See http://opensource.adobe.com/gil for most recent version including documentation.
10 /*************************************************************************************************/
12 #ifndef GIL_IO_ERROR_H
13 #define GIL_IO_ERROR_H
16 /// \brief Handle input-output errors
17 /// \author Lubomir Bourdev and Hailin Jin \n
18 /// Adobe Systems Incorporated
19 /// \date 2005-2007 \n Last updated on May 30, 2006
22 #include "../../gil_config.hpp"
23 #include <boost/shared_ptr.hpp>
25 namespace boost { namespace gil {
27 inline void io_error(const char* descr) { throw std::ios_base::failure(descr); }
28 inline void io_error_if(bool expr, const char* descr="") { if (expr) io_error(descr); }
35 struct null_deleter { void operator()(void const*) const {} };
36 file_mgr(FILE* file) : _fp(file, null_deleter()) {}
38 file_mgr(const char* filename, const char* flags) {
40 io_error_if((fp=fopen(filename,flags))==NULL, "file_mgr: failed to open file");
41 _fp=shared_ptr<FILE>(fp,fclose);
45 FILE* get() { return _fp.get(); }
49 } } // namespace boost::gil