Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 68d373e54fb21da3730c08bede406633 > files > 349

libCommonC++1.9_3-devel-1.9.4-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>StringTokenizer class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body bgcolor="#ffffff">
<!-- Generated by Doxygen 1.2.10 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; </center>
<hr><h1>StringTokenizer  Class Reference</h1>Splits delimited string into tokens. 
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="misc_8h-source.html">misc.h</a>&gt;</code>
<p>
<a href="class_string_tokenizer-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
<tr><td colspan=2><br><h2>Public Methods</h2></td></tr>
<tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="class_string_tokenizer.html#a0">StringTokenizer</a> (const char *str, const char *delim, bool skipAllDelim=false, bool trim=false)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>creates a new StringTokenizer for a string and a given set of delimiters.</em> <a href="#a0">More...</a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="class_string_tokenizer.html#a1">StringTokenizer</a> (const char *s)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>create a new StringTokenizer which splits the input string at whitespaces.</em> <a href="#a1">More...</a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top><a class="el" href="class_string_tokenizer_1_1iterator.html">iterator</a>&nbsp;</td><td valign=bottom><a class="el" href="class_string_tokenizer.html#a2">begin</a> () const</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>returns the begin <a class="el" href="class_string_tokenizer_1_1iterator.html">iterator</a>.</em> <a href="#a2">More...</a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>void&nbsp;</td><td valign=bottom><a class="el" href="class_string_tokenizer.html#a3">setDelimiters</a> (const char *d)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>changes the set of delimiters used in subsequent iterations.</em> <a href="#a3">More...</a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top><a class="el" href="class_string_tokenizer_1_1iterator.html">iterator</a>&nbsp;</td><td valign=bottom><a class="el" href="class_string_tokenizer.html#a4">begin</a> (const char *d)</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>returns a begin <a class="el" href="class_string_tokenizer_1_1iterator.html">iterator</a> with an alternate set of delimiters.</em> <a href="#a4">More...</a><em></em></font><br><br></td></tr>
<tr><td nowrap align=right valign=top>const <a class="el" href="class_string_tokenizer_1_1iterator.html">iterator</a> &amp;&nbsp;</td><td valign=bottom><a class="el" href="class_string_tokenizer.html#a5">end</a> () const</td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>the <a class="el" href="class_string_tokenizer_1_1iterator.html">iterator</a> marking the end.</em> <a href="#a5">More...</a><em></em></font><br><br></td></tr>
<tr><td colspan=2><br><h2>Static Public Attributes</h2></td></tr>
<tr><td nowrap align=right valign=top>const char *const&nbsp;</td><td valign=bottom><a class="el" href="class_string_tokenizer.html#p0">SPACE</a></td></tr>
<tr><td>&nbsp;</td><td><font size=-1><em>a delimiter string containing all usual whitespace delimiters.</em> <a href="#p0">More...</a><em></em></font><br><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Splits delimited string into tokens.
<p>
The StringTokenizer takes a pointer to a string and a pointer to a string containing a number of possible delimiters. The StringTokenizer provides an input forward <a class="el" href="class_string_tokenizer_1_1iterator.html">iterator</a> which allows to iterate through all tokens. An <a class="el" href="class_string_tokenizer_1_1iterator.html">iterator</a> behaves like a logical pointer to the tokens, i.e. to shift to the next token, you've  to increment the <a class="el" href="class_string_tokenizer_1_1iterator.html">iterator</a>, you get the token by dereferencing the <a class="el" href="class_string_tokenizer_1_1iterator.html">iterator</a>.
<p>
Memory consumption: This class operates on the original string and only allocates memory for the individual tokens actually requested, so this class  allocates at maximum the space required for the longest token in the  given string. Since for each iteration, memory is reclaimed for the last token, you MAY NOT store pointers to them; if you need them afterwards, copy them. You may not modify the original string while you operate on it with the StringTokenizer; the behaviour is undefined in that case.
<p>
The <a class="el" href="class_string_tokenizer_1_1iterator.html">iterator</a> has one special method 'nextDelimiter()' which returns a character containing the next delimiter following this tokenization process or '\0', if there are no following delimiters. In case of skipAllDelim, it returns the FIRST delimiter.
<p>
With the method '<a class="el" href="class_string_tokenizer.html#a3">setDelimiters</a>(const char*)' you may change the set of delimiters. It affects all running iterators.
<p>
Example: <code><pre>
  StringTokenizer st("mary had a little lamb;its fleece was..", " ;");
  <a class="el" href="class_string_tokenizer_1_1iterator.html">StringTokenizer::iterator</a> i;
  for (i = st.begin() ; i != st.end() ; ++i) {
        cout &lt;&lt; "Token: '" &lt;&lt; *i &lt;&lt; "'\t";
        cout &lt;&lt; " next Delim: '" &lt;&lt; i.nextDelimiter() &lt;&lt; "'" &lt;&lt; endl;
  }
  </pre></code>
<p>
<dl compact><dt><b>
Author: </b><dd>
Henner Zeller &lt;<a href="mailto:foobar@to.com">foobar@to.com</a>&gt; @license LGPL </dl>
<p>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a name="a0" doxytag="StringTokenizer::StringTokenizer"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> StringTokenizer::StringTokenizer </td>
          <td class="md">(&nbsp;</td>
          <td class="md">const char *</td>
          <td class="mdname">&nbsp; <em>str</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md">const char *</td>
          <td class="mdname">&nbsp; <em>delim</em>, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md">bool</td>
          <td class="mdname">&nbsp; <em>skipAllDelim</em> = false, </td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <td class="md">bool</td>
          <td class="mdname">&nbsp; <em>trim</em> = false</td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
creates a new StringTokenizer for a string and a given set of delimiters.
<p>
<dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>str
</em>&nbsp;</td><td>
String to be split up. This string will not be modified by this StringTokenizer, but you may as well not modfiy this string while tokenizing is in process, which may lead to undefined behaviour.</td></tr>
<tr><td valign=top><em>delim
</em>&nbsp;</td><td>
String containing the characters which should be regarded as delimiters.</td></tr>
<tr><td valign=top><em>skipAllDelim
</em>&nbsp;</td><td>
OPTIONAL.  true, if subsequent delimiters should be skipped at once or false, if empty tokens should be returned for two delimiters with no other text inbetween. The first behaviour may be desirable for whitespace skipping, the second for input with delimited entry e.g. /etc/passwd like files or CSV input. NOTE, that 'true' here resembles the  ANSI-C strtok(char *s,char *d) behaviour. DEFAULT = false</td></tr>
<tr><td valign=top><em>trim
</em>&nbsp;</td><td>
OPTIONAL.  true, if the tokens returned should be trimmed, so that they don't have any whitespaces at the beginning or end. Whitespaces are any of the characters  defined in <a class="el" href="class_string_tokenizer.html#p0">StringTokenizer::SPACE</a>. If delim itself is <a class="el" href="class_string_tokenizer.html#p0">StringTokenizer::SPACE</a>, this will result in a behaviour with  skipAllDelim = true. DEFAULT = false </td></tr>
</table>
</dl>    </td>
  </tr>
</table>
<a name="a1" doxytag="StringTokenizer::StringTokenizer"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> StringTokenizer::StringTokenizer </td>
          <td class="md">(&nbsp;</td>
          <td class="md">const char *</td>
          <td class="mdname1">&nbsp; <em>s</em>          </td>
          <td class="md">)&nbsp;</td>
          <td class="md"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
create a new StringTokenizer which splits the input string at whitespaces.
<p>
The tokens are stripped from whitespaces. This means, if you change the set of delimiters in either the '<a class="el" href="class_string_tokenizer.html#a4">begin</a>(const char *delim)' method or in '<a class="el" href="class_string_tokenizer.html#a3">setDelimiters</a>()', you then get whitespace trimmed tokens, delimited by the new set. Behaves like StringTokenizer(s, StringTokenizer::SPACE,false,true);     </td>
  </tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a name="a4" doxytag="StringTokenizer::begin"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="class_string_tokenizer_1_1iterator.html">iterator</a> StringTokenizer::begin </td>
          <td class="md">(&nbsp;</td>
          <td class="md">const char *</td>
          <td class="mdname1">&nbsp; <em>delim</em>          </td>
          <td class="md">)&nbsp;</td>
          <td class="md"><code> [inline]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
returns a begin <a class="el" href="class_string_tokenizer_1_1iterator.html">iterator</a> with an alternate set of delimiters.
<p>
    </td>
  </tr>
</table>
<a name="a2" doxytag="StringTokenizer::begin"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="class_string_tokenizer_1_1iterator.html">iterator</a> StringTokenizer::begin </td>
          <td class="md">(&nbsp;</td>
          <td class="mdname1">&nbsp;          </td>
          <td class="md">)&nbsp;</td>
          <td class="md"> const<code> [inline]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
returns the begin <a class="el" href="class_string_tokenizer_1_1iterator.html">iterator</a>.
<p>
    </td>
  </tr>
</table>
<a name="a5" doxytag="StringTokenizer::end"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> const <a class="el" href="class_string_tokenizer_1_1iterator.html">iterator</a>&amp; StringTokenizer::end </td>
          <td class="md">(&nbsp;</td>
          <td class="mdname1">&nbsp;          </td>
          <td class="md">)&nbsp;</td>
          <td class="md"> const<code> [inline]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
the <a class="el" href="class_string_tokenizer_1_1iterator.html">iterator</a> marking the end.
<p>
    </td>
  </tr>
</table>
<a name="a3" doxytag="StringTokenizer::setDelimiters"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void StringTokenizer::setDelimiters </td>
          <td class="md">(&nbsp;</td>
          <td class="md">const char *</td>
          <td class="mdname1">&nbsp; <em>d</em>          </td>
          <td class="md">)&nbsp;</td>
          <td class="md"><code> [inline]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
changes the set of delimiters used in subsequent iterations.
<p>
    </td>
  </tr>
</table>
<hr><h2>Member Data Documentation</h2>
<a name="p0" doxytag="StringTokenizer::SPACE"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td class="md">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> const char* const StringTokenizer::SPACE<code> [static]</code>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
a delimiter string containing all usual whitespace delimiters.
<p>
These are space, tab, newline, carriage return, formfeed and vertical tab. (see isspace() manpage).     </td>
  </tr>
</table>
<hr>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="misc_8h-source.html">misc.h</a></ul>
<hr><address><small>Generated at Tue Nov 20 13:28:50 2001 for CommonC++ by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.gif" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.10 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>,
 &copy;&nbsp;1997-2001</small></address>
</body>
</html>