1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Determine if a Type Should be Treated as a String (Qi and 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="is_container.html" title="Determine if a Type Should be Treated as a Container (Qi and Karma)"> 10<link rel="next" href="handles_container.html" title="Determine Whether a Component Handles Container 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="is_container.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="handles_container.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.is_string"></a><a class="link" href="is_string.html" title="Determine if a Type Should be Treated as a String (Qi and Karma)">Determine if a 28 Type Should be Treated as a String (Qi and Karma)</a> 29</h4></div></div></div> 30<h6> 31<a name="spirit.advanced.customize.is_string.h0"></a> 32 <span class="phrase"><a name="spirit.advanced.customize.is_string.is_string"></a></span><a class="link" href="is_string.html#spirit.advanced.customize.is_string.is_string">is_string</a> 33 </h6> 34<p> 35 The <code class="computeroutput"><span class="identifier">is_string</span></code> customization 36 point is a template meta-function. It is used by <span class="emphasis"><em>Qi</em></span> 37 <a class="link" href="../../qi/reference/string/string.html" title="String Parsers (string, lit)">String Literals</a> 38 (<code class="computeroutput"><span class="identifier">lit</span><span class="special">(</span><span class="identifier">str</span><span class="special">)</span></code>), 39 <span class="emphasis"><em>Qi</em></span> <a class="link" href="../../qi/reference/char/char.html" title="Character Parser (char_, lit)">Character 40 Literals</a> (<code class="computeroutput"><span class="identifier">lit</span><span class="special">(</span><span class="identifier">c</span><span class="special">)</span></code>), 41 <span class="emphasis"><em>Karma</em></span> <a class="link" href="../../karma/reference/string/string.html" title="String Generators (string, lit)">String 42 Literals</a> (<code class="computeroutput"><span class="identifier">lit</span><span class="special">(</span><span class="identifier">str</span><span class="special">)</span></code>), 43 <span class="emphasis"><em>Karma</em></span> <a class="link" href="../../karma/reference/char/char_generator.html" title="Character Generators (char_, lit)">Character 44 Literals</a> (<code class="computeroutput"><span class="identifier">lit</span><span class="special">(</span><span class="identifier">c</span><span class="special">)</span></code>) and 45 other Spirit components. It determines whether a supplied type can be treated 46 as a string. 47 </p> 48<h6> 49<a name="spirit.advanced.customize.is_string.h1"></a> 50 <span class="phrase"><a name="spirit.advanced.customize.is_string.module_headers"></a></span><a class="link" href="is_string.html#spirit.advanced.customize.is_string.module_headers">Module Headers</a> 51 </h6> 52<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">home</span><span class="special">/</span><span class="identifier">support</span><span class="special">/</span><span class="identifier">string_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 53</pre> 54<p> 55 Also, see <a class="link" href="../../structure/include.html" title="Include">Include Structure</a>. 56 </p> 57<div class="note"><table border="0" summary="Note"> 58<tr> 59<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../images/note.png"></td> 60<th align="left">Note</th> 61</tr> 62<tr><td align="left" valign="top"><p> 63 This header file does not need to be included directly by any user program 64 as it is normally included by other Spirit header files relying on its 65 content. 66 </p></td></tr> 67</table></div> 68<h6> 69<a name="spirit.advanced.customize.is_string.h2"></a> 70 <span class="phrase"><a name="spirit.advanced.customize.is_string.namespace"></a></span><a class="link" href="is_string.html#spirit.advanced.customize.is_string.namespace">Namespace</a> 71 </h6> 72<div class="informaltable"><table class="table"> 73<colgroup><col></colgroup> 74<thead><tr><th> 75 <p> 76 Name 77 </p> 78 </th></tr></thead> 79<tbody><tr><td> 80 <p> 81 <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> 82 </p> 83 </td></tr></tbody> 84</table></div> 85<h6> 86<a name="spirit.advanced.customize.is_string.h3"></a> 87 <span class="phrase"><a name="spirit.advanced.customize.is_string.synopsis"></a></span><a class="link" href="is_string.html#spirit.advanced.customize.is_string.synopsis">Synopsis</a> 88 </h6> 89<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span> 90<span class="keyword">struct</span> <span class="identifier">is_string</span> 91<span class="special">{</span> 92 <span class="special"><</span><span class="identifier">unspecified</span><span class="special">>;</span> 93<span class="special">};</span> 94</pre> 95<h6> 96<a name="spirit.advanced.customize.is_string.h4"></a> 97 <span class="phrase"><a name="spirit.advanced.customize.is_string.template_parameters"></a></span><a class="link" href="is_string.html#spirit.advanced.customize.is_string.template_parameters">Template 98 parameters</a> 99 </h6> 100<div class="informaltable"><table class="table"> 101<colgroup> 102<col> 103<col> 104<col> 105</colgroup> 106<thead><tr> 107<th> 108 <p> 109 Parameter 110 </p> 111 </th> 112<th> 113 <p> 114 Description 115 </p> 116 </th> 117<th> 118 <p> 119 Default 120 </p> 121 </th> 122</tr></thead> 123<tbody><tr> 124<td> 125 <p> 126 <code class="computeroutput"><span class="identifier">T</span></code> 127 </p> 128 </td> 129<td> 130 <p> 131 The type, <code class="computeroutput"><span class="identifier">T</span></code> which 132 needs to be tested as a string 133 </p> 134 </td> 135<td> 136 <p> 137 none 138 </p> 139 </td> 140</tr></tbody> 141</table></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">T</span></code></span></dt> 146<dd><p> 147 An arbitrary type. 148 </p></dd> 149<dt><span class="term"><code class="computeroutput"><span class="identifier">N</span></code></span></dt> 150<dd><p> 151 An arbitrary integral constant. 152 </p></dd> 153<dt><span class="term"><code class="computeroutput"><span class="identifier">Char</span></code></span></dt> 154<dd><p> 155 A character type. 156 </p></dd> 157<dt><span class="term"><code class="computeroutput"><span class="identifier">Traits</span></code></span></dt> 158<dd><p> 159 A character traits type. 160 </p></dd> 161<dt><span class="term"><code class="computeroutput"><span class="identifier">Allocator</span></code></span></dt> 162<dd><p> 163 A standard allocator type. 164 </p></dd> 165</dl> 166</div> 167<h6> 168<a name="spirit.advanced.customize.is_string.h5"></a> 169 <span class="phrase"><a name="spirit.advanced.customize.is_string.expression_semantics"></a></span><a class="link" href="is_string.html#spirit.advanced.customize.is_string.expression_semantics">Expression 170 Semantics</a> 171 </h6> 172<div class="informaltable"><table class="table"> 173<colgroup> 174<col> 175<col> 176</colgroup> 177<thead><tr> 178<th> 179 <p> 180 Expression 181 </p> 182 </th> 183<th> 184 <p> 185 Semantics 186 </p> 187 </th> 188</tr></thead> 189<tbody><tr> 190<td> 191 <p> 192 <code class="computeroutput"><span class="identifier">is_string</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">type</span></code> 193 </p> 194 </td> 195<td> 196 <p> 197 Result of the metafunction that evaluates to mpl::true_ if a 198 given type, <code class="computeroutput"><span class="identifier">T</span></code>, 199 is to be treated as a string and mpl::false_ otherwise. Generally, 200 any implementation of <code class="computeroutput"><span class="identifier">is_string</span></code> 201 needs to behave as if if was a <a href="../../../../../../../libs/mpl/doc/refmanual/integral-constant.html" target="_top">MPL 202 Boolean Constant</a>. 203 </p> 204 </td> 205</tr></tbody> 206</table></div> 207<h6> 208<a name="spirit.advanced.customize.is_string.h6"></a> 209 <span class="phrase"><a name="spirit.advanced.customize.is_string.predefined_specializations"></a></span><a class="link" href="is_string.html#spirit.advanced.customize.is_string.predefined_specializations">Predefined 210 Specializations</a> 211 </h6> 212<div class="informaltable"><table class="table"> 213<colgroup> 214<col> 215<col> 216</colgroup> 217<thead><tr> 218<th> 219 <p> 220 Type 221 </p> 222 </th> 223<th> 224 <p> 225 Semantics 226 </p> 227 </th> 228</tr></thead> 229<tbody> 230<tr> 231<td> 232 <p> 233 <code class="computeroutput"><span class="identifier">T</span></code> 234 </p> 235 </td> 236<td> 237 <p> 238 Returns <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">false_</span></code>. 239 </p> 240 </td> 241</tr> 242<tr> 243<td> 244 <p> 245 <code class="computeroutput"><span class="identifier">T</span> <span class="keyword">const</span></code> 246 </p> 247 </td> 248<td> 249 <p> 250 Returns <code class="computeroutput"><span class="identifier">is_string</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code>. 251 </p> 252 </td> 253</tr> 254<tr> 255<td> 256 <p> 257 <code class="computeroutput"><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span></code> 258 </p> 259 </td> 260<td> 261 <p> 262 Returns <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code>. 263 </p> 264 </td> 265</tr> 266<tr> 267<td> 268 <p> 269 <code class="computeroutput"><span class="keyword">wchar_t</span> <span class="keyword">const</span><span class="special">*</span></code> 270 </p> 271 </td> 272<td> 273 <p> 274 Returns <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code>. 275 </p> 276 </td> 277</tr> 278<tr> 279<td> 280 <p> 281 <code class="computeroutput"><span class="keyword">char</span><span class="special">*</span></code> 282 </p> 283 </td> 284<td> 285 <p> 286 Returns <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code>. 287 </p> 288 </td> 289</tr> 290<tr> 291<td> 292 <p> 293 <code class="computeroutput"><span class="keyword">wchar_t</span><span class="special">*</span></code> 294 </p> 295 </td> 296<td> 297 <p> 298 Returns <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code>. 299 </p> 300 </td> 301</tr> 302<tr> 303<td> 304 <p> 305 <code class="computeroutput"><span class="keyword">char</span><span class="special">[</span><span class="identifier">N</span><span class="special">]</span></code> 306 </p> 307 </td> 308<td> 309 <p> 310 Returns <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code>. 311 </p> 312 </td> 313</tr> 314<tr> 315<td> 316 <p> 317 <code class="computeroutput"><span class="keyword">wchar_t</span><span class="special">[</span><span class="identifier">N</span><span class="special">]</span></code> 318 </p> 319 </td> 320<td> 321 <p> 322 Returns <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code>. 323 </p> 324 </td> 325</tr> 326<tr> 327<td> 328 <p> 329 <code class="computeroutput"><span class="keyword">char</span> <span class="keyword">const</span><span class="special">[</span><span class="identifier">N</span><span class="special">]</span></code> 330 </p> 331 </td> 332<td> 333 <p> 334 Returns <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code>. 335 </p> 336 </td> 337</tr> 338<tr> 339<td> 340 <p> 341 <code class="computeroutput"><span class="keyword">wchar_t</span> <span class="keyword">const</span><span class="special">[</span><span class="identifier">N</span><span class="special">]</span></code> 342 </p> 343 </td> 344<td> 345 <p> 346 Returns <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code>. 347 </p> 348 </td> 349</tr> 350<tr> 351<td> 352 <p> 353 <code class="computeroutput"><span class="keyword">char</span><span class="special">(&)[</span><span class="identifier">N</span><span class="special">]</span></code> 354 </p> 355 </td> 356<td> 357 <p> 358 Returns <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code>. 359 </p> 360 </td> 361</tr> 362<tr> 363<td> 364 <p> 365 <code class="computeroutput"><span class="keyword">wchar_t</span><span class="special">(&)[</span><span class="identifier">N</span><span class="special">]</span></code> 366 </p> 367 </td> 368<td> 369 <p> 370 Returns <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code>. 371 </p> 372 </td> 373</tr> 374<tr> 375<td> 376 <p> 377 <code class="computeroutput"><span class="keyword">char</span> <span class="keyword">const</span><span class="special">(&)[</span><span class="identifier">N</span><span class="special">]</span></code> 378 </p> 379 </td> 380<td> 381 <p> 382 Returns <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code>. 383 </p> 384 </td> 385</tr> 386<tr> 387<td> 388 <p> 389 <code class="computeroutput"><span class="keyword">wchar_t</span> <span class="keyword">const</span><span class="special">(&)[</span><span class="identifier">N</span><span class="special">]</span></code> 390 </p> 391 </td> 392<td> 393 <p> 394 Returns <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code>. 395 </p> 396 </td> 397</tr> 398<tr> 399<td> 400 <p> 401 <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_string</span><span class="special"><</span><span class="identifier">Char</span><span class="special">,</span> 402 <span class="identifier">Traits</span><span class="special">,</span> 403 <span class="identifier">Allocator</span><span class="special">></span></code> 404 </p> 405 </td> 406<td> 407 <p> 408 Returns <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code>. 409 </p> 410 </td> 411</tr> 412</tbody> 413</table></div> 414<h6> 415<a name="spirit.advanced.customize.is_string.h7"></a> 416 <span class="phrase"><a name="spirit.advanced.customize.is_string.when_to_implement"></a></span><a class="link" href="is_string.html#spirit.advanced.customize.is_string.when_to_implement">When to 417 implement</a> 418 </h6> 419<p> 420 This customization point needs to be implemented to use user-defined string 421 classes that do not correspond to std::string syntax and semantics. 422 </p> 423<h6> 424<a name="spirit.advanced.customize.is_string.h8"></a> 425 <span class="phrase"><a name="spirit.advanced.customize.is_string.related_attribute_customization_points"></a></span><a class="link" href="is_string.html#spirit.advanced.customize.is_string.related_attribute_customization_points">Related 426 Attribute Customization Points</a> 427 </h6> 428<p> 429 If this customization point is implemented, the following other customization 430 points need to be implemented as well. 431 </p> 432<div class="informaltable"><table class="table"> 433<colgroup> 434<col> 435<col> 436</colgroup> 437<thead><tr> 438<th> 439 <p> 440 Name 441 </p> 442 </th> 443<th> 444 <p> 445 When to implement 446 </p> 447 </th> 448</tr></thead> 449<tbody> 450<tr> 451<td> 452 <p> 453 <a class="link" href="string_traits/is_char.html" title="Determine if a Type is a Character"><code class="computeroutput"><span class="identifier">traits</span><span class="special">::</span><span class="identifier">is_char</span></code></a> 454 </p> 455 </td> 456<td> 457 <p> 458 For string types whose underlying character type is not <code class="computeroutput"><span class="keyword">char</span></code> or <code class="computeroutput"><span class="keyword">wchar_t</span></code>, 459 <code class="computeroutput"><span class="identifier">is_char</span></code> must 460 be implemented. 461 </p> 462 </td> 463</tr> 464<tr> 465<td> 466 <p> 467 <a class="link" href="string_traits/char_type_of.html" title="Determine the Character Type of a String"><code class="computeroutput"><span class="identifier">traits</span><span class="special">::</span><span class="identifier">char_type_of</span></code></a> 468 </p> 469 </td> 470<td> 471 <p> 472 Whenever <code class="computeroutput"><span class="identifier">is_string</span></code> 473 is implemented. 474 </p> 475 </td> 476</tr> 477<tr> 478<td> 479 <p> 480 <a class="link" href="string_traits/extract_c_string.html" title="Get a C-style String from a String Type"><code class="computeroutput"><span class="identifier">traits</span><span class="special">::</span><span class="identifier">extract_c_string</span></code></a> 481 </p> 482 </td> 483<td> 484 <p> 485 Whenever <code class="computeroutput"><span class="identifier">is_string</span></code> 486 is implemented. 487 </p> 488 </td> 489</tr> 490</tbody> 491</table></div> 492</div> 493<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 494<td align="left"></td> 495<td align="right"><div class="copyright-footer">Copyright © 2001-2011 Joel de Guzman, Hartmut Kaiser<p> 496 Distributed under the Boost Software License, Version 1.0. (See accompanying 497 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>) 498 </p> 499</div></td> 500</tr></table> 501<hr> 502<div class="spirit-nav"> 503<a accesskey="p" href="is_container.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="handles_container.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 504</div> 505</body> 506</html> 507