summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cc4bcba)
raw | patch | inline | side by side (parent: cc4bcba)
author | Daniel Dunbar <daniel@zuster.org> | |
Sun, 6 Nov 2011 18:04:43 +0000 (18:04 +0000) | ||
committer | Daniel Dunbar <daniel@zuster.org> | |
Sun, 6 Nov 2011 18:04:43 +0000 (18:04 +0000) |
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143880 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/ADT/StringRef.h | patch | blob | history | |
lib/Support/StringRef.cpp | patch | blob | history |
index 8396921744ad66105523ee1f911facce39807cd5..6c338068962865ed654e71b3b7fad7ea4b0704c1 100644 (file)
/// string is well-formed in the given radix.
bool getAsInteger(unsigned Radix, APInt &Result) const;
+ /// @}
+ /// @name String Operations
+ /// @{
+
+ // lower - Convert the given ASCII string to lowercase.
+ std::string lower() const;
+
+ /// upper - Convert the given ASCII string to uppercase.
+ std::string upper() const;
+
/// @}
/// @name Substring Operations
/// @{
index 576b95f6a4e3c339131b15ca9b65d5366ae00409..c78b6d0afc83b85de9d795b231ce1aa7020c47de 100644 (file)
return x;
}
+static char ascii_toupper(char x) {
+ if (x >= 'a' && x <= 'z')
+ return x - 'a' + 'A';
+ return x;
+}
+
static bool ascii_isdigit(char x) {
return x >= '0' && x <= '9';
}
return Result;
}
+//===----------------------------------------------------------------------===//
+// String Operations
+//===----------------------------------------------------------------------===//
+
+std::string StringRef::lower() const {
+ std::string Result(size(), char());
+ for (size_type i = 0, e = size(); i != e; ++i) {
+ Result[i] = ascii_tolower(Data[i]);
+ }
+ return Result;
+}
+
+std::string StringRef::upper() const {
+ std::string Result(size(), char());
+ for (size_type i = 0, e = size(); i != e; ++i) {
+ Result[i] = ascii_tolower(Data[i]);
+ }
+ return Result;
+}
+
//===----------------------------------------------------------------------===//
// String Searching
//===----------------------------------------------------------------------===//