Common: Modified split to be more pure function

This commit is contained in:
Paul Beckingham 2015-12-20 16:35:45 -05:00
parent 801f39d2fa
commit 1e6412bcb1
3 changed files with 24 additions and 6 deletions

View file

@ -29,6 +29,24 @@
#include <iomanip>
#include <math.h>
////////////////////////////////////////////////////////////////////////////////
std::vector <std::string> split (const std::string& input, const char delimiter)
{
std::vector <std::string> results;
std::string::size_type start = 0;
std::string::size_type i;
while ((i = input.find (delimiter, start)) != std::string::npos)
{
results.push_back (input.substr (start, i - start));
start = i + 1;
}
if (input.length ())
results.push_back (input.substr (start));
return results;
}
////////////////////////////////////////////////////////////////////////////////
void split (
std::vector<std::string>& results,