// Copyright (c) 2005-2007 Hartmut Kaiser (hartmut.kaiser@gmail.com) // // 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 SAGA_IMPL_EXCEPTION_HPP #define SAGA_IMPL_EXCEPTION_HPP // filesystem will be in TR2 #include #include #include #include #include #include #include #include /////////////////////////////////////////////////////////////////////////////// namespace saga { /////////////////////////////////////////////////////////////////////////// namespace impl { /////////////////////////////////////////////////////////////////////// // throw a saga::exception SAGA_EXPORT void throw_exception(saga::object const& obj, std::string const& m, error e); /////////////////////////////////////////////////////////////////////// // throw a saga::exception from a saga object member function SAGA_EXPORT void throw_exception(saga::impl::object const *this_, std::string const& m, error e); /////////////////////////////////////////////////////////////////////// // throw a saga::exception from an adaptor member function SAGA_EXPORT void throw_exception(saga::impl::v1_0::cpi const *this_, std::string const& m, error e); /////////////////////////////////////////////////////////////////////// // throw a saga::exception from any other function SAGA_EXPORT void throw_exception(void const *this_, std::string const& m, error e); /////////////////////////////////////////////////////////////////////////// } /////////////////////////////////////////////////////////////////////////// namespace adaptors { /////////////////////////////////////////////////////////////////////// // throw a saga::adaptors::exception SAGA_EXPORT void throw_adaptor_exception( saga::impl::v1_0::cpi const *this_, std::string const& adaptor_name, std::string const& m, error e); SAGA_EXPORT void throw_adaptor_exception( std::string const& adaptor_name, std::string const& m, error e); /////////////////////////////////////////////////////////////////////////// } /////////////////////////////////////////////////////////////////////////////// } // namespace saga /////////////////////////////////////////////////////////////////////////////// #define SAGA_THROW_VERBATIM(obj, msg, errcode) \ { \ boost::filesystem::path __p(__FILE__, boost::filesystem::native); \ std::string __s(__p.leaf()); \ __s += std::string("(") + BOOST_PP_STRINGIZE(__LINE__) + "): " + msg; \ saga::impl::throw_exception(obj, __s, errcode); \ } \ /**/ /////////////////////////////////////////////////////////////////////////////// #define SAGA_THROW(msg, errcode) \ SAGA_THROW_VERBATIM(this, msg, errcode) \ /**/ /////////////////////////////////////////////////////////////////////////////// #define SAGA_ADAPTOR_THROW_VERBATIM(cpi, msg, errcode) \ { \ boost::filesystem::path __p(__FILE__, boost::filesystem::native); \ std::string __s(__p.leaf()); \ __s += std::string("(") + BOOST_PP_STRINGIZE(__LINE__) + "): " + msg; \ saga::adaptors::throw_adaptor_exception(cpi, \ BOOST_PP_STRINGIZE(SAGA_ADAPTOR_NAME), __s, errcode); \ } \ /**/ /////////////////////////////////////////////////////////////////////////////// #define SAGA_ADAPTOR_THROW(msg, errcode) \ SAGA_ADAPTOR_THROW_VERBATIM(this, msg, errcode) \ /**/ /////////////////////////////////////////////////////////////////////////////// #define SAGA_ADAPTOR_THROW_NO_CONTEXT(msg, errcode) \ { \ boost::filesystem::path __p(__FILE__, boost::filesystem::native); \ std::string __s(__p.leaf()); \ __s += std::string("(") + BOOST_PP_STRINGIZE(__LINE__) + "): " + msg; \ saga::adaptors::throw_adaptor_exception( \ BOOST_PP_STRINGIZE(SAGA_ADAPTOR_NAME), __s, errcode); \ } \ /**/ #endif // !SAGA_IMPL_EXCEPTION_HPP