Changeset 2706 in Sophya for trunk/SophyaLib/SUtils/strutilxx.cc
- Timestamp:
- Apr 28, 2005, 7:31:47 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/SUtils/strutilxx.cc
r2615 r2706 8 8 9 9 10 /* methode */ 10 11 void FillVStringFrString(string const & s,vector<string>& vs,char sep) 11 12 // Use string "s" to fill vector of strings "vs" … … 43 44 if(dum.size() > 0) vs.push_back(dum); 44 45 } 46 47 /* methode */ 48 void SplitStringToVString(string const & s,vector<string>& vs,char separator) 49 // Split the string "s" into a string vector "vs" 50 // - Separator is "separator" 51 // - If the separator is not a space (' '), the space is considered 52 // as a dummy character: 53 // - If ',' is the separator, "1, 2 ,3 , 4 " == "1,2,3,4" 54 // - If ',' is the separator, "1, 2 3 , 4 " == "1,23,4" 55 // - Fill "vs" at the end: NO RESET IS DONE 56 // - If ',' is the separator, ",,," is c 57 // That routine is much more rapid than FillVStringFrString altouch less general 58 // (ex no '\' gestion is done) 59 { 60 uint_4 ls = s.size(); 61 if(ls<=0) return; 62 bool sep_non_blanc = (separator==' ')? false: true; 63 char *str = new char[ls+2]; 64 65 uint_4 i=0, lstr=0; 66 while(i<ls) { 67 // le caractere n'est ni un blanc ni un separateur 68 if(s[i]!=separator && s[i]!=' ') { 69 str[lstr] = s[i]; lstr++; 70 } 71 // Condition de remplissage du vecteur 72 if(s[i]==separator || i==ls-1) { 73 if(lstr>0) {str[lstr]='\0'; vs.push_back(str); lstr=0;} 74 } 75 i++; 76 } 77 78 delete [] str; 79 return; 80 }
Note:
See TracChangeset
for help on using the changeset viewer.