• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Atomically Extract an Attribute Value from a Container (Karma)</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="../customize.html" title="Customization of Spirit's Attribute Handling">
9<link rel="prev" href="string_traits/extract_c_string.html" title="Get a C-style String from a String Type">
10<link rel="next" href="auto.html" title="Create Components from Attributes (Qi and Karma)">
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="string_traits/extract_c_string.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../customize.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="auto.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h4 class="title">
27<a name="spirit.advanced.customize.attribute_as"></a><a class="link" href="attribute_as.html" title="Atomically Extract an Attribute Value from a Container (Karma)">Atomically
28        Extract an Attribute Value from a Container (Karma)</a>
29</h4></div></div></div>
30<h6>
31<a name="spirit.advanced.customize.attribute_as.h0"></a>
32          <span class="phrase"><a name="spirit.advanced.customize.attribute_as.attribute_as"></a></span><a class="link" href="attribute_as.html#spirit.advanced.customize.attribute_as.attribute_as">attribute_as</a>
33        </h6>
34<p>
35          <code class="computeroutput"><span class="identifier">attribute_as</span></code> atomically
36          extracts an instance of a type from another type. This customization point
37          is used by the <a class="link" href="../../karma/reference/directive/as.html" title="Generator Directives Forcing Atomic Extraction (as&lt;T&gt;, as_string[], as_wstring[])"><code class="computeroutput"><span class="identifier">as</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;[]</span></code></a>
38          directive.
39        </p>
40<h6>
41<a name="spirit.advanced.customize.attribute_as.h1"></a>
42          <span class="phrase"><a name="spirit.advanced.customize.attribute_as.module_headers"></a></span><a class="link" href="attribute_as.html#spirit.advanced.customize.attribute_as.module_headers">Module
43          Headers</a>
44        </h6>
45<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">support</span><span class="special">/</span><span class="identifier">attributes_fwd</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
46</pre>
47<p>
48          Also, see <a class="link" href="../../structure/include.html" title="Include">Include Structure</a>.
49        </p>
50<div class="note"><table border="0" summary="Note">
51<tr>
52<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../images/note.png"></td>
53<th align="left">Note</th>
54</tr>
55<tr><td align="left" valign="top"><p>
56            This header file does not need to be included directly by any user program
57            as it is normally included by other Spirit header files relying on its
58            content.
59          </p></td></tr>
60</table></div>
61<h6>
62<a name="spirit.advanced.customize.attribute_as.h2"></a>
63          <span class="phrase"><a name="spirit.advanced.customize.attribute_as.namespace"></a></span><a class="link" href="attribute_as.html#spirit.advanced.customize.attribute_as.namespace">Namespace</a>
64        </h6>
65<div class="informaltable"><table class="table">
66<colgroup><col></colgroup>
67<thead><tr><th>
68                  <p>
69                    Name
70                  </p>
71                </th></tr></thead>
72<tbody><tr><td>
73                  <p>
74                    <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>
75                  </p>
76                </td></tr></tbody>
77</table></div>
78<h6>
79<a name="spirit.advanced.customize.attribute_as.h3"></a>
80          <span class="phrase"><a name="spirit.advanced.customize.attribute_as.synopsis"></a></span><a class="link" href="attribute_as.html#spirit.advanced.customize.attribute_as.synopsis">Synopsis</a>
81        </h6>
82<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Attribute</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Enable</span> <span class="special">=</span> <span class="keyword">void</span><span class="special">&gt;</span>
83<span class="keyword">struct</span> <span class="identifier">attribute_as</span><span class="special">;</span>
84</pre>
85<h6>
86<a name="spirit.advanced.customize.attribute_as.h4"></a>
87          <span class="phrase"><a name="spirit.advanced.customize.attribute_as.template_parameters"></a></span><a class="link" href="attribute_as.html#spirit.advanced.customize.attribute_as.template_parameters">Template
88          parameters</a>
89        </h6>
90<div class="informaltable"><table class="table">
91<colgroup>
92<col>
93<col>
94<col>
95</colgroup>
96<thead><tr>
97<th>
98                  <p>
99                    Parameter
100                  </p>
101                </th>
102<th>
103                  <p>
104                    Description
105                  </p>
106                </th>
107<th>
108                  <p>
109                    Default
110                  </p>
111                </th>
112</tr></thead>
113<tbody>
114<tr>
115<td>
116                  <p>
117                    <code class="computeroutput"><span class="identifier">T</span></code>
118                  </p>
119                </td>
120<td>
121                  <p>
122                    The type of the attribute natively exposed by the component the
123                    <code class="computeroutput"><span class="identifier">attribute_as</span></code>
124                    is invoked from.
125                  </p>
126                </td>
127<td>
128                  <p>
129                    none
130                  </p>
131                </td>
132</tr>
133<tr>
134<td>
135                  <p>
136                    <code class="computeroutput"><span class="identifier">Attribute</span></code>
137                  </p>
138                </td>
139<td>
140                  <p>
141                    The type of the attribute to be used to generate output from.
142                  </p>
143                </td>
144<td>
145                  <p>
146                    none
147                  </p>
148                </td>
149</tr>
150<tr>
151<td>
152                  <p>
153                    <code class="computeroutput"><span class="identifier">Enable</span></code>
154                  </p>
155                </td>
156<td>
157                  <p>
158                    Helper template parameter usable to selectively enable or disable
159                    certain specializations of <code class="computeroutput"><span class="identifier">attribute_as</span></code>
160                    utilizing SFINAE (i.e. <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">enable_if</span></code>
161                    or <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">disable_if</span></code>).
162                  </p>
163                </td>
164<td>
165                  <p>
166                    <code class="computeroutput"><span class="keyword">void</span></code>
167                  </p>
168                </td>
169</tr>
170</tbody>
171</table></div>
172<div class="variablelist">
173<p class="title"><b>Notation</b></p>
174<dl class="variablelist">
175<dt><span class="term"><code class="computeroutput"><span class="identifier">attr</span></code></span></dt>
176<dd><p>
177                An instance of type <code class="computeroutput"><span class="identifier">Attrib</span></code>.
178              </p></dd>
179</dl>
180</div>
181<h6>
182<a name="spirit.advanced.customize.attribute_as.h5"></a>
183          <span class="phrase"><a name="spirit.advanced.customize.attribute_as.expression_semantics"></a></span><a class="link" href="attribute_as.html#spirit.advanced.customize.attribute_as.expression_semantics">Expression
184          Semantics</a>
185        </h6>
186<div class="informaltable"><table class="table">
187<colgroup>
188<col>
189<col>
190</colgroup>
191<thead><tr>
192<th>
193                  <p>
194                    Expression
195                  </p>
196                </th>
197<th>
198                  <p>
199                    Semantics
200                  </p>
201                </th>
202</tr></thead>
203<tbody>
204<tr>
205<td>
206                  <p>
207                    <code class="computeroutput"><span class="identifier">attribute_as</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">Attribute</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
208                  </p>
209                </td>
210<td>
211                  <p>
212                    The result type of the extraction.
213                  </p>
214                </td>
215</tr>
216<tr>
217<td>
218                  <p>
219                    <code class="computeroutput"><span class="identifier">attribute_as</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">Attribute</span><span class="special">&gt;::</span><span class="identifier">call</span><span class="special">(</span><span class="identifier">attr</span><span class="special">)</span></code>
220                  </p>
221                </td>
222<td>
223                  <p>
224                    Extract and return an instance of <code class="computeroutput"><span class="identifier">type</span></code>.
225                  </p>
226                </td>
227</tr>
228<tr>
229<td>
230                  <p>
231                    <code class="computeroutput"><span class="identifier">attribute_as</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">Attribute</span><span class="special">&gt;::</span><span class="identifier">valid_as</span><span class="special">(</span><span class="identifier">attr</span><span class="special">)</span></code>
232                  </p>
233                </td>
234<td>
235                  <p>
236                    Determine, at runtime, if the extraction of an instance of <code class="computeroutput"><span class="identifier">type</span></code> from <code class="computeroutput"><span class="identifier">attr</span></code>
237                    would cause an error.
238                  </p>
239                </td>
240</tr>
241</tbody>
242</table></div>
243<h6>
244<a name="spirit.advanced.customize.attribute_as.h6"></a>
245          <span class="phrase"><a name="spirit.advanced.customize.attribute_as.predefined_specializations"></a></span><a class="link" href="attribute_as.html#spirit.advanced.customize.attribute_as.predefined_specializations">Predefined
246          Specializations</a>
247        </h6>
248<p>
249          <a href="http://boost-spirit.com" target="_top">Spirit</a> predefines specializations
250          of this customization point for several types. The following table lists
251          those types together with the types exposed and the corresponding semantics:
252        </p>
253<div class="informaltable"><table class="table">
254<colgroup>
255<col>
256<col>
257</colgroup>
258<thead><tr>
259<th>
260                  <p>
261                    Template Parameters
262                  </p>
263                </th>
264<th>
265                  <p>
266                    Semantics
267                  </p>
268                </th>
269</tr></thead>
270<tbody><tr>
271<td>
272                  <p>
273                    <code class="computeroutput"><span class="identifier">unused_type</span></code>
274                  </p>
275                </td>
276<td>
277                  <p>
278                    The exposed typedef <code class="computeroutput"><span class="identifier">type</span></code>
279                    is defined to <code class="computeroutput"><span class="identifier">unused_type</span></code>.
280                    The function <code class="computeroutput"><span class="identifier">call</span><span class="special">()</span></code> returns an instance of <code class="computeroutput"><span class="identifier">unused_type</span></code>.
281                  </p>
282                </td>
283</tr></tbody>
284</table></div>
285<h6>
286<a name="spirit.advanced.customize.attribute_as.h7"></a>
287          <span class="phrase"><a name="spirit.advanced.customize.attribute_as.when_to_implement"></a></span><a class="link" href="attribute_as.html#spirit.advanced.customize.attribute_as.when_to_implement">When
288          to implement</a>
289        </h6>
290<p>
291          This customization point may need to be implemented when using the <a class="link" href="../../karma/reference/directive/as.html" title="Generator Directives Forcing Atomic Extraction (as&lt;T&gt;, as_string[], as_wstring[])"><code class="computeroutput"><span class="identifier">as</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;[]</span></code></a> directive.
292        </p>
293</div>
294<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
295<td align="left"></td>
296<td align="right"><div class="copyright-footer">Copyright © 2001-2011 Joel de Guzman, Hartmut Kaiser<p>
297        Distributed under the Boost Software License, Version 1.0. (See accompanying
298        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>)
299      </p>
300</div></td>
301</tr></table>
302<hr>
303<div class="spirit-nav">
304<a accesskey="p" href="string_traits/extract_c_string.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../customize.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="auto.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
305</div>
306</body>
307</html>
308