dev: added some string helper functions, updated gitignore
This commit is contained in:
parent
31499ed6e1
commit
7fad5e53af
3 changed files with 40 additions and 0 deletions
16
strFuncs.cpp
Normal file
16
strFuncs.cpp
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include "inc/strFuncs.hpp"
|
||||
|
||||
template <typename Out>
|
||||
void split(const std::string &s, char delim, Out result) {
|
||||
std::istringstream iss(s);
|
||||
std::string item;
|
||||
while (std::getline(iss, item, delim)) {
|
||||
*result++ = item;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> split(const std::string &s, char delim) {
|
||||
std::vector<std::string> elems;
|
||||
split(s, delim, std::back_inserter(elems));
|
||||
return elems;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue