[29] | 1 | /*============================================================================= |
---|
| 2 | Boost.Wave: A Standard compliant C++ preprocessor library |
---|
| 3 | |
---|
| 4 | http://www.boost.org/ |
---|
| 5 | |
---|
| 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 | =============================================================================*/ |
---|
| 10 | |
---|
| 11 | #if !defined(BOOST_WAVE_CPP_THROW_HPP_INCLUDED) |
---|
| 12 | #define BOOST_WAVE_CPP_THROW_HPP_INCLUDED |
---|
| 13 | |
---|
| 14 | #include <string> |
---|
| 15 | #include <boost/throw_exception.hpp> |
---|
| 16 | |
---|
| 17 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 18 | // helper macro for throwing exceptions |
---|
| 19 | #if !defined(BOOST_WAVE_THROW) |
---|
| 20 | #ifdef BOOST_NO_STRINGSTREAM |
---|
| 21 | #include <strstream> |
---|
| 22 | #define BOOST_WAVE_THROW(cls, code, msg, act_pos) \ |
---|
| 23 | { \ |
---|
| 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())); \ |
---|
| 34 | } \ |
---|
| 35 | /**/ |
---|
| 36 | #else |
---|
| 37 | #include <sstream> |
---|
| 38 | #define BOOST_WAVE_THROW(cls, code, msg, act_pos) \ |
---|
| 39 | { \ |
---|
| 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())); \ |
---|
| 49 | } \ |
---|
| 50 | /**/ |
---|
| 51 | #endif // BOOST_NO_STRINGSTREAM |
---|
| 52 | #endif // BOOST_WAVE_THROW |
---|
| 53 | |
---|
| 54 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 55 | // helper macro for throwing exceptions with additional parameter |
---|
| 56 | #if !defined(BOOST_WAVE_THROW_NAME) |
---|
| 57 | #ifdef BOOST_NO_STRINGSTREAM |
---|
| 58 | #include <strstream> |
---|
| 59 | #define BOOST_WAVE_THROW_NAME(cls, code, msg, act_pos, name) \ |
---|
| 60 | { \ |
---|
| 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))); \ |
---|
| 71 | } \ |
---|
| 72 | /**/ |
---|
| 73 | #else |
---|
| 74 | #include <sstream> |
---|
| 75 | #define BOOST_WAVE_THROW_NAME(cls, code, msg, act_pos, name) \ |
---|
| 76 | { \ |
---|
| 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))); \ |
---|
| 86 | } \ |
---|
| 87 | /**/ |
---|
| 88 | #endif // BOOST_NO_STRINGSTREAM |
---|
| 89 | #endif // BOOST_WAVE_THROW_NAME |
---|
| 90 | |
---|
| 91 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 92 | // helper macro for throwing exceptions with additional parameter |
---|
| 93 | #if !defined(BOOST_WAVE_THROW_VAR) |
---|
| 94 | #ifdef BOOST_NO_STRINGSTREAM |
---|
| 95 | #include <strstream> |
---|
| 96 | #define BOOST_WAVE_THROW_VAR(cls, code, msg, act_pos) \ |
---|
| 97 | { \ |
---|
| 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())); \ |
---|
| 108 | } \ |
---|
| 109 | /**/ |
---|
| 110 | #else |
---|
| 111 | #include <sstream> |
---|
| 112 | #define BOOST_WAVE_THROW_VAR(cls, code, msg, act_pos) \ |
---|
| 113 | { \ |
---|
| 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())); \ |
---|
| 123 | } \ |
---|
| 124 | /**/ |
---|
| 125 | #endif // BOOST_NO_STRINGSTREAM |
---|
| 126 | #endif // BOOST_WAVE_THROW_VAR |
---|
| 127 | |
---|
| 128 | #endif // !defined(BOOST_WAVE_CPP_THROW_HPP_INCLUDED) |
---|