This commit is contained in:
2022-11-20 13:52:18 -08:00
parent 234165c7f3
commit 6443b64932
8 changed files with 271 additions and 54 deletions

View File

@@ -1,2 +1,2 @@
add_library(aocpp src/Startup.cpp src/Coord.cpp)
add_library(aocpp src/Startup.cpp src/Coord.cpp src/Parsing.cpp)
target_include_directories(aocpp PUBLIC include)

View File

@@ -0,0 +1,13 @@
#ifndef AOCPP_PARSING_HPP_
#define AOCPP_PARSING_HPP_
#include <string>
#include <vector>
namespace aocpp {
auto SplitOn(std::string const& stuff, std::string const& sep) -> std::vector<std::string>;
}
#endif

22
lib/src/Parsing.cpp Normal file
View 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