Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/boost/test/utils/runtime/validation.hpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

  • Property svn:executable set to *
File size: 2.8 KB
Line 
1//  (C) Copyright Gennadiy Rozental 2005.
2//  Distributed under the Boost Software License, Version 1.0.
3//  (See accompanying file LICENSE_1_0.txt or copy at
4//  http://www.boost.org/LICENSE_1_0.txt)
5
6//  See http://www.boost.org/libs/test for the library home page.
7//
8//  File        : $RCSfile: validation.hpp,v $
9//
10//  Version     : $Revision: 1.1 $
11//
12//  Description : defines exceptions and validation tools
13// ***************************************************************************
14
15#ifndef BOOST_RT_VALIDATION_HPP_062604GER
16#define BOOST_RT_VALIDATION_HPP_062604GER
17
18// Boost.Runtime.Parameter
19#include <boost/test/utils/runtime/config.hpp>
20
21// Boost.Test
22#include <boost/test/utils/class_properties.hpp>
23
24// Boost
25#include <boost/shared_ptr.hpp>
26
27// STL
28#ifdef BOOST_RT_PARAM_EXCEPTION_INHERIT_STD
29#include <stdexcept>
30#endif
31
32namespace boost {
33
34namespace BOOST_RT_PARAM_NAMESPACE {
35
36// ************************************************************************** //
37// **************             runtime::logic_error             ************** //
38// ************************************************************************** //
39
40class logic_error 
41#ifdef BOOST_RT_PARAM_EXCEPTION_INHERIT_STD
42: public std::exception
43#endif
44{
45    typedef shared_ptr<dstring> dstring_ptr;
46public:
47    // Constructor // !! could we eliminate shared_ptr
48    explicit    logic_error( cstring msg ) : m_msg( new dstring( msg.begin(), msg.size() ) ) {}
49    ~logic_error() throw()                          {}
50
51    dstring const&   msg() const                    { return *m_msg; }
52    virtual char_type const* what() const throw()   { return m_msg->c_str(); }
53
54private:
55    dstring_ptr m_msg;
56};
57
58// ************************************************************************** //
59// **************          runtime::report_logic_error         ************** //
60// ************************************************************************** //
61
62inline void
63report_logic_error( format_stream& msg )
64{
65    throw BOOST_RT_PARAM_NAMESPACE::logic_error( msg.str() );
66}
67
68//____________________________________________________________________________//
69
70#define BOOST_RT_PARAM_REPORT_LOGIC_ERROR( msg ) \
71    boost::BOOST_RT_PARAM_NAMESPACE::report_logic_error( format_stream().ref() << msg )
72
73#define BOOST_RT_PARAM_VALIDATE_LOGIC( b, msg ) \
74    if( b ) {} else BOOST_RT_PARAM_REPORT_LOGIC_ERROR( msg )
75
76//____________________________________________________________________________//
77
78} // namespace BOOST_RT_PARAM_NAMESPACE
79
80} // namespace boost
81
82// ************************************************************************** //
83//   Revision History:
84//
85//   $Log: validation.hpp,v $
86//   Revision 1.1  2005/04/12 06:42:42  rogeeff
87//   Runtime.Param library initial commit
88//
89// ************************************************************************** //
90
91#endif // BOOST_RT_VALIDATION_HPP_062604GER
Note: See TracBrowser for help on using the repository browser.