backend/src/util/string.cpp
// To be symmetric, we assume an empty string (after trimming spaces)
// will give an empty vector.
// However, a non-empty string (with no delimiter) will give one item
// After that, you get an item per delimiter, plus 1.
// eg.  ""      => empty
//      "a"     => 1 item
//      "a,b"   => 2 items
//      "a,b,"  => 3 items (last one empty)
To be symmetric, we assume an empty string (after trimming spaces)
will give an empty vector.
However, a non-empty string (with no delimiter) will give one item
After that, you get an item per delimiter, plus 1.
eg.
To be symmetric we assume an empty string ( after trimming spaces ) will give an empty vector . However a non - empty string ( with no delimiter ) will give one item After that you get an item per delimiter plus 1 . eg .
void splitString( const std::string s, std::vector<std::string> & v, const std::string delim, const bool trim_spaces)
	{
		std::string s1 (trim_spaces ? trim (s) : s);
		v.clear (); 
		if (s1.empty ())
			return;
		while (!s1.empty () && s1.find (delim) != std::string::npos)
			v.push_back (getWord (s1, delim, trim_spaces));
		v.push_back (s1);
	}
void splitString ( const std :: string s , std :: vector < std :: string > & v , const std :: string delim , const bool trim_spaces ) { std :: string s1 ( trim_spaces ? trim ( s ) : s ) ; v . clear ( ) ; if ( s1 . empty ( ) ) return ; while ( ! s1 . empty ( ) && s1 . find ( delim ) != std :: string :: npos ) v . push_back ( getWord ( s1 , delim , trim_spaces ) ) ; v . push_back ( s1 ) ; }
To be symmetric, we assume an empty string (after trimming spaces)
will give an empty vector.
To be symmetric we assume an empty string ( after trimming spaces ) will give an empty vector .
// start with initial string, trimmed of leading/trailing spaces if required // ensure vector empty // no string? no elements // add to vector while we have a delimiter // add final element