home *** CD-ROM | disk | FTP | other *** search
- #ifndef __Tokenizer_h__
- #define __Tokenizer_h__
-
- #include <string.h>
-
- #define TOKENIZER_MAX_TOKENS 32
-
- #define streq(x,y) (!strcmp(x,y))
- #ifdef WIN32
- #define strcasecmp stricmp
- #endif
- //#define newString(x) strcpy(new char[strlen(x)+1], (x)) jetzt als funktion
-
- /*
- This class is VERY simple tokenizer. It takes a string, a set of separators and a brackets (which bundle tokens)
- and then splits the string into [tokc] tokens, that can be read out of the tokv array.
- */
- class Tokenizer{
- public:
- int tokc;
- char* tokv[TOKENIZER_MAX_TOKENS];
- const char* separators;
- const char* brackets;
-
- Tokenizer(const char* string, const char* separators, const char* brackets);
- Tokenizer(const char* separators, const char* brackets);
- ~Tokenizer();
-
- bool tokenize(const char* string);
- void clearTokens(); /* clears tokv */
-
- private:
- static bool contains(const char* str, char c); /* checks whether or not str contains the character c */
- bool addToken(char *start, unsigned int length); /* adds a token to tokv and increases tokc */
- };
-
- char* newString(const char* str);
- char* newString(const char* start, int length);
-
- #endif /* __Tokenizer_h__ */
-