File indexing completed on 2025-01-18 09:53:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #if !defined(BOOST_WAVE_CPP_THROW_HPP_INCLUDED)
0012 #define BOOST_WAVE_CPP_THROW_HPP_INCLUDED
0013
0014 #include <string>
0015 #include <boost/throw_exception.hpp>
0016
0017 #ifdef BOOST_NO_STRINGSTREAM
0018 #include <strstream>
0019 #else
0020 #include <sstream>
0021 #endif
0022
0023 namespace boost { namespace wave { namespace util
0024 {
0025 #ifdef BOOST_NO_STRINGSTREAM
0026 template <typename Exception, typename S1, typename Pos>
0027 void throw_(typename Exception::error_code code, S1 msg, Pos const& pos)
0028 {
0029 std::strstream stream;
0030 stream << Exception::severity_text(code) << ": "
0031 << Exception::error_text(code);
0032 if (msg[0] != 0)
0033 stream << ": " << msg;
0034 stream << std::ends;
0035 std::string throwmsg = stream.str(); stream.freeze(false);
0036 boost::throw_exception(Exception(throwmsg.c_str(), code,
0037 pos.get_line(), pos.get_column(), pos.get_file().c_str()));
0038 }
0039
0040 template <typename Exception, typename Context, typename S1, typename Pos>
0041 void throw_(Context& ctx, typename Exception::error_code code,
0042 S1 msg, Pos const& pos)
0043 {
0044 std::strstream stream;
0045 stream << Exception::severity_text(code) << ": "
0046 << Exception::error_text(code);
0047 if (msg[0] != 0)
0048 stream << ": " << msg;
0049 stream << std::ends;
0050 std::string throwmsg = stream.str(); stream.freeze(false);
0051 ctx.get_hooks().throw_exception(ctx.derived(),
0052 Exception(throwmsg.c_str(), code, pos.get_line(), pos.get_column(),
0053 pos.get_file().c_str()));
0054 }
0055
0056 template <typename Exception, typename S1, typename Pos, typename S2>
0057 void throw_(typename Exception::error_code code, S1 msg, Pos const& pos,
0058 S2 name)
0059 {
0060 std::strstream stream;
0061 stream << Exception::severity_text(code) << ": "
0062 << Exception::error_text(code);
0063 if (msg[0] != 0)
0064 stream << ": " << msg;
0065 stream << std::ends;
0066 std::string throwmsg = stream.str(); stream.freeze(false);
0067 boost::throw_exception(Exception(throwmsg.c_str(), code,
0068 pos.get_line(), pos.get_column(), pos.get_file().c_str(), name));
0069 }
0070
0071 template <typename Exception, typename Context, typename S1, typename Pos,
0072 typename S2>
0073 void throw_(Context& ctx, typename Exception::error_code code,
0074 S1 msg, Pos const& pos, S2 name)
0075 {
0076 std::strstream stream;
0077 stream << Exception::severity_text(code) << ": "
0078 << Exception::error_text(code);
0079 if (msg[0] != 0)
0080 stream << ": " << msg;
0081 stream << std::ends;
0082 std::string throwmsg = stream.str(); stream.freeze(false);
0083 ctx.get_hooks().throw_exception(ctx.derived(),
0084 Exception(throwmsg.c_str(), code, pos.get_line(), pos.get_column(),
0085 pos.get_file().c_str(), name));
0086 }
0087 #else
0088 template <typename Exception, typename S1, typename Pos>
0089 void throw_(typename Exception::error_code code, S1 msg, Pos const& pos)
0090 {
0091 std::stringstream stream;
0092 stream << Exception::severity_text(code) << ": "
0093 << Exception::error_text(code);
0094 if (msg[0] != 0)
0095 stream << ": " << msg;
0096 stream << std::ends;
0097 std::string throwmsg = stream.str();
0098 boost::throw_exception(Exception(throwmsg.c_str(), code,
0099 pos.get_line(), pos.get_column(), pos.get_file().c_str()));
0100 }
0101
0102 template <typename Exception, typename Context, typename S1, typename Pos>
0103 void throw_(Context& ctx, typename Exception::error_code code,
0104 S1 msg, Pos const& pos)
0105 {
0106 std::stringstream stream;
0107 stream << Exception::severity_text(code) << ": "
0108 << Exception::error_text(code);
0109 if (msg[0] != 0)
0110 stream << ": " << msg;
0111 stream << std::ends;
0112 std::string throwmsg = stream.str();
0113 ctx.get_hooks().throw_exception(ctx.derived(),
0114 Exception(throwmsg.c_str(), code, pos.get_line(), pos.get_column(),
0115 pos.get_file().c_str()));
0116 }
0117
0118 template <typename Exception, typename S1, typename Pos, typename S2>
0119 void throw_(typename Exception::error_code code, S1 msg, Pos const& pos,
0120 S2 name)
0121 {
0122 std::stringstream stream;
0123 stream << Exception::severity_text(code) << ": "
0124 << Exception::error_text(code);
0125 if (msg[0] != 0)
0126 stream << ": " << msg;
0127 stream << std::ends;
0128 std::string throwmsg = stream.str();
0129 boost::throw_exception(Exception(throwmsg.c_str(), code,
0130 pos.get_line(), pos.get_column(), pos.get_file().c_str(), name));
0131 }
0132
0133 template <typename Exception, typename Context, typename S1, typename Pos1,
0134 typename S2>
0135 void throw_(Context& ctx, typename Exception::error_code code,
0136 S1 msg, Pos1 const& pos, S2 name)
0137 {
0138 std::stringstream stream;
0139 stream << Exception::severity_text(code) << ": "
0140 << Exception::error_text(code);
0141 if (msg[0] != 0)
0142 stream << ": " << msg;
0143 stream << std::ends;
0144 std::string throwmsg = stream.str();
0145 ctx.get_hooks().throw_exception(ctx.derived(),
0146 Exception(throwmsg.c_str(), code, pos.get_line(), pos.get_column(),
0147 pos.get_file().c_str(), name));
0148 }
0149 #endif
0150 }}}
0151
0152
0153
0154 #if !defined(BOOST_WAVE_THROW)
0155 #define BOOST_WAVE_THROW(cls, code, msg, act_pos) \
0156 boost::wave::util::throw_<cls>(cls::code, msg, act_pos) \
0157
0158
0159 #define BOOST_WAVE_THROW_CTX(ctx, cls, code, msg, act_pos) \
0160 boost::wave::util::throw_<cls>(ctx, cls::code, msg, act_pos) \
0161
0162 #endif
0163
0164
0165
0166 #if !defined(BOOST_WAVE_THROW_NAME_CTX)
0167 #define BOOST_WAVE_THROW_NAME_CTX(ctx, cls, code, msg, act_pos, name) \
0168 boost::wave::util::throw_<cls>(ctx, cls::code, msg, act_pos, name) \
0169
0170 #endif
0171
0172
0173
0174 #if !defined(BOOST_WAVE_THROW_VAR_CTX)
0175 #define BOOST_WAVE_THROW_VAR_CTX(ctx, cls, code, msg, act_pos) \
0176 boost::wave::util::throw_<cls>(ctx, code, msg, act_pos) \
0177
0178 #endif
0179
0180 #endif