00001 00003 00023 #ifndef _STRTOK_H_ 00024 #define _STRTOK_H_ 00025 00026 00027 #include <string> 00028 00030 00042 class StringTokenizer 00043 { 00044 public: 00046 00052 StringTokenizer(const std::string& rStr, char cDelim = ','); 00053 00055 ~StringTokenizer() {} 00056 00058 00061 inline bool HasMoreTokens() const 00062 { 00063 return m_pos < m_len; 00064 } 00065 00067 00070 std::string GetNextToken(); 00071 00073 00079 inline void SetDelimiter(char cDelim) 00080 { 00081 m_cDelim = cDelim; 00082 } 00083 00085 00088 inline char GetDelimiter() const 00089 { 00090 return m_cDelim; 00091 } 00092 00094 00097 inline void Reset() 00098 { 00099 m_pos = 0; 00100 } 00101 00102 private: 00103 std::string m_str; 00104 char m_cDelim; 00105 std::string::size_type m_pos; 00106 std::string::size_type m_len; 00107 }; 00108 00109 00110 #endif //_STRTOK_H_