mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
multiline labels
This commit is contained in:
parent
fcc5d11814
commit
d189bdc107
7 changed files with 239 additions and 95 deletions
|
|
@ -292,6 +292,10 @@ double util::parse_double(const std::string& str, size_t offset, size_t len) {
|
|||
return parse_double(str.substr(offset, len));
|
||||
}
|
||||
|
||||
/// @brief Split string by delimiter
|
||||
/// @param str source string
|
||||
/// @param delimiter split delimiter size
|
||||
/// @return vector of string parts, containing at least one string
|
||||
std::vector<std::string> util::split(const std::string& str, char delimiter) {
|
||||
std::vector<std::string> result;
|
||||
std::stringstream ss(str);
|
||||
|
|
@ -299,9 +303,16 @@ std::vector<std::string> util::split(const std::string& str, char delimiter) {
|
|||
while (std::getline(ss, tmp, delimiter)) {
|
||||
result.push_back(tmp);
|
||||
}
|
||||
if (result.empty()) {
|
||||
result.push_back("");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// @brief Split wstring by delimiter
|
||||
/// @param str source string
|
||||
/// @param delimiter split delimiter size
|
||||
/// @return vector of string parts, containing at least one string
|
||||
std::vector<std::wstring> util::split(const std::wstring& str, char delimiter) {
|
||||
std::vector<std::wstring> result;
|
||||
std::wstringstream ss(str);
|
||||
|
|
@ -309,5 +320,8 @@ std::vector<std::wstring> util::split(const std::wstring& str, char delimiter) {
|
|||
while (std::getline(ss, tmp, static_cast<wchar_t>(delimiter))) {
|
||||
result.push_back(tmp);
|
||||
}
|
||||
if (result.empty()) {
|
||||
result.push_back(L"");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue