forked from boostorg/exception
Examples/documentation update
[SVN r54842]
This commit is contained in:
@ -64,7 +64,7 @@ else return <unspecified-string-value>;</pre>
|
|||||||
<div class="RenoIncludeDIV"><h4>Example:</h4>
|
<div class="RenoIncludeDIV"><h4>Example:</h4>
|
||||||
<p>this is a possible output from the <span class="RenoLink">diagnostic_information</span> function, as used in <i>libs/exception/example/example_io.cpp:</i></p>
|
<p>this is a possible output from the <span class="RenoLink">diagnostic_information</span> function, as used in <i>libs/exception/example/example_io.cpp:</i></p>
|
||||||
<pre>example_io.cpp(70): Throw in function class boost::shared_ptr<struct _iobuf> __cdecl my_fopen(const char *,const char *)
|
<pre>example_io.cpp(70): Throw in function class boost::shared_ptr<struct _iobuf> __cdecl my_fopen(const char *,const char *)
|
||||||
Dynamic exception type: class boost::exception_detail::clone_impl<class fopen_error>
|
Dynamic exception type: class boost::exception_detail::clone_impl<struct fopen_error>
|
||||||
std::exception::what: example_io error
|
std::exception::what: example_io error
|
||||||
[struct boost::<span class="RenoLink"><a href="errinfo_api_function.html">errinfo_api_function</a></span>_ *] = fopen
|
[struct boost::<span class="RenoLink"><a href="errinfo_api_function.html">errinfo_api_function</a></span>_ *] = fopen
|
||||||
[struct boost::<span class="RenoLink"><a href="errinfo_errno.html">errinfo_errno</a></span>_ *] = 2, "No such file or directory"
|
[struct boost::<span class="RenoLink"><a href="errinfo_errno.html">errinfo_errno</a></span>_ *] = 2, "No such file or directory"
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -48,7 +48,7 @@ g()
|
|||||||
<div class="RenoIncludeDIV"><h4>Example:</h4>
|
<div class="RenoIncludeDIV"><h4>Example:</h4>
|
||||||
<p>this is a possible output from the <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span> function, as used in <i>libs/exception/example/example_io.cpp:</i></p>
|
<p>this is a possible output from the <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span> function, as used in <i>libs/exception/example/example_io.cpp:</i></p>
|
||||||
<pre>example_io.cpp(70): Throw in function class boost::shared_ptr<struct _iobuf> __cdecl my_fopen(const char *,const char *)
|
<pre>example_io.cpp(70): Throw in function class boost::shared_ptr<struct _iobuf> __cdecl my_fopen(const char *,const char *)
|
||||||
Dynamic exception type: class boost::exception_detail::clone_impl<class fopen_error>
|
Dynamic exception type: class boost::exception_detail::clone_impl<struct fopen_error>
|
||||||
std::exception::what: example_io error
|
std::exception::what: example_io error
|
||||||
[struct boost::<span class="RenoLink"><a href="errinfo_api_function.html">errinfo_api_function</a></span>_ *] = fopen
|
[struct boost::<span class="RenoLink"><a href="errinfo_api_function.html">errinfo_api_function</a></span>_ *] = fopen
|
||||||
[struct boost::<span class="RenoLink"><a href="errinfo_errno.html">errinfo_errno</a></span>_ *] = 2, "No such file or directory"
|
[struct boost::<span class="RenoLink"><a href="errinfo_errno.html">errinfo_errno</a></span>_ *] = 2, "No such file or directory"
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
class file_read_error: public boost::<span class="RenoLink"><a href="exception.html">exception</a></span> { };
|
struct file_read_error: virtual boost::<span class="RenoLink"><a href="exception.html">exception</a></span> { };
|
||||||
|
|
||||||
void
|
void
|
||||||
file_read( FILE * f, void * buffer, size_t size )
|
file_read( FILE * f, void * buffer, size_t size )
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
typedef boost::<span class="RenoLink"><a href="error_info.html">error_info</a></span><struct tag_my_info,int> my_info; //(1)
|
typedef boost::<span class="RenoLink"><a href="error_info.html">error_info</a></span><struct tag_my_info,int> my_info; //(1)
|
||||||
|
|
||||||
class my_error: public boost::<span class="RenoLink"><a href="exception.html">exception</a></span>, public std::exception { }; //(2)
|
struct my_error: virtual boost::<span class="RenoLink"><a href="exception.html">exception</a></span>, virtual std::exception { }; //(2)
|
||||||
|
|
||||||
void
|
void
|
||||||
f()
|
f()
|
||||||
@ -73,12 +73,12 @@ file_read( FILE * f, void * buffer, size_t size )
|
|||||||
}</pre>
|
}</pre>
|
||||||
<p>How can the file_read function pass a file name to the exception type constructor? All it has is a FILE handle.</p>
|
<p>How can the file_read function pass a file name to the exception type constructor? All it has is a FILE handle.</p>
|
||||||
<p>Using boost::<span class="RenoLink"><a href="exception.html">exception</a></span> allows us to free the file_read function from the burden of storing the file name in exceptions it throws:</p>
|
<p>Using boost::<span class="RenoLink"><a href="exception.html">exception</a></span> allows us to free the file_read function from the burden of storing the file name in exceptions it throws:</p>
|
||||||
<pre><span class="RenoLink"><a href="boost_exception_all_hpp.html">boost/exception/all.hpp</a></span>>
|
<pre>#include <<span class="RenoLink"><a href="boost_exception_all_hpp.html">boost/exception/all.hpp</a></span>>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
class file_read_error: public boost::<span class="RenoLink"><a href="exception.html">exception</a></span> { };
|
struct file_read_error: virtual boost::<span class="RenoLink"><a href="exception.html">exception</a></span> { };
|
||||||
|
|
||||||
void
|
void
|
||||||
file_read( FILE * f, void * buffer, size_t size )
|
file_read( FILE * f, void * buffer, size_t size )
|
||||||
@ -127,7 +127,7 @@ parse_file( char const * file_name )
|
|||||||
|
|
||||||
typedef boost::<span class="RenoLink"><a href="http://www.boost.org/libs/tuple/doc/tuple_users_guide.html">tuple</a></span><boost::<span class="RenoLink"><a href="errinfo_api_function.html">errinfo_api_function</a></span>,boost::<span class="RenoLink"><a href="errinfo_errno.html">errinfo_errno</a></span>> clib_failure;
|
typedef boost::<span class="RenoLink"><a href="http://www.boost.org/libs/tuple/doc/tuple_users_guide.html">tuple</a></span><boost::<span class="RenoLink"><a href="errinfo_api_function.html">errinfo_api_function</a></span>,boost::<span class="RenoLink"><a href="errinfo_errno.html">errinfo_errno</a></span>> clib_failure;
|
||||||
|
|
||||||
class file_open_error: public boost::<span class="RenoLink"><a href="exception.html">exception</a></span> { };
|
struct file_open_error: virtual boost::<span class="RenoLink"><a href="exception.html">exception</a></span> { };
|
||||||
|
|
||||||
boost::shared_ptr<FILE>
|
boost::shared_ptr<FILE>
|
||||||
file_open( char const * name, char const * mode )
|
file_open( char const * name, char const * mode )
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
class file_read_error: public boost::exception { };
|
struct file_read_error: virtual boost::exception { };
|
||||||
|
|
||||||
void
|
void
|
||||||
file_read( FILE * f, void * buffer, size_t size )
|
file_read( FILE * f, void * buffer, size_t size )
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
typedef boost::error_info<struct tag_my_info,int> my_info; //(1)
|
typedef boost::error_info<struct tag_my_info,int> my_info; //(1)
|
||||||
|
|
||||||
class my_error: public boost::exception, public std::exception { }; //(2)
|
struct my_error: virtual boost::exception, virtual std::exception { }; //(2)
|
||||||
|
|
||||||
void
|
void
|
||||||
f()
|
f()
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
class file_read_error: public boost::exception { };
|
struct file_read_error: virtual boost::exception { };
|
||||||
|
|
||||||
void
|
void
|
||||||
file_read( FILE * f, void * buffer, size_t size )
|
file_read( FILE * f, void * buffer, size_t size )
|
||||||
|
@ -29,8 +29,8 @@ size_t const data_size = sizeof(data);
|
|||||||
|
|
||||||
class
|
class
|
||||||
error: //Base for all exception objects we throw.
|
error: //Base for all exception objects we throw.
|
||||||
public std::exception,
|
public virtual std::exception,
|
||||||
public boost::exception
|
public virtual boost::exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -47,14 +47,12 @@ error: //Base for all exception objects we throw.
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class open_error: public error { };
|
struct open_error: virtual error { };
|
||||||
class read_error: public error { };
|
struct read_error: virtual error { };
|
||||||
class write_error: public error { };
|
struct write_error: virtual error { };
|
||||||
|
struct fopen_error: virtual open_error { };
|
||||||
class fopen_error: public open_error { };
|
struct fread_error: virtual read_error { };
|
||||||
class fread_error: public read_error { };
|
struct fwrite_error: virtual write_error { };
|
||||||
class fwrite_error: public write_error { };
|
|
||||||
|
|
||||||
|
|
||||||
boost::shared_ptr<FILE>
|
boost::shared_ptr<FILE>
|
||||||
my_fopen( char const * name, char const * mode )
|
my_fopen( char const * name, char const * mode )
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
typedef boost::tuple<boost::errinfo_api_function,boost::errinfo_errno> clib_failure;
|
typedef boost::tuple<boost::errinfo_api_function,boost::errinfo_errno> clib_failure;
|
||||||
|
|
||||||
class file_open_error: public boost::exception { };
|
struct file_open_error: virtual boost::exception { };
|
||||||
|
|
||||||
boost::shared_ptr<FILE>
|
boost::shared_ptr<FILE>
|
||||||
file_open( char const * name, char const * mode )
|
file_open( char const * name, char const * mode )
|
||||||
|
Reference in New Issue
Block a user