Implemented app result and SelectionDialog (#96)
This commit is contained in:
committed by
GitHub
parent
4744565b0e
commit
6094b9c3f2
@@ -1,5 +1,7 @@
|
||||
#include "StringUtils.h"
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
namespace tt {
|
||||
|
||||
@@ -27,4 +29,47 @@ bool string_get_path_parent(const char* path, char* output) {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> string_split(const std::string&input, const std::string&delimiter) {
|
||||
size_t token_index = 0;
|
||||
size_t delimiter_index;
|
||||
const size_t delimiter_length = delimiter.length();
|
||||
std::string token;
|
||||
std::vector<std::string> result;
|
||||
|
||||
while ((delimiter_index = input.find(delimiter, token_index)) != std::string::npos) {
|
||||
token = input.substr(token_index, delimiter_index - token_index);
|
||||
token_index = delimiter_index + delimiter_length;
|
||||
result.push_back(token);
|
||||
}
|
||||
|
||||
auto end_token = input.substr(token_index);
|
||||
if (!end_token.empty()) {
|
||||
result.push_back(end_token);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string string_join(const std::vector<std::string>& input, const std::string& delimiter) {
|
||||
std::stringstream stream;
|
||||
size_t size = input.size();
|
||||
|
||||
if (size == 0) {
|
||||
return "";
|
||||
} else if (size == 1) {
|
||||
return input.front();
|
||||
} else {
|
||||
auto iterator = input.begin();
|
||||
while (iterator != input.end()) {
|
||||
stream << *iterator;
|
||||
iterator++;
|
||||
if (iterator != input.end()) {
|
||||
stream << delimiter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user