Sophie

Sophie

distrib > Mandriva > 2007.0 > i586 > by-pkgid > ad1ba1135a9c9eeffc2e538163e00373 > files > 307

libCommonC++2_1.4-devel-1.4.1-1mdv2007.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>GNU CommonC++: ost::StringTokenizer Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="namespaces.html"><span>Namespaces</span></a></li>
    <li id="current"><a href="classes.html"><span>Classes</span></a></li>
    <li><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
    <li><a href="examples.html"><span>Examples</span></a></li>
  </ul></div>
<div class="tabs">
  <ul>
    <li><a href="classes.html"><span>Alphabetical&nbsp;List</span></a></li>
    <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
    <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
    <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
  </ul></div>
<div class="nav">
<a class="el" href="namespaceost.html">ost</a>::<a class="el" href="classost_1_1_string_tokenizer.html">StringTokenizer</a></div>
<h1>ost::StringTokenizer Class Reference</h1><!-- doxytag: class="ost::StringTokenizer" -->Splits delimited string into tokens.  
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="tokenizer_8h-source.html">tokenizer.h</a>&gt;</code>
<p>
<a href="classost_1_1_string_tokenizer-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_string_tokenizer.html#67c853d283920854b98c41fbe4e84d52">StringTokenizer</a> (const char *str, const char *delim, bool skipAllDelim=false, bool trim=false)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">creates a new <a class="el" href="classost_1_1_string_tokenizer.html">StringTokenizer</a> for a string and a given set of delimiters.  <a href="#67c853d283920854b98c41fbe4e84d52"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_string_tokenizer.html#d92ba14c987eee96b10f9fa177b5a4e0">StringTokenizer</a> (const char *s)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">create a new <a class="el" href="classost_1_1_string_tokenizer.html">StringTokenizer</a> which splits the input string at whitespaces.  <a href="#d92ba14c987eee96b10f9fa177b5a4e0"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="classost_1_1_string_tokenizer_1_1iterator.html">iterator</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_string_tokenizer.html#ec7ea216033f881b2bac13777525e415">begin</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">returns the begin iterator  <a href="#ec7ea216033f881b2bac13777525e415"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_string_tokenizer.html#192f7b20b494671b6f69225b4df3e299">setDelimiters</a> (const char *d)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">changes the set of delimiters used in subsequent iterations.  <a href="#192f7b20b494671b6f69225b4df3e299"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="classost_1_1_string_tokenizer_1_1iterator.html">iterator</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_string_tokenizer.html#f3dfeb0e48c9d2fc9629076da65acd86">begin</a> (const char *d)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">returns a begin iterator with an alternate set of delimiters.  <a href="#f3dfeb0e48c9d2fc9629076da65acd86"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">const <a class="el" href="classost_1_1_string_tokenizer_1_1iterator.html">iterator</a> &amp;&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_string_tokenizer.html#74b3471e3e481c0144758385c29cbfbf">end</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">the iterator marking the end.  <a href="#74b3471e3e481c0144758385c29cbfbf"></a><br></td></tr>
<tr><td colspan="2"><br><h2>Static Public Attributes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">static const char *const&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_string_tokenizer.html#4018e923303101ebd6d01cdbca10ce38">SPACE</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">a delimiter string containing all usual whitespace delimiters.  <a href="#4018e923303101ebd6d01cdbca10ce38"></a><br></td></tr>
<tr><td colspan="2"><br><h2>Friends</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_string_tokenizer.html#46c74d7c3ebac303a827a759155b5879">StringTokenizer::iterator</a></td></tr>

<tr><td colspan="2"><br><h2>Classes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_string_tokenizer_1_1iterator.html">iterator</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The input forward iterator for tokens.  <a href="classost_1_1_string_tokenizer_1_1iterator.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_string_tokenizer_1_1_no_such_element_exception.html">NoSuchElementException</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Exception thrown, if someone tried to read beyond the end of the tokens.  <a href="classost_1_1_string_tokenizer_1_1_no_such_element_exception.html#_details">More...</a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Splits delimited string into tokens. 
<p>
The <a class="el" href="classost_1_1_string_tokenizer.html">StringTokenizer</a> takes a pointer to a string and a pointer to a string containing a number of possible delimiters. The <a class="el" href="classost_1_1_string_tokenizer.html">StringTokenizer</a> provides an input forward iterator which allows to iterate through all tokens. An iterator behaves like a logical pointer to the tokens, i.e. to shift to the next token, you've to increment the iterator, you get the token by dereferencing the iterator.<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 <a class="el" href="classost_1_1_string_tokenizer.html">StringTokenizer</a>; the behaviour is undefined in that case.<p>
The iterator 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 'setDelimiters(const char*)' you may change the set of delimiters. It affects all running iterators.<p>
Example: <code><pre>
  <a class="el" href="classost_1_1_string_tokenizer.html">StringTokenizer</a> st("mary had a little lamb;its fleece was..", " ;");
  <a class="el" href="classost_1_1_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></dt><dd>Henner Zeller &lt;<a href="mailto:H.Zeller@acm.org">H.Zeller@acm.org</a>&gt; </dd></dl>
<dl compact><dt><b>License:</b></dt><dd>LGPL </dd></dl>

