File: quickstart.html

package info (click to toggle)
boost 1.33.1-10
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 100,948 kB
  • ctags: 145,103
  • sloc: cpp: 573,492; xml: 49,055; python: 15,626; ansic: 13,588; sh: 2,099; yacc: 858; makefile: 660; perl: 427; lex: 111; csh: 6
file content (121 lines) | stat: -rw-r--r-- 7,316 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Quick Start</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="theme/style.css" rel="stylesheet" type="text/css">
</head>

<body text="#000000" background="theme/bkd.gif">
<table width="100%" border="0" cellspacing="2" background="theme/bkd2.gif">
  <tr> 
    <td width="21"> <h1></h1></td>
    <td width="885"> <font face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">Quick 
      Start </font></b></font></td>
    <td width="96"><a href="http://www.boost.org"><img src="theme/wave.gif" width="93" height="68" align="right" border="0"></a></td>
  </tr>
</table>
<br>
<table border="0">
  <tr> 
    <td width="10"></td>
    <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
    <td width="30"><a href="introduction.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
    <td width="30"><a href="class_reference_context.html"><img src="theme/r_arr.gif" border="0"></a></td>
  </tr>
</table>
<p>Preprocessing with Wave is highly configurable. You must
define a few options to control it. Here are a few of the
options you can define:</p>
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px"> 
  <P><STRONG><IMG id="IMG1" height="13" src="theme/bullet.gif" width="13"></STRONG>&nbsp;include 
    search paths, which define, where to search for files to be included with 
    <tt>#include&nbsp;&lt;...&gt;</tt> and <tt>#include&nbsp;"..."</tt> directives<br>
    <STRONG><img src="theme/bullet.gif" width="13" height="13">&nbsp;</STRONG>which 
    macros to predefine and which of the predefined macros to undefine<br>
    <STRONG><img src="theme/bullet.gif" width="13" height="13">&nbsp;</STRONG>whether to enable any of several extensions to the C++
Standard (such as for variadics and placemarkers)<br>
  </P>
</BLOCKQUOTE>
<p>You can access all these processing parameters through the <tt>boost::wave::context</tt> 
  object. So you must instantiate one object of this type to use the <tt>Wave</tt> 
  library. (For more information about the context template class, please refer 
  to the class reference <a href="class_reference_context.html">here</a>.) To instantiate 
  the <tt>boost::wave::context</tt> object you have to supply at least two template parameters: 
  the iterator type of the underlying input stream to use and the type of the lexer iterator to be used as the token source for the preprocessing engine.</p>
<P dir="ltr">Do not instantiate the main preprocessing iterators yourself.
Get them from the wave::context object instead.<br>
The following code snippet is taken from the <tt>quick_start</tt> sample, which shows a minimal usage scenario for <tt>Wave</tt>. </P>
<pre><span class="comment">    // The following preprocesses a given input file.
    // Open the file and read it into a string variable</span>
    <span class="keyword">std::ifstream</span> instream(<span class="string">&quot;input.cpp&quot;</span>);
    <span class="keyword">std::string </span>input<span class="keyword">(
        std::istreambuf_iterator&lt;char&gt;</span>(instream.rdbuf()),
        <span class="keyword">std::istreambuf_iterator&lt;char&gt;</span>());

    <span class="comment">// The template boost::wave::cpplexer::lex_token&lt;&gt; is the  
    // token type to be used by the Wave library.
    // This token type is one of the central types throughout 
    // the library, because it is a template parameter to some 
    // of the public classes and templates and it is returned 
    // from the iterators.
    // The template boost::wave::cpplexer::lex_iterator&lt;&gt; is
    // the lexer iterator to use as the token source for the
    // preprocessing engine. In this case this is parametrized
    // with the token type.</span>
    <span class="keyword">typedef</span> <span class="identifier">boost::wave::cpplexer::lex_iterator</span><span class="special">&lt;</span>
            <span class="identifier">boost::wave::cpplexer::lex_token</span><span class="special">&lt;&gt; &gt;</span>
        <span class="identifier">lex_iterator_type</span><span class="special">;</span>
    <span class="keyword">typedef</span> <span class="identifier">boost::wave::context</span><span class="special">&lt;</span>
            std::string::iterator<span class="special">,</span> lex_iterator_type<span class="special">&gt;</span>
        <span class="identifier">context_type</span><span class="special">;</span>

    context_type ctx(input.begin(), input.end(), <span class="string">&quot;input.cpp&quot;</span>);

<span class="comment">    // At this point you may want to set the parameters of the
    // preprocessing as include paths and/or predefined macros.
</span>        ctx.add_include_path(<span class="literal">&quot;...&quot;</span>);
        ctx.add_macro_definition(...);

<span class="comment">    // Get the preprocessor iterators and use them to generate 
    // the token sequence.
</span>    context_type::iterator_type first = ctx.begin();
    context_type::iterator_type last = ctx.end();

<span class="comment">    // The input stream is preprocessed for you during iteration<br>    // over [first, last)<br></span>        <span class="keyword">while</span> (first != last) {
            <span class="keyword">std::cout</span> &lt;&lt; (*first).get_value();
            ++first;
        }

</pre>
<P dir="ltr">The constructor of the <tt>boost::wave::context</tt> object can 
  take a pair of arbitrary iterator types (at least <tt>input_iterator</tt> type 
  iterators) to the input stream, which must supply the data to be processed. 
  The third parameter supplies a filename, filename, which is reported in the preprocessor output to
indicate the current context. 
Note though, that this filename is used 
  only as long as no <tt>#include</tt> or <tt>#line</tt> directives are encountered, 
  which in turn will alter the current filename reported.</P>
<P dir="ltr">The iteration over the preprocessed tokens is relativley straightforward. Just get the starting and the ending iterators from the context object 
  (maybe after initializing some include search paths) and you are done! Dereferencing 
  the iterator will return the preprocessed tokens, which are generated on 
  the fly from the input stream. (To get further information about the token type, 
  you may want to look <a href="class_reference_tokentype.html">here</a>.)</P>
<table border="0">
  <tr> 
    <td width="10"></td>
    <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
    <td width="30"><a href="introduction.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
    <td width="30"><a href="class_reference_context.html"><img src="theme/r_arr.gif" border="0"></a></td>
  </tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 2003-2005 Hartmut Kaiser<br>
  <br>
<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>
<span class="updated"></span>
<p class="copyright"><span class="updated">Last updated: 
  <!-- #BeginDate format:fcAm1m -->Sunday, May 15, 2005  12:23<!-- #EndDate -->
</span></p>
</body>
</html>