mirror of
https://github.com/boostorg/wave.git
synced 2026-01-26 07:02:23 +00:00
115 lines
6.5 KiB
HTML
115 lines
6.5 KiB
HTML
<!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://spirit.sf.net"><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>The actual preprocessing itself is a highly configurable process, so obviously
|
|
you have to define a couple of parameters to control this process, such
|
|
as:</p>
|
|
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
|
|
<P><STRONG><IMG id="IMG1" height="13" src="theme/bullet.gif" width="13"></STRONG> include
|
|
search pathes, which define, where to search for files to be included with
|
|
<tt>#include <...></tt> and <tt>#include "..."</tt> directives<br>
|
|
<STRONG><img src="theme/bullet.gif" width="13" height="13"> </STRONG>which
|
|
macros to predefine and which of the predefined macros to undefine<br>
|
|
<STRONG><img src="theme/bullet.gif" width="13" height="13"> </STRONG>several
|
|
other options as for instance to control, whether to enable several extensions
|
|
to the C++ Standard (as for instance variadics and placemarkers) or not.</P>
|
|
</BLOCKQUOTE>
|
|
<p>You can access all these processing parameters through the <tt>boost::wave::context</tt>
|
|
object. So you have to 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
|
|
token to be returned from the preprocessing engine.</p>
|
|
<P dir="ltr">The main preprocessing iterators are not to be instantiated directly,
|
|
but should be generated through this context object too. </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">"input.cpp"</span>);<br> <span class="keyword">std::string </span>input<span class="keyword">(
|
|
std::istreambuf_iterator<char></span>(instream.rdbuf());
|
|
<span class="keyword">std::istreambuf_iterator<char></span>());
|
|
|
|
<span class="comment">// The template wave::cpplexer::lex_token<> 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 many
|
|
// of the public classes and templates and it is returned
|
|
// from the iterators itself.</span>
|
|
<span class="keyword">typedef</span> boost::wave::context<<span class=keyword>std::string::iterator</span>,
|
|
boost::wave::cpplexer::lex_token<> >
|
|
context_t;
|
|
|
|
<span class="comment">// The C++ preprocessor iterators shouldn't be constructed
|
|
// directly. These are to be generated through a
|
|
// wave::context<> object. Additionally this wave::context<>
|
|
// object is to be used to initialize and define different
|
|
// parameters of the actual preprocessing.
|
|
</span> context_t ctx(input.begin(), input.end(), <span class="string">"input.cpp"</span>);
|
|
context_t::iterator_t first = ctx.begin();
|
|
context_t::iterator_t last = ctx.end();
|
|
|
|
<span class="comment"> // The preprocessing of the input stream is done on the fly
|
|
// behind the scenes during the iteration over the
|
|
// context_t::iterator_t based stream. </span>
|
|
<span class="keyword">while</span> (first != last) {
|
|
<span class="keyword">std::cout</span> << (*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, from where should be read the data to be preprocessed.
|
|
The third parameter supplies a filename, which is used subsequently inside the
|
|
preprocessed tokens returned from the preprocessing to indicate the token position
|
|
inside the underlying input stream. Note though, that this filename is used
|
|
only as long no <tt>#include</tt> or <tt>#line</tt> directives are encountered,
|
|
which in turn will alter the current filename.</P>
|
|
<P dir="ltr">The iteration over the preprocessed tokens is relativly straight
|
|
forward. Just get the starting and the ending iterators from the context object
|
|
(maybe after initializing some include search paths) and you are done! The dereferencing
|
|
of 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 © 2003-2004 Hartmut Kaiser<br>
|
|
<br>
|
|
<font size="2">Use, modification and distribution is subject to 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">Last updated:
|
|
<!-- #BeginDate format:fcAm1m -->Wednesday, January 14, 2004 12:41<!-- #EndDate -->
|
|
</span></body>
|
|
</html>
|