From d0f116b619feede0cfdb647157ce5ab4d50a1c46 Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Fri, 8 Jul 2016 15:00:32 -0700 Subject: 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 --- tools/aapt2/ResourceTable.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'tools/aapt2/ResourceTable.cpp') diff --git a/tools/aapt2/ResourceTable.cpp b/tools/aapt2/ResourceTable.cpp index e700ed98365a..4d418d9c2e93 100644 --- a/tools/aapt2/ResourceTable.cpp +++ b/tools/aapt2/ResourceTable.cpp @@ -35,11 +35,11 @@ static bool lessThanType(const std::unique_ptr& lhs, Resource template static bool lessThanStructWithName(const std::unique_ptr& lhs, - const StringPiece16& rhs) { + const StringPiece& rhs) { return lhs->name.compare(0, lhs->name.size(), rhs.data(), rhs.size()) < 0; } -ResourceTablePackage* ResourceTable::findPackage(const StringPiece16& name) { +ResourceTablePackage* ResourceTable::findPackage(const StringPiece& name) { const auto last = packages.end(); auto iter = std::lower_bound(packages.begin(), last, name, lessThanStructWithName); @@ -58,7 +58,7 @@ ResourceTablePackage* ResourceTable::findPackageById(uint8_t id) { return nullptr; } -ResourceTablePackage* ResourceTable::createPackage(const StringPiece16& name, Maybe id) { +ResourceTablePackage* ResourceTable::createPackage(const StringPiece& name, Maybe id) { ResourceTablePackage* package = findOrCreatePackage(name); if (id && !package->id) { package->id = id; @@ -71,7 +71,7 @@ ResourceTablePackage* ResourceTable::createPackage(const StringPiece16& name, Ma return package; } -ResourceTablePackage* ResourceTable::findOrCreatePackage(const StringPiece16& name) { +ResourceTablePackage* ResourceTable::findOrCreatePackage(const StringPiece& name) { const auto last = packages.end(); auto iter = std::lower_bound(packages.begin(), last, name, lessThanStructWithName); @@ -102,7 +102,7 @@ ResourceTableType* ResourceTablePackage::findOrCreateType(ResourceType type) { return types.emplace(iter, new ResourceTableType(type))->get(); } -ResourceEntry* ResourceTableType::findEntry(const StringPiece16& name) { +ResourceEntry* ResourceTableType::findEntry(const StringPiece& name) { const auto last = entries.end(); auto iter = std::lower_bound(entries.begin(), last, name, lessThanStructWithName); @@ -112,7 +112,7 @@ ResourceEntry* ResourceTableType::findEntry(const StringPiece16& name) { return nullptr; } -ResourceEntry* ResourceTableType::findOrCreateEntry(const StringPiece16& name) { +ResourceEntry* ResourceTableType::findOrCreateEntry(const StringPiece& name) { auto last = entries.end(); auto iter = std::lower_bound(entries.begin(), last, name, lessThanStructWithName); @@ -261,8 +261,8 @@ int ResourceTable::resolveValueCollision(Value* existing, Value* incoming) { return 0; } -static constexpr const char16_t* kValidNameChars = u"._-"; -static constexpr const char16_t* kValidNameMangledChars = u"._-$"; +static constexpr const char* kValidNameChars = "._-"; +static constexpr const char* kValidNameMangledChars = "._-$"; bool ResourceTable::addResource(const ResourceNameRef& name, const ConfigDescription& config, @@ -286,7 +286,7 @@ bool ResourceTable::addResource(const ResourceNameRef& name, bool ResourceTable::addFileReference(const ResourceNameRef& name, const ConfigDescription& config, const Source& source, - const StringPiece16& path, + const StringPiece& path, IDiagnostics* diag) { return addFileReferenceImpl(name, config, source, path, nullptr, kValidNameChars, diag); } @@ -294,7 +294,7 @@ bool ResourceTable::addFileReference(const ResourceNameRef& name, bool ResourceTable::addFileReferenceAllowMangled(const ResourceNameRef& name, const ConfigDescription& config, const Source& source, - const StringPiece16& path, + const StringPiece& path, io::IFile* file, IDiagnostics* diag) { return addFileReferenceImpl(name, config, source, path, file, kValidNameMangledChars, diag); @@ -303,9 +303,9 @@ bool ResourceTable::addFileReferenceAllowMangled(const ResourceNameRef& name, bool ResourceTable::addFileReferenceImpl(const ResourceNameRef& name, const ConfigDescription& config, const Source& source, - const StringPiece16& path, + const StringPiece& path, io::IFile* file, - const char16_t* validChars, + const char* validChars, IDiagnostics* diag) { std::unique_ptr fileRef = util::make_unique( stringPool.makeRef(path)); @@ -339,7 +339,7 @@ bool ResourceTable::addResourceImpl(const ResourceNameRef& name, const ConfigDescription& config, const StringPiece& product, std::unique_ptr value, - const char16_t* validChars, + const char* validChars, std::function conflictResolver, IDiagnostics* diag) { assert(value && "value can't be nullptr"); @@ -353,7 +353,7 @@ bool ResourceTable::addResourceImpl(const ResourceNameRef& name, << "' has invalid entry name '" << name.entry << "'. Invalid character '" - << StringPiece16(badCharIter, 1) + << StringPiece(badCharIter, 1) << "'"); return false; } @@ -438,7 +438,7 @@ bool ResourceTable::setSymbolStateAllowMangled(const ResourceNameRef& name, } bool ResourceTable::setSymbolStateImpl(const ResourceNameRef& name, const ResourceId resId, - const Symbol& symbol, const char16_t* validChars, + const Symbol& symbol, const char* validChars, IDiagnostics* diag) { assert(diag && "diagnostics can't be nullptr"); @@ -450,7 +450,7 @@ bool ResourceTable::setSymbolStateImpl(const ResourceNameRef& name, const Resour << "' has invalid entry name '" << name.entry << "'. Invalid character '" - << StringPiece16(badCharIter, 1) + << StringPiece(badCharIter, 1) << "'"); return false; } -- cgit v1.2.3-59-g8ed1b