1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Generator Directives Controlling Case Sensitivity (upper[], lower[])</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="../directive.html" title="Generator Directives"> 9<link rel="prev" href="delimit.html" title="Generator Directives Controlling Automatic Delimiting (verbatim[], no_delimit[], delimit[])"> 10<link rel="next" href="maxwidth.html" title="Generator Directives Controlling the Maximum Field Width (maxwidth[])"> 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="delimit.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../directive.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="maxwidth.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.karma.reference.directive.upperlower"></a><a class="link" href="upperlower.html" title="Generator Directives Controlling Case Sensitivity (upper[], lower[])">Generator 28 Directives Controlling Case Sensitivity (<code class="computeroutput"><span class="identifier">upper</span><span class="special">[]</span></code>, <code class="computeroutput"><span class="identifier">lower</span><span class="special">[]</span></code>)</a> 29</h5></div></div></div> 30<h6> 31<a name="spirit.karma.reference.directive.upperlower.h0"></a> 32 <span class="phrase"><a name="spirit.karma.reference.directive.upperlower.description"></a></span><a class="link" href="upperlower.html#spirit.karma.reference.directive.upperlower.description">Description</a> 33 </h6> 34<p> 35 The generator directives <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">lower</span><span class="special">[]</span></code> and <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">upper</span><span class="special">[]</span></code> force their embedded generators to 36 emit lower case or upper case only characters based on the interpretation 37 of the generated characters in the character set defined by <code class="computeroutput"><span class="identifier">ns</span></code> (see <a class="link" href="../basics.html#spirit.karma.reference.basics.character_encoding_namespace">Character 38 Encoding Namespace</a>). 39 </p> 40<h6> 41<a name="spirit.karma.reference.directive.upperlower.h1"></a> 42 <span class="phrase"><a name="spirit.karma.reference.directive.upperlower.header"></a></span><a class="link" href="upperlower.html#spirit.karma.reference.directive.upperlower.header">Header</a> 43 </h6> 44<pre class="programlisting"><span class="comment">// forwards to <boost/spirit/home/karma/directive/upper_lower_case.hpp></span> 45<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">karma_upper_lower_case</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 46</pre> 47<p> 48 Also, see <a class="link" href="../../../structure/include.html" title="Include">Include Structure</a>. 49 </p> 50<h6> 51<a name="spirit.karma.reference.directive.upperlower.h2"></a> 52 <span class="phrase"><a name="spirit.karma.reference.directive.upperlower.namespace"></a></span><a class="link" href="upperlower.html#spirit.karma.reference.directive.upperlower.namespace">Namespace</a> 53 </h6> 54<div class="informaltable"><table class="table"> 55<colgroup><col></colgroup> 56<thead><tr><th> 57 <p> 58 Name 59 </p> 60 </th></tr></thead> 61<tbody> 62<tr><td> 63 <p> 64 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">lower</span></code> 65 </p> 66 </td></tr> 67<tr><td> 68 <p> 69 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">upper</span></code> 70 </p> 71 </td></tr> 72</tbody> 73</table></div> 74<p> 75 In the table above, <code class="computeroutput"><span class="identifier">ns</span></code> 76 represents a <a class="link" href="../basics.html#spirit.karma.reference.basics.character_encoding_namespace">Character 77 Encoding Namespace</a>. 78 </p> 79<h6> 80<a name="spirit.karma.reference.directive.upperlower.h3"></a> 81 <span class="phrase"><a name="spirit.karma.reference.directive.upperlower.model_of"></a></span><a class="link" href="upperlower.html#spirit.karma.reference.directive.upperlower.model_of">Model 82 of</a> 83 </h6> 84<div class="blockquote"><blockquote class="blockquote"><p> 85 The model of <code class="computeroutput"><span class="identifier">lower</span><span class="special">[]</span></code> and <code class="computeroutput"><span class="identifier">upper</span><span class="special">[]</span></code> is the model of its subject generator. 86 </p></blockquote></div> 87<div class="variablelist"> 88<p class="title"><b>Notation</b></p> 89<dl class="variablelist"> 90<dt><span class="term"><code class="computeroutput"><span class="identifier">a</span></code></span></dt> 91<dd><p> 92 A generator object 93 </p></dd> 94<dt><span class="term"><code class="computeroutput"><span class="identifier">A</span></code></span></dt> 95<dd><p> 96 Attribute type of the generator <code class="computeroutput"><span class="identifier">a</span></code> 97 </p></dd> 98<dt><span class="term"><code class="computeroutput"><span class="identifier">ns</span></code></span></dt> 99<dd><p> 100 A <a class="link" href="../basics.html#spirit.karma.reference.basics.character_encoding_namespace">Character 101 Encoding Namespace</a>. 102 </p></dd> 103</dl> 104</div> 105<h6> 106<a name="spirit.karma.reference.directive.upperlower.h4"></a> 107 <span class="phrase"><a name="spirit.karma.reference.directive.upperlower.expression_semantics"></a></span><a class="link" href="upperlower.html#spirit.karma.reference.directive.upperlower.expression_semantics">Expression 108 Semantics</a> 109 </h6> 110<p> 111 The <code class="computeroutput"><span class="identifier">lower</span><span class="special">[]</span></code> 112 and <code class="computeroutput"><span class="identifier">upper</span><span class="special">[]</span></code> 113 directives have no special generator semantics. They are pure modifier 114 directives. They indirectly influence the way all subject generators 115 work. They add information (the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">upper</span></code> 116 or <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">lower</span></code>) to the <code class="computeroutput"><span class="identifier">Modifier</span></code> 117 template parameter used while transforming the <code class="computeroutput"><span class="identifier">proto</span><span class="special">::</span><span class="identifier">expr</span></code> 118 into the corresponding generator expression. This is achieved by the 119 following specializations: 120 </p> 121<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">spirit</span> 122<span class="special">{</span> 123 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">CharEncoding</span><span class="special">></span> 124 <span class="keyword">struct</span> <span class="identifier">is_modifier_directive</span><span class="special"><</span> 125 <span class="identifier">karma</span><span class="special">::</span><span class="identifier">domain</span> 126 <span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">char_code</span><span class="special"><</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">lower</span><span class="special">,</span> <span class="identifier">CharEncoding</span><span class="special">></span> <span class="special">></span> 127 <span class="special">:</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span> 128 <span class="special">{};</span> 129 130 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">CharEncoding</span><span class="special">></span> 131 <span class="keyword">struct</span> <span class="identifier">is_modifier_directive</span><span class="special"><</span> 132 <span class="identifier">karma</span><span class="special">::</span><span class="identifier">domain</span> 133 <span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">char_code</span><span class="special"><</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">upper</span><span class="special">,</span> <span class="identifier">CharEncoding</span><span class="special">></span> <span class="special">></span> 134 <span class="special">:</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span> 135<span class="special">}}</span> 136</pre> 137<p> 138 (for more details see the section describing the compilation process 139 of the <a href="../../../../../../../../doc/html/proto.html" target="_top">Boost.Proto</a> expression 140 into the corresponding generator expressions). 141 </p> 142<div class="informaltable"><table class="table"> 143<colgroup> 144<col> 145<col> 146</colgroup> 147<thead><tr> 148<th> 149 <p> 150 Expression 151 </p> 152 </th> 153<th> 154 <p> 155 Semantics 156 </p> 157 </th> 158</tr></thead> 159<tbody> 160<tr> 161<td> 162 <p> 163 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">lower</span><span class="special">[</span><span class="identifier">a</span><span class="special">]</span></code> 164 </p> 165 </td> 166<td> 167 <p> 168 Generate <code class="computeroutput"><span class="identifier">a</span></code> 169 as lower case, interpreted in the character set defined by 170 <code class="computeroutput"><span class="identifier">ns</span></code>. The directive 171 succeeds as long as the embedded generator succeeded (unless 172 the underlying output stream reports an error). 173 </p> 174 </td> 175</tr> 176<tr> 177<td> 178 <p> 179 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">upper</span><span class="special">[</span><span class="identifier">a</span><span class="special">]</span></code> 180 </p> 181 </td> 182<td> 183 <p> 184 Generate <code class="computeroutput"><span class="identifier">a</span></code> 185 as upper case, interpreted in the character set defined by 186 <code class="computeroutput"><span class="identifier">ns</span></code>. The directive 187 succeeds as long as the embedded generator succeeded (unless 188 the underlying output stream reports an error). 189 </p> 190 </td> 191</tr> 192</tbody> 193</table></div> 194<div class="note"><table border="0" summary="Note"> 195<tr> 196<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td> 197<th align="left">Note</th> 198</tr> 199<tr><td align="left" valign="top"> 200<p> 201 If both directives are 'active' with regard to a generator, the innermost 202 of those directives takes precedence. For instance: 203</p> 204<pre class="programlisting"><span class="identifier">generate</span><span class="special">(</span><span class="identifier">sink</span><span class="special">,</span> <span class="identifier">ascii</span><span class="special">::</span><span class="identifier">lower</span><span class="special">[</span><span class="char">'A'</span> <span class="special"><<</span> <span class="identifier">ascii</span><span class="special">::</span><span class="identifier">upper</span><span class="special">[</span><span class="char">'b'</span><span class="special">]])</span> 205</pre> 206<p> 207 will generate <code class="computeroutput"><span class="string">"aB"</span></code> 208 (without the quotes). 209 </p> 210<p> 211 Further, the directives will have no effect on generators emitting 212 characters not having an upper case or lower case equivalent in the 213 character set defined by <code class="computeroutput"><span class="identifier">ns</span></code>. 214 </p> 215</td></tr> 216</table></div> 217<h6> 218<a name="spirit.karma.reference.directive.upperlower.h5"></a> 219 <span class="phrase"><a name="spirit.karma.reference.directive.upperlower.attributes"></a></span><a class="link" href="upperlower.html#spirit.karma.reference.directive.upperlower.attributes">Attributes</a> 220 </h6> 221<p> 222 See <a class="link" href="../../quick_reference/compound_attribute_rules.html#spirit.karma.quick_reference.compound_attribute_rules.notation">Compound 223 Attribute Notation</a>. 224 </p> 225<div class="informaltable"><table class="table"> 226<colgroup> 227<col> 228<col> 229</colgroup> 230<thead><tr> 231<th> 232 <p> 233 Expression 234 </p> 235 </th> 236<th> 237 <p> 238 Attribute 239 </p> 240 </th> 241</tr></thead> 242<tbody> 243<tr> 244<td> 245 <p> 246 <code class="computeroutput"><span class="identifier">ns</span><span class="special">:</span><span class="identifier">lower</span><span class="special">[</span><span class="identifier">a</span><span class="special">]</span></code> 247 </p> 248 </td> 249<td> 250 <p> 251</p> 252<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span> <span class="special">--></span> <span class="identifier">ns</span><span class="special">:</span><span class="identifier">lower</span><span class="special">[</span><span class="identifier">a</span><span class="special">]:</span> <span class="identifier">A</span> 253<span class="identifier">a</span><span class="special">:</span> <span class="identifier">Unused</span> <span class="special">--></span> <span class="identifier">ns</span><span class="special">:</span><span class="identifier">lower</span><span class="special">[</span><span class="identifier">a</span><span class="special">]:</span> <span class="identifier">Unused</span></pre> 254<p> 255 </p> 256 </td> 257</tr> 258<tr> 259<td> 260 <p> 261 <code class="computeroutput"><span class="identifier">ns</span><span class="special">:</span><span class="identifier">upper</span><span class="special">[</span><span class="identifier">a</span><span class="special">]</span></code> 262 </p> 263 </td> 264<td> 265 <p> 266</p> 267<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">a</span><span class="special">:</span> <span class="identifier">A</span> <span class="special">--></span> <span class="identifier">ns</span><span class="special">:</span><span class="identifier">upper</span><span class="special">[</span><span class="identifier">a</span><span class="special">]:</span> <span class="identifier">A</span> 268<span class="identifier">a</span><span class="special">:</span> <span class="identifier">Unused</span> <span class="special">--></span> <span class="identifier">ns</span><span class="special">:</span><span class="identifier">upper</span><span class="special">[</span><span class="identifier">a</span><span class="special">]:</span> <span class="identifier">Unused</span></pre> 269<p> 270 </p> 271 </td> 272</tr> 273</tbody> 274</table></div> 275<h6> 276<a name="spirit.karma.reference.directive.upperlower.h6"></a> 277 <span class="phrase"><a name="spirit.karma.reference.directive.upperlower.complexity"></a></span><a class="link" href="upperlower.html#spirit.karma.reference.directive.upperlower.complexity">Complexity</a> 278 </h6> 279<div class="blockquote"><blockquote class="blockquote"><p> 280 The overall complexity of the generator directives <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">lower</span><span class="special">[]</span></code> and <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">upper</span><span class="special">[]</span></code> is defined by the complexity of its 281 embedded generators. The directives themselves are compile time only 282 directives, having no impact on runtime performance. 283 </p></blockquote></div> 284<h6> 285<a name="spirit.karma.reference.directive.upperlower.h7"></a> 286 <span class="phrase"><a name="spirit.karma.reference.directive.upperlower.example"></a></span><a class="link" href="upperlower.html#spirit.karma.reference.directive.upperlower.example">Example</a> 287 </h6> 288<div class="note"><table border="0" summary="Note"> 289<tr> 290<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td> 291<th align="left">Note</th> 292</tr> 293<tr><td align="left" valign="top"><p> 294 The test harness for the example(s) below is presented in the <a class="link" href="../basics.html#spirit.karma.reference.basics.examples">Basics Examples</a> 295 section. 296 </p></td></tr> 297</table></div> 298<p> 299 Some includes: 300 </p> 301<p> 302</p> 303<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">karma</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 304<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> 305<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">string</span><span class="special">></span> 306</pre> 307<p> 308 </p> 309<p> 310 Some using declarations: 311 </p> 312<p> 313</p> 314<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">karma</span><span class="special">::</span><span class="identifier">double_</span><span class="special">;</span> 315<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">ascii</span><span class="special">::</span><span class="identifier">upper</span><span class="special">;</span> 316<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">ascii</span><span class="special">::</span><span class="identifier">lower</span><span class="special">;</span> 317</pre> 318<p> 319 </p> 320<p> 321 Basic usage of the <code class="computeroutput"><span class="identifier">upper</span></code> 322 and <code class="computeroutput"><span class="identifier">lower</span></code> generator directives: 323 </p> 324<p> 325</p> 326<pre class="programlisting"><span class="identifier">test_generator_attr</span><span class="special">(</span><span class="string">"abc:2.0e-06"</span><span class="special">,</span> <span class="identifier">lower</span><span class="special">[</span><span class="string">"ABC:"</span> <span class="special"><<</span> <span class="identifier">double_</span><span class="special">],</span> <span class="number">2e-6</span><span class="special">);</span> 327<span class="identifier">test_generator_attr</span><span class="special">(</span><span class="string">"ABC:2.0E-06"</span><span class="special">,</span> <span class="identifier">upper</span><span class="special">[</span><span class="string">"abc:"</span> <span class="special"><<</span> <span class="identifier">double_</span><span class="special">],</span> <span class="number">2e-6</span><span class="special">);</span> 328</pre> 329<p> 330 </p> 331</div> 332<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 333<td align="left"></td> 334<td align="right"><div class="copyright-footer">Copyright © 2001-2011 Joel de Guzman, Hartmut Kaiser<p> 335 Distributed under the Boost Software License, Version 1.0. (See accompanying 336 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>) 337 </p> 338</div></td> 339</tr></table> 340<hr> 341<div class="spirit-nav"> 342<a accesskey="p" href="delimit.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../directive.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="maxwidth.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 343</div> 344</body> 345</html> 346