diff options
Diffstat (limited to 'tools/aapt2/util/Util.cpp')
-rw-r--r-- | tools/aapt2/util/Util.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/aapt2/util/Util.cpp b/tools/aapt2/util/Util.cpp index f219b65378ff..6ef4ce504a63 100644 --- a/tools/aapt2/util/Util.cpp +++ b/tools/aapt2/util/Util.cpp @@ -76,6 +76,25 @@ StringPiece16 trimWhitespace(const StringPiece16& str) { return StringPiece16(start, end - start); } +StringPiece trimWhitespace(const StringPiece& str) { + if (str.size() == 0 || str.data() == nullptr) { + return str; + } + + const char* start = str.data(); + const char* end = str.data() + str.length(); + + while (start != end && isspace(*start)) { + start++; + } + + while (end != start && isspace(*(end - 1))) { + end--; + } + + return StringPiece(start, end - start); +} + StringPiece16::const_iterator findNonAlphaNumericAndNotInSet(const StringPiece16& str, const StringPiece16& allowedChars) { const auto endIter = str.end(); |