mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
Common: Modified split to be more pure function
This commit is contained in:
parent
801f39d2fa
commit
1e6412bcb1
3 changed files with 24 additions and 6 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue