| <!-- Copyright 2008 Lubomir Bourdev and Hailin Jin |
| |
| Distributed under the Boost Software License, Version 1.0. |
| (See accompanying file LICENSE_1_0.txt or copy at |
| http://www.boost.org/LICENSE_1_0.txt) |
| --> |
| |
| <!-- |
| Copyright 2005-2007 Adobe Systems Incorporated |
| Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt |
| or a copy at http://stlab.adobe.com/licenses.html) |
| |
| Some files are held under additional license. |
| Please see "http://stlab.adobe.com/licenses.html" for more information. |
| --> |
| |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> |
| |
| <head> |
| <TITLE>Generic Image Library: io_error.hpp Source File</TITLE> |
| <META HTTP-EQUIV="content-type" CONTENT="text/html;charset=ISO-8859-1"/> |
| <LINK TYPE="text/css" REL="stylesheet" HREF="adobe_source.css"/> |
| </head> |
| <body> |
| <table border="0" cellspacing="0" cellpadding="0" style='width: 100%; margin: 0; padding: 0'><tr> |
| <td width="100%" valign="top" style='padding-left: 10px; padding-right: 10px; padding-bottom: 10px'> |
| <div class="qindex"><a class="qindex" href="index.html">Modules</a> |
| | <a class="qindex" href="classes.html">Alphabetical List</a> |
| | <a class="qindex" href="annotated.html">Class List</a> |
| | <a class="qindex" href="dirs.html">Directories</a> |
| | <a class="qindex" href="files.html">File List</a> |
| | <a class="qindex" href="../index.html">GIL Home Page</a> |
| </div> |
| <!-- End Header --> |
| <!-- Generated by Doxygen 1.5.6 --> |
| <div class="navpath"><a class="el" href="g_i_l_0076.html">boost</a> » <a class="el" href="g_i_l_0079.html">gil</a> » <a class="el" href="g_i_l_0078.html">extension</a> » <a class="el" href="g_i_l_0077.html">io</a> |
| </div> |
| <div class="contents"> |
| <h1>io_error.hpp</h1><a href="io__error_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> |
| <a name="l00002"></a>00002 <span class="comment"> Copyright 2005-2007 Adobe Systems Incorporated</span> |
| <a name="l00003"></a>00003 <span class="comment"> </span> |
| <a name="l00004"></a>00004 <span class="comment"> Use, modification and distribution are subject to the Boost Software License,</span> |
| <a name="l00005"></a>00005 <span class="comment"> Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at</span> |
| <a name="l00006"></a>00006 <span class="comment"> http://www.boost.org/LICENSE_1_0.txt).</span> |
| <a name="l00007"></a>00007 <span class="comment"></span> |
| <a name="l00008"></a>00008 <span class="comment"> See http://opensource.adobe.com/gil for most recent version including documentation.</span> |
| <a name="l00009"></a>00009 <span class="comment">*/</span> |
| <a name="l00010"></a>00010 <span class="comment">/*************************************************************************************************/</span> |
| <a name="l00011"></a>00011 |
| <a name="l00012"></a>00012 <span class="preprocessor">#ifndef GIL_IO_ERROR_H</span> |
| <a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor">#define GIL_IO_ERROR_H</span> |
| <a name="l00014"></a>00014 <span class="preprocessor"></span> |
| <a name="l00020"></a>00020 |
| <a name="l00021"></a>00021 <span class="preprocessor">#include <ios></span> |
| <a name="l00022"></a>00022 <span class="preprocessor">#include "../../gil_config.hpp"</span> |
| <a name="l00023"></a>00023 <span class="preprocessor">#include <boost/shared_ptr.hpp></span> |
| <a name="l00024"></a>00024 |
| <a name="l00025"></a>00025 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>gil { |
| <a name="l00026"></a>00026 |
| <a name="l00027"></a>00027 <span class="keyword">inline</span> <span class="keywordtype">void</span> io_error(<span class="keyword">const</span> <span class="keywordtype">char</span>* descr) { <span class="keywordflow">throw</span> std::ios_base::failure(descr); } |
| <a name="l00028"></a>00028 <span class="keyword">inline</span> <span class="keywordtype">void</span> io_error_if(<span class="keywordtype">bool</span> expr, <span class="keyword">const</span> <span class="keywordtype">char</span>* descr=<span class="stringliteral">""</span>) { <span class="keywordflow">if</span> (expr) io_error(descr); } |
| <a name="l00029"></a>00029 |
| <a name="l00030"></a>00030 <span class="keyword">namespace </span>detail { |
| <a name="l00031"></a>00031 <span class="keyword">class </span>file_mgr { |
| <a name="l00032"></a>00032 <span class="keyword">protected</span>: |
| <a name="l00033"></a>00033 shared_ptr<FILE> _fp; |
| <a name="l00034"></a>00034 |
| <a name="l00035"></a>00035 <span class="keyword">struct </span>null_deleter { <span class="keywordtype">void</span> operator()(<span class="keywordtype">void</span> <span class="keyword">const</span>*)<span class="keyword"> const </span>{} }; |
| <a name="l00036"></a>00036 file_mgr(FILE* file) : _fp(file, null_deleter()) {} |
| <a name="l00037"></a>00037 |
| <a name="l00038"></a>00038 file_mgr(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename, <span class="keyword">const</span> <span class="keywordtype">char</span>* flags) { |
| <a name="l00039"></a>00039 FILE* fp; |
| <a name="l00040"></a>00040 io_error_if((fp=fopen(filename,flags))==NULL, <span class="stringliteral">"file_mgr: failed to open file"</span>); |
| <a name="l00041"></a>00041 _fp=shared_ptr<FILE>(fp,fclose); |
| <a name="l00042"></a>00042 } |
| <a name="l00043"></a>00043 |
| <a name="l00044"></a>00044 <span class="keyword">public</span>: |
| <a name="l00045"></a>00045 FILE* <span class="keyword">get</span>() { <span class="keywordflow">return</span> _fp.get(); } |
| <a name="l00046"></a>00046 }; |
| <a name="l00047"></a>00047 } |
| <a name="l00048"></a>00048 |
| <a name="l00049"></a>00049 } } <span class="comment">// namespace boost::gil</span> |
| <a name="l00050"></a>00050 |
| <a name="l00051"></a>00051 <span class="preprocessor">#endif</span> |
| </pre></div></div> |
| <hr size="1"><address style="text-align: right;"><small>Generated on Sat May 2 13:50:14 2009 for Generic Image Library by |
| <a href="http://www.doxygen.org/index.html"> |
| <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address> |
| </body> |
| </html> |