xstring.shtml

来自「mfc资源大全包含MFC编程各个方面的源码」· SHTML 代码 · 共 492 行 · 第 1/2 页

SHTML
492
字号
    </tr>    <tr>        <td><strong>ReplaceTabs</strong></td>        <td>Replace all \t in the string with the corresponding        number of spaces</td>        <td>&nbsp;</td>        <td>&nbsp;</td>    </tr>    <tr>        <td><strong>ReplaceText</strong></td>        <td>Replace '*' with specified text.<br>        When using more than one '*' devide the replace-texts        with '|'</td>        <td><font color="#990000">error.ReplaceText(&quot;75|120&quot;)</font></td>        <td><font color="#000000">&quot;Error 75 in Line        120&quot;</font></td>    </tr>    <tr>        <td>&nbsp;</td>        <td>&nbsp;</td>        <td colspan="2"><font color="#990000"><em>XString        format(&quot;###.##&quot;);</em></font></td>    </tr>    <tr>        <td><strong>GetDoubleFormatString</strong></td>        <td>Translate a formatting-string into C-notation</td>        <td><font color="#990000">format.GetDoubleFormatString()</font></td>        <td><font color="#000000">&quot;%6.2lf&quot;</font></td>    </tr></table><h4><a name="elementstring"></a>What are Elementstrings?</h4><p>Elementstrings are a special sort of short (and dynamic)stringarrays. Every array-entry was divided with a separator fromthe next entry. For example, the elementstring&quot;zero|one|two|three&quot; has four elemententrys. With thisclass you can easyly get, set or find a specified element. Youdon't have to specify the size of the 'array', because it's onlyone string. The entries can be strings, chars, doubles, ints orbools. If you set an entry, the numbers are converted intostrings and if you get one, it was back converted to thespecified type. Normaly the separator is '|', but it's possibleto use every other character.</p><h4><a name="elemstringfkt"></a>Elementstringfunctions:</h4><table border="1" cellspacing="1">    <tr>        <td bgcolor="#C0C0C0"><font color="#000000"><strong>Function</strong></font></td>        <td bgcolor="#C0C0C0"><font color="#000000"><strong>Description</strong></font></td>        <td bgcolor="#C0C0C0"><font color="#000000"><strong>Example</strong></font></td>        <td bgcolor="#C0C0C0"><font color="#000000"><strong>Result</strong></font></td>    </tr>    <tr>        <td>&nbsp;</td>        <td>&nbsp;</td>        <td colspan="2"><font color="#990000"><em>XString        str(&quot;zero|one|22|3.3|four|5||7&quot;)</em></font></td>    </tr>    <tr>        <td><strong>Element</strong></td>        <td>Return the given element as string</td>        <td><font color="#990000">str.Element(1)</font></td>        <td>&quot;one&quot;</td>    </tr>    <tr>        <td><strong>Elements</strong></td>        <td>Return the given elements as an elementstring</td>        <td><font color="#990000">str.Elements(1, 4)</font></td>        <td>&quot;one|22|3.3|four&quot;</td>    </tr>    <tr>        <td><strong>operator()</strong></td>        <td>same as Element or Elements</td>        <td><font color="#990000">str(3)</font></td>        <td>&quot;3.3&quot;</td>    </tr>    <tr>        <td><strong>GetString<br>        GetDouble<br>        GetInt<br>        GetChar<br>        GetBool</strong></td>        <td>Return the given element as specified type</td>        <td><font color="#990000">str.GetString(3)<br>        str.GetDouble(3)<br>        str.GetInt(3)<br>        str.GetChar(3)<br>        str.GetBool(3)</font></td>        <td>&quot;3.3&quot;<br>        3.3<br>        3<br>        '3'<br>        true</td>    </tr>    <tr>        <td><strong>SetElement</strong></td>        <td>Set the element at the given index with a<br>        string, double, int, char or bool</td>        <td><font color="#990000">str.SetElement(3, 99)<br>        str.SetElement(9, 'x')</font></td>        <td>&quot;zero|one|22|99|four|5||7&quot;<br>        &quot;zero|one|22|99|four|5||7||x&quot;</td>    </tr>    <tr>        <td><strong>ElementIndex</strong></td>        <td>Retrieve the index of the specified element</td>        <td><font color="#990000">str.ElementIndex(&quot;four&quot;)<br>        str.ElementIndex(1)</font></td>        <td>4<br>        -1</td>    </tr>    <tr>        <td><strong>ElementSortString<br>        ElementSortDouble<br>        ElementSortInt<br>        ElementSortChar<br>        ElementSort</strong></td>        <td>Sort the elementstring by using the specified type</td>        <td><font color="#990000">str.ElementSortString()<br>        str.ElementSortInt()<br>        str.ElementSortDouble()</font></td>        <td>&quot;|22|3.3|5|7|four|one|zero&quot;<br>        &quot;0|0|0|0|3|5|7|22&quot;<br>        &quot;0|0|0|0|3.3|5|7|22&quot;</td>    </tr>    <tr>        <td>&nbsp;</td>        <td>&nbsp;</td>        <td>&nbsp;</td>        <td>&nbsp;</td>    </tr>    <tr>        <td><strong>SetSeparator</strong></td>        <td>Defines a new separator</td>        <td><font color="#990000">XString::SetSeparator('#')</font></td>        <td>&nbsp;</td>    </tr>    <tr>        <td><strong>RestoreSeparator</strong></td>        <td>Restores temporary separators</td>        <td><font color="#990000">XString::RestoreSeparator()</font></td>        <td>&nbsp;</td>    </tr>    <tr>        <td>&nbsp;</td>        <td>&nbsp;</td>        <td colspan="2"><font color="#990000">XString        str(&quot;one#two#three&quot;)</font></td>    </tr>    <tr>        <td colspan="2">You can use all functions with an        additional parameter as temporar separator.</td>        <td><font color="#990000">str.Element(1)<br>        str.Element(1, '#')</font></td>        <td>&quot;one#two#three&quot;<br>        &quot;two&quot;</td>    </tr></table><h4><a name="friends"></a>Friendfunctions:</h4><table border="1" cellspacing="1">    <tr>        <td bgcolor="#C0C0C0"><font color="#000000"><strong>Function</strong></font></td>        <td bgcolor="#C0C0C0"><font color="#000000"><strong>Description</strong></font></td>        <td bgcolor="#C0C0C0"><font color="#000000"><strong>Example</strong></font></td>        <td bgcolor="#C0C0C0"><font color="#000000"><strong>Result</strong></font></td>    </tr>    <tr>        <td><strong>itoa</strong></td>        <td>Create a XString from an int</td>        <td><font color="#990000">itoa(5)</font></td>        <td>&quot;5&quot;</td>    </tr>    <tr>        <td><strong>utoa</strong></td>        <td>Create a XString from an unsinged int</td>        <td><font color="#990000">utoa(2)</font></td>        <td>&quot;2&quot;</td>    </tr>    <tr>        <td><strong>dtoa</strong></td>        <td>Create a XString from a doube</td>        <td><font color="#990000">dtoa(3.14)<br>        dtoa(3.14, 5)</font></td>        <td>&quot;3.14&quot;<br>        &quot;3.14000&quot;</td>    </tr>    <tr>        <td><strong>Repeat</strong></td>        <td>Create a XString with copies of a given string or        char</td>        <td><font color="#990000">Repeat('x', 10)<br>        Repeat(&quot;Test&quot;, 3&quot;)</font></td>        <td>&quot;xxxxxxxxxx&quot;<br>        &quot;TestTestTest&quot;</td>    </tr>    <tr>        <td><strong>GetStringTableEntry</strong></td>        <td>Return the entry of a stringtableresource</td>        <td><font color="#990000">GetStringTableEntry(<br>        AFX_IDS_IDLEMESSAGE)</font></td>        <td>&quot;Ready&quot;</td>    </tr>    <tr>        <td><strong>Concat</strong></td>        <td>Create an elementstring of 1 to 16 strings</td>        <td><font color="#990000">Concat(&quot;This&quot;,        &quot;Is&quot;, &quot;A&quot;, &quot;Test&quot;)</font></td>        <td>&quot;This|Is|A|Test&quot;</td>    </tr></table><p>&nbsp;</p><p>If you've questions, contact me at <ahref="mailto:Joachim.Raidl@iname.com">Joachim.Raidl@iname.com</a></p><!-- Remember to update this --><p>Last updated: 8 May 1998<P><HR><!-- Codeguru contact details --><TABLE BORDER=0 WIDTH="100%"><TR><TD WIDTH="33%"><FONT SIZE=-1><A HREF="http://www.codeguru.com">Goto HomePage</A></FONT></TD><TD WIDTH="33%"><CENTER><FONT SIZE=-2>&copy; 1998 Zafir Anjum</FONT>&nbsp;</CENTER></TD><TD WIDTH="34%"><DIV ALIGN=right><FONT SIZE=-1>Contact me: <A HREF="mailto:zafir@home.com">zafir@home.com</A>&nbsp;</FONT></DIV></TD></TR></TABLE><!-- Counter --></BODY></HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?