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