Compare commits

...

22 Commits

Author SHA1 Message Date
da0f861b05 Merge branch 'develop' 2016-11-07 11:31:01 -08:00
14d3b01c60 Fixing more struct/class discrepancies. 2016-11-02 23:53:42 -07:00
6cf231330a Ticket #12059 2016-10-26 12:35:25 -07:00
e1378f7aef Ticket #12553, plus tabs converted to spaces. 2016-10-26 11:51:40 -07:00
27598f92db Configuration option to allow Boost Exception to use std::shared_ptr instead of boost::shared_ptr. 2016-09-28 16:53:43 -07:00
44fcc63f36 Merge branch 'develop' 2016-07-12 19:22:35 -07:00
c1e2284628 Improved errno printing in diagnostic information messages. 2016-07-12 19:21:53 -07:00
3003123b2b Merge branch 'develop' 2016-06-06 14:51:52 -07:00
c1dc3b8dcb Included missing declaration before specialization of set_info_rv. 2016-06-05 22:33:02 -07:00
dac601519d Merge branch 'develop' 2016-05-31 18:32:34 -07:00
1afb7e0372 Ticket #12230 2016-05-31 14:46:13 -07:00
c57eefbf42 More complete error_info testing 2015-03-25 14:28:54 -07:00
5a040eedf5 rvalue references support in error_info 2015-03-24 15:44:28 -07:00
c1f6b743e4 Merge pull request #5 from danieljames/metadata
Create metadata file (thanks danieljames)
2015-01-05 15:11:57 -08:00
e5e4652b75 Merge remote-tracking branch 'origin/develop' 2014-08-29 17:51:11 -07:00
af4de75bac Add metadata file. 2014-08-18 14:58:41 +01:00
38bfc39d10 Merge pull request #4 from Lastique/develop
Port to Boost.Core demangle() and typeinfo. Thanks Lastique.
2014-06-11 11:33:04 -07:00
5dea76a301 Port to Boost.Core demangle() and typeinfo. 2014-06-11 22:02:59 +04:00
8931eb2e0d Merge pull request #1 from Lastique/develop
Re-enable type name demangling (thanks Lastique)
2014-06-04 23:29:56 -07:00
a129725e3e Switched from BOOST_ATTRIBUTE_NORETURN to BOOST_NORETURN. 2014-06-05 00:50:04 +04:00
8f097eb241 Comment fix. 2014-05-31 21:57:51 +04:00
7062572c8f Re-implemented type name demangling.
The new implementation does not depend on Boost.Units and is fully contained in Boost.Exception.
2014-05-31 21:54:52 +04:00
17 changed files with 274 additions and 39 deletions

View File

@ -12,6 +12,8 @@
#pragma warning(push,1)
#endif
#include <boost/config.hpp>
#include <utility>
#include <string>
namespace
@ -46,6 +48,11 @@ boost
typedef T value_type;
error_info( value_type const & value );
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
error_info( error_info const & );
error_info( value_type && value ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(value))));
error_info( error_info && x ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(x.value_))));
#endif
~error_info() throw();
value_type const &
@ -61,6 +68,10 @@ boost
}
private:
error_info & operator=( error_info const & );
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
error_info & operator=( error_info && x );
#endif
std::string name_value_string() const;

View File

@ -21,9 +21,9 @@
#include <boost/exception/diagnostic_information.hpp>
#include <boost/exception/detail/type_info.hpp>
#include <boost/exception/detail/clone_current_exception.hpp>
//#ifndef BOOST_NO_RTTI
//#include <boost/units/detail/utility.hpp>
//#endif
#ifndef BOOST_NO_RTTI
#include <boost/core/demangle.hpp>
#endif
#include <boost/shared_ptr.hpp>
#include <stdexcept>
#include <new>
@ -92,7 +92,7 @@ boost
std::string
to_string( original_exception_type const & x )
{
return /*units::detail::demangle*/(x.value()->name());
return core::demangle(x.value()->name());
}
#endif

View File

@ -0,0 +1,17 @@
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
//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)
#ifndef UUID_837060E885AF11E68DA91D15E31AC075
#define UUID_837060E885AF11E68DA91D15E31AC075
#ifdef BOOST_EXCEPTION_MINI_BOOST
#include <memory>
namespace boost { namespace exception_detail { using std::shared_ptr; } }
#else
#include <boost/shared_ptr.hpp>
namespace boost { namespace exception_detail { using boost::shared_ptr; } }
#endif
#endif

View File

@ -12,12 +12,10 @@
#pragma warning(push,1)
#endif
#include <boost/detail/sp_typeinfo.hpp>
#include <boost/core/typeinfo.hpp>
#include <boost/core/demangle.hpp>
#include <boost/current_function.hpp>
#include <boost/config.hpp>
//#ifndef BOOST_NO_TYPEID
//#include <boost/units/detail/utility.hpp>
//#endif
#include <string>
namespace
@ -31,7 +29,7 @@ boost
#ifdef BOOST_NO_TYPEID
return BOOST_CURRENT_FUNCTION;
#else
return /*units::detail::demangle*/(typeid(T*).name());
return core::demangle(typeid(T*).name());
#endif
}
@ -43,7 +41,7 @@ boost
#ifdef BOOST_NO_TYPEID
return BOOST_CURRENT_FUNCTION;
#else
return /*units::detail::demangle*/(typeid(T).name());
return core::demangle(typeid(T).name());
#endif
}
@ -53,10 +51,10 @@ boost
struct
type_info_
{
detail::sp_typeinfo const * type_;
core::typeinfo const * type_;
explicit
type_info_( detail::sp_typeinfo const & type ):
type_info_( core::typeinfo const & type ):
type_(&type)
{
}
@ -71,7 +69,7 @@ boost
}
}
#define BOOST_EXCEPTION_STATIC_TYPEID(T) ::boost::exception_detail::type_info_(BOOST_SP_TYPEID(T))
#define BOOST_EXCEPTION_STATIC_TYPEID(T) ::boost::exception_detail::type_info_(BOOST_CORE_TYPEID(T))
#ifndef BOOST_NO_RTTI
#define BOOST_EXCEPTION_DYNAMIC_TYPEID(x) ::boost::exception_detail::type_info_(typeid(x))

View File

@ -16,9 +16,9 @@
#include <boost/exception/get_error_info.hpp>
#include <boost/exception/info.hpp>
#include <boost/utility/enable_if.hpp>
//#ifndef BOOST_NO_RTTI
//#include <boost/units/detail/utility.hpp>
//#endif
#ifndef BOOST_NO_RTTI
#include <boost/core/demangle.hpp>
#endif
#include <exception>
#include <sstream>
#include <string>
@ -151,7 +151,7 @@ boost
#ifndef BOOST_NO_RTTI
if ( verbose )
tmp << std::string("Dynamic exception type: ") <<
/*units::detail::demangle*/((be?(BOOST_EXCEPTION_DYNAMIC_TYPEID(*be)):(BOOST_EXCEPTION_DYNAMIC_TYPEID(*se))).type_->name()) << '\n';
core::demangle((be?(BOOST_EXCEPTION_DYNAMIC_TYPEID(*be)):(BOOST_EXCEPTION_DYNAMIC_TYPEID(*se))).type_->name()) << '\n';
#endif
if( with_what && se && verbose )
tmp << "std::exception::what: " << wh << '\n';

View File

@ -6,7 +6,7 @@
#ifndef UUID_DDFBB4546C1211DEA4659E9055D89593
#define UUID_DDFBB4546C1211DEA4659E9055D89593
#include "boost/exception/error_info.hpp"
#include <boost/exception/error_info.hpp>
namespace
boost

View File

@ -10,9 +10,10 @@
#endif
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#pragma warning(push,1)
#pragma warning(disable:4996)
#endif
#include "boost/exception/info.hpp"
#include <boost/exception/info.hpp>
#include <errno.h>
#include <string.h>
@ -33,7 +34,7 @@ boost
{
std::ostringstream tmp;
int v=e.value();
tmp << v << ", \"" << strerror(v) << "\"";
tmp << '[' << error_info_name(e) << "] = " << v << ", \"" << strerror(v) << "\"\n";
return tmp.str();
}
}

View File

@ -15,7 +15,8 @@
#include <boost/exception/exception.hpp>
#include <boost/exception/detail/error_info_impl.hpp>
#include <boost/exception/detail/type_info.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/exception/detail/shared_ptr.hpp>
#include <boost/assert.hpp>
namespace
boost

View File

