OSDN Git Service

Initial Commit
[qcad/qcad.git] / qcadwin / StrUtils.h
1 //---------------------------------------------------------------------------\r
2 #ifndef StrUtilsH\r
3 #define StrUtilsH\r
4 //---------------------------------------------------------------------------\r
5 typedef vector<string> svector;\r
6 //---------------------------------------------------------------------------\r
7 class StrUtils {\r
8   public:\r
9   static vector<string> split_str(string str) {\r
10   vector<string> v;\r
11   bool inQuotation=false;
12   int index = 0;
13   for(unsigned int i=0;i<str.length();i++){
14     if(str[i] == '"') {
15       inQuotation = !inQuotation;
16     }
17     if(!inQuotation  && str[i] == ','){
18       string s = str.substr(index,i-index);
19       v.push_back(s);
20       index = i + 1;
21     }
22   }
23   string s = str.substr(index);
24   v.push_back(s);
25   return v;\r
26   }\r
27 };\r
28 //---------------------------------------------------------------------------\r
29 #endif\r