35 const std::string& delimiter,
36 std::vector<std::string>& results )
39 std::string::size_type first_pos = input.find_first_not_of(delimiter, 0);
41 std::string::size_type pos = input.find_first_of(delimiter, first_pos);
43 while (std::string::npos != pos || std::string::npos != first_pos)
46 results.push_back(input.substr(first_pos, pos - first_pos));
49 first_pos = input.find_first_not_of(delimiter, pos);
52 pos = input.find_first_of(delimiter, first_pos);
58 std::string newline_str =
"\n";
62 std::vector<std::vector<std::string>::iterator> its_to_be_removed;
64 for( std::vector<std::string>::iterator it = strings.begin(); it != strings.end(); ++it )
65 if( (*it) == newline_str )
66 its_to_be_removed.push_back(it);
68 for( std::vector<std::vector<std::string>::iterator>::iterator it = its_to_be_removed.begin();
69 it != its_to_be_removed.end(); ++it )
73 for( std::vector<std::string>::iterator it = strings.begin(); it != strings.end(); ++it )
75 std::string& elem = *it;
78 elem.erase( std::remove(elem.begin(), elem.end(),
'\n'), elem.end() );
void remove_newline_from_strings(std::vector< std::string > &strings)
Strips newline characters from strings in the input vector, strings.
void split_string(const std::string &input, const std::string &delimiter, std::vector< std::string > &results)
All characters in delimiter will be treated as a delimiter.
The parameters are reduced parameters.