@ -15,7 +15,7 @@
#include <boost/exception/exception.hpp>
#include <boost/exception/to_string_stub.hpp>
#include <boost/exception/detail/error_info_impl.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/exception/detail/shared_ptr.hpp>
#include <boost/config.hpp>
#include <map>
@ -46,6 +46,30 @@ boost
{
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <class Tag,class T>
inline
error_info<Tag,T>::
error_info( error_info const & x ):
value_(x.value_)
{
}
template <class Tag,class T>
inline
error_info<Tag,T>::
error_info( value_type && value ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(value)))):
value_(std::move(value))
{
}
template <class Tag,class T>
inline
error_info<Tag,T>::
error_info( error_info && x ) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(value_type(std::move(x.value_)))):
value_(std::move(x.value_))
{
}
#endif
template <class Tag,class T>
inline
error_info<Tag,T>::
@ -175,6 +199,85 @@ boost
return x;
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <class E,class Tag,class T>
E const & set_info( E const &, error_info<Tag,T> && );
template <class T>
struct set_info_rv;
template <class Tag,class T>
struct
set_info_rv<error_info<Tag,T> >
{
template <class E,class Tag1,class T1>
friend E const & set_info( E const &, error_info<Tag1,T1> && );
template <class E>
static
E const &
set( E const & x, error_info<Tag,T> && v )
{
typedef error_info<Tag,T> error_info_tag_t;
shared_ptr<error_info_tag_t> p( new error_info_tag_t(std::move(v)) );
exception_detail::error_info_container * c=x.data_.get();
if( !c )
x.data_.adopt(c=new exception_detail::error_info_container_impl);
c->set(p,BOOST_EXCEPTION_STATIC_TYPEID(error_info_tag_t));
return x;
}
};
template <>
struct
set_info_rv<throw_function>
{
template <class E,class Tag1,class T1>
friend E const & set_info( E const &, error_info<Tag1,T1> && );
template <class E>
static
E const &
set( E const & x, throw_function && y )
{
x.throw_function_=y.v_;
return x;
}
};
template <>
struct
set_info_rv<throw_file>
{
template <class E,class Tag1,class T1>
friend E const & set_info( E const &, error_info<Tag1,T1> && );
template <class E>
static
E const &
set( E const & x, throw_file && y )
{
x.throw_file_=y.v_;
return x;
}
};
template <>
struct
set_info_rv<throw_line>
{
template <class E,class Tag1,class T1>
friend E const & set_info( E const &, error_info<Tag1,T1> && );
template <class E>
static
E const &
set( E const & x, throw_line && y )
{
x.throw_line_=y.v_;
return x;
}
};
template <class E,class Tag,class T>
inline
E const &
set_info( E const & x, error_info<Tag,T> && v )
{
return set_info_rv<error_info<Tag,T> >::template set<E>(x,std::move(v));
}
#endif
template <class T>
struct
derives_boost_exception
@ -190,6 +293,16 @@ boost
{
return exception_detail::set_info(x,v);
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <class E,class Tag,class T>
inline
typename enable_if<exception_detail::derives_boost_exception<E>,E const &>::type
operator<<( E const & x, error_info<Tag,T> && v )
{
return exception_detail::set_info(x,std::move(v));
}
#endif
}
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)

15
meta/libraries.json Normal file
View File

@ -0,0 +1,15 @@
{
"key": "exception",
"name": "Exception",
"authors": [
"Emil Dotchevski"
],
"description": "The Boost Exception library supports transporting of arbitrary data in exception objects, and transporting of exceptions between threads.",
"documentation": "doc/boost-exception.html",
"category": [
"Emulation"
],
"maintainers": [
"Emil Dotchevski <emil -at- revergestudios.com>"
]
}

View File

@ -34,7 +34,10 @@ run exception_test.cpp ;
run enable_error_info_test.cpp helper1.cpp ;
run throw_exception_test.cpp helper2.cpp ;
run errno_test.cpp ;
run error_info_test.cpp ;
run error_info_lv_test.cpp ;
run error_info_lv_const_test.cpp ;
run error_info_rv_test.cpp ;
run error_info_rv_const_test.cpp ;
run diagnostic_information_test.cpp ;
run refcount_ptr_test.cpp ;
run current_exception_cast_test.cpp ;

View File

