Add String split method
This commit is contained in:
@@ -140,6 +140,22 @@ namespace OpenVulkano
|
||||
else return {str.substr(0, pos), str.substr(pos + 1)};
|
||||
}
|
||||
|
||||
static std::vector<std::string> Split(const std::string_view& str, char separator)
|
||||
{
|
||||
std::vector<std::string> subs;
|
||||
size_t startPos = 0;
|
||||
size_t pos = std::string::npos;
|
||||
while ((pos = str.find(separator, startPos)) != std::string::npos)
|
||||
{
|
||||
if (startPos == pos) { startPos++; continue; }
|
||||
subs.emplace_back(str.substr(startPos, pos));
|
||||
startPos = pos;
|
||||
}
|
||||
if (startPos != str.length() - 1)
|
||||
subs.emplace_back(str.substr(startPos));
|
||||
return subs;
|
||||
}
|
||||
|
||||
static Array<char> ReadFile(const std::string& filePath, bool emptyOnMissing = false);
|
||||
|
||||
template<class T>
|
||||
|
||||
Reference in New Issue
Block a user