class_reference_ctxpolicy.html 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>The Context Policy</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <link href="theme/style.css" rel="stylesheet" type="text/css">
  7. <style type="text/css">
  8. .style1 {
  9. background-color: #EEEEEE;
  10. }
  11. </style>
  12. </head>
  13. <body>
  14. <table background="theme/bkd2.gif" border="0" cellspacing="2" width="100%">
  15. <tbody>
  16. <tr>
  17. <td width="21">&nbsp;</td>
  18. <td width="885"><font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>The
  19. Context Policy </b></font></td>
  20. <td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" align="right" border="0" height="68" width="93"></a></td>
  21. </tr>
  22. </tbody>
  23. </table>
  24. <br>
  25. <table border="0">
  26. <tbody>
  27. <tr>
  28. <td width="10"></td>
  29. <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
  30. <td width="30"><a href="class_reference_inptpolcy.html"><img src="theme/l_arr.gif" border="0" height="19" width="20"></a></td>
  31. <td width="30"><a href="class_reference_lexer.html"><img src="theme/r_arr.gif" border="0"></a></td>
  32. </tr>
  33. </tbody>
  34. </table>
  35. <blockquote>
  36. <p><a href="class_reference_ctxpolicy.html#introduction">Introduction</a><br>
  37. <a href="class_reference_ctxpolicy.html#header_synopsis">Header 'wave/preprocessing_hooks.hpp'
  38. synopsis</a><br>
  39. <a href="class_reference_ctxpolicy.html#member_functions">Member functions</a></p>
  40. </blockquote>
  41. <h2><b><a name="introduction"></a>Introduction</b></h2>
  42. <p>Please note that the following description relates to the new
  43. preprocessing hooks interface used by default starting with the Boost
  44. V1.35.0 release. If you are interested in the older interface please
  45. look <a href="class_ref_ctxpolicy_depr.html">here</a>. </p>
  46. <p>The context policy is used to provide callback hooks, which are called from inside the library into the user code, whenever</p>
  47. <ul>
  48. <li>a preprocessor directive has been recognized, </li>
  49. <li>a token is about to be returned from the preprocessor, </li>
  50. <li>a macro get's defined or undefined, </li>
  51. <li>a macro has been expanded or rescanned,</li>
  52. <li>an include file has been opened or closed, </li>
  53. <li>a conditional expression was evaluated,</li>
  54. <li>a token has to be skipped because it is contained in a non-evaluated conditional block, </li>
  55. <li> a pragma of the form <tt>'wave option[(value)]'</tt> has been recognized. </li>
  56. </ul>
  57. <p>This policy type is used as a template parameter to the <a href="class_reference_context.html"><tt>boost::wave::context&lt;&gt;</tt></a> object, where the default policy provides empty hook functions only.</p>
  58. <h2><a name="header_synopsis"></a>Header <a href="http://svn.boost.org/trac/boost/browser/trunk/boost/wave/preprocessing_hooks.hpp">wave/preprocessing_hooks.hpp</a> synopsis</h2>
  59. <pre><span class="keyword">namespace</span> boost {<br><span class="keyword">namespace</span> wave {<br><span class="keyword">namespace</span> context_policies {<br> <br> <span class="keyword">struct</span> default_preprocessing_hooks {<br><br> <span class="comment">// general hook functions</span>
  60. <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> TokenT&gt;<br> <span class="keyword">bool</span> <a href="class_reference_ctxpolicy.html#found_directive">found_directive</a>(ContextT <span class="keyword">const</span> &amp;ctx, <br> TokenT <span class="keyword">const </span>&amp;directive);<br>
  61. <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> ExceptionT&gt;<br> void <a href="class_reference_ctxpolicy.html#trow_exception">throw_exception</a>(ContextT <span class="keyword">const</span> &amp;ctx, <br> ExceptionT <span class="keyword">const</span>&amp; e);<br><br> <span class="comment">// test, whether a given token may be skipped</span><br> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT&gt;<br> <span class="keyword">bool</span> <a href="class_reference_ctxpolicy.html#may_skip_whitespace">may_skip_whitespace</a> (ContextT <span class="keyword">const</span>&amp; ctx,<br> TokenT &amp;token, <span class="keyword">bool</span> &amp;skipped_newline);<br>
  62. <span class="comment">// Conditional compilation</span><span class="keyword">
  63. template</span> &lt;<br> <span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> TokenT, <br> <span class="keyword">typename</span> ContainerT<br> &gt;<br> <span class="keyword">bool</span> <a href="class_reference_ctxpolicy.html#evaluated_conditional_expression">evaluated_conditional_expression</a>(<br> ContextT <span class="keyword">const</span> &amp;ctx, TokenT <span class="keyword">const</span>&amp; directive, <br> ContainerT <span class="keyword">const</span>&amp; expression, <span class="keyword">bool</span> expression_value);<br>
  64. <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> TokenT&gt;<br> <span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#skipped_token">skipped_token</a>(ContextT <span class="keyword">const</span> &amp;ctx, <br> TokenT <span class="keyword">const</span>&amp; token);<br><br> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> TokenT&gt;<br> TokenT <span class="keyword">const</span>&amp; <a href="class_reference_ctxpolicy.html#generated_token">generated_token</a>(ContextT <span class="keyword">const</span> &amp;ctx, <br> TokenT <span class="keyword">const</span>&amp; token);<br><br> <span class="comment">// macro expansion tracing</span><span class="keyword">
  65. template</span> &lt;<span class="keyword">
  66. typename</span> ContextT, <span class="keyword">typename</span> TokenT, <span class="keyword">typename</span> ContainerT,<br> <span class="keyword">typename</span> IteratorT<br> &gt;<br> <span class="keyword">bool</span> <a href="class_reference_ctxpolicy.html#expanding_function_like_macro">expanding_function_like_macro</a>(<br> ContextT <span class="keyword">const</span> &amp;ctx, TokenT <span class="keyword">const</span> &amp;macrodef, <br> <span class="keyword">std::vector</span>&lt;TokenT&gt; <span class="keyword">const</span> &amp;formal_args, <br> ContainerT <span class="keyword">const</span> &amp;definition, TokenT <span class="keyword">const</span> &amp;macrocall, <br> <span class="keyword">std::vector</span>&lt;ContainerT&gt; <span class="keyword">const</span> &amp;arguments,<br> IteratorT <span class="keyword">const</span> &amp;seqstart, Iterator <span class="keyword">const</span> &amp;seqend);<br> <br> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> TokenT, <span class="keyword">typename</span> ContainerT&gt;<br> <span class="keyword">bool</span> <a href="class_reference_ctxpolicy.html#expanding_object_like_macro">expanding_object_like_macro</a>(<br> ContextT <span class="keyword">const</span> &amp;ctx, TokenT <span class="keyword">const</span> &amp;macro, <br> ContainerT <span class="keyword">const</span> &amp;definition, TokenT <span class="keyword">const</span> &amp;macrocall);<br> <br> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> ContainerT&gt;<br> <span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#expanded_macro">expanded_macro</a>(ContextT <span class="keyword">const</span> &amp;ctx, <br> ContainerT <span class="keyword">const</span> &amp;result);<br> <br> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> ContainerT&gt;<br> <span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#expanded_macro">rescanned_macro</a>(ContextT <span class="keyword">const</span> &amp;ctx, <br> ContainerT <span class="keyword">const</span> &amp;result);<br><br>
  67. <span class="comment">// include file tracing functions</span>
  68. <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT&gt;<br> <span class="keyword">bool</span> <a href="class_reference_ctxpolicy.html#opened_include_file">found_include_directive</a>(ContextT <span class="keyword">const</span> &amp;ctx, <br> std::string <span class="keyword">const</span> &amp;filename, <span class="keyword">bool</span> include_next);<br>
  69. <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT&gt;<br> <span class="keyword">void </span><a href="class_reference_ctxpolicy.html#opened_include_file">opened_include_file</a>(ContextT <span class="keyword">const</span> &amp;ctx, <br> std::string <span class="keyword">const</span> &amp;relname, std::string <span class="keyword">const</span>&amp; absname,<br> <span class="keyword">bool</span> is_system_include); <br>
  70. <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT&gt;<br> <span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#returning_from_include_file">returning_from_include_file</a>(ContextT <span class="keyword">const</span> &amp;ctx);<br>
  71. <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT&gt;<br> <span class="keyword">void</span> <a href="#detected_include_guard">detected_include_guard</a>(ContextT <span class="keyword">const</span> &amp;ctx,
  72. std::string <span class="keyword">const</span>&amp; filename,
  73. std::string <span class="keyword">const</span>&amp; include_guard);<br>
  74. <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> TokenT&gt;<br> <span class="keyword">void</span> <a href="#detected_pragma_once">detected_pragma_once</a>(ContextT <span class="keyword">const</span> &amp;ctx,
  75. TokenT <span class="keyword">const</span>&amp; pragma_token,
  76. std::string <span class="keyword">const</span>&amp; filename);<br><br>
  77. <span class="comment">// interpretation of #pragma's of the form </span>
  78. <span class="comment">// 'wave option[(value)]'</span>
  79. <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> ContainerT&gt;<br> <span class="keyword">bool</span> <a href="class_reference_ctxpolicy.html#interpret_pragma">interpret_pragma</a>(ContextT <span class="keyword">const</span> &amp;ctx, ContainerT &amp;pending, <br> <span class="keyword">typename</span> ContextT::token_type <span class="keyword">const</span> &amp;option, <br> ContainerT <span class="keyword">const</span> &amp;values, <br> <span class="keyword">typename</span> ContextT::token_type <span class="keyword">const</span> &amp;pragma_token);<br><br>
  80. <span class="comment">// macro definition hooks</span>
  81. <span class="keyword">template</span> &lt;<br> <span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> TokenT, <span class="keyword">
  82. typename</span> ParametersT, <span class="keyword">typename</span> DefinitionT<br> &gt;<br> <span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#defined_macro">defined_macro</a>(ContextT <span class="keyword">const</span> &amp;ctx, TokenT <span class="keyword">const</span> &amp;name, <span class="keyword">
  83. bool</span> is_functionlike, ParametersT <span class="keyword">const</span> &amp;parameters, <br> DefinitionT <span class="keyword">const</span> &amp;definition, <span class="keyword">bool</span> is_predefined);<br><br> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> TokenT&gt;<br> <span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#undefined_macro">undefined_macro</a>(ContextT <span class="keyword">const</span> &amp;ctx, <br> TokenT<span class="keyword"> const</span> &amp;name);<br><br>
  84. <span class="comment">// #error and #warning directive hooks</span>
  85. <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> ContainerT&gt;<br> <span class="keyword">bool</span> <a href="class_reference_ctxpolicy.html#found_warning_directive">found_warning_directive</a>(ContextT <span class="keyword">const</span> &amp;ctx, <br> ContainerT <span class="keyword">const</span> &amp;message);<br><br> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> ContainerT&gt;<br> <span class="keyword">bool</span> <a href="class_reference_ctxpolicy.html#found_error_directive">found_error_directive</a>(ContextT <span class="keyword">const</span> &amp;ctx, <br> ContainerT <span class="keyword">const</span> &amp;message);<br><br> <span class="comment">// #line directive hook</span>
  86. <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> ContainerT&gt;<br> <span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#found_line_directive">found_line_directive</a>(ContextT <span class="keyword">const</span> &amp;ctx, <br> ContainerT <span class="keyword">const</span> &amp;arguments, <span class="keyword">unsigned int</span> line,<br> std::string <span class="keyword">const</span>&amp; filename);<br> };<br><br>}}} <span class="comment">// namespace boost::wave::context_policies</span></pre>
  87. <h2><a name="member_functions"></a>Member functions</h2>
  88. <h3>General hook functions </h3>
  89. <p><a name="found_directive"></a><strong>found_directive</strong></p>
  90. <pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> TokenT&gt;<br> <span class="keyword">bool</span> found_directive(ContextT <span class="keyword">const</span>&amp; ctx, TokenT <span class="keyword">const </span>&amp;directive);
  91. </pre>
  92. <blockquote>
  93. <p>The function <tt>found_directive</tt> is called, whenever the preprocessor has detected one of the preprocessing directives (<span class="preprocessor">#define</span>, <span class="preprocessor">#undef</span>, <span class="preprocessor">#if</span>, <span class="preprocessor">#idef</span>, <span class="preprocessor">#ifndef</span>, <span class="preprocessor">#elif</span>, <span class="preprocessor">#endif</span>, <span class="preprocessor">#error</span>, <span class="preprocessor">#include</span>, <span class="preprocessor">#pragma</span> or <span class="preprocessor">#warning</span>) .</p>
  94. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user.
  95. Note, this parameter was added for the Boost V1.35.0 release. </p>
  96. <p>The parameter <tt>directive</tt> refers to the token containing the detected preprocessing directive. </p>
  97. <p>If the return value is <tt>true</tt>, the directive will be
  98. skipped altogether, i.e. no preprocessing is done. The overall
  99. directive is replaced by a single newline character. If the return
  100. value is <tt>false</tt>, the directive is processed in the normal manner. </p>
  101. </blockquote>
  102. <p><a name="throw_exception"></a><strong>throw_exception</strong></p>
  103. <pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> ExceptionT&gt;<br> void throw_exception(ContextT <span class="keyword">const</span> &amp;ctx, <br> ExceptionT <span class="keyword">const</span>&amp; e);</pre>
  104. <blockquote>
  105. <p>he function&nbsp;<tt>throw_exception</tt> is called, whenever a preprocessing exception occurs .</p>
  106. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user.&nbsp; </p>
  107. <p>The parameter&nbsp;<tt>e</tt> is the exception object containing detailed error information. </p>
  108. </blockquote>
  109. <p><a name="may_skip_whitespace" id="may_skip"></a><strong>may_skipwhitespace</strong></p>
  110. <pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> TokenT&gt;<br> <span class="keyword">bool</span> may_skip_whitespace(ContextT <span class="keyword">const</span>&amp; ctx, TokenT &amp;token, <br> <span class="keyword">bool</span>&amp; skipped_newline);
  111. </pre>
  112. <blockquote>
  113. <p>The function <tt>may_skipwhitespace</tt> will be called by the library, whenever a token is about to be returned to the calling application. </p>
  114. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user.
  115. Note, this parameter was added for the Wave V1.2.4 release. </p>
  116. <p>The <tt>token</tt> parameter holds a reference to the current token. The policy is free to change this token if needed.</p>
  117. <p>The <tt>skipped_newline</tt> parameter holds a reference to a
  118. boolean value which should be set to true by the policy function
  119. whenever a newline is going to be skipped. </p>
  120. <p>If the return value is <tt>true</tt>, the given token is skipped and the preprocessing continues to the next token. If the return value is <tt>false</tt>, the given token is returned to the calling application. Caution has to be used, because by returning <span class="keyword">true</span> the policy function is able to force skipping even significant tokens not only whitespace. </p>
  121. </blockquote>
  122. <h3>Conditional compilation hook functions </h3>
  123. <p><a name="evaluated_conditional_expression"></a><strong>evaluated_conditional_expression</strong></p>
  124. <pre><span class="keyword"> template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> TokenT, <span class="keyword">typename</span> ContainerT&gt;
  125. <span class="keyword"> bool</span> evaluated_conditional_expression(ContextT <span class="keyword">const</span>&amp; ctx, <br> TokenT <span class="keyword">const</span>&amp; directive, ContainerT <span class="keyword">const</span>&amp; expression, <span class="keyword"><br> bool</span> expression_value);
  126. </pre>
  127. <blockquote>
  128. <p>The function <tt>evaluated_conditional_expression</tt> is called, whenever the preprocessor has encountered a <span class="preprocessor">#if</span>, <span class="preprocessor">#elif</span>, <span class="preprocessor">#ifdef</span> or <span class="preprocessor">#ifndef</span> directive. This hook gets passed the non-expanded conditional
  129. expression (as it was given in the analysed source file) and the result
  130. of the evaluation of this expression in the current preprocessing
  131. context.</p>
  132. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user.
  133. Note, this parameter was added for the Boost V1.35.0 release. </p>
  134. <p>The <tt>token</tt> parameter holds a reference to the evaluated directive token.&nbsp;</p>
  135. <p>The parameter <tt>expression</tt> holds the non-expanded token sequence
  136. comprising the evaluated expression.</p>
  137. <p>The parameter <tt>expression_value</tt> contains the result of the evaluation of
  138. the expression in the current preprocessing context. </p>
  139. <p>The return value defines, whether the given expression has to be
  140. evaluated again, allowing to decide which of the conditional branches
  141. should be expanded. You need to return '<span class="keyword">true</span>' from this hook function to force the expression to be re-evaluated. Note, this was changed from a '<span class="keyword">void</span>' for the Boost V1.35.0 release. <br>
  142. </p>
  143. </blockquote>
  144. <p><a name="skipped_token"></a><strong>skipped_token</strong></p>
  145. <pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> TokenT&gt;<br> <span class="keyword">void</span> skipped_token(ContextT <span class="keyword">const</span>&amp; ctx, TokenT <span class="keyword">const</span>&amp; token);
  146. </pre>
  147. <blockquote>
  148. <p>The function <tt>skipped_token</tt> is called, whenever a token is about to be skipped due to a false preprocessor condition (code fragments to be
  149. skipped inside the not evaluated conditional <span class="preprocessor">#if</span>/<span class="preprocessor">#else</span>/<span class="preprocessor">#endif</span> branches).</p>
  150. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user.
  151. Note, this parameter was added for the Boost V1.35.0 release. </p>
  152. <p>The parameter <tt>token</tt> refers to the token to be skipped.</p>
  153. </blockquote>
  154. <p><a name="generated_token"></a><strong>generated_token</strong></p>
  155. <pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> TokenT&gt;<br> TokenT <span class="keyword">const</span>&amp; generated_token(ContextT <span class="keyword">const</span>&amp; ctx, TokenT <span class="keyword">const</span>&amp; token);
  156. </pre>
  157. <blockquote>
  158. <p>The function <tt>generated_token</tt> is called, whenever a token is about to be returned from the library.</p>
  159. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user.
  160. Note, this parameter was added for the Boost V1.35.0 release. </p>
  161. <p>The parameter <tt>token</tt> refers to the token about to be
  162. returned from the library. This function may alter the token, but in
  163. this case it must be implemented with a non-const reference for the
  164. token parameter, allowing to modify the token in place.</p>
  165. <p>The default behavior is to return the passed token reference unchanged to the caller.</p>
  166. </blockquote>
  167. <h3>Macro expansion tracking functions</h3>
  168. <p><a name="expanding_function_like_macro"></a><b>expanding_function_like_macro</b></p>
  169. <pre><span class="keyword"> template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> TokenT, <span class="keyword">typename</span> ContainerT&gt;<br> <span class="keyword">bool</span> expanding_function_like_macro(<br> ContextT <span class="keyword">const</span>&amp; ctx, TokenT <span class="keyword">const</span> &amp;macrodef, <br> <span class="keyword">std::vector</span>&lt;TokenT&gt; <span class="keyword">const</span> &amp;formal_args, <br> ContainerT <span class="keyword">const</span> &amp;definition, TokenT <span class="keyword">const</span> &amp;macrocall, <br> <span class="keyword">std::vector</span>&lt;ContainerT&gt; <span class="keyword">const</span> &amp;arguments,<br> IteratorT <span class="keyword">const</span> &amp;seqstart, Iterator <span class="keyword">const</span> &amp;seqend);</pre>
  170. <blockquote>
  171. <p>The function <tt>expanding_function_like_macro</tt> is called, whenever a
  172. function-like macro is to be expanded, i.e. <i>before</i> the actual expansion
  173. starts.</p>
  174. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user.
  175. Note, this parameter was added for the Boost V1.35.0 release. </p>
  176. <p>The <tt>macroname</tt> parameter marks the position where the macro to expand
  177. is defined. It contains the token which identifies the macro name used inside
  178. the corresponding macro definition.</p>
  179. <p>The <tt>formal_args</tt> parameter holds the formal arguments used during
  180. the definition of the macro. </p>
  181. <p>The <tt>definition</tt> parameter holds the macro definition for the macro
  182. to trace. This is a standard STL container which holds the token sequence
  183. identified during the macro definition as the macro replacement list.</p>
  184. <p>The <tt>macrocall</tt> parameter marks the position where this macro is invoked.
  185. It contains the token, which identifies the macro call inside the preprocessed
  186. input stream. </p>
  187. <p>The <tt>arguments</tt> parameter holds the macro arguments used during the
  188. invocation of the macro. This is a vector of standard STL containers which
  189. contain the token sequences identified at the position of the macro call as
  190. the arguments to be used during the macro expansion. </p>
  191. <p>The parameters <tt>seqstart</tt> and <tt>seqend</tt> point into the input token
  192. stream allowing to access the whole token sequence comprising the macro
  193. invocation (starting with the opening parenthesis and ending after the
  194. closing one).</p>
  195. <p>If the return value is <tt>true</tt>, the macro is not expanded,
  196. i.e. the overall macro invocation sequence, including the parameters
  197. are copied to the output without further processing . If the return
  198. value is <tt>false</tt>, the macro is expanded as expected. <br>
  199. </p>
  200. </blockquote>
  201. <p><a name="expanding_object_like_macro"></a><b>expanding_object_like_macro</b></p>
  202. <pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> TokenT, <span class="keyword">typename</span> ContainerT&gt;<br> <span class="keyword">bool</span> expanding_object_like_macro(<br> ContextT <span class="keyword">const</span>&amp; ctx, TokenT <span class="keyword">const</span> &amp;macro, <br> ContainerT <span class="keyword">const</span> &amp;definition, TokenT <span class="keyword">const</span> &amp;macrocall);
  203. </pre>
  204. <blockquote>
  205. <p>The function <tt>expanding_object_like_macro</tt> is called, whenever a object-like
  206. macro is to be expanded, i.e. <i>before</i> the actual expansion starts.</p>
  207. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user.
  208. Note, this parameter was added for the Boost V1.35.0 release. </p>
  209. <p>The <tt>macroname</tt> parameter marks the position where the macro to expand
  210. is defined. It contains the token which identifies the macro name used inside
  211. the corresponding macro definition.</p>
  212. <p> The <tt>definition</tt> parameter holds the macro definition for the macro
  213. to trace. This is a standard STL container which holds the token sequence
  214. identified during the macro definition as the macro replacement list.</p>
  215. <p>The <tt>macrocall</tt> parameter marks the position where this macro is invoked.
  216. It contains the token which identifies the macro call inside the preprocessed
  217. input stream. </p>
  218. <p>If the return value is <tt>true</tt>, the macro is not expanded, i.e. the macro symbol is copied to the output without further processing. If the return value is <tt>false</tt>, the macro is expanded as expected. <br>
  219. </p>
  220. </blockquote>
  221. <p><a name="expanded_macro"></a><b>expanded_macro</b></p>
  222. <pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> ContainerT&gt;<br> <span class="keyword">void</span> expanded_macro(ContextT <span class="keyword">const</span>&amp; ctx, ContainerT <span class="keyword">const</span> &amp;result);
  223. </pre>
  224. <blockquote>
  225. <p>The function <tt>expanded_macro</tt> is called whenever the expansion of
  226. a macro is finished, the replacement list is completely scanned and the identified
  227. macros herein are replaced by its corresponding expansion results, but <i>before</i> the rescanning process starts.</p>
  228. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user.
  229. Note, this parameter was added for the Boost V1.35.0 release. </p>
  230. <p>The parameter <tt>result</tt> contains the the result of the macro expansion
  231. so far. This is a standard STL container containing the generated token sequence.</p>
  232. </blockquote>
  233. <p><a name="rescanned_macro"></a><b>rescanned_macro</b></p>
  234. <pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> ContainerT&gt;<br> <span class="keyword">void</span> rescanned_macro(ContextT <span class="keyword">const</span>&amp; ctx, ContainerT <span class="keyword">const</span> &amp;result);
  235. </pre>
  236. <blockquote>
  237. <p>The function <tt>rescanned_macro</tt> is called whenever the rescanning
  238. of a macro is finished, i.e. the macro expansion is complete.</p>
  239. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user.
  240. Note, this parameter was added for the Boost V1.35.0 release. </p>
  241. <p>The parameter <tt>result</tt> contains the the result of the whole macro
  242. expansion. This is a standard STL container containing the generated token
  243. sequence.</p>
  244. </blockquote>
  245. <h3>Include file tracing functions</h3>
  246. <p><a name="opened_include_file" id="found_include_directive"></a><strong>found_include_directive</strong></p>
  247. <pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT&gt;<br> <span class="keyword">bool</span> found_include_directive(ContextT <span class="keyword">const</span>&amp; ctx, <br> std::string <span class="keyword">const</span> &amp;filename, <span class="keyword">bool</span> include_next);
  248. </pre>
  249. <blockquote>
  250. <p>The function <tt>found_include_directive</tt> is called whenever whenever a #include directive was located..</p>
  251. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user.
  252. Note, this parameter was added for the Boost V1.35.0 release. </p>
  253. <p>The parameter <tt>filename</tt> contains the (expanded) file name found after
  254. the <span class="preprocessor">#include</span> directive. This has the format <tt>&lt;file&gt;</tt>, <tt>"file"</tt> or <tt>file</tt>.
  255. The formats <tt>&lt;file&gt;</tt> or <tt>"file"</tt> are used for <span class="preprocessor">#include</span> directives found
  256. in the preprocessed token stream, the format <tt>file</tt> is used for files
  257. specified through the --force_include command line argument.</p>
  258. <p>The parameter <tt>include_next</tt> is set to true if the found directive was
  259. a <span class="preprocessor">#include_next</span> directive and the <tt>BOOST_WAVE_SUPPORT_INCLUDE_NEXT</tt> preprocessing constant was defined to something != 0.</p>
  260. <p>If the return value is <tt>true</tt>, the include directive is not
  261. executed, i.e. the file to include is not loaded nor processed. The
  262. overall directive is replaced by a single newline character. If the
  263. return value is <tt>false</tt>, the directive is executed in a normal manner. <br>
  264. </p>
  265. </blockquote>
  266. <p><a name="opened_include_file" id="opened_include_file"></a><strong>opened_include_file</strong></p>
  267. <pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT&gt;<br> <span class="keyword">void</span> opened_include_file(ContextT <span class="keyword">const</span>&amp; ctx, <br> std::string <span class="keyword">const</span> &amp;rel_filename, std::string <span class="keyword">const</span> &amp;abs_filename, <br> <span class="keyword">bool</span> is_system_include);
  268. </pre>
  269. <blockquote>
  270. <p>The function <tt>opened_include_file</tt> is called whenever a file referred
  271. by an <span class="preprocessor">#include</span> directive was successfully located and opened.</p>
  272. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user.
  273. Note, this parameter was added for the Boost V1.35.0 release. </p>
  274. <p>The parameter <tt>rel_filename</tt> contains the (normalised)
  275. probably relative file system path of the opened file. The concrete
  276. format of this file name depends on the format of the include search
  277. path given to the library beforehand.</p>
  278. <p>The parameter <tt>abs_filename</tt> contains the (normalised) full file system path of the
  279. opened file.</p>
  280. <p>The <tt>is_system_include</tt> parameter denotes, if the given file was found
  281. as a result of a <tt>#include&nbsp;&lt;...&gt;</tt> directive.</p>
  282. </blockquote>
  283. <p><a name="returning_from_include_file" id="returning_from_include_file"></a><strong>returning_from_include_file</strong></p>
  284. <pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT&gt;<br> <span class="keyword">void</span> returning_from_include_file(ContextT <span class="keyword">const</span>&amp; ctx);
  285. </pre>
  286. <blockquote>
  287. <p>The function <tt>returning_from_include_file</tt> is called whenever an
  288. included file is about to be closed after it's processing is complete.</p>
  289. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user.
  290. Note, this parameter was added for the Boost V1.35.0 release. </p>
  291. </blockquote>
  292. <p><a name="detected_include_guard" id="detected_include_guard"></a><strong>detected_include_guard</strong></p>
  293. <pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT&gt;<br> <span class="keyword">void</span> detected_include_guard(ContextT <span class="keyword">const</span>&amp; ctx,
  294. std::string <span class="keyword">const</span>&amp; filename,
  295. std::string <span class="keyword">const</span>&amp; include_guard);
  296. </pre>
  297. <blockquote>
  298. <p>The function <tt>detected_include_guard</tt> is called whenever a<span lang="de">n</span>
  299. include file is about to be added to the list of #pragma once headers as the
  300. result of a detected include guard scheme. That means this header file will
  301. not be opened and parsed again even if it is specified in a later
  302. <span class="preprocessor">#include</span> directive.&nbsp; </p>
  303. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt>
  304. used during instantiation of the preprocessing iterators by the user. </p>
  305. <p>The parameter <tt>filename</tt> contains the file system path of the opened file
  306. (this is relative to the directory of the currently processed file or a
  307. absolute path depending on the paths given as the include search paths).</p>
  308. <p>The parameter <tt>include_guard</tt> contains the name of the detected include guard.<br> </p>
  309. </blockquote>
  310. <p><a name="detected_pragma_once" id="detected_pragma_once"></a><strong>detected_pragma_once</strong></p>
  311. <pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename </span>TokenT&gt;<br> <span class="keyword">void</span> detected_<span lang="de">p<span class="style1">ragma<span lang="en-us">_</span>once</span></span>(ContextT <span class="keyword">const</span>&amp; ctx,
  312. <span lang="de"> TokenT <span class="keyword">const</span>&amp; pragma_token,</span>
  313. std::string <span class="keyword">const</span>&amp; filename);</pre>
  314. <blockquote>
  315. <p>The function <tt>detected_pragma_once</tt> is called whenever either a<span lang="de">n</span>
  316. include file is about to be added to the list of #pragma once headers as the
  317. result of a detected <span lang="de"><span class="preprocessor">#pragma once</span>
  318. directive</span>. That means this header file will not be opened and parsed
  319. again even if it is specified in a later <span class="preprocessor">#include</span>
  320. directive. </p>
  321. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt>
  322. used during instantiation of the preprocessing iterators by the user. </p>
  323. <p><span lang="de">The parameter pragma_token refers to the token &quot;#pragma&quot;
  324. triggering this preprocessing hook.</span></p>
  325. <p>The parameter <tt>filename</tt> contains the file system path of the opened file
  326. (this is relative to the directory of the currently processed file or a
  327. absolute path depending on the paths given as the include search paths).</p>
  328. </blockquote>
  329. <h3>Interpretation of #pragma's</h3>
  330. <p><strong><a name="interpret_pragma"></a>interpret_pragma</strong></p>
  331. <pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> ContainerT&gt;<br> bool <a href="class_reference_ctxpolicy.html#interpret_pragma">interpret_pragma</a>(ContextT <span class="keyword">const</span> &amp;ctx, ContainerT &amp;pending, <br> <span class="keyword">typename</span> ContextT::token_type <span class="keyword">const</span> &amp;option, <br> ContainerT <span class="keyword">const</span> &amp;values, <br> <span class="keyword">typename</span> ContextT::token_type<span class="keyword"> const</span> &amp;pragma_token);<br>
  332. </pre>
  333. <blockquote>
  334. <p>The function <tt>interpret_pragma</tt> is called whenever an unrecognized <tt>#pragma&nbsp;wave&nbsp;...</tt> or operator <tt>_Pragma("wave&nbsp;...")</tt> is found in the input stream.</p>
  335. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user. </p>
  336. <p>The <tt>pending</tt> parameter may be used to push tokens back into the input
  337. stream which are to be used as the replacement text for the whole <tt>#pragma&nbsp;wave()</tt> directive. If this sequence is left empty, no replacement takes place, i.e.
  338. the interpreted directive is removed from the generated token stream.</p>
  339. <p>The <tt>option</tt> parameter contains the name of the interpreted pragma.</p>
  340. <p>The <tt>values</tt> parameter holds the value of the parameter provided to
  341. the pragma operator.</p>
  342. <p>The <tt>pragma_token</tt> parameter contains the actual #pragma token which
  343. may be used for extraction of the location information for some error output.</p>
  344. <p>If the return value is 'false', the whole #pragma directive is interpreted
  345. as unknown and a corresponding error message is issued. A return value of
  346. 'true' signs a successful interpretation of the given #pragma.<br>
  347. </p>
  348. </blockquote>
  349. <h3>Macro definition </h3>
  350. <p><strong><a name="defined_macro" id="defined_macro"></a>defined_macro</strong></p>
  351. <pre> <span class="keyword">template</span> &lt;<br> <span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> TokenT, <span class="keyword">typename</span> ParametersT, <span class="keyword">
  352. typename</span> DefinitionT<br> &gt;<br> <span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#defined_macro">defined_macro</a>(ContextT <span class="keyword">const</span>&amp; ctx, <br> TokenT <span class="keyword">const</span> &amp;name, <span class="keyword">bool</span> is_functionlike,<br> ParametersT <span class="keyword">const</span> &amp;parameters, DefinitionT <span class="keyword">const</span> &amp;definition,<br> <span class="keyword">bool</span> is_predefined);<br>
  353. </pre>
  354. <blockquote>
  355. <p>The function <tt>defined_macro</tt> is called whenever a macro was defined successfully.</p>
  356. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user.
  357. Note, this parameter was added for the Boost V1.35.0 release. </p>
  358. <p>The parameter <tt>name</tt> is a reference to the token holding the macro name.</p>
  359. <p>The parameter <tt>is_functionlike</tt> is set to true whenever the newly
  360. defined macro is defined as a function like macro.</p>
  361. <p>The parameter <tt>parameters</tt> holds the parameter tokens for the macro
  362. definition. If the macro has no parameters or if it is a object like
  363. macro, then this container is empty.</p>
  364. <p>The parameter <tt>definition</tt> contains the token sequence given as the
  365. replacement sequence (definition part) of the newly defined macro.</p>
  366. <p>The parameter <tt>is_predefined</tt> is set to true for all macros predefined
  367. during the initialisation pahase of the library.<br>
  368. </p>
  369. </blockquote>
  370. <p><strong><a name="undefined_macro" id="undefined_macro"></a>undefined_macro</strong></p>
  371. <pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> TokenT&gt;<br> <span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#undefined_macro">undefined_macro</a>(ContextT <span class="keyword">const</span>&amp; ctx, TokenT <span class="keyword">const</span> &amp;name);<br>
  372. </pre>
  373. <blockquote>
  374. <p>The function <tt>undefined_macro</tt> is called whenever a macro definition
  375. was removed successfully.</p>
  376. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user.
  377. Note, this parameter was added for the Boost V1.35.0 release. </p>
  378. <p>The parameter <tt>name</tt> holds the token of the macro which definition was removed.<br>
  379. </p>
  380. </blockquote>
  381. <p><strong><a name="found_warning_directive" id="found_warning_directive"></a>found_warning_drective</strong></p>
  382. <pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> ContainerT&gt;<br> <span class="keyword">bool</span> <a href="class_reference_ctxpolicy.html#found_warning_directive">found_warning_directive</a>(ContextT <span class="keyword">const</span>&amp; ctx, <br> ContainerT <span class="keyword">const</span> &amp;message);<br>
  383. </pre>
  384. <blockquote>
  385. <p>The function <tt>found_warning_directive </tt> is called whenever a <span class="preprocessor">#warning </span>directive
  386. has been encountered. Note, this function was added for the Boost
  387. V1.35.0 release. This function will be called only if the <tt>BOOST_WAVE_SUPPORT_WARNING_DIRECTIVE</tt> compile time constant was defined to something not equal to zero (see the <a href="compiletime_config.html">Compile Time Configuration</a> for more information). </p>
  388. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user. </p>
  389. <p>The parameter <tt>message</tt> references the argument token sequence of the encountered <span class="preprocessor">#warning</span> directive.</p>
  390. <p>If the return value is <tt>false</tt>, the library throws a preprocessor
  391. exception of the type <code>warning_directive</code> (normal execution continues), if the return value is <tt>true</tt> the execution continues as if no <span class="preprocessor">#warning</span> directive has been found and the overall directive is replaced by a single newline. </p>
  392. </blockquote>
  393. <p><strong><a name="found_error_directive" id="found_error_directive"></a>found_error_drective</strong></p>
  394. <pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> ContainerT&gt;<br> <span class="keyword">bool</span> <a href="class_reference_ctxpolicy.html#found_error_directive">found_error_directive</a>(ContextT <span class="keyword">const</span>&amp; ctx, <br> ContainerT <span class="keyword">const</span> &amp;message);<br>
  395. </pre>
  396. <blockquote>
  397. <p>The function <tt>found_error_directive </tt> is called whenever a <span class="preprocessor">#error </span>directive has been encountered. Note, this function was added for the Boost V1.35.0 release. </p>
  398. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user. </p>
  399. <p>The parameter <tt>message</tt> references the argument token sequence of the encountered <span class="preprocessor">#error</span> directive.</p>
  400. <p>If the return value is <tt>false</tt>, the library throws a preprocessor
  401. exception of the type <code>error_directive</code> (normal execution continues), if the return value is <tt>true</tt> the execution continues as if no <span class="preprocessor">#error</span> directive has been found and the overall directive is replaced by a single newline. </p>
  402. </blockquote>
  403. <p><strong><a name="found_line_directive" id="found_line_directive"></a>found_line_drective</strong></p>
  404. <pre> <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ContextT, <span class="keyword">typename</span> ContainerT&gt;<br> <span class="keyword">void</span> <a href="class_reference_ctxpolicy.html#found_error_directive"><strong>found_line_drective</strong></a>(ContextT <span class="keyword">const</span>&amp; ctx, <br> ContainerT <span class="keyword">const</span> &amp;arguments, <span class="keyword">unsigned int</span> line,<br> std::string <span class="keyword">const</span>&amp; filename);
  405. </pre>
  406. <blockquote>
  407. <p>The function <tt>found_line_directive </tt> is called whenever a <span class="preprocessor">#line </span>directive has been encountered. Note, this function was added for the Boost V1.35.0 release. </p>
  408. <p>The <tt>ctx</tt> parameter provides a reference to the <tt>context_type</tt> used during instantiation of the preprocessing iterators by the user. </p>
  409. <p>The parameter <tt>arguments</tt> references the argument token sequence of the encountered <span class="preprocessor">#line</span> directive.</p>
  410. <p>The parameter <tt>line</tt> contains the recognized line number from the <span class="preprocessor">#line</span> directive.</p>
  411. <p>The parameter <tt>filename</tt> references the recognized file name from the <span class="preprocessor">#line</span> directive (if there was one given).<br>
  412. </p>
  413. </blockquote>
  414. <table border="0">
  415. <tbody>
  416. <tr>
  417. <td width="10"></td>
  418. <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
  419. <td width="30"><a href="class_reference_inptpolcy.html"><img src="theme/l_arr.gif" border="0" height="19" width="20"></a></td>
  420. <td width="30"><a href="class_reference_lexer.html"><img src="theme/r_arr.gif" border="0"></a></td>
  421. </tr>
  422. </tbody>
  423. </table>
  424. <hr size="1">
  425. <p class="copyright">Copyright &copy; 2003-2011 Hartmut Kaiser<br>
  426. <br>
  427. <font size="2">Distributed under the Boost Software License, Version
  428. 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  429. http://www.boost.org/LICENSE_1_0.txt) </font> </p>
  430. <p class="copyright"><span class="updated">Last updated:
  431. <!-- #BeginDate format:fcAm1m -->Thursday, September 1<span lang="de">8</span>, 2010
  432. <span lang="de">09</span>:<span lang="de">10</span><!-- #EndDate -->
  433. </span></p>
  434. </body>
  435. </html>