PageRenderTime 23ms CodeModel.GetById 20ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 0ms

/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>: 
14cset</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 
27set of integer values from 0 to 255, or set of characters. Unlike Pascal sets, 
28the range of a <span class="lang">cset</span> cannot be changed and is always 
290 through 255. <span class="lang">Cset</span> class implements various operators 
30(membership, union, intersection, equality, less than or equal to, etc.) as they 
31are described in the Pascal language. See <a href="cset.operators.html">Operators</a> 
32for details.</p>
33<p><span class="lang">Cset</span> is a packed array of 256 bits, it occupies 32 
34bytes of static or local memory. Each bit indicates whether the corresponding 
35character is a member of a given set.</p>
36<p>Another difference between <span class="lang">cset</span> and Pascal sets is 
37that since C++ compiler does not have a built-in set constructor like the one 
38in Pascal (e.g. ['A'..'Z', 'a'..'z']), <span class="lang">cset</span> provides 
39a 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
45include(s, '_');      <span class="comment">    // include underscore character</span>
46include(s, '0', '9'); <span class="comment">    // include all chars from '0' to '9'</span>
47
48if ('a' &amp; s)          <span class="comment">    // check membership</span>
49    cout &lt;&lt; &quot;Letter 'a' found in the set! :)\n&quot;;
50
51const cset letters = &quot;A-Za-z_&quot;;     <span class="comment">// define a set of letters</span>
52string tok = pin.token(letters);    <span class="comment">// read a token from the input stream</span></pre>
53</blockquote>
54<p class="seealso">See also: <a href="cset.constructors.html">Constructors</a>, 
55<a href="cset.operators.html">Operators</a>, <a href="cset.manipulation.html">Manipulation</a></p>
56<!-- #EndEditable -->
57<hr size="1">
58<a href="../index.html" class="ns">PTypes home</a>
59</body>
60<!-- #EndTemplate --></html>