2020/16
This commit is contained in:
22
lib/src/Parsing.cpp
Normal file
22
lib/src/Parsing.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <aocpp/Parsing.hpp>
|
||||
|
||||
namespace aocpp {
|
||||
|
||||
auto SplitOn(std::string const& stuff, std::string const& sep) -> std::vector<std::string>
|
||||
{
|
||||
std::vector<std::string> results;
|
||||
std::size_t cursor = 0;
|
||||
for (;;) {
|
||||
auto i = stuff.find(sep, cursor);
|
||||
if (i != std::string::npos) {
|
||||
results.push_back(stuff.substr(cursor, i-cursor));
|
||||
cursor = i + sep.size();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
results.push_back(stuff.substr(cursor));
|
||||
return results;
|
||||
}
|
||||
|
||||
} // namespace
|
Reference in New Issue
Block a user