@ -37,7 +37,7 @@ main()
throw my_exception();
}
catch(
boost::exception & e )
boost::exception & e )
{
e.set<tag1>(42);
e.set<tag2>("42");

View File

@ -0,0 +1,13 @@
//Copyright (c) 2006-2015 Emil Dotchevski and Reverge Studios, Inc.
//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)
#include <boost/exception/info.hpp>
template <class E,class I>
E const &
add_info( E const & e, I const & i )
{
return e << i;
}
#include "error_info_test.hpp"

View File

@ -0,0 +1,13 @@
//Copyright (c) 2006-2015 Emil Dotchevski and Reverge Studios, Inc.
//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)
#include <boost/exception/info.hpp>
template <class E,class I>
E const &
add_info( E const & e, I i )
{
return e << i;
}
#include "error_info_test.hpp"

View File

@ -0,0 +1,28 @@
//Copyright (c) 2006-2015 Emil Dotchevski and Reverge Studios, Inc.
//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)
#include <boost/exception/info.hpp>
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
int
main()
{
return 0;
}
#else
template <class I>
I const
rv_const( I i )
{
return i;
}
template <class E,class I>
E const &
add_info( E const & e, I i )
{
return e << rv_const(i);
}
#include "error_info_test.hpp"
#endif

View File

@ -0,0 +1,22 @@
//Copyright (c) 2006-2015 Emil Dotchevski and Reverge Studios, Inc.
//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)
#include <boost/exception/info.hpp>
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
int
main()
{
return 0;
}
#else
template <class E,class I>
E const &
add_info( E const & e, I i )
{
return e << std::move(i);
}
#include "error_info_test.hpp"
#endif

View File

@ -1,4 +1,4 @@
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
//Copyright (c) 2006-2015 Emil Dotchevski and Reverge Studios, Inc.
//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)
@ -69,7 +69,7 @@ basic_test()
try
{
test_exception x;
x << test_1(1) << test_2(2u) << test_3(3.14159f);
add_info(add_info(add_info(x,test_1(1)),test_2(2u)),test_3(3.14159f));
throw x;
}
catch(
@ -86,7 +86,7 @@ basic_test()
try
{
test_exception x;
x << test_1(1) << test_2(2u) << test_3(3.14159f);
add_info(add_info(add_info(x,test_1(1)),test_2(2u)),test_3(3.14159f));
throw x;
}
catch(
@ -105,7 +105,7 @@ exception_safety_test()
test_exception x;
try
{
x << test_4(throws_on_copy());
add_info(x,test_4(throws_on_copy()));
BOOST_TEST(false);
}
catch(
@ -124,13 +124,13 @@ throw_empty()
void
throw_test_1( char const * value )
{
throw test_exception() << test_5(std::string(value));
throw add_info(test_exception(),test_5(std::string(value)));
}
void
throw_test_2()
{
throw test_exception() << test_6(non_printable());
throw add_info(test_exception(),test_6(non_printable()));
}
void
@ -144,7 +144,7 @@ throw_catch_add_file_name( char const * name )
catch(
boost::exception & x )
{
x << test_5(std::string(name));
add_info(x,test_5(std::string(name)));
throw;
}
}
@ -256,10 +256,10 @@ test_add_tuple()
typedef boost::tuple<test_1,test_2,test_3,test_5> tuple_test_1235;
try
{
throw test_exception() << tuple_test_();
throw add_info(test_exception(),tuple_test_());
}
catch(
test_exception & x )
test_exception & )
{
}
catch(
@ -269,7 +269,7 @@ test_add_tuple()
}
try
{
throw test_exception() << tuple_test_1(42);
throw add_info(test_exception(),tuple_test_1(42));
}
catch(
test_exception & x )
@ -283,7 +283,7 @@ test_add_tuple()
}
try
{
throw test_exception() << tuple_test_12(42,42u);
throw add_info(test_exception(),tuple_test_12(42,42u));
}
catch(
test_exception & x )
@ -298,7 +298,7 @@ test_add_tuple()
}
try
{
throw test_exception() << tuple_test_123(42,42u,42.0f);
throw add_info(test_exception(),tuple_test_123(42,42u,42.0f));
}
catch(
test_exception & x )
@ -314,7 +314,7 @@ test_add_tuple()
}
try
{
throw test_exception() << tuple_test_1235(42,42u,42.0f,std::string("42"));
throw add_info(test_exception(),tuple_test_1235(42,42u,42.0f,std::string("42")));
}
catch(
test_exception & x )
@ -337,7 +337,7 @@ test_lifetime1()
int count=0;
try
{
throw test_exception() << test_7(user_data(count));
throw add_info(test_exception(),test_7(user_data(count)));
}
catch(
boost::exception & x )
@ -359,7 +359,7 @@ test_lifetime2()
int count=0;
{
boost::exception_ptr ep;
test_exception e; e<<test_7(user_data(count));
test_exception e; add_info(e,test_7(user_data(count)));
ep=boost::copy_exception(e);
BOOST_TEST(count>0);
}