diff options
Diffstat (limited to 'tools/aapt2/unflatten/BinaryResourceParser.cpp')
-rw-r--r-- | tools/aapt2/unflatten/BinaryResourceParser.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/tools/aapt2/unflatten/BinaryResourceParser.cpp b/tools/aapt2/unflatten/BinaryResourceParser.cpp index ec4675167676..4fd77c83a891 100644 --- a/tools/aapt2/unflatten/BinaryResourceParser.cpp +++ b/tools/aapt2/unflatten/BinaryResourceParser.cpp @@ -47,7 +47,7 @@ private: public: using ValueVisitor::visit; - ReferenceIdToNameVisitor(const std::map<ResourceId, ResourceName>* mapping) : + explicit ReferenceIdToNameVisitor(const std::map<ResourceId, ResourceName>* mapping) : mMapping(mapping) { assert(mMapping); } @@ -61,7 +61,6 @@ public: auto cacheIter = mMapping->find(id); if (cacheIter != mMapping->end()) { reference->name = cacheIter->second; - reference->id = {}; } } }; @@ -179,7 +178,8 @@ bool BinaryResourceParser::parsePackage(const ResChunk_header* chunk) { packageName[i] = util::deviceToHost16(packageHeader->name[i]); } - ResourceTablePackage* package = mTable->createPackage(packageName, (uint8_t) packageId); + ResourceTablePackage* package = mTable->createPackage(util::utf16ToUtf8(packageName), + static_cast<uint8_t>(packageId)); if (!package) { mContext->getDiagnostics()->error(DiagMessage(mSource) << "incompatible package '" << packageName @@ -309,12 +309,12 @@ bool BinaryResourceParser::parseType(const ResourceTablePackage* package, ConfigDescription config; config.copyFromDtoH(type->config); - StringPiece16 typeStr16 = util::getString(mTypePool, type->id - 1); + const std::string typeStr = util::getString(mTypePool, type->id - 1); - const ResourceType* parsedType = parseResourceType(typeStr16); + const ResourceType* parsedType = parseResourceType(typeStr); if (!parsedType) { mContext->getDiagnostics()->error(DiagMessage(mSource) - << "invalid type name '" << typeStr16 + << "invalid type name '" << typeStr << "' for type with ID " << (int) type->id); return false; } @@ -328,7 +328,7 @@ bool BinaryResourceParser::parseType(const ResourceTablePackage* package, const ResourceName name(package->name, *parsedType, util::getString(mKeyPool, - util::deviceToHost32(entry->key.index)).toString()); + util::deviceToHost32(entry->key.index))); const ResourceId resId(package->id.value(), type->id, static_cast<uint16_t>(it.index())); @@ -388,16 +388,16 @@ std::unique_ptr<Item> BinaryResourceParser::parseValue(const ResourceNameRef& na const uint32_t data = util::deviceToHost32(value->data); if (value->dataType == Res_value::TYPE_STRING) { - StringPiece16 str = util::getString(mValuePool, data); + const std::string str = util::getString(mValuePool, data); const ResStringPool_span* spans = mValuePool.styleAt(data); // Check if the string has a valid style associated with it. if (spans != nullptr && spans->name.index != ResStringPool_span::END) { - StyleString styleStr = { str.toString() }; + StyleString styleStr = { str }; while (spans->name.index != ResStringPool_span::END) { styleStr.spans.push_back(Span{ - util::getString(mValuePool, spans->name.index).toString(), + util::getString(mValuePool, spans->name.index), spans->firstChar, spans->lastChar }); @@ -407,7 +407,7 @@ std::unique_ptr<Item> BinaryResourceParser::parseValue(const ResourceNameRef& na styleStr, StringPool::Context{1, config})); } else { if (name.type != ResourceType::kString && - util::stringStartsWith<char16_t>(str, u"res/")) { + util::stringStartsWith(str, "res/")) { // This must be a FileReference. return util::make_unique<FileReference>(mTable->stringPool.makeRef( str, StringPool::Context{ 0, config })); |