/******************************************************************
*
* SKALA Knowledge Project
*
* $Id: strtok.h,v 1.2 2001/11/12 03:45:47 jbakus Exp $
* $Source: /u/jbakus/cvs/skala/kr/include/strtok.h,v $
* $Author: jbakus $
* $Date: 2001/11/12 03:45:47 $
* $Revision: 1.2 $
* this is some one elses, i just grabbed it off the web, thanks!
******************************************************************/
#ifndef CS_STRTOK_H_
#define CS_STRTOK_H_
#include <string>
/** string tokenizer
*
* @doc
* The StringTokenizer is implements such that the input string is passed
* in as a pointer. The string of delimiters is passed in by value and
* copied in.
*
* The individual tokens are extracted from the string and passed out
* by value.
******************************************************************/
/*! \ingroup lib_kr
*/
class stringTok {
public:
stringTok (string *_str, string delim, bool returnTokens);
stringTok (string *_str, string delim);
stringTok (string *_str);
stringTok ();
~stringTok ();
bool HasMoreTokens ();
string NextToken (void);
bool NextToken (string &_str);
int CountTokens (void);
void Reset (string *_str, string delim, bool returnTokens);
void Reset (string *_str, bool returnTokens);
void Reset (string *_str);
private:
void skipDelimiters (void);
int getStart (void);
private:
int currentPosition;
int maxPosition;
string *str;
string delimiters;
bool retTokens;
};
#endif