📄 cset.constructors.html
字号:
<html><!-- #BeginTemplate "/Templates/tmpl.dwt" --><head><!-- #BeginEditable "doctitle" --> <title>PTypes: cset: constructors</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-1.7.gif" width="213" height="34" alt="C++ Portable Types Library (PTypes) Version 1.7" border="0"></a> <hr noshade><!-- #BeginEditable "body" --> <p class="hpath"><a href="index.html">Top</a>: <a href="basic.html">Basic types</a>: <a href="cset.html">cset</a>: Constructors</p><blockquote> <pre class="lang">#include <ptypes.h>cset::cset();cset::cset(const cset& s);cset::cset(const char* setinit);</pre></blockquote><p><span class="def">cset::cset()</span> -- default constructor, initializes the set object to an empty set.</p><p><span class="def">cset::cset(const cset& s)</span> -- copy constructor.</p><p><span class="def">cset::cset(const char* setinit)</span> constructs a character set from a string. The <span class="lang">setinit</span> parameter is a sequence of characters, range specifiers and escape sequences. Range specifier consists of: lower boundary, dash "-" and higher boundary, e.g. "A-Z". Escape sequence begins with tilde "~" and can be followed by a two-digit hexadecimal number. Escape sequences are also used to include special characters tilde "~" and dash "-" (see examples below).</p><p>Constructing character sets using this interpreter can be a time-consuming operation. A better practice is to declare all constant character sets as static variables, so that the interpretation of all set constructing strings will be done only once during program startup.</p><p>An initializer string can also be passed to a cset object through <span class="lang">assign()</span> function.</p><p><b>Note</b>: this constructor does not generate errors if the syntax is violated.</p><p><b>Examples:</b></p><blockquote> <pre>cset s1 = "135A-CZ"; <span class="comment">// digits 1, 3, 5, letters A through C, and also Z</span>cset wspace1 = "~09~0d~0a "; <span class="comment">// tab, CR, LF and space</span>cset wspace2 = "~00-~20"; <span class="comment">// all control and whitespace chars</span>cset s2 = ":@~~"; <span class="comment">// colon, at and tilde (must be escaped with another tilde)</span></pre></blockquote><p class="seealso">See also: <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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -