aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/ADT/StringExtras.h7
-rw-r--r--lib/Support/StringExtras.cpp15
2 files changed, 22 insertions, 0 deletions
diff --git a/include/llvm/ADT/StringExtras.h b/include/llvm/ADT/StringExtras.h
index 16132cd880..f0788a1b11 100644
--- a/include/llvm/ADT/StringExtras.h
+++ b/include/llvm/ADT/StringExtras.h
@@ -18,6 +18,7 @@
#include <cctype>
#include <cstdio>
#include <string>
+#include <vector>
namespace llvm {
@@ -129,6 +130,12 @@ static inline bool StringsEqualNoCase(const std::string &LHS,
std::string getToken(std::string &Source,
const char *Delimiters = " \t\n\v\f\r");
+/// SplitString - Split up the specified string according to the specified
+/// delimiters, appending the result fragments to the output list.
+void SplitString(const std::string &Source,
+ std::vector<std::string> &OutFragments,
+ const char *Delimiters = " \t\n\v\f\r");
+
/// UnescapeString - Modify the argument string, turning two character sequences
/// like '\\' 'n' into '\n'. This handles: \e \a \b \f \n \r \t \v \' \\ and
/// \num (where num is a 1-3 byte octal value).
diff --git a/lib/Support/StringExtras.cpp b/lib/Support/StringExtras.cpp
index 8ce371535b..2ce234970a 100644
--- a/lib/Support/StringExtras.cpp
+++ b/lib/Support/StringExtras.cpp
@@ -42,6 +42,21 @@ std::string llvm::getToken(std::string &Source, const char *Delimiters) {
return Result;
}
+/// SplitString - Split up the specified string according to the specified
+/// delimiters, appending the result fragments to the output list.
+void llvm::SplitString(const std::string &Source,
+ std::vector<std::string> &OutFragments,
+ const char *Delimiters) {
+ std::string S = Source;
+
+ std::string S2 = getToken(S, Delimiters);
+ while (!S2.empty()) {
+ OutFragments.push_back(S2);
+ S2 = getToken(S, Delimiters);
+ }
+}
+
+
/// UnescapeString - Modify the argument string, turning two character sequences
/// like '\\' 'n' into '\n'. This handles: \e \a \b \f \n \r \t \v \' \\ and