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/xml/XmlUtil.h b/tools/aapt2/xml/XmlUtil.h
index 98e5520..f0d59b7 100644
--- a/tools/aapt2/xml/XmlUtil.h
+++ b/tools/aapt2/xml/XmlUtil.h
@@ -25,10 +25,10 @@
namespace aapt {
namespace xml {
-constexpr const char16_t* kSchemaAuto = u"http://schemas.android.com/apk/res-auto";
-constexpr const char16_t* kSchemaPublicPrefix = u"http://schemas.android.com/apk/res/";
-constexpr const char16_t* kSchemaPrivatePrefix = u"http://schemas.android.com/apk/prv/res/";
-constexpr const char16_t* kSchemaAndroid = u"http://schemas.android.com/apk/res/android";
+constexpr const char* kSchemaAuto = "http://schemas.android.com/apk/res-auto";
+constexpr const char* kSchemaPublicPrefix = "http://schemas.android.com/apk/res/";
+constexpr const char* kSchemaPrivatePrefix = "http://schemas.android.com/apk/prv/res/";
+constexpr const char* kSchemaAndroid = "http://schemas.android.com/apk/res/android";
/**
* Result of extracting a package name from a namespace URI declaration.
@@ -38,7 +38,7 @@
* The name of the package. This can be the empty string, which means that the package
* should be assumed to be the package being compiled.
*/
- std::u16string package;
+ std::string package;
/**
* True if the package's private namespace was declared. This means that private resources
@@ -55,7 +55,14 @@
* Special case: if namespaceUri is http://schemas.android.com/apk/res-auto,
* returns an empty package name.
*/
-Maybe<ExtractedPackage> extractPackageFromNamespace(const std::u16string& namespaceUri);
+Maybe<ExtractedPackage> extractPackageFromNamespace(const std::string& namespaceUri);
+
+/**
+ * Returns an XML Android namespace for the given package of the form:
+ *
+ * http://schemas.android.com/apk/res/<package>
+ */
+std::string buildPackageNamespace(const StringPiece& package);
/**
* Interface representing a stack of XML namespace declarations. When looking up the package
@@ -68,7 +75,7 @@
* Returns an ExtractedPackage struct if the alias given corresponds with a package declaration.
*/
virtual Maybe<ExtractedPackage> transformPackageAlias(
- const StringPiece16& alias, const StringPiece16& localPackage) const = 0;
+ const StringPiece& alias, const StringPiece& localPackage) const = 0;
};
/**
@@ -77,7 +84,7 @@
* the package declaration was private.
*/
void transformReferenceFromNamespace(IPackageDeclStack* declStack,
- const StringPiece16& localPackage, Reference* inRef);
+ const StringPiece& localPackage, Reference* inRef);
} // namespace xml
} // namespace aapt