Refactored #7 out into class files like I should have to begin with.
This commit is contained in:
22
2022/7/SplitStr.h
Normal file
22
2022/7/SplitStr.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef ADVENT_DVEREB_SPLITSTR_H
|
||||
#define ADVENT_DVEREB_SPLITSTR_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
std::vector<std::string> SplitStr(std::string str, const std::string &delim)
|
||||
{
|
||||
std::vector<std::string> rtn;
|
||||
|
||||
for(auto split = str.find(delim); split != std::string::npos; split = str.find(delim))
|
||||
{
|
||||
rtn.push_back(str.substr(0, split));
|
||||
str = str.substr(split + delim.size()); // chop off beginning
|
||||
}
|
||||
if(str.size())
|
||||
rtn.push_back(str);
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user