Click here to Skip to main content
15,885,216 members
Articles / Programming Languages / C++

Wave: a Standard conformant C++ preprocessor library

Rate me:
Please Sign up or sign in to vote.
4.96/5 (58 votes)
10 Jan 200413 min read 395.4K   4.4K   81  
Describes a free and fully Standard conformant C++ preprocessor library
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>The File Position</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>
<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">The 
      File Position</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="token_ids.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
    <td width="30"><a href="predefined_macros.html"><img src="theme/r_arr.gif" border="0"></a></td>
  </tr>
</table>
<blockquote> 
  <p><a href="class_reference_fileposition.html#introduction">Introduction</a><br>
    <a href="class_reference_fileposition.html#header_synopsis">Header 'wave/util/file_position.hpp' 
    synopsis</a><br>
    <a href="class_reference_fileposition.html#template_parameters">Template parameters</a><br>
    <a href="class_reference_fileposition.html#member_functions">Member functions</a></p>
</blockquote>
<h2><b><a name="introduction"></a>Introduction</b></h2>
<p>The file position template is used to represent a concrete token position inside 
  the underlying input stream. This token position contains the corresponding 
  filename, the line number and the column number, where the token was recognized.</p>
<h2><b><a name="header_synopsis"></a>Header <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/spirit/spirit/wave/wave/util/file_position.h?rev=HEAD&content-type=text/vnd.viewcvs-markup">wave/util/file_position.hpp</a> 
  synopsis</b></h2>
<pre><span class="keyword">namespace</span> <span class="identifier">wave</span> {
<span class="keyword">namespace</span> <span class="identifier">util</span> {

    <span class="keyword">template</span> &lt;<span class="keyword">typename</span> StringT = <span class="keyword">std::string</span>&gt;
    <span class="keyword">class</span> file_position {
 
    <span class="keyword">public</span>:
        <a href="class_reference_fileposition.html#constructors">file_position</a>();
        <span class="keyword">explicit</span> <a href="class_reference_fileposition.html#constructors">file_position</a>(StringT const &amp;file, 
            int line_ = 1, int column_ = 1);

    // accessors
        StringT <span class="keyword">const</span> &amp;<a href="class_reference_fileposition.html#get_accessors">get_file</a>() <span class="keyword">const</span>;
        <span class="keyword">int</span> <a href="class_reference_fileposition.html#get_accessors">get_line</a>() <span class="keyword">const</span>;
        <span class="keyword">int</span> <a href="class_reference_fileposition.html#get_accessors">get_column</a>() <span class="keyword">const</span>;
    
        <span class="keyword">void</span> <a href="class_reference_fileposition.html#set_accessors">set_file</a>(StringT <span class="keyword">const</span> &amp;file);
        <span class="keyword">void</span> <a href="class_reference_fileposition.html#set_accessors">set_line</a>(<span class="keyword">int</span> line);
        <span class="keyword">void</span> <a href="class_reference_fileposition.html#set_accessors">set_column</a>(<span class="keyword">int</span> column);
    };

}   <span class="comment">// namespace util</span>
}   <span class="comment">// namespace wave</span></pre>
<h2><a name="template_parameters"></a>Template parameters</h2>
<p>The <tt>file_position</tt> template may be instantiatet with one template parameter, 
  which gives the string type to use for storing the file name member of the file 
  position. If this parameter isn't given, it defaults to a <tt>std::string</tt>. 
  Please note, that the type given as the template parameter must be compatible 
  with a <tt>std::string</tt>.</p>
<h2><a name="member_functions"></a>Member functions</h2>
<h3><a name="constructors"></a>Constructors</h3>
<pre>        <a href="class_reference_fileposition.html#constructors">file_position</a>();
        <span class="keyword">explicit</span> <a href="class_reference_fileposition.html#constructors">file_position</a>(StringT const &amp;file, 
            int line_ = 1, int column_ = 1);
</pre>
<blockquote>
  <p>The constructors initialize a new instance of a <tt>file_position</tt> in 
    correspondence to the supplied parameters. The parameters default to an empty 
    filename and the line number and column number set to one.</p>
</blockquote>
<p><a name="get_accesssors"></a><b>get_file</b>, <b>get_line</b>, <b>get_column</b></p>
<pre>        StringT <span class="keyword">const</span> &amp;<a href="class_reference_fileposition.html#get_accessors">get_file</a>() <span class="keyword">const</span>;
        <span class="keyword">int</span> <a href="class_reference_fileposition.html#get_accessors">get_line</a>() <span class="keyword">const</span>;
        <span class="keyword">int</span> <a href="class_reference_fileposition.html#get_accessors">get_column</a>() <span class="keyword">const</span>;
</pre>
<blockquote>
  <p>The <tt>get_...</tt> functions are used to access the current values of the 
    file position members: the filename (<tt>get_file</tt>), the line number (<tt>get_line</tt>) 
    and the column number (<tt>get_column</tt>).</p>
</blockquote>
<p><a name="set_accessors"></a><b>set_file</b>, <b>set_line</b>, <b>set_column</b></p>
<pre>        <span class="keyword">void</span> <a href="class_reference_fileposition.html#set_accessors">set_file</a>(StringT <span class="keyword">const</span> &amp;file);
        <span class="keyword">void</span> <a href="class_reference_fileposition.html#set_accessors">set_line</a>(<span class="keyword">int</span> line);
        <span class="keyword">void</span> <a href="class_reference_fileposition.html#set_accessors">set_column</a>(<span class="keyword">int</span> column);
</pre>
<blockquote>
  <p>The <tt>set_...</tt> functions are used to set new values to the file position 
    members: the filename (<tt>set_file</tt>), the line number (<tt>set_line</tt>) 
    and the column number (<tt>set_column</tt>).</p>
</blockquote>
<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="token_ids.html"><img src="theme/l_arr.gif" width="20" height="19" border="0"></a></td>
    <td width="30"><a href="predefined_macros.html"><img src="theme/r_arr.gif" border="0"></a></td>
  </tr>
</table>
<hr size="1">
<p class="copyright">Copyright &copy; 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 -->Monday, January 5, 2004  14:57<!-- #EndDate -->
  </span></body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
Actively involved in Boost and the development of the Spirit parser construction framework.

Comments and Discussions