[*] Split string may not ignore empty tokens anymore
This commit is contained in:
parent
7a838d4a51
commit
17e778eb5e
@ -347,7 +347,7 @@ static inline std::string ReplaceAll(std::string &str, const std::string &from,
|
||||
}
|
||||
|
||||
// i told myself not to copy this, required a split function twice, now here we are :D
|
||||
static inline AuList<AuString> SplitString(const AuString& str, const AuString& delim)
|
||||
static inline AuList<AuString> SplitString(const AuString& str, const AuString& delim, bool ignoreEmpty = true)
|
||||
{
|
||||
AuList<AuString> tokens;
|
||||
AuUInt prev = 0, pos = 0;
|
||||
@ -356,7 +356,7 @@ static inline AuList<AuString> SplitString(const AuString& str, const AuString&
|
||||
pos = str.find(delim, prev);
|
||||
if (pos == AuString::npos) pos = str.length();
|
||||
auto token = str.substr(prev, pos-prev);
|
||||
if (!token.empty()) tokens.push_back(token);
|
||||
if ((!token.empty()) && ignoreEmpty) tokens.push_back(token);
|
||||
prev = pos + delim.length();
|
||||
}
|
||||
while (pos < str.length() && prev < str.length());
|
||||
|
Loading…
Reference in New Issue
Block a user