Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > media > main-updates > by-pkgid > f36f42783f75191f5f2d47f1e8c5504e > files > 667

lib64commoncpp-devel-1.8.0-5.1mdv2010.1.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>GNU CommonC++: tokenizer.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
  <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><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>tokenizer.h</h1><a href="tokenizer_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (C) 1999-2005 Open Source Telecom Corporation.</span>
<a name="l00002"></a>00002 <span class="comment">// Copyright (C) 2006-2008 David Sugar, Tycho Softworks.</span>
<a name="l00003"></a>00003 <span class="comment">//</span>
<a name="l00004"></a>00004 <span class="comment">// This program is free software; you can redistribute it and/or modify</span>
<a name="l00005"></a>00005 <span class="comment">// it under the terms of the GNU General Public License as published by</span>
<a name="l00006"></a>00006 <span class="comment">// the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00007"></a>00007 <span class="comment">// (at your option) any later version.</span>
<a name="l00008"></a>00008 <span class="comment">//</span>
<a name="l00009"></a>00009 <span class="comment">// This program is distributed in the hope that it will be useful,</span>
<a name="l00010"></a>00010 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00011"></a>00011 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00012"></a>00012 <span class="comment">// GNU General Public License for more details.</span>
<a name="l00013"></a>00013 <span class="comment">//</span>
<a name="l00014"></a>00014 <span class="comment">// You should have received a copy of the GNU General Public License</span>
<a name="l00015"></a>00015 <span class="comment">// along with this program; if not, write to the Free Software</span>
<a name="l00016"></a>00016 <span class="comment">// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.</span>
<a name="l00017"></a>00017 <span class="comment">//</span>
<a name="l00018"></a>00018 <span class="comment">// As a special exception, you may use this file as part of a free software</span>
<a name="l00019"></a>00019 <span class="comment">// library without restriction.  Specifically, if other files instantiate</span>
<a name="l00020"></a>00020 <span class="comment">// templates or use macros or inline functions from this file, or you compile</span>
<a name="l00021"></a>00021 <span class="comment">// this file and link it with other files to produce an executable, this</span>
<a name="l00022"></a>00022 <span class="comment">// file does not by itself cause the resulting executable to be covered by</span>
<a name="l00023"></a>00023 <span class="comment">// the GNU General Public License.  This exception does not however</span>
<a name="l00024"></a>00024 <span class="comment">// invalidate any other reasons why the executable file might be covered by</span>
<a name="l00025"></a>00025 <span class="comment">// the GNU General Public License.</span>
<a name="l00026"></a>00026 <span class="comment">//</span>
<a name="l00027"></a>00027 <span class="comment">// This exception applies only to the code released under the name GNU</span>
<a name="l00028"></a>00028 <span class="comment">// Common C++.  If you copy code from other releases into a copy of GNU</span>
<a name="l00029"></a>00029 <span class="comment">// Common C++, as the General Public License permits, the exception does</span>
<a name="l00030"></a>00030 <span class="comment">// not apply to the code that you add in this way.  To avoid misleading</span>
<a name="l00031"></a>00031 <span class="comment">// anyone as to the status of such modified files, you must delete</span>
<a name="l00032"></a>00032 <span class="comment">// this exception notice from them.</span>
<a name="l00033"></a>00033 <span class="comment">//</span>
<a name="l00034"></a>00034 <span class="comment">// If you write modifications of your own for GNU Common C++, it is your choice</span>
<a name="l00035"></a>00035 <span class="comment">// whether to permit this exception to apply to your modifications.</span>
<a name="l00036"></a>00036 <span class="comment">// If you do not wish that, delete this exception notice.</span>
<a name="l00037"></a>00037 <span class="comment">//</span>
<a name="l00038"></a>00038 
<a name="l00044"></a>00044 <span class="preprocessor">#ifndef CCXX_TOKENIZER_H_</span>
<a name="l00045"></a>00045 <span class="preprocessor"></span><span class="preprocessor">#define CCXX_TOKENIZER_H_</span>
<a name="l00046"></a>00046 <span class="preprocessor"></span>
<a name="l00047"></a>00047 <span class="preprocessor">#ifndef CCXX_MISSING_H_</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span><span class="preprocessor">#include &lt;<a class="code" href="missing_8h.html" title="substitute functions which may be missing in target platform libc.">cc++/missing.h</a>&gt;</span>
<a name="l00049"></a>00049 <span class="preprocessor">#endif</span>
<a name="l00050"></a>00050 <span class="preprocessor"></span>
<a name="l00051"></a>00051 <span class="preprocessor">#ifndef CCXX_THREAD_H_</span>
<a name="l00052"></a>00052 <span class="preprocessor"></span><span class="preprocessor">#include &lt;<a class="code" href="thread_8h.html" title="Synchronization and threading services.">cc++/thread.h</a>&gt;</span>
<a name="l00053"></a>00053 <span class="preprocessor">#endif</span>
<a name="l00054"></a>00054 <span class="preprocessor"></span>
<a name="l00055"></a>00055 <span class="preprocessor">#ifdef  CCXX_NAMESPACES</span>
<a name="l00056"></a>00056 <span class="preprocessor"></span><span class="keyword">namespace </span>ost {
<a name="l00057"></a>00057 <span class="preprocessor">#endif</span>
<a name="l00058"></a>00058 <span class="preprocessor"></span>
<a name="l00102"></a><a class="code" href="classost_1_1_string_tokenizer.html">00102</a> <span class="keyword">class </span><a class="code" href="config_8h.html#ad10ef148ba8327bd530fc6c32c1e181c">__EXPORT</a> <a class="code" href="classost_1_1_string_tokenizer.html" title="Splits delimited string into tokens.">StringTokenizer</a> {
<a name="l00103"></a>00103 <span class="keyword">public</span>:
<a name="l00109"></a><a class="code" href="classost_1_1_string_tokenizer.html#a4018e923303101ebd6d01cdbca10ce38">00109</a>         <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> * <span class="keyword">const</span> SPACE;
<a name="l00110"></a>00110 
<a name="l00120"></a>00120         <span class="comment">// maybe move more global ?</span>
<a name="l00121"></a><a class="code" href="classost_1_1_string_tokenizer_1_1_no_such_element_exception.html">00121</a>         <span class="keyword">class </span><a class="code" href="classost_1_1_string_tokenizer_1_1_no_such_element_exception.html" title="Exception thrown, if someone tried to read beyond the end of the tokens.">NoSuchElementException</a> { };
<a name="l00122"></a>00122 
<a name="l00127"></a><a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html">00127</a>         <span class="keyword">class </span><a class="code" href="config_8h.html#ad10ef148ba8327bd530fc6c32c1e181c">__EXPORT</a> <a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html" title="The input forward iterator for tokens.">iterator</a> {
<a name="l00128"></a><a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html#ae4c807aed5a3c9b17fa4b6f44e1f8012">00128</a>                 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classost_1_1_string_tokenizer.html" title="Splits delimited string into tokens.">StringTokenizer</a>;  <span class="comment">// access our private constructors</span>
<a name="l00129"></a>00129         <span class="keyword">private</span>:
<a name="l00130"></a>00130                 <span class="keyword">const</span> <a class="code" href="classost_1_1_string_tokenizer.html" title="Splits delimited string into tokens.">StringTokenizer</a> *myTok; <span class="comment">// my StringTokenizer</span>
<a name="l00131"></a>00131                 <span class="keyword">const</span> <span class="keywordtype">char</span> *start;      <span class="comment">// start of current token</span>
<a name="l00132"></a>00132                 <span class="keyword">const</span> <span class="keywordtype">char</span> *tokEnd;     <span class="comment">// end of current token (-&gt;nxDelimiter)</span>
<a name="l00133"></a>00133                 <span class="keyword">const</span> <span class="keywordtype">char</span> *endp;       <span class="comment">// one before next token</span>
<a name="l00134"></a>00134                 <span class="keywordtype">char</span> *token;            <span class="comment">// allocated token, if requested</span>
<a name="l00135"></a>00135 
<a name="l00136"></a>00136                 <span class="comment">// for initialization of the itEnd iterator</span>
<a name="l00137"></a>00137                 <a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html" title="The input forward iterator for tokens.">iterator</a>(<span class="keyword">const</span> <a class="code" href="classost_1_1_string_tokenizer.html" title="Splits delimited string into tokens.">StringTokenizer</a> &amp;tok, <span class="keyword">const</span> <span class="keywordtype">char</span> *end)
<a name="l00138"></a>00138                         : myTok(&amp;tok),tokEnd(0),endp(end),token(0) {}
<a name="l00139"></a>00139 
<a name="l00140"></a>00140                 <a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html" title="The input forward iterator for tokens.">iterator</a>(<span class="keyword">const</span> <a class="code" href="classost_1_1_string_tokenizer.html" title="Splits delimited string into tokens.">StringTokenizer</a> &amp;tok)
<a name="l00141"></a>00141                         : myTok(&amp;tok),tokEnd(0),endp(myTok-&gt;str-1),token(0) {
<a name="l00142"></a>00142                         ++(*this); <span class="comment">// init first token.</span>
<a name="l00143"></a>00143                 }
<a name="l00144"></a>00144 
<a name="l00145"></a>00145         <span class="keyword">public</span>:
<a name="l00146"></a><a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html#ae6300cd59e2f0026319f5f8860d086d3">00146</a>                 <a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html#ae6300cd59e2f0026319f5f8860d086d3">iterator</a>() : myTok(0),start(0),tokEnd(0),endp(0),token(0) {}
<a name="l00147"></a>00147 
<a name="l00148"></a>00148                 <span class="comment">// see also: comment in implementation of operator++</span>
<a name="l00149"></a><a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html#a365b92953a6e7b19287a12cb9fe61904">00149</a>                 <span class="keyword">virtual</span> ~<a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html" title="The input forward iterator for tokens.">iterator</a>() 
<a name="l00150"></a>00150                         { <span class="keywordflow">if</span> (token) *token=<span class="charliteral">&#39;\0&#39;</span>; <span class="keyword">delete</span> [] token; }
<a name="l00151"></a>00151 
<a name="l00155"></a>00155                 <span class="comment">// everything, but not responsible for the allocated token.</span>
<a name="l00156"></a><a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html#a1c99b3999e0c08589666c22830c54b62">00156</a>                 <a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html" title="The input forward iterator for tokens.">iterator</a>(<span class="keyword">const</span> <a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html" title="The input forward iterator for tokens.">iterator</a>&amp; i) :
<a name="l00157"></a>00157                         myTok(i.myTok),start(i.start),tokEnd(i.tokEnd),
<a name="l00158"></a>00158                         endp(i.endp),token(0) {}
<a name="l00159"></a>00159 
<a name="l00163"></a>00163                 <span class="comment">// everything, but not responsible for the allocated token.</span>
<a name="l00164"></a><a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html#a8cfac0a3036d1a1a41f8bc0e0c837515">00164</a>                 <a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html" title="The input forward iterator for tokens.">iterator</a> &amp;operator = (<span class="keyword">const</span> <a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html" title="The input forward iterator for tokens.">iterator</a> &amp;i) 
<a name="l00165"></a>00165                 {
<a name="l00166"></a>00166                         myTok = i.myTok;
<a name="l00167"></a>00167                         start = i.start; endp = i.endp; tokEnd = i.tokEnd;
<a name="l00168"></a>00168                         <span class="keywordflow">if</span> ( token )
<a name="l00169"></a>00169                                 <span class="keyword">delete</span> [] token;
<a name="l00170"></a>00170                         token = 0;
<a name="l00171"></a>00171                         <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00172"></a>00172                 }
<a name="l00173"></a>00173 
<a name="l00177"></a>00177                 <a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html" title="The input forward iterator for tokens.">iterator</a> &amp;operator ++ () <a class="code" href="config_8h.html#a9c5a7b689682c471df78bc5892d4ea11">THROWS</a> (<a class="code" href="classost_1_1_string_tokenizer_1_1_no_such_element_exception.html" title="Exception thrown, if someone tried to read beyond the end of the tokens.">NoSuchElementException</a>);
<a name="l00178"></a>00178 
<a name="l00187"></a>00187                 const <span class="keywordtype">char</span>*  operator *  () <a class="code" href="config_8h.html#a9c5a7b689682c471df78bc5892d4ea11">THROWS</a> (NoSuchElementException);
<a name="l00188"></a>00188 
<a name="l00195"></a><a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html#a3aa3b96b05055ef6e58a13c1418b20b7">00195</a>                 inline <span class="keywordtype">char</span> nextDelimiter()<span class="keyword"> const </span>
<a name="l00196"></a>00196 <span class="keyword">                        </span>{<span class="keywordflow">return</span> (tokEnd) ? *tokEnd : <span class="charliteral">&#39;\0&#39;</span>;}
<a name="l00197"></a>00197 
<a name="l00202"></a>00202                 <span class="comment">// only compare the end-position. speed.</span>
<a name="l00203"></a><a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html#abc13d5278b0706125d72e28df2e98ba7">00203</a>                 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator == (<span class="keyword">const</span> <a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html" title="The input forward iterator for tokens.">iterator</a> &amp;other)<span class="keyword"> const </span>
<a name="l00204"></a>00204 <span class="keyword">                        </span>{<span class="keywordflow">return</span> (endp == other.endp);}
<a name="l00205"></a>00205 
<a name="l00210"></a>00210                 <span class="comment">// only compare the end position. speed.</span>
<a name="l00211"></a><a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html#a2c844808f928c1f939534c49a12d3a94">00211</a>                 <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator != (<span class="keyword">const</span> <a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html" title="The input forward iterator for tokens.">iterator</a> &amp;other)<span class="keyword"> const </span>
<a name="l00212"></a>00212 <span class="keyword">                        </span>{<span class="keywordflow">return</span> (endp != other.endp);}
<a name="l00213"></a>00213         };
<a name="l00214"></a>00214 <span class="keyword">private</span>:
<a name="l00215"></a><a class="code" href="classost_1_1_string_tokenizer.html#a46c74d7c3ebac303a827a759155b5879">00215</a>         <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html" title="The input forward iterator for tokens.">StringTokenizer::iterator</a>;
<a name="l00216"></a>00216         <span class="keyword">const</span> <span class="keywordtype">char</span> *str;
<a name="l00217"></a>00217         <span class="keyword">const</span> <span class="keywordtype">char</span> *delim;
<a name="l00218"></a>00218         <span class="keywordtype">bool</span> skipAll, trim;
<a name="l00219"></a>00219         <a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html" title="The input forward iterator for tokens.">iterator</a> itEnd;
<a name="l00220"></a>00220 
<a name="l00221"></a>00221 <span class="keyword">public</span>:
<a name="l00260"></a>00260         <a class="code" href="classost_1_1_string_tokenizer.html" title="Splits delimited string into tokens.">StringTokenizer</a> (<span class="keyword">const</span> <span class="keywordtype">char</span> *str,
<a name="l00261"></a>00261                          <span class="keyword">const</span> <span class="keywordtype">char</span> *delim,
<a name="l00262"></a>00262                          <span class="keywordtype">bool</span> skipAllDelim = <span class="keyword">false</span>,
<a name="l00263"></a>00263                          <span class="keywordtype">bool</span> trim = <span class="keyword">false</span>);
<a name="l00264"></a>00264 
<a name="l00274"></a>00274         <a class="code" href="classost_1_1_string_tokenizer.html" title="Splits delimited string into tokens.">StringTokenizer</a> (<span class="keyword">const</span> <span class="keywordtype">char</span> *s);
<a name="l00275"></a>00275 
<a name="l00279"></a><a class="code" href="classost_1_1_string_tokenizer.html#aec7ea216033f881b2bac13777525e415">00279</a>         <a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html" title="The input forward iterator for tokens.">iterator</a> begin()<span class="keyword"> const </span>
<a name="l00280"></a>00280 <span class="keyword">                </span>{<span class="keywordflow">return</span> <a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html" title="The input forward iterator for tokens.">iterator</a>(*<span class="keyword">this</span>);}
<a name="l00281"></a>00281 
<a name="l00286"></a><a class="code" href="classost_1_1_string_tokenizer.html#a192f7b20b494671b6f69225b4df3e299">00286</a>         <span class="keywordtype">void</span> setDelimiters (<span class="keyword">const</span> <span class="keywordtype">char</span> *d) 
<a name="l00287"></a>00287                 {delim = d;}
<a name="l00288"></a>00288 
<a name="l00293"></a><a class="code" href="classost_1_1_string_tokenizer.html#af3dfeb0e48c9d2fc9629076da65acd86">00293</a>         <a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html" title="The input forward iterator for tokens.">iterator</a> begin(<span class="keyword">const</span> <span class="keywordtype">char</span> *d) 
<a name="l00294"></a>00294         {
<a name="l00295"></a>00295                 delim = d;
<a name="l00296"></a>00296                 <span class="keywordflow">return</span> <a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html" title="The input forward iterator for tokens.">iterator</a>(*<span class="keyword">this</span>);
<a name="l00297"></a>00297         }
<a name="l00298"></a>00298 
<a name="l00302"></a><a class="code" href="classost_1_1_string_tokenizer.html#a74b3471e3e481c0144758385c29cbfbf">00302</a>         <span class="keyword">const</span> <a class="code" href="classost_1_1_string_tokenizer_1_1iterator.html" title="The input forward iterator for tokens.">iterator</a>&amp; end()<span class="keyword"> const </span>
<a name="l00303"></a>00303 <span class="keyword">                </span>{<span class="keywordflow">return</span> itEnd;}
<a name="l00304"></a>00304 };
<a name="l00305"></a>00305 
<a name="l00306"></a>00306 <span class="preprocessor">#ifdef  CCXX_NAMESPACES</span>
<a name="l00307"></a>00307 <span class="preprocessor"></span>}
<a name="l00308"></a>00308 <span class="preprocessor">#endif</span>
<a name="l00309"></a>00309 <span class="preprocessor"></span>
<a name="l00310"></a>00310 <span class="preprocessor">#endif</span>
<a name="l00311"></a>00311 <span class="preprocessor"></span>
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Fri Nov 12 09:57:39 2010 for GNU CommonC++ by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>