/doc/cset.html

http://github.com/foodmike/PTypes · HTML · 60 lines · 53 code · 3 blank · 4 comment · 0 complexity · bf2e9cc10c837c591a35073f9587b40b MD5 · raw file

  1. <html><!-- #BeginTemplate "/Templates/tmpl.dwt" --><!-- DW6 -->
  2. <head>
  3. <!-- #BeginEditable "doctitle" -->
  4. <title>PTypes: cset</title>
  5. <!-- #EndEditable -->
  6. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  7. <link rel="stylesheet" href="styles.css">
  8. </head>
  9. <body bgcolor="#FFFFFF" leftmargin="40" marginwidth="40">
  10. <p><a href="../index.html"><img src="title-21.png" width="253" height="39" alt="C++ Portable Types Library (PTypes) Version 2.1" border="0"></a>
  11. <hr size="1" noshade>
  12. <!-- #BeginEditable "body" -->
  13. <p class="hpath"><a href="index.html">Top</a>: <a href="basic.html">Basic types</a>:
  14. cset</p>
  15. <ul>
  16. <li>
  17. <h5><a href="cset.constructors.html">Constructors</a></h5>
  18. </li>
  19. <li>
  20. <h5><a href="cset.operators.html">Operators</a></h5>
  21. </li>
  22. <li>
  23. <h5><a href="cset.manipulation.html">Manipulation</a></h5>
  24. </li>
  25. </ul>
  26. <p>The character set class (<span class="lang">cset</span>) implements Pascal-style
  27. set of integer values from 0 to 255, or set of characters. Unlike Pascal sets,
  28. the range of a <span class="lang">cset</span> cannot be changed and is always
  29. 0 through 255. <span class="lang">Cset</span> class implements various operators
  30. (membership, union, intersection, equality, less than or equal to, etc.) as they
  31. are described in the Pascal language. See <a href="cset.operators.html">Operators</a>
  32. for details.</p>
  33. <p><span class="lang">Cset</span> is a packed array of 256 bits, it occupies 32
  34. bytes of static or local memory. Each bit indicates whether the corresponding
  35. character is a member of a given set.</p>
  36. <p>Another difference between <span class="lang">cset</span> and Pascal sets is
  37. that since C++ compiler does not have a built-in set constructor like the one
  38. in Pascal (e.g. ['A'..'Z', 'a'..'z']), <span class="lang">cset</span> provides
  39. a simple run-time interpreter instead (see <a href="cset.constructors.html"> Constructors</a>).</p>
  40. <p>The <span class="lang">cset</span> class is declared in <a href="include/ptypes.h.html">&lt;ptypes.h&gt;</a>.</p>
  41. <p>The example below shows the general usage of character sets.</p>
  42. <blockquote>
  43. <pre>cset s = &quot;A-Za-z!&quot;; <span class="comment">// same as ['A'..'Z', 'a'..'z', '!'] in Pascal</span>
  44. include(s, '_'); <span class="comment"> // include underscore character</span>
  45. include(s, '0', '9'); <span class="comment"> // include all chars from '0' to '9'</span>
  46. if ('a' &amp; s) <span class="comment"> // check membership</span>
  47. cout &lt;&lt; &quot;Letter 'a' found in the set! :)\n&quot;;
  48. const cset letters = &quot;A-Za-z_&quot;; <span class="comment">// define a set of letters</span>
  49. string tok = pin.token(letters); <span class="comment">// read a token from the input stream</span></pre>
  50. </blockquote>
  51. <p class="seealso">See also: <a href="cset.constructors.html">Constructors</a>,
  52. <a href="cset.operators.html">Operators</a>, <a href="cset.manipulation.html">Manipulation</a></p>
  53. <!-- #EndEditable -->
  54. <hr size="1">
  55. <a href="../index.html" class="ns">PTypes home</a>
  56. </body>
  57. <!-- #EndTemplate --></html>