Update contrib.
1 /*=============================================================================
2 Boost.Wave: A Standard compliant C++ preprocessor library
6 Copyright (c) 2001-2007 Hartmut Kaiser. Distributed under the Boost
7 Software License, Version 1.0. (See accompanying file
8 LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 =============================================================================*/
11 #if !defined(BOOST_WAVE_CPP_THROW_HPP_INCLUDED)
12 #define BOOST_WAVE_CPP_THROW_HPP_INCLUDED
15 #include <boost/throw_exception.hpp>
17 ///////////////////////////////////////////////////////////////////////////////
18 // helper macro for throwing exceptions
19 #if !defined(BOOST_WAVE_THROW)
20 #ifdef BOOST_NO_STRINGSTREAM
22 #define BOOST_WAVE_THROW(cls, code, msg, act_pos) \
24 using namespace boost::wave; \
25 std::strstream stream; \
26 stream << cls::severity_text(cls::code) << ": " \
27 << cls::error_text(cls::code); \
28 if ((msg)[0] != 0) stream << ": " << (msg); \
29 stream << std::ends; \
30 std::string throwmsg = stream.str(); stream.freeze(false); \
31 boost::throw_exception(cls(throwmsg.c_str(), cls::code, \
32 (act_pos).get_line(), (act_pos).get_column(), \
33 (act_pos).get_file().c_str())); \
38 #define BOOST_WAVE_THROW(cls, code, msg, act_pos) \
40 using namespace boost::wave; \
41 std::stringstream stream; \
42 stream << cls::severity_text(cls::code) << ": " \
43 << cls::error_text(cls::code); \
44 if ((msg)[0] != 0) stream << ": " << (msg); \
45 stream << std::ends; \
46 boost::throw_exception(cls(stream.str().c_str(), cls::code, \
47 (act_pos).get_line(), (act_pos).get_column(), \
48 (act_pos).get_file().c_str())); \
51 #endif // BOOST_NO_STRINGSTREAM
52 #endif // BOOST_WAVE_THROW
54 ///////////////////////////////////////////////////////////////////////////////
55 // helper macro for throwing exceptions with additional parameter
56 #if !defined(BOOST_WAVE_THROW_NAME)
57 #ifdef BOOST_NO_STRINGSTREAM
59 #define BOOST_WAVE_THROW_NAME(cls, code, msg, act_pos, name) \
61 using namespace boost::wave; \
62 std::strstream stream; \
63 stream << cls::severity_text(cls::code) << ": " \
64 << cls::error_text(cls::code); \
65 if ((msg)[0] != 0) stream << ": " << (msg); \
66 stream << std::ends; \
67 std::string throwmsg = stream.str(); stream.freeze(false); \
68 boost::throw_exception(cls(throwmsg.c_str(), cls::code, \
69 (act_pos).get_line(), (act_pos).get_column(), \
70 (act_pos).get_file().c_str(), (name))); \
75 #define BOOST_WAVE_THROW_NAME(cls, code, msg, act_pos, name) \
77 using namespace boost::wave; \
78 std::stringstream stream; \
79 stream << cls::severity_text(cls::code) << ": " \
80 << cls::error_text(cls::code); \
81 if ((msg)[0] != 0) stream << ": " << (msg); \
82 stream << std::ends; \
83 boost::throw_exception(cls(stream.str().c_str(), cls::code, \
84 (act_pos).get_line(), (act_pos).get_column(), \
85 (act_pos).get_file().c_str(), (name))); \
88 #endif // BOOST_NO_STRINGSTREAM
89 #endif // BOOST_WAVE_THROW_NAME
91 ///////////////////////////////////////////////////////////////////////////////
92 // helper macro for throwing exceptions with additional parameter
93 #if !defined(BOOST_WAVE_THROW_VAR)
94 #ifdef BOOST_NO_STRINGSTREAM
96 #define BOOST_WAVE_THROW_VAR(cls, code, msg, act_pos) \
98 using namespace boost::wave; \
99 std::strstream stream; \
100 stream << cls::severity_text(code) << ": " \
101 << cls::error_text(code); \
102 if ((msg)[0] != 0) stream << ": " << (msg); \
103 stream << std::ends; \
104 std::string throwmsg = stream.str(); stream.freeze(false); \
105 boost::throw_exception(cls(throwmsg.c_str(), code, \
106 (act_pos).get_line(), (act_pos).get_column(), \
107 (act_pos).get_file().c_str())); \
112 #define BOOST_WAVE_THROW_VAR(cls, code, msg, act_pos) \
114 using namespace boost::wave; \
115 std::stringstream stream; \
116 stream << cls::severity_text(code) << ": " \
117 << cls::error_text(code); \
118 if ((msg)[0] != 0) stream << ": " << (msg); \
119 stream << std::ends; \
120 boost::throw_exception(cls(stream.str().c_str(), code, \
121 (act_pos).get_line(), (act_pos).get_column(), \
122 (act_pos).get_file().c_str())); \
125 #endif // BOOST_NO_STRINGSTREAM
126 #endif // BOOST_WAVE_THROW_VAR
128 #endif // !defined(BOOST_WAVE_CPP_THROW_HPP_INCLUDED)