• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>The line position iterator</title>
5<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../index.html" title="Spirit 2.5.8">
8<link rel="up" href="../support.html" title="Supporting Libraries">
9<link rel="prev" href="multi_pass.html" title="The multi pass iterator">
10<link rel="next" href="utree.html" title="The utree data structure">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="multi_pass.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../support.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="utree.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h3 class="title">
27<a name="spirit.support.line_pos_iterator"></a><a class="link" href="line_pos_iterator.html" title="The line position iterator">The line position iterator</a>
28</h3></div></div></div>
29<p>
30        The <code class="computeroutput"><span class="identifier">line_pos_iterator</span></code> is
31        a lightweight line position iterator. This iterator adapter only stores the
32        current line number, nothing else. Unlike <a href="../../../../../../libs/spirit/classic/index.html" target="_top"><span class="emphasis"><em>Spirit.Classic</em></span></a>'s
33        <code class="computeroutput"><span class="identifier">position_iterator</span></code>, it does
34        not store the column number and does not need an end iterator. The current
35        column can be computed, if needed.
36      </p>
37<h5>
38<a name="spirit.support.line_pos_iterator.h0"></a>
39        <span class="phrase"><a name="spirit.support.line_pos_iterator.class_reference"></a></span><a class="link" href="line_pos_iterator.html#spirit.support.line_pos_iterator.class_reference">Class
40        Reference</a>
41      </h5>
42<p>
43</p>
44<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Iterator</span><span class="special">&gt;</span>
45<span class="keyword">class</span> <span class="identifier">line_pos_iterator</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">iterator_adaptor</span><span class="special">&lt;</span>
46    <span class="identifier">line_pos_iterator</span><span class="special">&lt;</span><span class="identifier">Iterator</span><span class="special">&gt;</span>  <span class="comment">// Derived</span>
47  <span class="special">,</span> <span class="identifier">Iterator</span>                     <span class="comment">// Base</span>
48  <span class="special">,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">use_default</span>           <span class="comment">// Value</span>
49  <span class="special">,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">forward_traversal_tag</span> <span class="comment">// CategoryOrTraversal</span>
50<span class="special">&gt;</span> <span class="special">{</span>
51<span class="keyword">public</span><span class="special">:</span>
52    <span class="identifier">line_pos_iterator</span><span class="special">();</span>
53
54    <span class="keyword">explicit</span> <span class="identifier">line_pos_iterator</span><span class="special">(</span><span class="identifier">Iterator</span><span class="special">);</span>
55
56    <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">position</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
57
58<span class="keyword">private</span><span class="special">:</span>
59    <span class="keyword">friend</span> <span class="keyword">class</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">iterator_core_access</span><span class="special">;</span>
60
61    <span class="keyword">void</span> <span class="identifier">increment</span><span class="special">();</span>
62
63    <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">line</span><span class="special">;</span> <span class="comment">// The line position.</span>
64    <span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">iterator_traits</span><span class="special">&lt;</span><span class="identifier">Iterator</span><span class="special">&gt;::</span><span class="identifier">value_type</span> <span class="identifier">prev</span><span class="special">;</span>
65<span class="special">};</span>
66</pre>
67<p>
68      </p>
69<h5>
70<a name="spirit.support.line_pos_iterator.h1"></a>
71        <span class="phrase"><a name="spirit.support.line_pos_iterator.get_line"></a></span><a class="link" href="line_pos_iterator.html#spirit.support.line_pos_iterator.get_line">get_line</a>
72      </h5>
73<p>
74</p>
75<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Iterator</span><span class="special">&gt;</span>
76<span class="keyword">inline</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">get_line</span><span class="special">(</span><span class="identifier">Iterator</span><span class="special">);</span>
77</pre>
78<p>
79      </p>
80<p>
81        Get the line position. Returns -1 if Iterator is not a <code class="computeroutput"><span class="identifier">line_pos_iterator</span></code>.
82      </p>
83<h5>
84<a name="spirit.support.line_pos_iterator.h2"></a>
85        <span class="phrase"><a name="spirit.support.line_pos_iterator.get_line_start"></a></span><a class="link" href="line_pos_iterator.html#spirit.support.line_pos_iterator.get_line_start">get_line_start</a>
86      </h5>
87<p>
88</p>
89<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Iterator</span><span class="special">&gt;</span>
90<span class="keyword">inline</span> <span class="identifier">Iterator</span> <span class="identifier">get_line_start</span><span class="special">(</span><span class="identifier">Iterator</span> <span class="identifier">lower_bound</span><span class="special">,</span> <span class="identifier">Iterator</span> <span class="identifier">current</span><span class="special">);</span>
91</pre>
92<p>
93      </p>
94<p>
95        Get an iterator to the beginning of the line. Applicable to any iterator.
96      </p>
97<h5>
98<a name="spirit.support.line_pos_iterator.h3"></a>
99        <span class="phrase"><a name="spirit.support.line_pos_iterator.get_current_line"></a></span><a class="link" href="line_pos_iterator.html#spirit.support.line_pos_iterator.get_current_line">get_current_line</a>
100      </h5>
101<p>
102</p>
103<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Iterator</span><span class="special">&gt;</span>
104<span class="keyword">inline</span> <span class="identifier">iterator_range</span><span class="special">&lt;</span><span class="identifier">Iterator</span><span class="special">&gt;</span>
105<span class="identifier">get_current_line</span><span class="special">(</span><span class="identifier">Iterator</span> <span class="identifier">lower_bound</span><span class="special">,</span> <span class="identifier">Iterator</span> <span class="identifier">current</span><span class="special">,</span>
106                 <span class="identifier">Iterator</span> <span class="identifier">upper_bound</span><span class="special">);</span>
107</pre>
108<p>
109      </p>
110<p>
111        Get an <code class="computeroutput"><span class="identifier">iterator_range</span></code> containing
112        the current line. Applicable to any iterator.
113      </p>
114<h5>
115<a name="spirit.support.line_pos_iterator.h4"></a>
116        <span class="phrase"><a name="spirit.support.line_pos_iterator.get_column"></a></span><a class="link" href="line_pos_iterator.html#spirit.support.line_pos_iterator.get_column">get_column</a>
117      </h5>
118<p>
119</p>
120<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Iterator</span><span class="special">&gt;</span>
121<span class="keyword">inline</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">get_column</span><span class="special">(</span><span class="identifier">Iterator</span> <span class="identifier">lower_bound</span><span class="special">,</span> <span class="identifier">Iterator</span> <span class="identifier">current</span><span class="special">,</span>
122                              <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">tabs</span> <span class="special">=</span> <span class="number">4</span><span class="special">);</span>
123</pre>
124<p>
125      </p>
126<p>
127        Get the current column. Applicable to any iterator.
128      </p>
129</div>
130<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
131<td align="left"></td>
132<td align="right"><div class="copyright-footer">Copyright © 2001-2011 Joel de Guzman, Hartmut Kaiser<p>
133        Distributed under the Boost Software License, Version 1.0. (See accompanying
134        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
135      </p>
136</div></td>
137</tr></table>
138<hr>
139<div class="spirit-nav">
140<a accesskey="p" href="multi_pass.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../support.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="utree.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
141</div>
142</body>
143</html>
144