865
872
///////////////////////////////////////////////////////////////////////////////
874
///////////////////////////////////////////////////////////////////////////////
867
///////////////////////////////////////////////////////////////////////////////
868
878
vector<string> sinsp_split(const string &s, char delim)
870
880
vector<string> res;
895
string& ltrim(string &s)
897
s.erase(s.begin(), find_if(s.begin(), s.end(), not1(ptr_fun<int, int>(isspace))));
904
string& rtrim(string &s)
906
s.erase(find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(), s.end());
911
// trim from both ends
913
string& trim(string &s)
915
return ltrim(rtrim(s));
918
void replace_in_place(string &s, const string &search, const string &replace)
920
for(size_t pos = 0; ; pos += replace.length())
922
// Locate the substring to replace
923
pos = s.find(search, pos);
924
if(pos == string::npos ) break;
925
// Replace by erasing and inserting
926
s.erase(pos, search.length());
927
s.insert(pos, replace );
931
void replace_in_place(string& str, string& substr_to_replace, string& new_substr)
934
uint32_t nsize = substr_to_replace.size();
938
index = str.find(substr_to_replace, index);
939
if (index == string::npos) break;
941
str.replace(index, nsize, new_substr);
882
947
///////////////////////////////////////////////////////////////////////////////
883
948
// sinsp_numparser implementation
884
949
///////////////////////////////////////////////////////////////////////////////