1 //Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
3 //Distributed under the Boost Software License, Version 1.0. (See accompanying
4 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef UUID_274DA366004E11DCB1DDFE2E56D89593
7 #define UUID_274DA366004E11DCB1DDFE2E56D89593
31 refcount_ptr( refcount_ptr
const & x
):
38 operator=( refcount_ptr
const & x
)
78 ////////////////////////////////////////////////////////////////////////
80 template <class Tag
,class T
>
83 typedef error_info
<struct tag_throw_function
,char const *> throw_function
;
84 typedef error_info
<struct tag_throw_file
,char const *> throw_file
;
85 typedef error_info
<struct tag_throw_line
,int> throw_line
;
89 error_info
<tag_throw_function
,char const *>
92 typedef char const * value_type
;
95 error_info( value_type v
):
103 error_info
<tag_throw_file
,char const *>
106 typedef char const * value_type
;
109 error_info( value_type v
):
117 error_info
<tag_throw_line
,int>
120 typedef int value_type
;
123 error_info( value_type v
):
129 template <class E
,class Tag
,class T
>
130 E
const & operator<<( E
const &, error_info
<Tag
,T
> const & );
140 class error_info_base
;
146 virtual char const * diagnostic_information() const = 0;
147 virtual shared_ptr
<error_info_base
const> get( type_info_
const & ) const = 0;
148 virtual void set( shared_ptr
<error_info_base
const> const &, type_info_
const & ) = 0;
149 virtual void add_ref() const = 0;
150 virtual void release() const = 0;
155 ~error_info_container() throw()
164 struct get_info
<throw_function
>;
167 struct get_info
<throw_file
>;
170 struct get_info
<throw_line
>;
172 char const * get_diagnostic_information( exception
const & );
188 //On HP aCC, this protected copy constructor prevents throwing boost::exception.
189 //On all other platforms, the same effect is achieved by the pure virtual destructor.
190 exception( exception
const & x
) throw():
192 throw_function_(x
.throw_function_
),
193 throw_file_(x
.throw_file_
),
194 throw_line_(x
.throw_line_
)
199 virtual ~exception() throw()
201 = 0 //Workaround for HP aCC, =0 incorrectly leads to link errors.
210 operator<<( E
const & x
, throw_function
const & y
)
212 x
.throw_function_
=y
.v_
;
219 operator<<( E
const & x
, throw_file
const & y
)
228 operator<<( E
const & x
, throw_line
const & y
)
234 friend char const * exception_detail::get_diagnostic_information( exception
const & );
236 template <class E
,class Tag
,class T
>
237 friend E
const & operator<<( E
const &, error_info
<Tag
,T
> const & );
240 friend struct exception_detail::get_info
;
241 friend struct exception_detail::get_info
<throw_function
>;
242 friend struct exception_detail::get_info
<throw_file
>;
243 friend struct exception_detail::get_info
<throw_line
>;
245 mutable exception_detail::refcount_ptr
<exception_detail::error_info_container
> data_
;
246 mutable char const * throw_function_
;
247 mutable char const * throw_file_
;
248 mutable int throw_line_
;
257 ////////////////////////////////////////////////////////////////////////
269 error_info_injector( T
const & x
):
274 ~error_info_injector() throw()
279 struct large_size
{ char c
[256]; };
280 large_size
dispatch( exception
* );
282 struct small_size
{ };
283 small_size
dispatch( void * );
286 struct enable_error_info_helper
;
290 enable_error_info_helper
<T
,sizeof(large_size
)>
297 enable_error_info_helper
<T
,sizeof(small_size
)>
299 typedef error_info_injector
<T
> type
;
304 enable_error_info_return_type
306 typedef typename enable_error_info_helper
<T
,sizeof(dispatch((T
*)0))>::type type
;
313 exception_detail::enable_error_info_return_type
<T
>::type
314 enable_error_info( T
const & x
)
316 typedef typename
exception_detail::enable_error_info_return_type
<T
>::type rt
;
320 ////////////////////////////////////////////////////////////////////////
330 virtual clone_base
const * clone() const = 0;
331 virtual void rethrow() const = 0;
334 ~clone_base() throw()
341 copy_boost_exception( exception
* a
, exception
const * b
)
348 copy_boost_exception( void *, void const * )
361 clone_impl( T
const & x
):
364 copy_boost_exception(this,&x
);
367 ~clone_impl() throw()
376 return new clone_impl(*this);
389 exception_detail::clone_impl
<T
>
390 enable_current_exception( T
const & x
)
392 return exception_detail::clone_impl
<T
>(x
);