Make split method static
parent
06a2eee692
commit
617a3d426f
|
@ -236,28 +236,27 @@ GUITable* GUIFormSpecMenu::getTable(std::wstring tablename)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> split(const std::string &s, char delim) {
|
static std::vector<std::string> split(const std::string &s, char delim)
|
||||||
|
{
|
||||||
std::vector<std::string> tokens;
|
std::vector<std::string> tokens;
|
||||||
|
|
||||||
std::string current = "";
|
std::string current = "";
|
||||||
bool last_was_escape = false;
|
bool last_was_escape = false;
|
||||||
for(unsigned int i=0; i < s.size(); i++) {
|
for (unsigned int i = 0; i < s.size(); i++) {
|
||||||
|
char si = s.c_str()[i];
|
||||||
if (last_was_escape) {
|
if (last_was_escape) {
|
||||||
current += '\\';
|
current += '\\';
|
||||||
current += s.c_str()[i];
|
current += si;
|
||||||
last_was_escape = false;
|
last_was_escape = false;
|
||||||
}
|
} else {
|
||||||
else {
|
if (si == delim) {
|
||||||
if (s.c_str()[i] == delim) {
|
|
||||||
tokens.push_back(current);
|
tokens.push_back(current);
|
||||||
current = "";
|
current = "";
|
||||||
last_was_escape = false;
|
last_was_escape = false;
|
||||||
}
|
} else if (si == '\\') {
|
||||||
else if (s.c_str()[i] == '\\'){
|
|
||||||
last_was_escape = true;
|
last_was_escape = true;
|
||||||
}
|
} else {
|
||||||
else {
|
current += si;
|
||||||
current += s.c_str()[i];
|
|
||||||
last_was_escape = false;
|
last_was_escape = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue