1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
2 | <html> |
---|
3 | <head> |
---|
4 | <title>The Context Object</title> |
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
6 | <link rel="stylesheet" href="theme/style.css" type="text/css"> |
---|
7 | </head> |
---|
8 | <body text="#000000" background="theme/bkd.gif"> |
---|
9 | <table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif"> |
---|
10 | <tr> |
---|
11 | <td width="21"> <h1></h1></td> |
---|
12 | <td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">The |
---|
13 | Context Object</font></b></font></td> |
---|
14 | <td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td> |
---|
15 | </tr> |
---|
16 | </table> |
---|
17 | <br> |
---|
18 | <table border="0"> |
---|
19 | <tr> |
---|
20 | <td width="10"></td> |
---|
21 | <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td> |
---|
22 | <td width="30"><a href="quickstart.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td> |
---|
23 | <td width="30"><a href="class_reference_inptpolcy.html"><img src="theme/r_arr.gif" border="0"></a></td> |
---|
24 | </tr> |
---|
25 | </table> |
---|
26 | <blockquote> |
---|
27 | <p><a href="class_reference_context.html#introduction">Introduction</a><br> |
---|
28 | <a href="class_reference_context.html#header_synopsis">Header 'wave/context.hpp' synopsis</a><br> |
---|
29 | <a href="class_reference_context.html#public_typedefs">Public Typedefs</a><br> |
---|
30 | <a href="class_reference_context.html#template_parameters">Template parameters</a><br> |
---|
31 | <a href="class_reference_context.html#member_functions">Member functions</a></p> |
---|
32 | </blockquote> |
---|
33 | <h2><b><a name="introduction"></a>Introduction</b></h2> |
---|
34 | <p>The <tt>boost::wave::context<></tt> object is the main user visible object of |
---|
35 | the <tt>Wave</tt> library. It exists to generate the pair of iterators, which |
---|
36 | while dereferenced return the preprocessed tokens. Additionally it is used |
---|
37 | to control other aspects of the preprocessing, such as </p> |
---|
38 | <blockquote> |
---|
39 | <p><STRONG><IMG id="IMG1" height="13" src="theme/bullet.gif" width="13"></STRONG> include |
---|
40 | search paths, which define, where to search for files to be included with |
---|
41 | <tt>#include <...></tt> and <tt>#include "..."</tt> directives<br> |
---|
42 | <STRONG><img src="theme/bullet.gif" width="13" height="13"> </STRONG>which |
---|
43 | macros to predefine and which of the predefined macros to undefine<br> |
---|
44 | <STRONG><img src="theme/bullet.gif" width="13" height="13"> </STRONG>several |
---|
45 | other options as for instance to control, whether to enable several extensions |
---|
46 | to the C++ Standard (as for instance variadics and placemarkers) or not.</p> |
---|
47 | </blockquote> |
---|
48 | <h2><b><a name="header_synopsis"></a>Header <a href="http://cvs.sourceforge.net/viewcvs.py/boost/boost/boost/wave/cpp_context.hpp?view=markup">wave/cpp_context.hpp</a> |
---|
49 | synopsis</b></h2> |
---|
50 | <pre><span class="keyword">namespace</span> <span class="identifier">boost</span> { |
---|
51 | <span class="keyword">namespace</span> <span class="identifier">wave</span> { |
---|
52 | |
---|
53 | <span class="keyword">template</span> < |
---|
54 | <span class="keyword">typename</span> Iterator, <span class="keyword">typename</span> LexIterator, |
---|
55 | <span class="keyword">typename</span> InputPolicy, <span class="keyword">typename</span> TracePolicy |
---|
56 | > |
---|
57 | <span class="keyword">class</span> context <span class="special">:</span> <span class="keyword">public</span> InputPolicy |
---|
58 | { |
---|
59 | <span class="keyword">public</span>: |
---|
60 | |
---|
61 | <span class="keyword">typedef</span> pp_iterator<context> iterator_type; |
---|
62 | <span class="keyword">typedef</span> Token token_type; |
---|
63 | <span class="keyword">typedef</span> <span class="keyword">typename</span> token_type::position_type position_type; |
---|
64 | |
---|
65 | <span class="comment">// constructor</span> |
---|
66 | <a href="class_reference_context.html#constructor">context</a>(Iterator<span class="keyword"> const</span> &first_, |
---|
67 | Iterator <span class="keyword">const</span> &last_, |
---|
68 | <span class="keyword">char const</span> *fname = <span class="string">"<Unknown>"</span>, |
---|
69 | TracePolicy &trace = TracePolicy()) |
---|
70 | |
---|
71 | <span class="comment">// iterator interface</span> |
---|
72 | iterator_type <a href="class_reference_context.html#iterator_interface_begin">begin</a>() <span class="keyword">const</span>; |
---|
73 | iterator_type <a href="class_reference_context.html#iterator_interface_end">end</a>() <span class="keyword">const</span>; |
---|
74 | |
---|
75 | <span class="comment">// maintain include paths</span> |
---|
76 | <span class="keyword">bool</span> <a href="class_reference_context.html#add_include_path">add_include_path</a>(<span class="keyword">char const</span> *path_); |
---|
77 | <span class="keyword">bool</span> <a href="class_reference_context.html#add_sysinclude_path">add_sysinclude_path</a>(<span class="keyword">char const</span> *path_); |
---|
78 | <span class="keyword">void</span> <a href="class_reference_context.html#set_sysinclude_delimiter">set_sysinclude_delimiter</a>(); |
---|
79 | |
---|
80 | size_t <a href="class_reference_context.html#get_iteration_depth">get_iteration_depth</a>() <span class="keyword">const</span>; |
---|
81 | |
---|
82 | <span class="comment">// maintain defined macros</span> |
---|
83 | <span class="keyword">bool</span> <a href="class_reference_context.html#add_macro_definition">add_macro_definition</a>(<span class="keyword">std::string</span> macrostring, |
---|
84 | <span class="keyword">bool</span> is_predefined = <span class="keyword">false</span>); |
---|
85 | <span class="keyword">bool</span> <a href="class_reference_context.html#is_defined_macro">is_defined_macro</a>(<span class="keyword">std::string const</span> &name) <span class="keyword">const</span>; |
---|
86 | <span class="keyword">bool</span> <a href="class_reference_context.html#remove_macro_definition">remove_macro_definition</a>(<span class="keyword">std::string const</span> &name, |
---|
87 | <span class="keyword">bool</span> even_predefined = <span class="keyword">false</span>); |
---|
88 | <span class="keyword">void</span> <a href="class_reference_context.html#reset_macro_definitions">reset_macro_definitions</a>(); |
---|
89 | |
---|
90 | <span class="comment">// other options</span> |
---|
91 | <span class="keyword">void</span> <a href="class_reference_context.html#language_support">set_language</a>(language_support enable); |
---|
92 | language_support <a href="class_reference_context.html#language_support">get_language</a>() <span class="keyword">const</span>;<br> |
---|
93 | <span class="keyword">void</span> <a href="class_reference_context.html#set_max_include_nesting_depth">set_max_include_nesting_depth</a>(std::size_t new_depth);<br> size_t <a href="class_reference_context.html#set_max_include_nesting_depth">get_max_include_nesting_depth</a>() <span class="keyword">const</span>;<br> |
---|
94 | <span class="comment">// get the Wave version information </span> |
---|
95 | <span class="keyword">static std::string</span> <a href="class_reference_context.html#get_version">get_version</a>(); |
---|
96 | <span class="keyword">static std::string</span> <a href="class_reference_context.html#get_version">get_version_string</a>(); |
---|
97 | }; |
---|
98 | |
---|
99 | } <span class="comment">// namespace wave</span> |
---|
100 | } <span class="comment">// namespace boost</span></pre> |
---|
101 | <h2><b><a name="template_parameters"></a>Template parameters</b></h2> |
---|
102 | <p>The <tt>boost::wave::context</tt> object has three template parameters to specify |
---|
103 | the concrete behaviour of its operation. The following table describes these |
---|
104 | with more detail.</p> |
---|
105 | <table width="90%" border="0" align="center"> |
---|
106 | <tr> |
---|
107 | <td colspan="2" class="table_title"><b>Template parameters required for the |
---|
108 | <tt>boost::wave::context</tt> class </b></td> |
---|
109 | </tr> |
---|
110 | <tr> |
---|
111 | <td width="32%" class="table_cells"><code>Iterator</code></td> |
---|
112 | <td width="68%" class="table_cells"><p>The type of the underlying iterator, |
---|
113 | through which the input stream is accessed. <br> |
---|
114 | This should be at least an <tt>forward_iterator</tt> type iterator.</p></td> |
---|
115 | </tr> |
---|
116 | <tr> |
---|
117 | <td class="table_cells"><code>LexIterator</code></td> |
---|
118 | <td class="table_cells"><p>The type of the lexer type to be used by the <tt>Wave</tt> |
---|
119 | library to identify tokens in the input stream.</p></td> |
---|
120 | </tr> |
---|
121 | <tr> |
---|
122 | <td class="table_cells"><code>InputPolicy</code></td> |
---|
123 | <td class="table_cells"><p>The type of the input policy class, which allows |
---|
124 | to customize the behaviour of the Wave library and the type of the iterators |
---|
125 | to use, when it comes to including and opening an included file.</p></td> |
---|
126 | </tr> |
---|
127 | <tr> |
---|
128 | <td class="table_cells"><code>TracePolicy</code></td> |
---|
129 | <td class="table_cells"><p>The type of the trace policy class, which allows |
---|
130 | to customize the trace output generated while expanding macros. </p></td> |
---|
131 | </tr> |
---|
132 | </table> |
---|
133 | <p>For further information about the lexer type to use, please refer to the <a href="class_reference_lexer.html">The |
---|
134 | Lexer Interface </a>.</p> |
---|
135 | <p>If the template parameter <tt>InputPolicy</tt> is omitted, the template <tt>wave::iteration_context_policies::load_file_to_string</tt> |
---|
136 | is used. For further information about the input policy, please refer to the |
---|
137 | topic <a href="class_reference_inptpolcy.html">The Input Policy</a>.</p> |
---|
138 | <p>If the template parameter TracePolicyT is omitted, the <tt>wave::macro_trace_policies::no_tracing</tt> |
---|
139 | policy type is used, i.e. by default there is no tracing performed. For further |
---|
140 | information about the tracing policy, please refer to the topic <a href="class_reference_ctxpolicy.html">The |
---|
141 | Tracing Policy</a>. </p> |
---|
142 | <h2><a name="public_typedefs"></a>Public Typedefs</h2> |
---|
143 | <p>The <tt>boost::wave::context</tt> template defines the following public typedefs, which may be useful while using this class:</p> |
---|
144 | <table width="90%" border="0" align="center"> |
---|
145 | <tr> |
---|
146 | <td colspan="2" class="table_title"><b>Public typedef's defined by the <tt>boost::wave::context</tt> class </b></td> |
---|
147 | </tr> |
---|
148 | <tr> |
---|
149 | <td class="table_cells"><code>iterator_type</code></td> |
---|
150 | <td class="table_cells"><p>The <tt>Iterator</tt> template parameter provided, while the <tt>context</tt> class was instantiated. </p></td> |
---|
151 | </tr> |
---|
152 | <tr> |
---|
153 | <td class="table_cells"><code>lex_type</code></td> |
---|
154 | <td class="table_cells"><p>The <tt>LexIterator</tt> template parameter provided, while the <tt>context</tt> class was instantiated. </p></td> |
---|
155 | </tr> |
---|
156 | <tr> |
---|
157 | <td width="32%" class="table_cells"><code>token_type</code></td> |
---|
158 | <td width="68%" class="table_cells"><p>The token type, which is returned by the <tt>context</tt> generated iterators. This type is taken from the <tt>LexIterator</tt> template parameter provided, whicle the <tt>context</tt> class was instantiated.</p></td> |
---|
159 | </tr> |
---|
160 | <tr> |
---|
161 | <td class="table_cells"><code>input_policy_type</code></td> |
---|
162 | <td class="table_cells"><p>The <tt>InputPolicy</tt> template parameter provided, while the <tt>context</tt> class was instantiated. </p></td> |
---|
163 | </tr> |
---|
164 | <tr> |
---|
165 | <td class="table_cells"><code>trace_policy_type</code></td> |
---|
166 | <td class="table_cells"><p>The <tt>TracePolicy</tt> template parameter provided, while the <tt>context</tt> class was instantiated. </p></td> |
---|
167 | </tr> |
---|
168 | <tr> |
---|
169 | <td class="table_cells"><code>position_type</code></td> |
---|
170 | <td class="table_cells"><p>The type of the position information contained in every returned token, which describes the point, at which the given token was recognised. </p></td> |
---|
171 | </tr> |
---|
172 | </table> |
---|
173 | <h2><b><a name="member_functions"></a>Member functions</b></h2> |
---|
174 | <p><b><a name="constructor" id="constructor"></a>Constructor</b></p> |
---|
175 | <pre> context(Iterator <span class="keyword">const</span> &first, |
---|
176 | Iterator <span class="keyword">const</span> &last, <span class="keyword">char</span> <span class="keyword">const</span> *filename, |
---|
177 | TracePolicy &trace);</pre> |
---|
178 | <p>Constructs a context object on top of the input stream given by the pair |
---|
179 | of auxilliary iterators <tt>[first, last)</tt>. The iterators should |
---|
180 | be at least <tt>forward_iterator</tt> type iterators. The filename parameter |
---|
181 | is to be supplied for informational purposes only. This string is used for |
---|
182 | indicating the token positions inside the input stream, it is not validated |
---|
183 | against the file system. If the filename parameter is not given it defaults |
---|
184 | to <span class="copyright">"<Unknown>"</span>. If the trace |
---|
185 | parameter isn't supplied it defaults to a default constructed <tt>TracePolicy</tt> |
---|
186 | object. </p> |
---|
187 | <p>Additionally the macro symbol table is filled with the predefined macros |
---|
188 | and the current reference directory is set to the path of the given filename. |
---|
189 | If this filename does not reference valid file system item, the current reference |
---|
190 | directory is set to the current system directory. (The current reference directory |
---|
191 | is the file system path, which is used as the target directory during the |
---|
192 | processing of <tt>#include "..."</tt> directives).</p> |
---|
193 | <h3>Iterator interface</h3> |
---|
194 | <p>The pair of iterators returned by the <tt>context::begin</tt> and <tt>context::end</tt> |
---|
195 | functions is the main interface for accessing the preprocessed tokens from the |
---|
196 | preprocessor engine. While iterating over the given iterator range <tt>[begin, end)</tt> |
---|
197 | there are returned the preprocessed C++ tokens, which are generated on the fly |
---|
198 | from the underlying input stream. The returned iterators are conceptually of |
---|
199 | <tt>forward_iterator</tt> type.</p> |
---|
200 | <p><b><a name="iterator_interface_begin"></a></b><b>begin</b></p> |
---|
201 | <pre> iterator_type begin();</pre> |
---|
202 | <blockquote> |
---|
203 | <p>Initializes and returns the starting iterator for the preprocessed token |
---|
204 | stream.</p> |
---|
205 | |
---|
206 | </blockquote> |
---|
207 | <p><b><a name="iterator_interface_end" id="iterator_interface_end"></a></b><b>end</b></p> |
---|
208 | <pre> iterator_type end() <span class="keyword">const</span>;</pre> |
---|
209 | <blockquote> |
---|
210 | <p>Initializes and returns the end of stream iterator to compare with for detecting |
---|
211 | the end of the preprocessed token stream.</p> |
---|
212 | </blockquote> |
---|
213 | <h3>Maintain include paths</h3> |
---|
214 | <p>The <tt>Wave</tt> library maintains two separate search paths for include |
---|
215 | files. A search path for user include files and a search path for system include |
---|
216 | files. Any directories specified with the <a href="#add_include_path">add_include_path()</a> |
---|
217 | function before the function <a href="class_reference_context.html#set_sysinclude_delimiter">set_sysinclude_delimiter()</a> |
---|
218 | is called are searched only for the case of <tt>#include "..."</tt> |
---|
219 | directives, they are not searched for <tt>#include <file></tt> directives. |
---|
220 | I.e. these directories are added to the user include search path. </p> |
---|
221 | <p>If additional directories are specified with the <a href="#add_include_path">add_include_path()</a> |
---|
222 | function after a call to the function <a href="class_reference_context.html#set_sysinclude_delimiter">set_sysinclude_delimiter()</a>, |
---|
223 | these directories are searched for all <tt>#include</tt> directives. I.e. these |
---|
224 | directories are added to the system include search path.</p> |
---|
225 | <p>In addition, a call to the function <a href="class_reference_context.html#set_sysinclude_delimiter">set_sysinclude_delimiter()</a> |
---|
226 | inhibits the use of the current reference directory as the first search directory |
---|
227 | for <tt>#include "..."</tt> directives. Therefore, the current |
---|
228 | reference directory is searched only, if it is requested explicitly with a call |
---|
229 | to the function <a href="#add_include_path">add_include_path(".")</a>. |
---|
230 | </p> |
---|
231 | <p>Callig both functions, the <a href="class_reference_context.html#set_sysinclude_delimiter">set_sysinclude_delimiter()</a> |
---|
232 | and <a href="#add_include_path">add_include_path(".")</a> allows you |
---|
233 | to control precisely, which directories are searched before the current one |
---|
234 | and which are searched after.</p> |
---|
235 | <p>These functions are modelled after the command line behaviour implemented by |
---|
236 | the popular gcc compiler.<br> |
---|
237 | </p> |
---|
238 | <p><a name="add_include_path"></a><b>add_include_path</b></p> |
---|
239 | <pre> <span class="keyword">bool</span> add_include_path(<span class="keyword">char const</span> *path); |
---|
240 | </pre> |
---|
241 | <blockquote> |
---|
242 | <p>Adds the given file system path to the user include search paths. After a |
---|
243 | call to the <a href="class_reference_context.html#set_sysinclude_delimiter">set_sysinclude_delimiter()</a> |
---|
244 | this function adds the given file system path to the system include search |
---|
245 | paths. Note though, that the given path is validated against the file system. |
---|
246 | </p> |
---|
247 | <p>If the given path string does not form a name of a valid file system directory |
---|
248 | item, the function returns <tt>false</tt>. If the given path was successfully |
---|
249 | added to the include search paths in question, the function returns <tt>true</tt>.</p> |
---|
250 | </blockquote> |
---|
251 | <p><a name="add_sysinclude_path"></a><b>add_sysinclude_path</b></p> |
---|
252 | <pre> <span class="keyword">bool</span> add_sysinclude_path(<span class="keyword">char const</span> *path);</pre> |
---|
253 | <blockquote> |
---|
254 | <p>Adds the given file system path to the system include search paths. This |
---|
255 | function operates on the system include search path regardless of the mode |
---|
256 | of operation of the <a href="#add_include_path">add_include_path()</a>. Note |
---|
257 | though, that the given path is validated against the file system.</p> |
---|
258 | <p>If the given path string does not form a name of a valid file system directory |
---|
259 | item, the function returns <tt>false</tt>. If the given path was successfully |
---|
260 | added to the system include search paths, the function returns <tt>true</tt>.</p> |
---|
261 | </blockquote> |
---|
262 | <p><a name="set_sysinclude_delimiter"></a><b>set_sysinclude_delimiter</b></p> |
---|
263 | <pre> <span class="keyword">void</span> set_sysinclude_delimiter();</pre> |
---|
264 | <blockquote> |
---|
265 | <p>Switches the mode, how the <a href="#add_include_path">add_include_path()</a> |
---|
266 | function operates. By default the given file system path is added to the user |
---|
267 | include search paths. After calling this function a subsequent call to the |
---|
268 | <a href="#add_include_path">add_include_path()</a> adds the given file system |
---|
269 | path to the system include search paths. Additionally it inhibits the the |
---|
270 | use of the current reference directory as the first search directory for <tt>#include "..."</tt> |
---|
271 | directives.</p> |
---|
272 | </blockquote> |
---|
273 | <p><a name="get_iteration_depth"></a><b>get_iteration_depth</b></p> |
---|
274 | <pre> size_t get_iteration_depth() <span class="keyword">const</span>;</pre> |
---|
275 | <blockquote> |
---|
276 | <p>Returns the actual include iteration depth, i.e. the current number of include |
---|
277 | levels to be poped from the include iteration context, before the main (topmost) |
---|
278 | iteration context is reached.</p> |
---|
279 | </blockquote> |
---|
280 | <h3>Maintain defined macros</h3> |
---|
281 | <p><a name="add_macro_definition"></a><b>add_macro_definition</b></p> |
---|
282 | <pre><span class="keyword"> bool</span> add_macro_definition( |
---|
283 | <span class="keyword">std::string</span> macrostring, |
---|
284 | bool is_predefined); |
---|
285 | </pre> |
---|
286 | <blockquote> |
---|
287 | <p>Adds a new macro definition to the macro symbol table. The parameter <tt>macrostring</tt> |
---|
288 | should contain the macro to define in the command line format, i.e. something |
---|
289 | like <tt>MACRO(x)=definition</tt>. The following table describes this format |
---|
290 | in more detail. The parameter <tt>is_predefined</tt> should be true while |
---|
291 | defining predefined macros, i.e. macros, which are not undefinable with an |
---|
292 | <tt>#undef</tt> directive from inside the preprocessed input stream. If this |
---|
293 | parameter is not given, it defaults to <tt>false</tt>.</p> |
---|
294 | <table width="90%" border="0" align="center"> |
---|
295 | <tr> |
---|
296 | <td colspan="2" class="table_title"><b>Summary of possible formats for defining |
---|
297 | macros </b></td> |
---|
298 | </tr> |
---|
299 | <tr> |
---|
300 | <td width="32%" class="table_cells"><code>MACRO</code></td> |
---|
301 | <td width="68%" class="table_cells"><code>define <tt>MACRO</tt> as 1</code></td> |
---|
302 | </tr> |
---|
303 | <tr> |
---|
304 | <td class="table_cells"><code>MACRO=</code></td> |
---|
305 | <td class="table_cells"><code>define <tt>MACRO</tt> as nothing (empty)</code></td> |
---|
306 | </tr> |
---|
307 | <tr> |
---|
308 | <td class="table_cells"><code>MACRO=definition</code></td> |
---|
309 | <td class="table_cells"><code>define <tt>MACRO</tt> as <tt>definition</tt></code></td> |
---|
310 | </tr> |
---|
311 | <tr> |
---|
312 | <td width="32%" class="table_cells"><code>MACRO(x)</code></td> |
---|
313 | <td width="68%" class="table_cells"><code>define <tt>MACRO(x)</tt> as 1</code></td> |
---|
314 | </tr> |
---|
315 | <tr> |
---|
316 | <td class="table_cells"><code>MACRO(x)=</code></td> |
---|
317 | <td class="table_cells"><code>define <tt>MACRO(x)</tt> as nothing (empty)</code></td> |
---|
318 | </tr> |
---|
319 | <tr> |
---|
320 | <td class="table_cells"><code>MACRO(x)=definition</code></td> |
---|
321 | <td class="table_cells"><code>define <tt>MACRO(x)</tt> as <tt>definition</tt></code></td> |
---|
322 | </tr> |
---|
323 | </table> |
---|
324 | <p>The function returns <tt>false</tt>, if the macro to define already was defined |
---|
325 | and the new definition is equivalent to the existing one, it returns true, |
---|
326 | if the new macro was successfully added to the macro symbol table.</p> |
---|
327 | <p>If the given macro definition resembles a redefinition and the new macro |
---|
328 | is not identical to the already defined macro (in the sense defined by the |
---|
329 | C++ Standard), the function throws a corresponding <tt>preprocess_exception</tt>.</p> |
---|
330 | </blockquote> |
---|
331 | <p><a name="is_defined_macro"></a><b>is_defined_macro</b></p> |
---|
332 | <pre><span class="keyword"> bool</span> is_defined_macro(<span class="keyword">std::string const</span> &name) <span class="keyword">const</span>; </pre> |
---|
333 | <blockquote> |
---|
334 | <p>Returns, if a macro with the given <tt>name</tt> is defined, i.e. if it is |
---|
335 | contained in the macro symbol table.</p> |
---|
336 | </blockquote> |
---|
337 | <p><a name="remove_macro_definition"></a><b>remove_macro_definition</b></p> |
---|
338 | <pre><span class="keyword"> bool</span> remove_macro_definition( |
---|
339 | <span class="keyword">std::string const</span> &name, |
---|
340 | <span class="keyword">bool</span> even_predefined); </pre> |
---|
341 | <blockquote> |
---|
342 | <p>Removes the definition of the macro with the given <tt>name</tt> from the |
---|
343 | macro symbol table. This operation is equivalent to an <tt>#undef</tt> directive |
---|
344 | with this <tt>name</tt> executed from within the input stream. If the parameter |
---|
345 | <tt>even_predefined</tt> is <tt>true</tt>, then the macro is removed from |
---|
346 | the macro symbol table even, if it is defined as a predefined macro. </p> |
---|
347 | <p>Note though, that the following macros are <b>not</b> undefinable in any |
---|
348 | case: <tt>__FILE__</tt>, <tt>__LINE__</tt>, <tt>__DATE__</tt>, <tt>__TIME__</tt>, |
---|
349 | <tt>__cplusplus</tt>, <tt>__STDC__</tt>. If the parameter <tt>even_predefined</tt> |
---|
350 | is not given, it defaults to <tt>false</tt>.</p> |
---|
351 | <p>The function returns <tt>false</tt>, if the macro to undefine was not defined |
---|
352 | and returns <tt>true</tt> otherwise.</p> |
---|
353 | <p>If the macro to remove may not be undefined (it is a predefined macro and |
---|
354 | the parameter <tt>even_predefined</tt> is set to <tt>false</tt> or it is one |
---|
355 | of the mentioned not undefinable macros above) the function throws a <tt>preprocess_exception</tt>.</p> |
---|
356 | </blockquote> |
---|
357 | <p><a name="reset_macro_definitions"></a><b>reset_macro_definitions</b></p> |
---|
358 | <pre><span class="keyword"> void</span> reset_macro_definitions(); </pre> |
---|
359 | <blockquote> |
---|
360 | <p>Resets the macro symbol table to it's initial state, i.e. undefines all user defined macros and inserts the internal predefined macros as described <a href="predefined_macros.html">here</a>.</p> |
---|
361 | </blockquote> |
---|
362 | <h3><a name="get_version"></a>Get Version information</h3> |
---|
363 | <p><b>get_version</b></p> |
---|
364 | <pre><span class="keyword"> </span><span class="keyword">static std::string</span> get_version(); </pre> |
---|
365 | <blockquote> |
---|
366 | <p>Returns a string containing the current Wave version formatted as <span class="string">0xvvrsbbbb</span> |
---|
367 | (this is a string representation of the equivalent hexadecimal number), where |
---|
368 | <span class="literal">'vv'</span> is the version number, <span class="literal">'r'</span> |
---|
369 | the release number, <span class="literal">'s'</span> the subrelease number |
---|
370 | and <span class="literal">'bbbb'</span> the build number. A possible return |
---|
371 | value looks like <span class="literal">0x00910454</span>. The returned value |
---|
372 | is the same as is inserted in the preprocessed token stream, when the predefined |
---|
373 | macro <tt>__WAVE_VERSION__</tt> is expanded.</p> |
---|
374 | </blockquote> |
---|
375 | <p><b>get_version_str</b></p> |
---|
376 | <pre><span class="keyword"> </span><span class="keyword">static std::string</span> get_version_str(); </pre> |
---|
377 | <blockquote> |
---|
378 | <p>Returns a string containing the current Wave version formatted as <span class="string">"v.rr.ss.bbbb"</span>, |
---|
379 | where <span class="literal">'v'</span> is the version number, <span class="literal">'rr'</span> |
---|
380 | the release number, <span class="literal">'ss'</span> the subrelease number |
---|
381 | and <span class="literal">'bbbb'</span> the build number. A possible return |
---|
382 | value looks like <span class="literal">"0.9.1.454"</span>. The returned |
---|
383 | value is the same as is inserted in the preprocessed token stream, when the |
---|
384 | predefined macro <tt>__WAVE_VERSION_STR__</tt> is expanded.</p> |
---|
385 | </blockquote> |
---|
386 | <h3>Control extended options</h3> |
---|
387 | <p><a name="language_support"></a>set_language<br> |
---|
388 | get_language</p> |
---|
389 | <pre><span class="keyword"> void</span> set_language(<span class="keyword">language_support</span> language); |
---|
390 | <span class="keyword">language_support</span> get_language() <span class="keyword">const</span>;</pre> |
---|
391 | <blockquote> |
---|
392 | <p>This functions allows to specify the language mode, in which the <tt>Wave</tt> |
---|
393 | library should work. The possible language modes are defined by the enumerated |
---|
394 | type <tt>language_support</tt>:</p> |
---|
395 | <pre> <span class="keyword">enum</span> language_support { |
---|
396 | <span class="comment">// support flags for C++98</span> |
---|
397 | support_normal = 0x01, |
---|
398 | support_cpp = support_normal, |
---|
399 | |
---|
400 | <span class="comment">// support flags for C99</span> |
---|
401 | support_long_long = 0x02, |
---|
402 | support_variadics = 0x04, |
---|
403 | support_c99 = support_variadics | |
---|
404 | support_long_long | 0x08, |
---|
405 | |
---|
406 | <span class="comment"> // the mask for the main language settings</span> |
---|
407 | support_option_mask = 0xFF00,<br> |
---|
408 | <span class="comment"> // additional fine tuning of the general behaviour</span> |
---|
409 | support_option_preserve_comments = 0x0100,<br> support_option_no_character_validation = 0x0200,<br> support_option_convert_trigraphs = 0x0400<br> };</pre> |
---|
410 | <p>When used with <tt>support_variadics</tt> the support for variadics, placemarkers |
---|
411 | and the <tt>operator _Pragma()</tt> is enabled in normal C++ mode. When used with the <tt>support_long_long</tt> the support for long long suffixes is enabled in C++ mode. </p> |
---|
412 | <p>The <tt>support_c99</tt> switches to the C99 language support, which enables variadics, placemarkers, the <tt>operator _Pragma</tt> and long long suffixes by default. Additionally it disables the C++ specific tokens such as <tt>'->*'</tt>, <tt>'.*'</tt>, <tt>'::'</tt> etc. </p> |
---|
413 | <p>The <tt>support_option_...</tt> values are to be used in conjunction with the main language settings (<tt>support_normal</tt> and <tt>support_c99</tt>) . </p> |
---|
414 | <ul> |
---|
415 | <li>If the <tt>support_option_preserve_comments</tt> flag is set, the <tt>Wave</tt> library preserves almost all comments in the source code. The only comments not preserved are those contained inside macro definitions. By default all comments are replaced by a single space. </li> |
---|
416 | <li>If the <tt>support_option_no_character_validation</tt> flag is set , the <tt>Wave</tt> library doesn't validate universal character literals (given in the form of <tt>'u1234'</tt> or <tt>'U12345678'</tt>) to be in the allowed value range. This flag is merely used for internal purposes by the testing framework and will be rarely used by a user of the library.</li> |
---|
417 | <li>If the <tt>support_option_convert_trigraphs</tt> flag is set, the <tt>Wave</tt> library replaces all occurences of trigraph characters with their non-trigraph character sequence (i.e. <tt>'??='</tt> is replaced by <tt>'#'</tt> etc.) . By default no replacement is performed. </li> |
---|
418 | </ul> |
---|
419 | </blockquote> |
---|
420 | <p><strong>Note:</strong> The set_language function internally resets the list of defined macros, so please be careful not to call it after you have defined your own macros already. </p> |
---|
421 | <p><a name="set_max_include_nesting_depth" id="set_max_include_nesting_depth"></a>set_max_include_nesting_depth<br> |
---|
422 | g et_max_include_nesting_depth</p> |
---|
423 | <pre><span class="keyword"> void</span> set_max_include_nesting_depth(size_t new_depth); |
---|
424 | size_t get_max_include_nesting_depth() <span class="keyword">const</span>;</pre> |
---|
425 | <blockquote> |
---|
426 | <p>This functions allow to set or to get the maximal possible include file nesting |
---|
427 | depth supported by the <tt>Wave</tt> library. The initial value for this is |
---|
428 | determined by the preprocessing constant <tt>WAVE_MAX_INCLUDE_LEVEL_DEPTH</tt> |
---|
429 | (see <a href="compiletime_config.html">here</a>).</p> |
---|
430 | </blockquote> |
---|
431 | <table border="0"> |
---|
432 | <tr> |
---|
433 | <td width="10"></td> |
---|
434 | <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td> |
---|
435 | <td width="30"><a href="quickstart.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td> |
---|
436 | <td width="30"><a href="class_reference_inptpolcy.html"><img src="theme/r_arr.gif" border="0"></a></td> |
---|
437 | </tr> |
---|
438 | </table> |
---|
439 | <hr size="1"> |
---|
440 | <p class="copyright">Copyright © 2003-2005 Hartmut Kaiser<br> |
---|
441 | <br> |
---|
442 | <font size="2">Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p> |
---|
443 | <span class="updated"></span> |
---|
444 | <p class="copyright"><span class="updated">Last updated: |
---|
445 | <!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005 12:23<!-- #EndDate --> |
---|
446 | </span> |
---|
447 | </p> |
---|
448 | <p> </p> |
---|
449 | </body> |
---|
450 | </html> |
---|