1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Character Classification Generators (alnum, digit, etc.)</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="../char.html" title="Char Generators"> 9<link rel="prev" href="char_generator.html" title="Character Generators (char_, lit)"> 10<link rel="next" href="../directive.html" title="Generator Directives"> 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="char_generator.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../char.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="../directive.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.char.char_class"></a><a class="link" href="char_class.html" title="Character Classification Generators (alnum, digit, etc.)">Character 28 Classification Generators (<code class="computeroutput"><span class="identifier">alnum</span></code>, 29 <code class="computeroutput"><span class="identifier">digit</span></code>, etc.)</a> 30</h5></div></div></div> 31<h6> 32<a name="spirit.karma.reference.char.char_class.h0"></a> 33 <span class="phrase"><a name="spirit.karma.reference.char.char_class.description"></a></span><a class="link" href="char_class.html#spirit.karma.reference.char.char_class.description">Description</a> 34 </h6> 35<p> 36 The library has the full repertoire of single character generators for 37 character classification. This includes the usual <code class="computeroutput"><span class="identifier">alnum</span></code>, 38 <code class="computeroutput"><span class="identifier">alpha</span></code>, <code class="computeroutput"><span class="identifier">digit</span></code>, <code class="computeroutput"><span class="identifier">xdigit</span></code>, 39 etc. generators. These generators have an associated <a class="link" href="../basics.html#spirit.karma.reference.basics.character_encoding_namespace">Character 40 Encoding Namespace</a>. This is needed when doing basic operations 41 such as forcing lower or upper case. 42 </p> 43<h6> 44<a name="spirit.karma.reference.char.char_class.h1"></a> 45 <span class="phrase"><a name="spirit.karma.reference.char.char_class.header"></a></span><a class="link" href="char_class.html#spirit.karma.reference.char.char_class.header">Header</a> 46 </h6> 47<pre class="programlisting"><span class="comment">// forwards to <boost/spirit/home/karma/char/char_class.hpp></span> 48<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_char_class</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 49</pre> 50<p> 51 Also, see <a class="link" href="../../../structure/include.html" title="Include">Include Structure</a>. 52 </p> 53<h6> 54<a name="spirit.karma.reference.char.char_class.h2"></a> 55 <span class="phrase"><a name="spirit.karma.reference.char.char_class.namespace"></a></span><a class="link" href="char_class.html#spirit.karma.reference.char.char_class.namespace">Namespace</a> 56 </h6> 57<div class="informaltable"><table class="table"> 58<colgroup><col></colgroup> 59<thead><tr><th> 60 <p> 61 Name 62 </p> 63 </th></tr></thead> 64<tbody> 65<tr><td> 66 <p> 67 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">alnum</span></code> 68 </p> 69 </td></tr> 70<tr><td> 71 <p> 72 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">alpha</span></code> 73 </p> 74 </td></tr> 75<tr><td> 76 <p> 77 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">blank</span></code> 78 </p> 79 </td></tr> 80<tr><td> 81 <p> 82 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">cntrl</span></code> 83 </p> 84 </td></tr> 85<tr><td> 86 <p> 87 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">digit</span></code> 88 </p> 89 </td></tr> 90<tr><td> 91 <p> 92 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">graph</span></code> 93 </p> 94 </td></tr> 95<tr><td> 96 <p> 97 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">lower</span></code> 98 </p> 99 </td></tr> 100<tr><td> 101 <p> 102 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">print</span></code> 103 </p> 104 </td></tr> 105<tr><td> 106 <p> 107 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">punct</span></code> 108 </p> 109 </td></tr> 110<tr><td> 111 <p> 112 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">space</span></code> 113 </p> 114 </td></tr> 115<tr><td> 116 <p> 117 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">upper</span></code> 118 </p> 119 </td></tr> 120<tr><td> 121 <p> 122 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">xdigit</span></code> 123 </p> 124 </td></tr> 125</tbody> 126</table></div> 127<p> 128 In the table above, <code class="computeroutput"><span class="identifier">ns</span></code> 129 represents a <a class="link" href="../basics.html#spirit.karma.reference.basics.character_encoding_namespace">Character 130 Encoding Namespace</a> used by the corresponding character class generator. 131 All listed generators have a mandatory attribute <code class="computeroutput"><span class="identifier">Ch</span></code> 132 and will not compile if no attribute is associated. 133 </p> 134<h6> 135<a name="spirit.karma.reference.char.char_class.h3"></a> 136 <span class="phrase"><a name="spirit.karma.reference.char.char_class.model_of"></a></span><a class="link" href="char_class.html#spirit.karma.reference.char.char_class.model_of">Model 137 of</a> 138 </h6> 139<div class="blockquote"><blockquote class="blockquote"><p> 140 <a class="link" href="../generator_concepts/primitivegenerator.html" title="PrimitiveGenerator"><code class="computeroutput"><span class="identifier">PrimitiveGenerator</span></code></a> 141 </p></blockquote></div> 142<div class="variablelist"> 143<p class="title"><b>Notation</b></p> 144<dl class="variablelist"> 145<dt><span class="term"><code class="computeroutput"><span class="identifier">ns</span></code></span></dt> 146<dd><p> 147 A <a class="link" href="../basics.html#spirit.karma.reference.basics.character_encoding_namespace">Character 148 Encoding Namespace</a>. 149 </p></dd> 150</dl> 151</div> 152<h6> 153<a name="spirit.karma.reference.char.char_class.h4"></a> 154 <span class="phrase"><a name="spirit.karma.reference.char.char_class.expression_semantics"></a></span><a class="link" href="char_class.html#spirit.karma.reference.char.char_class.expression_semantics">Expression 155 Semantics</a> 156 </h6> 157<p> 158 Semantics of an expression is defined only where it differs from, or 159 is not defined in <a class="link" href="../generator_concepts/primitivegenerator.html" title="PrimitiveGenerator"><code class="computeroutput"><span class="identifier">PrimitiveGenerator</span></code></a>. 160 </p> 161<div class="informaltable"><table class="table"> 162<colgroup> 163<col> 164<col> 165</colgroup> 166<thead><tr> 167<th> 168 <p> 169 Expression 170 </p> 171 </th> 172<th> 173 <p> 174 Semantics 175 </p> 176 </th> 177</tr></thead> 178<tbody> 179<tr> 180<td> 181 <p> 182 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">alnum</span></code> 183 </p> 184 </td> 185<td> 186 <p> 187 If the mandatory attribute satisfies the concept of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">isalnum</span></code> in the <a class="link" href="../basics.html#spirit.karma.reference.basics.character_encoding_namespace">Character 188 Encoding Namespace</a> the generator succeeds after emitting 189 its attribute (unless the underlying output stream reports 190 an error). This generator fails otherwise while not generating 191 anything. 192 </p> 193 </td> 194</tr> 195<tr> 196<td> 197 <p> 198 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">alpha</span></code> 199 </p> 200 </td> 201<td> 202 <p> 203 If the mandatory attribute satisfies the concept of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">isalpha</span></code> in the <a class="link" href="../basics.html#spirit.karma.reference.basics.character_encoding_namespace">Character 204 Encoding Namespace</a> the generator succeeds after emitting 205 its attribute (unless the underlying output stream reports 206 an error). This generator fails otherwise while not generating 207 anything. 208 </p> 209 </td> 210</tr> 211<tr> 212<td> 213 <p> 214 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">blank</span></code> 215 </p> 216 </td> 217<td> 218 <p> 219 If the mandatory attribute satisfies the concept of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">isblank</span></code> in the <a class="link" href="../basics.html#spirit.karma.reference.basics.character_encoding_namespace">Character 220 Encoding Namespace</a> the generator succeeds after emitting 221 its attribute (unless the underlying output stream reports 222 an error). This generator fails otherwise while not generating 223 anything. 224 </p> 225 </td> 226</tr> 227<tr> 228<td> 229 <p> 230 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">cntrl</span></code> 231 </p> 232 </td> 233<td> 234 <p> 235 If the mandatory attribute satisfies the concept of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">iscntrl</span></code> in the <a class="link" href="../basics.html#spirit.karma.reference.basics.character_encoding_namespace">Character 236 Encoding Namespace</a> the generator succeeds after emitting 237 its attribute (unless the underlying output stream reports 238 an error). This generator fails otherwise while not generating 239 anything. 240 </p> 241 </td> 242</tr> 243<tr> 244<td> 245 <p> 246 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">digit</span></code> 247 </p> 248 </td> 249<td> 250 <p> 251 If the mandatory attribute satisfies the concept of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">isdigit</span></code> in the <a class="link" href="../basics.html#spirit.karma.reference.basics.character_encoding_namespace">Character 252 Encoding Namespace</a> the generator succeeds after emitting 253 its attribute (unless the underlying output stream reports 254 an error). This generator fails otherwise while not generating 255 anything. 256 </p> 257 </td> 258</tr> 259<tr> 260<td> 261 <p> 262 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">graph</span></code> 263 </p> 264 </td> 265<td> 266 <p> 267 If the mandatory attribute satisfies the concept of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">isgraph</span></code> in the <a class="link" href="../basics.html#spirit.karma.reference.basics.character_encoding_namespace">Character 268 Encoding Namespace</a> the generator succeeds after emitting 269 its attribute (unless the underlying output stream reports 270 an error). This generator fails otherwise while not generating 271 anything. 272 </p> 273 </td> 274</tr> 275<tr> 276<td> 277 <p> 278 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">print</span></code> 279 </p> 280 </td> 281<td> 282 <p> 283 If the mandatory attribute satisfies the concept of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">isprint</span></code> in the <a class="link" href="../basics.html#spirit.karma.reference.basics.character_encoding_namespace">Character 284 Encoding Namespace</a> the generator succeeds after emitting 285 its attribute (unless the underlying output stream reports 286 an error). This generator fails otherwise while not generating 287 anything. 288 </p> 289 </td> 290</tr> 291<tr> 292<td> 293 <p> 294 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">punct</span></code> 295 </p> 296 </td> 297<td> 298 <p> 299 If the mandatory attribute satisfies the concept of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ispunct</span></code> in the <a class="link" href="../basics.html#spirit.karma.reference.basics.character_encoding_namespace">Character 300 Encoding Namespace</a> the generator succeeds after emitting 301 its attribute (unless the underlying output stream reports 302 an error). This generator fails otherwise while not generating 303 anything. 304 </p> 305 </td> 306</tr> 307<tr> 308<td> 309 <p> 310 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">xdigit</span></code> 311 </p> 312 </td> 313<td> 314 <p> 315 If the mandatory attribute satisfies the concept of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">isxdigit</span></code> in the <a class="link" href="../basics.html#spirit.karma.reference.basics.character_encoding_namespace">Character 316 Encoding Namespace</a> the generator succeeds after emitting 317 its attribute (unless the underlying output stream reports 318 an error). This generator fails otherwise while not generating 319 anything. 320 </p> 321 </td> 322</tr> 323<tr> 324<td> 325 <p> 326 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">lower</span></code> 327 </p> 328 </td> 329<td> 330 <p> 331 If the mandatory attribute satisfies the concept of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">islower</span></code> in the <a class="link" href="../basics.html#spirit.karma.reference.basics.character_encoding_namespace">Character 332 Encoding Namespace</a> the generator succeeds after emitting 333 its attribute (unless the underlying output stream reports 334 an error). This generator fails otherwise while not generating 335 anything. 336 </p> 337 </td> 338</tr> 339<tr> 340<td> 341 <p> 342 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">upper</span></code> 343 </p> 344 </td> 345<td> 346 <p> 347 If the mandatory attribute satisfies the concept of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">isupper</span></code> in the <a class="link" href="../basics.html#spirit.karma.reference.basics.character_encoding_namespace">Character 348 Encoding Namespace</a> the generator succeeds after emitting 349 its attribute (unless the underlying output stream reports 350 an error). This generator fails otherwise while not generating 351 anything. 352 </p> 353 </td> 354</tr> 355<tr> 356<td> 357 <p> 358 <code class="computeroutput"><span class="identifier">ns</span><span class="special">::</span><span class="identifier">space</span></code> 359 </p> 360 </td> 361<td> 362 <p> 363 If the optional attribute satisfies the concept of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">isspace</span></code> in the <a class="link" href="../basics.html#spirit.karma.reference.basics.character_encoding_namespace">Character 364 Encoding Namespace</a> the generator succeeds after emitting 365 its attribute (unless the underlying output stream reports 366 an error). This generator fails otherwise while not generating 367 anything.If no attribute is supplied this generator emits a 368 single space character in the character set defined by <code class="computeroutput"><span class="identifier">ns</span></code>. 369 </p> 370 </td> 371</tr> 372</tbody> 373</table></div> 374<p> 375 Possible values for <code class="computeroutput"><span class="identifier">ns</span></code> 376 are described in the section <a class="link" href="../basics.html#spirit.karma.reference.basics.character_encoding_namespace">Character 377 Encoding Namespace</a>. 378 </p> 379<div class="note"><table border="0" summary="Note"> 380<tr> 381<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td> 382<th align="left">Note</th> 383</tr> 384<tr><td align="left" valign="top"> 385<p> 386 The generators <code class="computeroutput"><span class="identifier">alpha</span></code> 387 and <code class="computeroutput"><span class="identifier">alnum</span></code> might seem 388 to behave unexpected if used inside a <code class="computeroutput"><span class="identifier">lower</span><span class="special">[]</span></code> or <code class="computeroutput"><span class="identifier">upper</span><span class="special">[]</span></code> directive. Both directives additionally 389 apply the semantics of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">islower</span></code> 390 or <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">isupper</span></code> to the respective character 391 class. Some examples: 392</p> 393<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">s</span><span class="special">;</span> 394<span class="identifier">std</span><span class="special">::</span><span class="identifier">back_insert_iterator</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">></span> <span class="identifier">out</span><span class="special">(</span><span class="identifier">s</span><span class="special">);</span> 395<span class="identifier">generate</span><span class="special">(</span><span class="identifier">out</span><span class="special">,</span> <span class="identifier">lower</span><span class="special">[</span><span class="identifier">alpha</span><span class="special">],</span> <span class="char">'a'</span><span class="special">);</span> <span class="comment">// succeeds emitting 'a'</span> 396<span class="identifier">generate</span><span class="special">(</span><span class="identifier">out</span><span class="special">,</span> <span class="identifier">lower</span><span class="special">[</span><span class="identifier">alpha</span><span class="special">],</span> <span class="char">'A'</span><span class="special">);</span> <span class="comment">// fails </span> 397</pre> 398<p> 399 The generator directive <code class="computeroutput"><span class="identifier">upper</span><span class="special">[]</span></code> behaves correspondingly. 400 </p> 401</td></tr> 402</table></div> 403<h6> 404<a name="spirit.karma.reference.char.char_class.h5"></a> 405 <span class="phrase"><a name="spirit.karma.reference.char.char_class.attributes"></a></span><a class="link" href="char_class.html#spirit.karma.reference.char.char_class.attributes">Attributes</a> 406 </h6> 407<div class="blockquote"><blockquote class="blockquote"><p> 408 All listed character class generators can take any attribute <code class="computeroutput"><span class="identifier">Ch</span></code>. All character class generators 409 (except <code class="computeroutput"><span class="identifier">space</span></code>) require 410 an attribute and will fail compiling otherwise. 411 </p></blockquote></div> 412<div class="note"><table border="0" summary="Note"> 413<tr> 414<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td> 415<th align="left">Note</th> 416</tr> 417<tr><td align="left" valign="top"><p> 418 In addition to their usual attribute of type <code class="computeroutput"><span class="identifier">Ch</span></code> 419 all listed generators accept an instance of a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span><span class="special"><</span><span class="identifier">Ch</span><span class="special">></span></code> as well. If the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span><span class="special"><></span></code> is initialized (holds a value) 420 the generators behave as if their attribute was an instance of <code class="computeroutput"><span class="identifier">Ch</span></code> and emit the value stored in the 421 <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span><span class="special"><></span></code>. 422 Otherwise the generators will fail. 423 </p></td></tr> 424</table></div> 425<h6> 426<a name="spirit.karma.reference.char.char_class.h6"></a> 427 <span class="phrase"><a name="spirit.karma.reference.char.char_class.complexity"></a></span><a class="link" href="char_class.html#spirit.karma.reference.char.char_class.complexity">Complexity</a> 428 </h6> 429<div class="blockquote"><blockquote class="blockquote"><p> 430 O(1) 431 </p></blockquote></div> 432<p> 433 The complexity is constant as the generators emit not more than one character 434 per invocation. 435 </p> 436<h6> 437<a name="spirit.karma.reference.char.char_class.h7"></a> 438 <span class="phrase"><a name="spirit.karma.reference.char.char_class.example"></a></span><a class="link" href="char_class.html#spirit.karma.reference.char.char_class.example">Example</a> 439 </h6> 440<div class="note"><table border="0" summary="Note"> 441<tr> 442<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td> 443<th align="left">Note</th> 444</tr> 445<tr><td align="left" valign="top"><p> 446 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> 447 section. 448 </p></td></tr> 449</table></div> 450<p> 451 Some includes: 452 </p> 453<p> 454</p> 455<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> 456<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">support_utree</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 457<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">phoenix_core</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 458<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">phoenix_operator</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 459<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">fusion</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">std_pair</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 460<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> 461<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">string</span><span class="special">></span> 462</pre> 463<p> 464 </p> 465<p> 466 Some using declarations: 467 </p> 468<p> 469</p> 470<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">alpha</span><span class="special">;</span> 471<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">upper</span><span class="special">;</span> 472</pre> 473<p> 474 </p> 475<p> 476 Basic usage of an <code class="computeroutput"><span class="identifier">alpha</span></code> 477 generator: 478 </p> 479<p> 480</p> 481<pre class="programlisting"><span class="identifier">test_generator_attr</span><span class="special">(</span><span class="string">"a"</span><span class="special">,</span> <span class="identifier">alpha</span><span class="special">,</span> <span class="char">'a'</span><span class="special">);</span> 482<span class="identifier">test_generator_attr</span><span class="special">(</span><span class="string">"A"</span><span class="special">,</span> <span class="identifier">alpha</span><span class="special">,</span> <span class="char">'A'</span><span class="special">);</span> 483<span class="identifier">test_generator_attr</span><span class="special">(</span><span class="string">""</span><span class="special">,</span> <span class="identifier">alpha</span><span class="special">,</span> <span class="char">'1'</span><span class="special">);</span> <span class="comment">// fails (as isalpha('1') is false)</span> 484<span class="identifier">test_generator_attr</span><span class="special">(</span><span class="string">"A"</span><span class="special">,</span> <span class="identifier">upper</span><span class="special">[</span><span class="identifier">alpha</span><span class="special">],</span> <span class="char">'A'</span><span class="special">);</span> 485<span class="identifier">test_generator_attr</span><span class="special">(</span><span class="string">""</span><span class="special">,</span> <span class="identifier">upper</span><span class="special">[</span><span class="identifier">alpha</span><span class="special">],</span> <span class="char">'a'</span><span class="special">);</span> <span class="comment">// fails (as isupper('a') is false)</span> 486</pre> 487<p> 488 </p> 489</div> 490<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 491<td align="left"></td> 492<td align="right"><div class="copyright-footer">Copyright © 2001-2011 Joel de Guzman, Hartmut Kaiser<p> 493 Distributed under the Boost Software License, Version 1.0. (See accompanying 494 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>) 495 </p> 496</div></td> 497</tr></table> 498<hr> 499<div class="spirit-nav"> 500<a accesskey="p" href="char_generator.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../char.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="../directive.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 501</div> 502</body> 503</html> 504