• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Store an Attribute after a Parser Produced a Pair of Iterators (Qi)</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="../assign_to.html" title="Store a Parsed Attribute Value (Qi)">
9<link rel="prev" href="../assign_to.html" title="Store a Parsed Attribute Value (Qi)">
10<link rel="next" href="assign_to_attribute_from_value.html" title="Store an Attribute Value after a Parser Produced a Value (Qi)">
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="../assign_to.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../assign_to.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="assign_to_attribute_from_value.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h5 class="title">
27<a name="spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators"></a><a class="link" href="assign_to_attribute_from_iterators.html" title="Store an Attribute after a Parser Produced a Pair of Iterators (Qi)">Store
28          an Attribute after a Parser Produced a Pair of Iterators (Qi)</a>
29</h5></div></div></div>
30<h6>
31<a name="spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.h0"></a>
32            <span class="phrase"><a name="spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.assign_to_attribute_from_iterators"></a></span><a class="link" href="assign_to_attribute_from_iterators.html#spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.assign_to_attribute_from_iterators">assign_to_attribute_from_iterators</a>
33          </h6>
34<p>
35            The template <code class="computeroutput"><span class="identifier">assign_to_attribute_from_iterators</span></code>
36            is a type used as an attribute customization point. It is invoked by
37            the those <span class="emphasis"><em>Qi</em></span> parsers not producing any attribute
38            value but returning a pair of iterators pointing to the matched input
39            sequence. It is used to either store the iterator pair into the attribute
40            instance provided by the user or to convert the iterator pair into an
41            attribute as provided by the user.
42          </p>
43<h6>
44<a name="spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.h1"></a>
45            <span class="phrase"><a name="spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.module_headers"></a></span><a class="link" href="assign_to_attribute_from_iterators.html#spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.module_headers">Module
46            Headers</a>
47          </h6>
48<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">home</span><span class="special">/</span><span class="identifier">qi</span><span class="special">/</span><span class="identifier">detail</span><span class="special">/</span><span class="identifier">assign_to</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
49</pre>
50<p>
51            Also, see <a class="link" href="../../../structure/include.html" title="Include">Include Structure</a>.
52          </p>
53<div class="note"><table border="0" summary="Note">
54<tr>
55<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td>
56<th align="left">Note</th>
57</tr>
58<tr><td align="left" valign="top"><p>
59              This header file does not need to be included directly by any user
60              program as it is normally included by other Spirit header files relying
61              on its content.
62            </p></td></tr>
63</table></div>
64<h6>
65<a name="spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.h2"></a>
66            <span class="phrase"><a name="spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.namespace"></a></span><a class="link" href="assign_to_attribute_from_iterators.html#spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.namespace">Namespace</a>
67          </h6>
68<div class="informaltable"><table class="table">
69<colgroup><col></colgroup>
70<thead><tr><th>
71                    <p>
72                      Name
73                    </p>
74                  </th></tr></thead>
75<tbody><tr><td>
76                    <p>
77                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">traits</span></code>
78                    </p>
79                  </td></tr></tbody>
80</table></div>
81<h6>
82<a name="spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.h3"></a>
83            <span class="phrase"><a name="spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.synopsis"></a></span><a class="link" href="assign_to_attribute_from_iterators.html#spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.synopsis">Synopsis</a>
84          </h6>
85<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Attrib</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Iterator</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Enable</span><span class="special">&gt;</span>
86<span class="keyword">struct</span> <span class="identifier">assign_to_attribute_from_iterators</span>
87<span class="special">{</span>
88    <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">call</span><span class="special">(</span><span class="identifier">Iterator</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">Iterator</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">last</span><span class="special">,</span> <span class="identifier">Attrib</span><span class="special">&amp;</span> <span class="identifier">attr</span><span class="special">);</span>
89<span class="special">};</span>
90</pre>
91<h6>
92<a name="spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.h4"></a>
93            <span class="phrase"><a name="spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.template_parameters"></a></span><a class="link" href="assign_to_attribute_from_iterators.html#spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.template_parameters">Template
94            parameters</a>
95          </h6>
96<div class="informaltable"><table class="table">
97<colgroup>
98<col>
99<col>
100<col>
101</colgroup>
102<thead><tr>
103<th>
104                    <p>
105                      Parameter
106                    </p>
107                  </th>
108<th>
109                    <p>
110                      Description
111                    </p>
112                  </th>
113<th>
114                    <p>
115                      Default
116                    </p>
117                  </th>
118</tr></thead>
119<tbody>
120<tr>
121<td>
122                    <p>
123                      <code class="computeroutput"><span class="identifier">Attrib</span></code>
124                    </p>
125                  </td>
126<td>
127                    <p>
128                      The type, <code class="computeroutput"><span class="identifier">Attrib</span></code>
129                      is the type of the attribute as passed in by the user.
130                    </p>
131                  </td>
132<td>
133                    <p>
134                      none
135                    </p>
136                  </td>
137</tr>
138<tr>
139<td>
140                    <p>
141                      <code class="computeroutput"><span class="identifier">Iterator</span></code>
142                    </p>
143                  </td>
144<td>
145                    <p>
146                      The type, <code class="computeroutput"><span class="identifier">Iterator</span></code>
147                      is the type of the iterators as produced by the parser.
148                    </p>
149                  </td>
150<td>
151                    <p>
152                      none
153                    </p>
154                  </td>
155</tr>
156<tr>
157<td>
158                    <p>
159                      <code class="computeroutput"><span class="identifier">Enable</span></code>
160                    </p>
161                  </td>
162<td>
163                    <p>
164                      Helper template parameter usable to selectively enable or disable
165                      certain specializations of <code class="computeroutput"><span class="identifier">assign_to_attribute_from_value</span></code>
166                      utilizing SFINAE (i.e. <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">enable_if</span></code>
167                      or <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">disable_if</span></code>).
168                    </p>
169                  </td>
170<td>
171                    <p>
172                      <code class="computeroutput"><span class="keyword">void</span></code>
173                    </p>
174                  </td>
175</tr>
176</tbody>
177</table></div>
178<div class="variablelist">
179<p class="title"><b>Notation</b></p>
180<dl class="variablelist">
181<dt><span class="term"><code class="computeroutput"><span class="identifier">Attrib</span></code></span></dt>
182<dd><p>
183                  A type to be used as the target to store the attribute value in.
184                </p></dd>
185<dt><span class="term"><code class="computeroutput"><span class="identifier">attr</span></code></span></dt>
186<dd><p>
187                  An attribute instance of type <code class="computeroutput"><span class="identifier">Attrib</span></code>.
188                </p></dd>
189<dt><span class="term"><code class="computeroutput"><span class="identifier">Iterator</span></code></span></dt>
190<dd><p>
191                  The iterator type used by the parser. This type usually corresponds
192                  to the iterators as passed in by the user.
193                </p></dd>
194<dt><span class="term"><code class="computeroutput"><span class="identifier">begin</span></code>, <code class="computeroutput"><span class="identifier">end</span></code></span></dt>
195<dd><p>
196                  Iterator instances of type <code class="computeroutput"><span class="identifier">Iterator</span></code>
197                  pointing to the begin and the end of the matched input sequence.
198                </p></dd>
199</dl>
200</div>
201<h6>
202<a name="spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.h5"></a>
203            <span class="phrase"><a name="spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.expression_semantics"></a></span><a class="link" href="assign_to_attribute_from_iterators.html#spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.expression_semantics">Expression
204            Semantics</a>
205          </h6>
206<div class="informaltable"><table class="table">
207<colgroup>
208<col>
209<col>
210</colgroup>
211<thead><tr>
212<th>
213                    <p>
214                      Expression
215                    </p>
216                  </th>
217<th>
218                    <p>
219                      Semantics
220                    </p>
221                  </th>
222</tr></thead>
223<tbody><tr>
224<td>
225                    <p>
226</p>
227<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">assign_to_attribute_from_iterators</span><span class="special">&lt;</span><span class="identifier">Attrib</span><span class="special">,</span> <span class="identifier">Iterator</span><span class="special">&gt;::</span><span class="identifier">call</span><span class="special">(</span><span class="identifier">b</span><span class="special">,</span> <span class="identifier">e</span><span class="special">,</span> <span class="identifier">attr</span><span class="special">)</span></pre>
228<p>
229                    </p>
230                  </td>
231<td>
232                    <p>
233                      Use the iterators <code class="computeroutput"><span class="identifier">begin</span></code>
234                      and <code class="computeroutput"><span class="identifier">end</span></code> to
235                      initialize the attribute <code class="computeroutput"><span class="identifier">attr</span></code>.
236                    </p>
237                  </td>
238</tr></tbody>
239</table></div>
240<h6>
241<a name="spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.h6"></a>
242            <span class="phrase"><a name="spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.predefined_specializations"></a></span><a class="link" href="assign_to_attribute_from_iterators.html#spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.predefined_specializations">Predefined
243            Specializations</a>
244          </h6>
245<div class="informaltable"><table class="table">
246<colgroup>
247<col>
248<col>
249</colgroup>
250<thead><tr>
251<th>
252                    <p>
253                      Template Parameters
254                    </p>
255                  </th>
256<th>
257                    <p>
258                      Semantics
259                    </p>
260                  </th>
261</tr></thead>
262<tbody>
263<tr>
264<td>
265                    <p>
266                      <code class="computeroutput"><span class="identifier">Attrib</span></code>, <code class="computeroutput"><span class="identifier">Iterator</span></code>
267                    </p>
268                  </td>
269<td>
270                    <p>
271                      Execute an assignment <code class="computeroutput"><span class="identifier">attr</span>
272                      <span class="special">=</span> <span class="identifier">Attrib</span><span class="special">(</span><span class="identifier">begin</span><span class="special">,</span> <span class="identifier">end</span><span class="special">)</span></code>.
273                    </p>
274                  </td>
275</tr>
276<tr>
277<td>
278                    <p>
279                      <code class="computeroutput"><span class="identifier">unused_type</span></code>,
280                      <code class="computeroutput"><span class="identifier">T</span></code>
281                    </p>
282                  </td>
283<td>
284                    <p>
285                      Do nothing.
286                    </p>
287                  </td>
288</tr>
289</tbody>
290</table></div>
291<h6>
292<a name="spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.h7"></a>
293            <span class="phrase"><a name="spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.when_to_implement"></a></span><a class="link" href="assign_to_attribute_from_iterators.html#spirit.advanced.customize.assign_to.assign_to_attribute_from_iterators.when_to_implement">When
294            to implement</a>
295          </h6>
296<p>
297            The customization point <code class="computeroutput"><span class="identifier">assign_to_attribute_from_iterators</span></code>
298            needs to be implemented for a specific type whenever the default implementation
299            as shown above is not applicable. Examples for this could be that the
300            type <code class="computeroutput"><span class="identifier">Attrib</span></code> is not constructible
301            from the pair of iterators.
302          </p>
303</div>
304<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
305<td align="left"></td>
306<td align="right"><div class="copyright-footer">Copyright © 2001-2011 Joel de Guzman, Hartmut Kaiser<p>
307        Distributed under the Boost Software License, Version 1.0. (See accompanying
308        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>)
309      </p>
310</div></td>
311</tr></table>
312<hr>
313<div class="spirit-nav">
314<a accesskey="p" href="../assign_to.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../assign_to.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="assign_to_attribute_from_value.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
315</div>
316</body>
317</html>
318