• 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 Value into a Container after a Parser Produced a Value (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_attribute_from_value.html" title="Store an Attribute Value after a Parser Produced a Value (Qi)">
10<link rel="next" href="../store_value.html" title="Store Parsed Attribute Values into a Container (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_attribute_from_value.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="../store_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_container_from_value"></a><a class="link" href="assign_to_container_from_value.html" title="Store an Attribute Value into a Container after a Parser Produced a Value (Qi)">Store
28          an Attribute Value into a Container after a Parser Produced a Value (Qi)</a>
29</h5></div></div></div>
30<h6>
31<a name="spirit.advanced.customize.assign_to.assign_to_container_from_value.h0"></a>
32            <span class="phrase"><a name="spirit.advanced.customize.assign_to.assign_to_container_from_value.assign_to_container_from_value"></a></span><a class="link" href="assign_to_container_from_value.html#spirit.advanced.customize.assign_to.assign_to_container_from_value.assign_to_container_from_value">assign_to_container_from_value</a>
33          </h6>
34<p>
35            The template <code class="computeroutput"><span class="identifier">assign_to_container_from_value</span></code>
36            is a type used as an attribute customization point. It is invoked by
37            all primitive <span class="emphasis"><em>Qi</em></span> parsers in order to store a parsed
38            attribute value into the attribute instance provided by the user, if
39            this attribute is a container type (<code class="computeroutput"><span class="identifier">is_container</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
40            evaluates to <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code>, where <code class="computeroutput"><span class="identifier">T</span></code>
41            is the attribute type).
42          </p>
43<h6>
44<a name="spirit.advanced.customize.assign_to.assign_to_container_from_value.h1"></a>
45            <span class="phrase"><a name="spirit.advanced.customize.assign_to.assign_to_container_from_value.module_headers"></a></span><a class="link" href="assign_to_container_from_value.html#spirit.advanced.customize.assign_to.assign_to_container_from_value.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_container_from_value.h2"></a>
66            <span class="phrase"><a name="spirit.advanced.customize.assign_to.assign_to_container_from_value.namespace"></a></span><a class="link" href="assign_to_container_from_value.html#spirit.advanced.customize.assign_to.assign_to_container_from_value.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_container_from_value.h3"></a>
83            <span class="phrase"><a name="spirit.advanced.customize.assign_to.assign_to_container_from_value.synopsis"></a></span><a class="link" href="assign_to_container_from_value.html#spirit.advanced.customize.assign_to.assign_to_container_from_value.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">T</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_container_from_value</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">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">val</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_container_from_value.h4"></a>
93            <span class="phrase"><a name="spirit.advanced.customize.assign_to.assign_to_container_from_value.template_parameters"></a></span><a class="link" href="assign_to_container_from_value.html#spirit.advanced.customize.assign_to.assign_to_container_from_value.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. This
130                      type is a container type (<code class="computeroutput"><span class="identifier">is_container</span><span class="special">&lt;</span><span class="identifier">Attrib</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
131                      evaluates to <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code>).
132                    </p>
133                  </td>
134<td>
135                    <p>
136                      none
137                    </p>
138                  </td>
139</tr>
140<tr>
141<td>
142                    <p>
143                      <code class="computeroutput"><span class="identifier">T</span></code>
144                    </p>
145                  </td>
146<td>
147                    <p>
148                      The type, <code class="computeroutput"><span class="identifier">T</span></code>
149                      is the type of the attribute instance as produced by the parser.
150                    </p>
151                  </td>
152<td>
153                    <p>
154                      none
155                    </p>
156                  </td>
157</tr>
158<tr>
159<td>
160                    <p>
161                      <code class="computeroutput"><span class="identifier">Enable</span></code>
162                    </p>
163                  </td>
164<td>
165                    <p>
166                      Helper template parameter usable to selectively enable or disable
167                      certain specializations of <code class="computeroutput"><span class="identifier">assign_to_container_from_value</span></code>
168                      utilizing SFINAE (i.e. <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">enable_if</span></code>
169                      or <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">disable_if</span></code>).
170                    </p>
171                  </td>
172<td>
173                    <p>
174                      <code class="computeroutput"><span class="keyword">void</span></code>
175                    </p>
176                  </td>
177</tr>
178</tbody>
179</table></div>
180<div class="variablelist">
181<p class="title"><b>Notation</b></p>
182<dl class="variablelist">
183<dt><span class="term"><code class="computeroutput"><span class="identifier">Attrib</span></code></span></dt>
184<dd><p>
185                  A type to be used as the target to store the attribute value in.
186                  This type is guaranteed to be a container type (<code class="computeroutput"><span class="identifier">is_container</span><span class="special">&lt;</span><span class="identifier">Attrib</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
187                  evaluates to <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code>).
188                </p></dd>
189<dt><span class="term"><code class="computeroutput"><span class="identifier">attr</span></code></span></dt>
190<dd><p>
191                  An attribute instance of type <code class="computeroutput"><span class="identifier">Attrib</span></code>.
192                </p></dd>
193<dt><span class="term"><code class="computeroutput"><span class="identifier">T</span></code></span></dt>
194<dd><p>
195                  A type as produced by the parser. The parser temporarily stores
196                  its parsed values using this type.
197                </p></dd>
198<dt><span class="term"><code class="computeroutput"><span class="identifier">t</span></code></span></dt>
199<dd><p>
200                  An attribute instance of type <code class="computeroutput"><span class="identifier">T</span></code>.
201                </p></dd>
202</dl>
203</div>
204<h6>
205<a name="spirit.advanced.customize.assign_to.assign_to_container_from_value.h5"></a>
206            <span class="phrase"><a name="spirit.advanced.customize.assign_to.assign_to_container_from_value.expression_semantics"></a></span><a class="link" href="assign_to_container_from_value.html#spirit.advanced.customize.assign_to.assign_to_container_from_value.expression_semantics">Expression
207            Semantics</a>
208          </h6>
209<div class="informaltable"><table class="table">
210<colgroup>
211<col>
212<col>
213</colgroup>
214<thead><tr>
215<th>
216                    <p>
217                      Expression
218                    </p>
219                  </th>
220<th>
221                    <p>
222                      Semantics
223                    </p>
224                  </th>
225</tr></thead>
226<tbody><tr>
227<td>
228                    <p>
229</p>
230<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">assign_to_container_from_value</span><span class="special">&lt;</span><span class="identifier">Attrib</span><span class="special">,</span> <span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">call</span><span class="special">(</span><span class="identifier">t</span><span class="special">,</span> <span class="identifier">attr</span><span class="special">)</span></pre>
231<p>
232                    </p>
233                  </td>
234<td>
235                    <p>
236                      Add the value <code class="computeroutput"><span class="identifier">t</span></code>
237                      to the container attribute <code class="computeroutput"><span class="identifier">attr</span></code>.
238                    </p>
239                  </td>
240</tr></tbody>
241</table></div>
242<h6>
243<a name="spirit.advanced.customize.assign_to.assign_to_container_from_value.h6"></a>
244            <span class="phrase"><a name="spirit.advanced.customize.assign_to.assign_to_container_from_value.predefined_specializations"></a></span><a class="link" href="assign_to_container_from_value.html#spirit.advanced.customize.assign_to.assign_to_container_from_value.predefined_specializations">Predefined
245            Specializations</a>
246          </h6>
247<div class="informaltable"><table class="table">
248<colgroup>
249<col>
250<col>
251</colgroup>
252<thead><tr>
253<th>
254                    <p>
255                      Template Parameters
256                    </p>
257                  </th>
258<th>
259                    <p>
260                      Semantics
261                    </p>
262                  </th>
263</tr></thead>
264<tbody>
265<tr>
266<td>
267                    <p>
268                      <code class="computeroutput"><span class="identifier">Attrib</span></code>, <code class="computeroutput"><span class="identifier">T</span></code>
269                    </p>
270                  </td>
271<td>
272                    <p>
273                      Add the argument <code class="computeroutput"><span class="identifier">t</span></code>
274                      to <code class="computeroutput"><span class="identifier">attr</span></code>.
275                    </p>
276                  </td>
277</tr>
278<tr>
279<td>
280                    <p>
281                      <code class="computeroutput"><span class="identifier">unused_type</span></code>,
282                      <code class="computeroutput"><span class="identifier">T</span></code>
283                    </p>
284                  </td>
285<td>
286                    <p>
287                      Do nothing.
288                    </p>
289                  </td>
290</tr>
291</tbody>
292</table></div>
293<h6>
294<a name="spirit.advanced.customize.assign_to.assign_to_container_from_value.h7"></a>
295            <span class="phrase"><a name="spirit.advanced.customize.assign_to.assign_to_container_from_value.when_to_implement"></a></span><a class="link" href="assign_to_container_from_value.html#spirit.advanced.customize.assign_to.assign_to_container_from_value.when_to_implement">When
296            to implement</a>
297          </h6>
298<p>
299            The customization point <code class="computeroutput"><span class="identifier">assign_to_container_from_value</span></code>
300            needs to be implemented for a specific type whenever the default implementation
301            as shown above is not applicable. Examples for this could be that the
302            type <code class="computeroutput"><span class="identifier">Attrib</span></code> is not copy
303            constructible.
304          </p>
305</div>
306<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
307<td align="left"></td>
308<td align="right"><div class="copyright-footer">Copyright © 2001-2011 Joel de Guzman, Hartmut Kaiser<p>
309        Distributed under the Boost Software License, Version 1.0. (See accompanying
310        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>)
311      </p>
312</div></td>
313</tr></table>
314<hr>
315<div class="spirit-nav">
316<a accesskey="p" href="assign_to_attribute_from_value.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="../store_value.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
317</div>
318</body>
319</html>
320