Str Join(double** str, int len1, int len2) { VStr tmp; for (int i = 0; i < len1; i++) { tmp.push_back(Join(str[i], len2)); } return Join(tmp, "\n"); }
Str Join(const VVVReal &data, StrC &del1, StrC &del2, StrC &del3) { VStr tmp; for (VVVReal::size_type i = 0; i < data.size(); i++) { tmp.push_back(Join(data.at(i), del1, del2)); } return Join(tmp, "\n"); }
Str Join(double* str, int len) { VStr tmp; for (int i = 0; i < len; i++) { tmp.push_back(ToStr(str[i])); } return Join(tmp, " "); }
Str Join(const VVReal &data, const Str &del1, const Str &del2) { VStr tmp; for (VVReal::size_type i = 0; i < data.size(); i++) { tmp.push_back(Join(data.at(i), del1)); } return Join(tmp, del2); }
Str Join(VVIntC &data, StrC &del1, StrC &del2) { VStr tmp; for (VVInt::size_type i = 0; i < data.size(); i++) { tmp.push_back(Join(data.at(i), del1)); } return Join(tmp, del2); }
Str Join(It beg, It end, StrC &del) { VStr tmp; for (It it = beg; it != end; ++it) { tmp.push_back(ToStr(*it, 7)); } return Join(tmp, del); }
Str Join(const VVStr &vec, const Str &del1, const Str &del2) { VStr tmp; for (VVStr::size_type i = 0; i < vec.size(); i++) { tmp.push_back(Join(vec.at(i), del1)); } return Join(tmp, del2); }
VStr StrSplit(string theString, char dlim){ istringstream iss(theString); VStr result; string tmp; while(!iss.eof() ){ getline(iss , tmp, dlim ); result.push_back(tmp); } return result; }
VStr * newVStrFromFile(fstream &infile){ VStr *allLine = new VStr; while(! infile.eof() ){ string tmp; getline(infile,tmp,'\n'); allLine->push_back(tmp); } // infile.close(); return allLine; }
VStr StrSplit(string theString){ istringstream iss(theString); VStr result; string tmp; while(!iss.eof() ){ //getline(iss , tmp); iss >> tmp; result.push_back(tmp); } return result; }
// split string by dlim == ' ' (two space) VStr StrSplitBy2Space(string str){ string ttmp= str; VStr res; string ts("\n\n"); for(int i = 0 ;i < ttmp.size()-1;i++ ){ if (ttmp.c_str()[i] == ' ' && ttmp.c_str()[i+1] == ' ') ttmp.replace(i,2,ts); } istringstream iss(ttmp); while(!iss.eof() ){ string tmp; getline(iss,tmp ); if(tmp.size() == 0) continue; res.push_back(tmp); } return res; }