StringTokenizer.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005 Palmsource, Inc.
00003  * 
00004  * This software is licensed as described in the file LICENSE, which
00005  * you should have received as part of this distribution. The terms
00006  * are also available at http://www.openbinder.org/license.html.
00007  * 
00008  * This software consists of voluntary contributions made by many
00009  * individuals. For the exact contribution history, see the revision
00010  * history and logs, available at http://www.openbinder.org
00011  */
00012 
00013 #ifndef _SUPPORT_STRINGTOKENIZER_H
00014 #define _SUPPORT_STRINGTOKENIZER_H
00015 
00021 #include <support/RegExp.h>
00022 #include <support/String.h>
00023 
00024 #if _SUPPORTS_NAMESPACE
00025 namespace palmos {
00026 namespace support {
00027 #endif
00028 
00033 class SStringTokenizer
00034 {
00035 public:
00036     SStringTokenizer(const SString& string, const SString& delimeters);
00037     SStringTokenizer(const SString& string, const char* delimeters = " \t\n\r\f");
00038     SStringTokenizer(const char* string, const char* delimeters = " \t\n\r\f");
00039 
00040     int32_t CountTokens();
00041     bool HasMoreTokens();
00042     SString NextToken();
00043     SString NextToken(const SString& delimeters);
00044     
00045 private:
00046     void RegularExpressionize();
00047 
00048     SRegExp m_regexp;
00049     SString m_string;
00050     SString m_delimeters;
00051     int32_t m_position;
00052 };
00053 
00056 #if _SUPPORTS_NAMESPACE
00057 } } // palmos::support
00058 #endif
00059 
00060 #endif // _SUPPORT_STRINGTOKENIZER_H