#ifndef PSTADE_REQUIRE_HPP
#define PSTADE_REQUIRE_HPP
// PStade.Wine
//
// Copyright 2006 MB.
// 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)
// See: <boost/test/minimal.hpp>
//
// (C) Copyright Gennadiy Rozental 2002-2005.
// 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 <stdexcept> // runtime_error
#include <sstream>
#include <boost/throw_exception.hpp>
#define PSTADE_REQUIRE(expr) \
( \
(expr) ? \
static_cast<void>(0) : \
pstade::require_detail::report(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) \
) \
/**/
namespace pstade {
struct require_error :
std::runtime_error
{
explicit require_error(const std::string& msg) :
std::runtime_error(msg)
{ }
};
namespace require_detail {
inline
void report(const char *expr, const char *file, int line, const char *func)
{
std::stringstream msg;
msg <<
"<require result=\"fail\">" <<
"<file>" << file << "</file>" <<
"<line>" << line << "</line>" <<
"<expression>" << expr << "</expression>" <<
"<function>" << func << "</function>" <<
"</require>";
require_error err(msg.str());
boost::throw_exceptioin(err);
}
} // require_detail
} // namespace pstade
#endif