#include "sopnamsp.h" #include "machdefs.h" #include #include #include #include #include "strutilxx.h" /* methode */ void FillVStringFrString(string const & s,vector& vs,char sep) // Use string "s" to fill vector of strings "vs" // considering char "sep" as a separator. // Vector is filled from its end (no reset done). // To write a "sep" char, use \'sep' // Warning: separator "sep" could not be set to '\' // Ex: sep=' ': s="aaa bbb cc d " -> vs=(aaa,bbb,cc,d) // Ex: sep=';': s="aaa ;bbb; cc;d " -> vs=(aaa ,bbb, cc,d ) // Ex: sep=';': s=";aaa\;bbb;;;ccc;ddd" -> vs=(aaa;bbb,ccc,ddd) // Ex: sep=';': s=";aaa\;bbb;;;ccc;ddd\" -> vs=(aaa;bbb,ccc,ddd\) { uint_4 ls = s.size(); if(ls<=0 || sep=='\\') return; const char* str = s.c_str(); ls = strlen(str); // str[ls-1]==sep cf ci-dessus string dum = ""; for(uint_4 i=0; i 0) vs.push_back(dum); } /* methode */ void SplitStringToVString(string const & s,vector& vs,char separator) // Split the string "s" into a string vector "vs" // - Separator is "separator" // - If the separator is not a space (' '), the space is considered // as a dummy character: // - If ',' is the separator, "1, 2 ,3 , 4 " == "1,2,3,4" // - If ',' is the separator, "1, 2 3 , 4 " == "1,23,4" // - Fill "vs" at the end: NO RESET IS DONE // - If ',' is the separator, ",,," is c // That routine is much more rapid than FillVStringFrString although less general // (ex no '\' gestion is done) { uint_4 ls = s.size(); if(ls<=0) return; //bool sep_non_blanc = (separator==' ')? false: true; char *str = new char[ls+2]; uint_4 i=0, lstr=0; while(i0) {str[lstr]='\0'; vs.push_back(str); lstr=0;} } i++; } delete [] str; return; }