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