1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-26 01:15:37 +00:00

[css2xpath] explode

This commit is contained in:
Witold Filipczyk 2021-09-29 16:25:35 +02:00
parent 12e33d8ec3
commit b67d79a661

View File

@ -2,6 +2,7 @@
#include <vector>
#include <sstream>
#include <iterator>
#include <utility>
std::string
implode(const char *const delim, std::vector<std::string> x)
@ -21,11 +22,26 @@ implode(const char *const delim, std::vector<std::string> x)
}
}
std::vector<std::string>
explode(char delim, std::string const & s)
{
std::vector<std::string> result;
std::istringstream iss(s);
for (std::string token; std::getline(iss, token, delim); )
{
result.push_back(std::move(token));
}
return result;
}
#if 0
#include <iostream>
int
main(int argc, char **argv)
{
#if 0
std::vector<std::string> x;
for (int i = 2; i < argc; i++) {
@ -33,6 +49,14 @@ main(int argc, char **argv)
}
std::string res = implode(argv[1], x);
std::cout << res << "\n";
#endif
auto v = explode(' ', "hello world foo bar");
for (auto e : v)
{
std::cout << e << "\n";
}
return 0;
}
#endif