env.xml 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--
  3. Copyright 2012 Eric Niebler
  4. Distributed under the Boost
  5. Software License, Version 1.0. (See accompanying
  6. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. -->
  8. <header name="boost/proto/transform/env.hpp">
  9. <namespace name="boost">
  10. <namespace name="proto">
  11. <struct name="key_not_found">
  12. <purpose>
  13. The type of objects returned when a key-based lookup fails in a
  14. transform environment.
  15. </purpose>
  16. </struct>
  17. <!-- empty_env -->
  18. <struct name="empty_env">
  19. <purpose>
  20. The type of an object that represents a transform environment
  21. with no key/value pairs in it.
  22. </purpose>
  23. <method-group name="public member functions">
  24. <method name="operator[]" cv="const">
  25. <type><classname>proto::key_not_found</classname></type>
  26. <parameter name="">
  27. <paramtype><replaceable>unspecified</replaceable></paramtype>
  28. </parameter>
  29. <description>
  30. <para>The type of the argument to this function has a
  31. user-defined implicit conversion from any type.</para>
  32. </description>
  33. </method>
  34. </method-group>
  35. </struct>
  36. <!-- env -->
  37. <struct name="env">
  38. <template>
  39. <template-type-parameter name="Key"/>
  40. <template-type-parameter name="Value"/>
  41. <template-type-parameter name="Env">
  42. <default><classname>proto::empty_env</classname></default>
  43. </template-type-parameter>
  44. </template>
  45. <constructor specifiers="explicit">
  46. <parameter name="value">
  47. <paramtype>Value const &amp;</paramtype>
  48. <description>
  49. <para>
  50. The value to be associated with the <code>Key</code>.
  51. </para>
  52. </description>
  53. </parameter>
  54. <parameter name="other">
  55. <paramtype>Env const &amp;</paramtype>
  56. <default>Env()</default>
  57. <description>
  58. <para>
  59. Another key/value store.
  60. </para>
  61. </description>
  62. </parameter>
  63. </constructor>
  64. <method-group name="public member functions">
  65. <method name="operator[]" cv="const">
  66. <type><replaceable>see-below</replaceable></type>
  67. <parameter name="">
  68. <paramtype><replaceable>see-below</replaceable></paramtype>
  69. </parameter>
  70. <description>
  71. <para>
  72. If called with an object that is implicitly convertible to type <code>Key</code>,
  73. this function returns the <code>Value</code> passed to the constructor. Otherwise, it returns
  74. the result of calling <code>operator[]</code> on the <code>Env</code> passed to
  75. the constructor.
  76. </para>
  77. </description>
  78. </method>
  79. </method-group>
  80. </struct>
  81. <!-- is_env -->
  82. <struct name="is_env">
  83. <template>
  84. <template-type-parameter name="T"/>
  85. </template>
  86. <inherit><type>mpl::bool_&lt;<replaceable>true-or-false</replaceable>&gt;</type></inherit>
  87. <purpose>
  88. <para>A Boolean metafuntion for determining whether or not a type is a Proto
  89. transform environment.</para>
  90. </purpose>
  91. <description>
  92. <para><code>is_env&lt;T&gt;</code> inherits from <code>mpl::true_</code> under the following
  93. conditions:
  94. <itemizedlist>
  95. <listitem>If <code>T</code> is <classname>proto::empty_env</classname>.</listitem>
  96. <listitem>If <code>T</code> is a specialization of <classname>proto::env&lt;&gt;</classname>.</listitem>
  97. <listitem>If <code>T</code> is derived from any of the above.</listitem>
  98. <listitem>If <code>T</code> is a cv-qualified variant of any of the above.</listitem>
  99. <listitem>If <code>T</code> is a reference to any of the above.</listitem>
  100. </itemizedlist>
  101. </para>
  102. <para>Otherwise, <code>is_env&lt;T&gt;</code> inherits from <code>mpl::false_</code>.
  103. </para>
  104. </description>
  105. </struct>
  106. <struct name="data_type">
  107. <purpose>
  108. The type of <code><globalname>proto::data</globalname></code>, a key for use when creating
  109. a transform environment that associates a piece of data with this type.
  110. </purpose>
  111. <description>
  112. <para>
  113. The <code>proto::data_type</code> type, along with the <code><globalname>proto::data</globalname></code>
  114. global, are declared using the <code><macroname>BOOST_PROTO_DEFINE_ENV_VAR</macroname>()</code> macro.
  115. </para>
  116. </description>
  117. <method-group name="public member functions">
  118. <overloaded-method name="operator=">
  119. <signature cv="const">
  120. <template>
  121. <template-type-parameter name="Value"/>
  122. </template>
  123. <type><classname>env</classname>&lt;data_type, <replaceable>see-below</replaceable>&gt;</type>
  124. <parameter name="value">
  125. <paramtype>Value &amp;</paramtype>
  126. </parameter>
  127. </signature>
  128. <signature cv="const">
  129. <template>
  130. <template-type-parameter name="Value"/>
  131. </template>
  132. <type><classname>env</classname>&lt;data_type, <replaceable>see-below</replaceable>&gt;</type>
  133. <parameter name="value">
  134. <paramtype>Value const &amp;</paramtype>
  135. </parameter>
  136. </signature>
  137. <description>
  138. <para>
  139. If <code>Value</code> is a specialization <code>boost::reference_wrapper&lt;T&gt;</code>,
  140. this function returns <code><classname>env</classname>&lt;data_type, T &amp;&gt;(value.get())</code>.
  141. </para>
  142. <para>
  143. Else, if the type <code>Value</code> is non-copyable (i.e., a function, an array, abstract, or an ostream),
  144. this function returns <code><classname>env</classname>&lt;data_type, Value <replaceable>cv</replaceable> &amp;&gt;(value)</code>,
  145. where <code><replaceable>cv</replaceable></code> is <code>const</code> for the second overload, and empty
  146. for the first.
  147. </para>
  148. <para>
  149. Otherwise, this function returns <code><classname>env</classname>&lt;data_type, Value&gt;(value)</code>.
  150. </para>
  151. </description>
  152. </overloaded-method>
  153. </method-group>
  154. </struct>
  155. <data-member name="data">
  156. <description>
  157. <para>A key used for creating a transform environment.</para>
  158. </description>
  159. <type><classname>proto::data_type</classname> const</type>
  160. </data-member>
  161. <namespace name="functional">
  162. <!-- functional::as_env -->
  163. <struct name="as_env">
  164. <inherit><classname>proto::callable</classname></inherit>
  165. <purpose>
  166. A unary <conceptname>PolymorphicFunctionObject</conceptname> for ensuring that an object
  167. is a transform environment. If it isn't already, it is turned into one such that the
  168. object is associated with the <classname>proto::data_type</classname> key.
  169. </purpose>
  170. <struct name="result">
  171. <template>
  172. <template-type-parameter name="Sig"/>
  173. </template>
  174. <typedef name="type">
  175. <type><replaceable>see-below</replaceable></type>
  176. <description>
  177. <para>See <code><methodname>proto::functional::as_env::operator()</methodname></code>.</para>
  178. </description>
  179. </typedef>
  180. <description>
  181. <para>
  182. Encodes the return type of <code><methodname>proto::functional::as_env::operator()</methodname></code>.
  183. The presence of this member template makes <code><classname>proto::functional::as_env</classname></code>
  184. a valid TR1-style function object type usable with <code>boost::result_of&lt;&gt;</code>.
  185. </para>
  186. </description>
  187. </struct>
  188. <method-group name="public member functions">
  189. <overloaded-method name="operator()">
  190. <signature cv="const">
  191. <template>
  192. <template-type-parameter name="T"/>
  193. </template>
  194. <type><replaceable>see-below</replaceable></type>
  195. <parameter name="t">
  196. <paramtype>T &amp;</paramtype>
  197. </parameter>
  198. </signature>
  199. <signature cv="const">
  200. <template>
  201. <template-type-parameter name="T"/>
  202. </template>
  203. <type><replaceable>see-below</replaceable></type>
  204. <parameter name="t">
  205. <paramtype>T const &amp;</paramtype>
  206. </parameter>
  207. </signature>
  208. <description>
  209. <para>
  210. If <code><classname>proto::is_env</classname>&lt;T&gt;::value</code> is <code>false</code>,
  211. this function returns the result of <code>(<globalname>proto::data</globalname> = t)</code>.
  212. See <code><methodname>proto::data_type::operator=</methodname></code> for details.
  213. </para>
  214. <para>
  215. Otherwise, this function returns <code>t</code> by reference.
  216. </para>
  217. </description>
  218. </overloaded-method>
  219. </method-group>
  220. </struct>
  221. <!-- functional::has_env_var -->
  222. <struct name="has_env_var">
  223. <inherit><classname>proto::callable</classname></inherit>
  224. <template>
  225. <template-type-parameter name="Key"/>
  226. </template>
  227. <purpose>
  228. A unary boolean <conceptname>PolymorphicFunctionObject</conceptname> used for determining whether a particular
  229. transform environment has a value associated with a particular key.
  230. </purpose>
  231. <struct name="result">
  232. <template>
  233. <template-type-parameter name="Sig"/>
  234. </template>
  235. <typedef name="type">
  236. <type><replaceable>see-below</replaceable></type>
  237. <description>
  238. <para>See <code><methodname>proto::functional::has_env_var::operator()</methodname></code>.</para>
  239. </description>
  240. </typedef>
  241. <description>
  242. <para>
  243. Encodes the return type of <code><methodname>proto::functional::has_env_var::operator()</methodname></code>.
  244. The presence of this member template makes <code><classname>proto::functional::has_env_var</classname></code>
  245. a valid TR1-style function object type usable with <code>boost::result_of&lt;&gt;</code>.
  246. </para>
  247. </description>
  248. </struct>
  249. <method-group name="public member functions">
  250. <method name="operator()" cv="const">
  251. <template>
  252. <template-type-parameter name="Env"/>
  253. </template>
  254. <type><replaceable>see-below</replaceable></type>
  255. <parameter name="e">
  256. <paramtype>Env const &amp;</paramtype>
  257. </parameter>
  258. <description>
  259. <para>
  260. This function behaves as follows:
  261. <itemizedlist>
  262. <listitem>
  263. If <code><classname>proto::is_env</classname>&lt;Env&gt;::value</code> is <code>true</code>:
  264. <itemizedlist>
  265. <listitem>
  266. If <code>e[Key()]</code> returns an instance of
  267. <code><classname>proto::key_not_found</classname></code>, return
  268. <code>mpl::false_</code>. See <code><methodname>proto::env::operator[]</methodname></code>
  269. for more information.
  270. </listitem>
  271. <listitem>
  272. Otherwise, return <code>mpl::true_</code>.
  273. </listitem>
  274. </itemizedlist>
  275. </listitem>
  276. <listitem>
  277. Otherwise:
  278. <itemizedlist>
  279. <listitem>
  280. If <code>Key</code> is <code><classname>proto::data_type</classname></code>,
  281. return <code>mpl::true_</code>.
  282. </listitem>
  283. <listitem>
  284. Otherwise, return <code>mpl::false_</code>.
  285. </listitem>
  286. </itemizedlist>
  287. </listitem>
  288. </itemizedlist>
  289. </para>
  290. </description>
  291. </method>
  292. </method-group>
  293. </struct>
  294. <!-- functional::env_var -->
  295. <struct name="env_var">
  296. <inherit><classname>proto::callable</classname></inherit>
  297. <template>
  298. <template-type-parameter name="Key"/>
  299. </template>
  300. <purpose>
  301. A unary <conceptname>PolymorphicFunctionObject</conceptname> used for fetching the value
  302. associated with a particular key in a transform environment.
  303. </purpose>
  304. <struct name="result">
  305. <template>
  306. <template-type-parameter name="Sig"/>
  307. </template>
  308. <typedef name="type">
  309. <type><replaceable>see-below</replaceable></type>
  310. <description>
  311. <para>See <code><methodname>proto::functional::env_var::operator()</methodname></code>.</para>
  312. </description>
  313. </typedef>
  314. <description>
  315. <para>
  316. Encodes the return type of <code><methodname>proto::functional::env_var::operator()</methodname></code>.
  317. The presence of this member template makes <code><classname>proto::functional::env_var</classname></code>
  318. a valid TR1-style function object type usable with <code>boost::result_of&lt;&gt;</code>.
  319. </para>
  320. </description>
  321. </struct>
  322. <method-group name="public member functions">
  323. <method name="operator()" cv="const">
  324. <template>
  325. <template-type-parameter name="Env"/>
  326. </template>
  327. <type><replaceable>see-below</replaceable></type>
  328. <parameter name="e">
  329. <paramtype>Env const &amp;</paramtype>
  330. </parameter>
  331. <description>
  332. <para>
  333. This function behaves as follows:
  334. <itemizedlist>
  335. <listitem>
  336. If <code>Key</code> is <code><classname>proto::data_type</classname></code>:
  337. <itemizedlist>
  338. <listitem>
  339. If <code><classname>proto::is_env</classname>&lt;Env&gt;::value</code> is <code>true</code>,
  340. return <code>e[<globalname>proto::data</globalname>]</code>.
  341. </listitem>
  342. <listitem>
  343. Otherwise, return <code>e</code>.
  344. </listitem>
  345. </itemizedlist>
  346. </listitem>
  347. <listitem>
  348. Otherwise, return <code>e[Key()]</code>.
  349. </listitem>
  350. </itemizedlist>
  351. </para>
  352. <para>
  353. See <code><methodname>proto::env::operator[]</methodname></code> for additional information.
  354. </para>
  355. </description>
  356. </method>
  357. </method-group>
  358. </struct>
  359. </namespace>
  360. <namespace name="result_of">
  361. <struct name="as_env">
  362. <template>
  363. <template-type-parameter name="T"/>
  364. </template>
  365. <inherit><type>boost::result_of&lt;<classname>proto::functional::as_env</classname>(T)&gt;</type></inherit>
  366. <purpose>
  367. Metafunction for computing the return type of <code><functionname>proto::as_env()</functionname></code>.
  368. </purpose>
  369. </struct>
  370. <struct name="has_env_var">
  371. <template>
  372. <template-type-parameter name="Env"/>
  373. <template-type-parameter name="Key"/>
  374. </template>
  375. <inherit><type>boost::result_of&lt;<classname>proto::functional::has_env_var</classname>&lt;Key&gt;(Env)&gt;::type</type></inherit>
  376. <purpose>
  377. Metafunction for computing the return type of <code><functionname>proto::has_env_var()</functionname></code>.
  378. </purpose>
  379. </struct>
  380. <struct name="env_var">
  381. <template>
  382. <template-type-parameter name="Env"/>
  383. <template-type-parameter name="Key"/>
  384. </template>
  385. <inherit><type>boost::result_of&lt;<classname>proto::functional::env_var</classname>&lt;Key&gt;(Env)&gt;</type></inherit>
  386. <purpose>
  387. Metafunction for computing the return type of <code><functionname>proto::env_var()</functionname></code>.
  388. </purpose>
  389. </struct>
  390. </namespace>
  391. <!-- proto::as_env -->
  392. <overloaded-function name="as_env">
  393. <signature>
  394. <template>
  395. <template-type-parameter name="T"/>
  396. </template>
  397. <type>typename <classname>proto::result_of::as_env</classname>&lt;T &amp;&gt;::type</type>
  398. <parameter name="t">
  399. <paramtype>T &amp;</paramtype>
  400. </parameter>
  401. </signature>
  402. <signature>
  403. <template>
  404. <template-type-parameter name="T"/>
  405. </template>
  406. <type>typename <classname>proto::result_of::as_env</classname>&lt;T const &amp;&gt;::type</type>
  407. <parameter name="t">
  408. <paramtype>T const &amp;</paramtype>
  409. </parameter>
  410. </signature>
  411. <purpose>
  412. For ensuring that the given argument is a transform environment. If it is not already,
  413. it is made one as if by <code>(<globalname>proto::data</globalname> = t)</code>.
  414. </purpose>
  415. <description>
  416. <para>
  417. See also:
  418. <itemizedlist>
  419. <listitem>
  420. <code><methodname>proto::data_type::operator=</methodname></code>
  421. </listitem>
  422. <listitem>
  423. <code><methodname>proto::functional::as_env::operator()</methodname></code>
  424. </listitem>
  425. </itemizedlist>
  426. </para>
  427. </description>
  428. <returns><code><classname>proto::functional::as_env</classname>()(t)</code></returns>
  429. </overloaded-function>
  430. <!-- proto::has_env_var -->
  431. <overloaded-function name="has_env_var">
  432. <signature>
  433. <template>
  434. <template-type-parameter name="Key"/>
  435. <template-type-parameter name="Env"/>
  436. </template>
  437. <type>typename <classname>proto::result_of::has_env_var</classname>&lt;Env &amp;, Key&gt;::type</type>
  438. <parameter name="e">
  439. <paramtype>Env &amp;</paramtype>
  440. </parameter>
  441. </signature>
  442. <signature>
  443. <template>
  444. <template-type-parameter name="Key"/>
  445. <template-type-parameter name="Env"/>
  446. </template>
  447. <type>typename <classname>proto::result_of::has_env_var</classname>&lt;Env const &amp;, Key&gt;::type</type>
  448. <parameter name="e">
  449. <paramtype>Env const &amp;</paramtype>
  450. </parameter>
  451. </signature>
  452. <purpose>
  453. For testing to see whether a value exists in a transform environment corresponding to the
  454. specified <code>Key</code>.
  455. </purpose>
  456. <description>
  457. <para>
  458. See also:
  459. <itemizedlist>
  460. <listitem>
  461. <code><methodname>proto::functional::has_env_var::operator()</methodname></code>
  462. </listitem>
  463. </itemizedlist>
  464. </para>
  465. </description>
  466. <returns><code><classname>proto::functional::has_env_var&lt;Key&gt;</classname>()(e)</code></returns>
  467. </overloaded-function>
  468. <!-- proto::env_var -->
  469. <overloaded-function name="env_var">
  470. <signature>
  471. <template>
  472. <template-type-parameter name="Key"/>
  473. <template-type-parameter name="Env"/>
  474. </template>
  475. <type>typename <classname>proto::result_of::env_var</classname>&lt;Env &amp;, Key&gt;::type</type>
  476. <parameter name="e">
  477. <paramtype>Env &amp;</paramtype>
  478. </parameter>
  479. </signature>
  480. <signature>
  481. <template>
  482. <template-type-parameter name="Key"/>
  483. <template-type-parameter name="Env"/>
  484. </template>
  485. <type>typename <classname>proto::result_of::env_var</classname>&lt;Env const &amp;, Key&gt;::type</type>
  486. <parameter name="e">
  487. <paramtype>Env const &amp;</paramtype>
  488. </parameter>
  489. </signature>
  490. <purpose>
  491. For fetching the value from a transform environment corresponding to the
  492. specified <code>Key</code>.
  493. </purpose>
  494. <description>
  495. <para>
  496. See also:
  497. <itemizedlist>
  498. <listitem>
  499. <code><methodname>proto::functional::env_var::operator()</methodname></code>
  500. </listitem>
  501. </itemizedlist>
  502. </para>
  503. </description>
  504. <returns><code><classname>proto::functional::env_var&lt;Key&gt;</classname>()(e)</code></returns>
  505. </overloaded-function>
  506. <!-- proto::operator, -->
  507. <overloaded-function name="operator,">
  508. <signature>
  509. <template>
  510. <template-type-parameter name="Env"/>
  511. <template-type-parameter name="Key"/>
  512. <template-type-parameter name="Value"/>
  513. </template>
  514. <type><classname>proto::env</classname>&lt;Key, Value, <replaceable>UNCVREF</replaceable>(typename <classname>proto::result_of::as_env</classname>&lt;Env &amp;&gt;::type)&gt;</type>
  515. <parameter name="other">
  516. <paramtype>Env &amp;</paramtype>
  517. </parameter>
  518. <parameter name="head">
  519. <paramtype><classname>proto::env</classname>&lt;Key, Value&gt; const &amp;</paramtype>
  520. </parameter>
  521. </signature>
  522. <signature>
  523. <template>
  524. <template-type-parameter name="Env"/>
  525. <template-type-parameter name="Key"/>
  526. <template-type-parameter name="Value"/>
  527. </template>
  528. <type><classname>proto::env</classname>&lt;Key, Value, <replaceable>UNCVREF</replaceable>(typename <classname>proto::result_of::as_env</classname>&lt;Env const &amp;&gt;::type)&gt;</type>
  529. <parameter name="other">
  530. <paramtype>Env const &amp;</paramtype>
  531. </parameter>
  532. <parameter name="head">
  533. <paramtype><classname>proto::env</classname>&lt;Key, Value&gt; const &amp;</paramtype>
  534. </parameter>
  535. </signature>
  536. <purpose>
  537. For composing a larger transform environment from two smaller ones.
  538. </purpose>
  539. <description>
  540. <para>
  541. The effect of this function is to take two transform environments and compose them into
  542. a larger environment that contains the key/values pairs of the two. The first argument
  543. is allowed to not be a transform environment, in which case it is turned into one with
  544. the <functionname>proto::as_env()</functionname> function before composition with the
  545. second argument. The second argument is required to be a transform environment with exactly
  546. one key/value pair.
  547. </para>
  548. <para>
  549. <emphasis role="bold">Example:</emphasis>
  550. </para>
  551. <para>
  552. Given user-defined keys <code>key0</code> and <code>key1</code> of types <code>key0_type</code>
  553. and <code>key1_type</code>, the following code demonstrates how the chained use of <code>operator,</code>
  554. can build a composite transform environment containing a number of key/value pairs:
  555. <programlisting><classname>proto::env</classname>&lt;
  556. key1_type
  557. , int
  558. , <classname>proto::env</classname>&lt;
  559. key0_type
  560. , char const (&amp;)[6]
  561. , <classname>proto::env</classname>&lt;<classname>proto::data_type</classname>, int&gt;
  562. &gt;
  563. &gt; myenv = (<globalname>proto::data</globalname> = 1, key0 = "hello", key1 = 42);
  564. // NOTE: operator, here --^ and here --^
  565. // Check the results:
  566. assert(1 == myenv[proto::data]);
  567. assert(0 == std::strcmp(myenv[key0], "hello"));
  568. assert(42 == myenv[key1]);</programlisting>
  569. </para>
  570. <para>
  571. <emphasis role="bold">Note:</emphasis> In the return type and the "Returns" clause, <code><replaceable>UNCVREF</replaceable>(X)</code> is
  572. the type <code>X</code> stripped of top-level reference and cv-qualifiers.
  573. </para>
  574. <para>
  575. <emphasis role="bold">Note:</emphasis> In the "Returns" clause, <code><replaceable>cv</replaceable></code> is replaced with <code>const</code>
  576. for the second overload, and nothing for the first.
  577. </para>
  578. <para>
  579. <emphasis role="bold">See also:</emphasis>
  580. <itemizedlist>
  581. <listitem>
  582. <code><methodname>proto::env::operator[]</methodname></code>
  583. </listitem>
  584. </itemizedlist>
  585. </para>
  586. </description>
  587. <returns><code><classname>proto::env</classname>&lt;Key, Value, <replaceable>UNCVREF</replaceable>(typename <classname>proto::result_of::as_env</classname>&lt;Env <replaceable>cv</replaceable> &amp;&gt;::type)&gt;(head[Key()], <functionname>proto::as_env</functionname>(other))</code></returns>
  588. </overloaded-function>
  589. <!-- struct _env_var -->
  590. <struct name="_env_var">
  591. <template>
  592. <template-type-parameter name="Key"/>
  593. </template>
  594. <purpose>
  595. A primitive transform that returns the value associated with a particular <code>Key</code>
  596. in the current transform environment.
  597. </purpose>
  598. <inherit>
  599. <type><classname>proto::transform</classname>&lt;_env_var&lt;Key&gt; &gt;</type>
  600. </inherit>
  601. <struct name="impl">
  602. <template>
  603. <template-type-name name="Expr"/>
  604. <template-type-name name="State"/>
  605. <template-type-name name="Data"/>
  606. </template>
  607. <inherit>
  608. <type><classname>proto::transform_impl</classname>&lt;Expr, State, Data&gt; &gt;</type>
  609. </inherit>
  610. <typedef name="result_type">
  611. <type>typename <classname>proto::result_of::env_var</classname>&lt;Data, Key&gt;::type</type>
  612. </typedef>
  613. <method-group name="public member functions">
  614. <method name="operator()" cv="const">
  615. <type>result_type</type>
  616. <parameter name="">
  617. <paramtype>typename impl::expr_param</paramtype>
  618. </parameter>
  619. <parameter name="">
  620. <paramtype>typename impl::state_param</paramtype>
  621. </parameter>
  622. <parameter name="data">
  623. <paramtype>typename impl::data_param</paramtype>
  624. <description>
  625. <para>The current transform environment</para>
  626. </description>
  627. </parameter>
  628. <description>
  629. <para>
  630. Fetches the value associated with <code>Key</code> from the transform environment
  631. passed in the data (third) parameter.
  632. </para>
  633. </description>
  634. <requires>
  635. <para>
  636. <code><classname>proto::is_env</classname>&lt;Data&gt;::value</code>
  637. is <code>true</code>.
  638. </para>
  639. </requires>
  640. <returns>
  641. <para>
  642. <code><functionname>proto::env_var</functionname>(data)</code>
  643. </para>
  644. </returns>
  645. </method>
  646. </method-group>
  647. </struct>
  648. <description>
  649. <para>
  650. See <code><classname>proto::_env_var::impl</classname></code> for the full details.
  651. </para>
  652. </description>
  653. </struct>
  654. <!-- struct _env -->
  655. <struct name="_env">
  656. <purpose>
  657. A primitive transform that returns the current transform environment unmodified.
  658. </purpose>
  659. <inherit>
  660. <type><classname>proto::transform</classname>&lt;_env&gt;</type>
  661. </inherit>
  662. <struct name="impl">
  663. <template>
  664. <template-type-name name="Expr"/>
  665. <template-type-name name="State"/>
  666. <template-type-name name="Data"/>
  667. </template>
  668. <inherit>
  669. <type><classname>proto::transform_impl</classname>&lt;Expr, State, Data&gt;</type>
  670. </inherit>
  671. <typedef name="result_type">
  672. <type>Data</type>
  673. </typedef>
  674. <method-group name="public member functions">
  675. <method name="operator()" cv="const">
  676. <type>result_type</type>
  677. <parameter name="">
  678. <paramtype>typename impl::expr_param</paramtype>
  679. </parameter>
  680. <parameter name="">
  681. <paramtype>typename impl::state_param</paramtype>
  682. </parameter>
  683. <parameter name="data">
  684. <paramtype>typename impl::data_param</paramtype>
  685. <description>
  686. <para>The current transform environment </para>
  687. </description>
  688. </parameter>
  689. <description>
  690. <para>
  691. Returns the current transform environment
  692. passed in the data (third) parameter.
  693. </para>
  694. </description>
  695. <returns>
  696. <para>
  697. <code>data</code>
  698. </para>
  699. </returns>
  700. </method>
  701. </method-group>
  702. </struct>
  703. <description>
  704. <para>
  705. See <code><classname>proto::_env::impl</classname></code> for the full details.
  706. </para>
  707. </description>
  708. </struct>
  709. </namespace>
  710. </namespace>
  711. <!-- BOOST_PROTO_DEFINE_ENV_VAR() -->
  712. <macro name="BOOST_PROTO_DEFINE_ENV_VAR" kind="functionlike">
  713. <macro-parameter name="Type"/>
  714. <macro-parameter name="Name"/>
  715. <purpose>
  716. Define a type and a global variable of that type that can be used
  717. to initialize a slot in a Proto transform environment.
  718. </purpose>
  719. <description>
  720. <para>
  721. Proto primitive transforms can optionally accept an environment in
  722. their third parameter which is a key/value store of environment
  723. variables. Use the <code>BOOST_PROTO_DEFINE_ENV_VAR()</code> macro
  724. to define the keys.
  725. </para>
  726. <para>
  727. See the description for <code><classname alt="boost::proto::data_type">proto::data_type</classname></code>
  728. for an example of the class interface created by this macro.
  729. </para>
  730. <para>
  731. <emphasis role="bold">Example:</emphasis>
  732. </para>
  733. <para>
  734. <programlisting>BOOST_PROTO_DEFINE_ENV_VAR(mykey_type, mykey);
  735. struct FetchMyKey
  736. : <classname alt="boost::proto::when">proto::when</classname>&lt; <classname alt="boost::proto::_">_</classname>, <classname alt="boost::proto::_env_var">proto::_env_var</classname>&lt;mykey_type&gt; &gt;
  737. {};
  738. int main()
  739. {
  740. <classname alt="boost::proto::terminal">proto::terminal</classname>&lt;int&gt;::type i = {42};
  741. char const * sz = FetchMyKey()(i, 0, (mykey = "hello!"));
  742. assert(0 == std::strcmp(sz, "hello!");
  743. }</programlisting>
  744. </para>
  745. </description>
  746. </macro>
  747. </header>