00001 #ifndef __STRING_H__
00002 #define __STRING_H__
00003
00004 #include <vector>
00005 #include <string>
00006 using namespace std;
00007
00008 class String
00009 {
00010 public:
00011 static void Tokenize (const string& str, vector<string>& tokens, const string& delimiters = ",")
00012 {
00013 tokens.clear();
00014
00015
00016 string::size_type lastPos = str.find_first_not_of (delimiters, 0);
00017
00018 string::size_type pos = str.find_first_of (delimiters, lastPos);
00019
00020 while (string::npos != pos || string::npos != lastPos)
00021 {
00022
00023 tokens.push_back (str.substr (lastPos, pos - lastPos));
00024
00025 lastPos = str.find_first_not_of (delimiters, pos);
00026
00027 pos = str.find_first_of (delimiters, lastPos);
00028 }
00029 };
00030 };
00031
00032 #endif