mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 20:23:59 +00:00
Add a new split method to StringRef that puts the substrings in a vector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@87058 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -56,3 +56,22 @@ void llvm::SplitString(const std::string &Source,
|
||||
S2 = getToken(S, Delimiters);
|
||||
}
|
||||
}
|
||||
|
||||
void llvm::StringRef::split(std::vector<StringRef> &A,
|
||||
StringRef Separators, unsigned MaxSplit,
|
||||
bool KeepEmpty) const {
|
||||
StringRef rest = *this;
|
||||
|
||||
for (unsigned splits = 0;
|
||||
rest.size() != 0 && (MaxSplit < 0 || splits < MaxSplit);
|
||||
++splits) {
|
||||
std::pair<llvm::StringRef, llvm::StringRef> p = rest.split(Separators);
|
||||
|
||||
if (p.first.size() != 0 || KeepEmpty)
|
||||
A.push_back(p.first);
|
||||
rest = p.second;
|
||||
}
|
||||
|
||||
if (rest.size() != 0 || KeepEmpty)
|
||||
A.push_back(rest);
|
||||
}
|
||||
|
Reference in New Issue
Block a user