<p>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="67c853d283920854b98c41fbe4e84d52"></a><!-- doxytag: member="ost::StringTokenizer::StringTokenizer" ref="67c853d283920854b98c41fbe4e84d52" args="(const char *str, const char *delim, bool skipAllDelim=false, bool trim=false)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">ost::StringTokenizer::StringTokenizer           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const char *&nbsp;</td>
          <td class="mdname" nowrap> <em>str</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>const char *&nbsp;</td>
          <td class="mdname" nowrap> <em>delim</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>bool&nbsp;</td>
          <td class="mdname" nowrap> <em>skipAllDelim</em> = <code>false</code>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>bool&nbsp;</td>
          <td class="mdname" nowrap> <em>trim</em> = <code>false</code></td>
        </tr>
        <tr>
          <td class="md"></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 <a class="el" href="classost_1_1_string_tokenizer.html">StringTokenizer</a> for a string and a given set of delimiters. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>str</em>&nbsp;</td><td><a class="el" href="classost_1_1_string.html">String</a> to be split up. This string will not be modified by this <a class="el" href="classost_1_1_string_tokenizer.html">StringTokenizer</a>, 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"></td><td valign="top"><em>delim</em>&nbsp;</td><td><a class="el" href="classost_1_1_string.html">String</a> containing the characters which should be regarded as delimiters.</td></tr>
    <tr><td valign="top"></td><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"></td><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="classost_1_1_string_tokenizer.html#4018e923303101ebd6d01cdbca10ce38">StringTokenizer::SPACE</a>. If delim itself is <a class="el" href="classost_1_1_string_tokenizer.html#4018e923303101ebd6d01cdbca10ce38">StringTokenizer::SPACE</a>, this will result in a behaviour with skipAllDelim = true. DEFAULT = false </td></tr>
  </table>
</dl>
    </td>
  </tr>
</table>
<a class="anchor" name="d92ba14c987eee96b10f9fa177b5a4e0"></a><!-- doxytag: member="ost::StringTokenizer::StringTokenizer" ref="d92ba14c987eee96b10f9fa177b5a4e0" args="(const char *s)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">ost::StringTokenizer::StringTokenizer           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const char *&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>s</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
create a new <a class="el" href="classost_1_1_string_tokenizer.html">StringTokenizer</a> 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 'begin(const char *delim)' method or in 'setDelimiters()', 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 class="anchor" name="f3dfeb0e48c9d2fc9629076da65acd86"></a><!-- doxytag: member="ost::StringTokenizer::begin" ref="f3dfeb0e48c9d2fc9629076da65acd86" args="(const char *d)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"><a class="el" href="classost_1_1_string_tokenizer_1_1iterator.html">iterator</a> ost::StringTokenizer::begin           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const char *&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>d</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><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 iterator with an alternate set of delimiters. 
<p>
    </td>
  </tr>
</table>
<a class="anchor" name="ec7ea216033f881b2bac13777525e415"></a><!-- doxytag: member="ost::StringTokenizer::begin" ref="ec7ea216033f881b2bac13777525e415" args="() const " --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"><a class="el" href="classost_1_1_string_tokenizer_1_1iterator.html">iterator</a> ost::StringTokenizer::begin           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> 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 iterator 
<p>
    </td>
  </tr>
</table>
<a class="anchor" name="74b3471e3e481c0144758385c29cbfbf"></a><!-- doxytag: member="ost::StringTokenizer::end" ref="74b3471e3e481c0144758385c29cbfbf" args="() const " --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">const <a class="el" href="classost_1_1_string_tokenizer_1_1iterator.html">iterator</a>&amp; ost::StringTokenizer::end           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">void&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap> const<code> [inline]</code></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
the iterator marking the end. 
<p>
    </td>
  </tr>
</table>
<a class="anchor" name="192f7b20b494671b6f69225b4df3e299"></a><!-- doxytag: member="ost::StringTokenizer::setDelimiters" ref="192f7b20b494671b6f69225b4df3e299" args="(const char *d)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">void ost::StringTokenizer::setDelimiters           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const char *&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>d</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><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>Friends And Related Function Documentation</h2>
<a class="anchor" name="46c74d7c3ebac303a827a759155b5879"></a><!-- doxytag: member="ost::StringTokenizer::StringTokenizer::iterator" ref="46c74d7c3ebac303a827a759155b5879" args="" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">friend class <a class="el" href="classost_1_1_string_tokenizer_1_1iterator.html">StringTokenizer::iterator</a><code> [friend]</code>          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
    </td>
  </tr>
</table>
<hr><h2>Member Data Documentation</h2>
<a class="anchor" name="4018e923303101ebd6d01cdbca10ce38"></a><!-- doxytag: member="ost::StringTokenizer::SPACE" ref="4018e923303101ebd6d01cdbca10ce38" args="" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">const char* const <a class="el" href="classost_1_1_string_tokenizer.html#4018e923303101ebd6d01cdbca10ce38">ost::StringTokenizer::SPACE</a><code> [static]</code>          </td>
        </tr>
      </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="tokenizer_8h-source.html">tokenizer.h</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Mon Jun 19 10:50:58 2006 for GNU CommonC++ by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>