AAPT2: Remove usage of u16string
For legacy reasons, we kept around the use of UTF-16 internally
in AAPT2. We don't need this and this CL removes all instances of
std::u16string and StringPiece16. The only places still needed
are when interacting with the ResTable APIs that only operate in
UTF16.
Change-Id: I492475b84bb9014fa13bf992cff447ee7a5fe588
diff --git a/tools/aapt2/NameMangler.h b/tools/aapt2/NameMangler.h
index 054b9ee..505a982e 100644
--- a/tools/aapt2/NameMangler.h
+++ b/tools/aapt2/NameMangler.h
@@ -18,7 +18,6 @@
#define AAPT_NAME_MANGLER_H
#include "Resource.h"
-
#include "util/Maybe.h"
#include <set>
@@ -31,12 +30,12 @@
* Represents the package we are trying to build. References pointing
* to this package are not mangled, and mangled references inherit this package name.
*/
- std::u16string targetPackageName;
+ std::string targetPackageName;
/**
* We must know which references to mangle, and which to keep (android vs. com.android.support).
*/
- std::set<std::u16string> packagesToMangle;
+ std::set<std::string> packagesToMangle;
};
class NameMangler {
@@ -53,14 +52,11 @@
return {};
}
- return ResourceName{
- mPolicy.targetPackageName,
- name.type,
- mangleEntry(name.package, name.entry)
- };
+ std::string mangledEntryName = mangleEntry(name.package, name.entry);
+ return ResourceName(mPolicy.targetPackageName, name.type, mangledEntryName);
}
- bool shouldMangle(const std::u16string& package) const {
+ bool shouldMangle(const std::string& package) const {
if (package.empty() || mPolicy.targetPackageName == package) {
return false;
}
@@ -72,8 +68,8 @@
* The mangled name should contain symbols that are illegal to define in XML,
* so that there will never be name mangling collisions.
*/
- static std::u16string mangleEntry(const std::u16string& package, const std::u16string& name) {
- return package + u"$" + name;
+ static std::string mangleEntry(const std::string& package, const std::string& name) {
+ return package + "$" + name;
}
/**
@@ -81,8 +77,8 @@
* and the package in `outPackage`. Returns true if the name was unmangled or
* false if the name was never mangled to begin with.
*/
- static bool unmangle(std::u16string* outName, std::u16string* outPackage) {
- size_t pivot = outName->find(u'$');
+ static bool unmangle(std::string* outName, std::string* outPackage) {
+ size_t pivot = outName->find('$');
if (pivot == std::string::npos) {
return false;
}