//Copyright (c) 2006-2009 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_D63C9FFE03C611E7B6F710AB63EDCBF1 #define UUID_D63C9FFE03C611E7B6F710AB63EDCBF1 namespace boost { class exception_datum { exception_datum( exception_datum const & ); exception_datum & operator=( exception_datum const & ); std::type_info ti_; shared_ptr v_; public: explicit template exception_datum( T const & v ): ti_(typeid(T)), v_(make_shared(v)) { } template T * cast() { if( typeid(T)==ti_ ) return static_cast(v_.get()); else return 0; } }; class exception_data { std::map data_; protected: exception_data() { } ~exception_data() { } public: template exception_data & set( char const * tag, T const & value ) { data_[tag]=exception_datum(value); return *this; } template T const * get( char const * tag ) const { auto it=data_.find(tag); if( it!=data_.end() ) return it->cast(); else return 0; } }; } catch( exception_data & d ) { d["file_name"].set("foo.txt"); d["file_name"].get(); d.set("file_name","foo.txt"); throw; } throw_exception(foo_error(),make_pair("errno",errno),pair("width",width)); #endif