mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-24 19:16:49 +08:00
Move string split to misc
This commit is contained in:
14
src/misc.h
14
src/misc.h
@@ -30,6 +30,7 @@
|
||||
#include <utility>
|
||||
#include <cmath>
|
||||
#include <cctype>
|
||||
#include <sstream>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
@@ -273,6 +274,19 @@ namespace Algo {
|
||||
for (uint64_t i = 0; i < size; ++i)
|
||||
std::swap(buf[i], buf[prng.rand(size - i) + i]);
|
||||
}
|
||||
|
||||
// split the string
|
||||
inline std::vector<std::string> split(const std::string& input, char delimiter) {
|
||||
std::istringstream stream(input);
|
||||
std::string field;
|
||||
std::vector<std::string> fields;
|
||||
|
||||
while (std::getline(stream, field, delimiter)) {
|
||||
fields.push_back(field);
|
||||
}
|
||||
|
||||
return fields;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------
|
||||
|
||||
Reference in New Issue
Block a user