mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05:00
[css2xpath] explode
This commit is contained in:
parent
12e33d8ec3
commit
b67d79a661
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user