Add a helper function

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31981 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2006-11-28 22:32:35 +00:00
parent 30579799ed
commit d5b58c239e
2 changed files with 22 additions and 0 deletions

View File

@ -18,6 +18,7 @@
#include <cctype> #include <cctype>
#include <cstdio> #include <cstdio>
#include <string> #include <string>
#include <vector>
namespace llvm { namespace llvm {
@ -129,6 +130,12 @@ static inline bool StringsEqualNoCase(const std::string &LHS,
std::string getToken(std::string &Source, std::string getToken(std::string &Source,
const char *Delimiters = " \t\n\v\f\r"); 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 /// UnescapeString - Modify the argument string, turning two character sequences
/// like '\\' 'n' into '\n'. This handles: \e \a \b \f \n \r \t \v \' \\ and /// 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). /// \num (where num is a 1-3 byte octal value).

View File

@ -42,6 +42,21 @@ std::string llvm::getToken(std::string &Source, const char *Delimiters) {
return Result; 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 /// UnescapeString - Modify the argument string, turning two character sequences
/// like '\\' 'n' into '\n'. This handles: \e \a \b \f \n \r \t \v \' \\ and /// like '\\' 'n' into '\n'. This handles: \e \a \b \f \n \r \t \v \' \\ and