diff options
author | MÃ¥rten Kongstad <marten.kongstad@sony.com> | 2018-06-20 08:46:41 +0200 |
---|---|---|
committer | Todd Kennedy <toddke@google.com> | 2018-10-08 06:50:22 -0700 |
commit | 24c9aa65411207067f509c5e88ad31b303d26fcd (patch) | |
tree | 9a7405282c003f0c360c95bd051681733d765919 /libs/androidfw/Util.cpp | |
parent | ec5c04f4ab781938123e5f68569048cf65fddc14 (diff) |
libandroidfw: move ConfigDescription from aapt2 to libandroidfw
This is to allow idmap2 to access ConfigDescription.
Test: libandroidfw_tests
Test: aapt2_tests
Change-Id: I54210bbbd8dad5903cb7100807df977efa394ad5
Diffstat (limited to 'libs/androidfw/Util.cpp')
-rw-r--r-- | libs/androidfw/Util.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libs/androidfw/Util.cpp b/libs/androidfw/Util.cpp index 575cd18a36dd..59c9d640bb91 100644 --- a/libs/androidfw/Util.cpp +++ b/libs/androidfw/Util.cpp @@ -16,6 +16,7 @@ #include "androidfw/Util.h" +#include <algorithm> #include <string> #include "utils/ByteOrder.h" @@ -67,5 +68,28 @@ std::string Utf16ToUtf8(const StringPiece16& utf16) { return utf8; } +static std::vector<std::string> SplitAndTransform( + const StringPiece& str, char sep, const std::function<char(char)>& f) { + std::vector<std::string> parts; + const StringPiece::const_iterator end = std::end(str); + StringPiece::const_iterator start = std::begin(str); + StringPiece::const_iterator current; + do { + current = std::find(start, end, sep); + parts.emplace_back(str.substr(start, current).to_string()); + if (f) { + std::string& part = parts.back(); + std::transform(part.begin(), part.end(), part.begin(), f); + } + start = current + 1; + } while (current != end); + return parts; +} + +std::vector<std::string> SplitAndLowercase(const StringPiece& str, char sep) { + return SplitAndTransform(str, sep, ::tolower); +} + + } // namespace util } // namespace android |