X-Git-Url: https://git.saurik.com/android/aapt.git/blobdiff_plain/3c80e5c0dc993f14ed11bca00e023ce8c073a7f4..71ea618365e88756ac7d573a7a2825ae0c265e03:/ResourceTable.h?ds=sidebyside diff --git a/ResourceTable.h b/ResourceTable.h index fff4f49..a3e0666 100644 --- a/ResourceTable.h +++ b/ResourceTable.h @@ -15,6 +15,7 @@ using namespace std; +class XMLNode; class ResourceTable; enum { @@ -23,6 +24,7 @@ enum { XML_COMPILE_COMPACT_WHITESPACE = 1<<2, XML_COMPILE_STRIP_WHITESPACE = 1<<3, XML_COMPILE_STRIP_RAW_VALUES = 1<<4, + XML_COMPILE_UTF8 = 1<<5, XML_COMPILE_STANDARD_RESOURCE = XML_COMPILE_STRIP_COMMENTS | XML_COMPILE_ASSIGN_ATTRIBUTE_IDS @@ -34,10 +36,23 @@ status_t compileXmlFile(const sp& assets, ResourceTable* table, int options = XML_COMPILE_STANDARD_RESOURCE); +status_t compileXmlFile(const sp& assets, + const sp& target, + const sp& outTarget, + ResourceTable* table, + int options = XML_COMPILE_STANDARD_RESOURCE); + +status_t compileXmlFile(const sp& assets, + const sp& xmlTree, + const sp& target, + ResourceTable* table, + int options = XML_COMPILE_STANDARD_RESOURCE); + status_t compileResourceFile(Bundle* bundle, const sp& assets, const sp& in, const ResTable_config& defParams, + const bool overwrite, ResourceTable* outTable); struct AccessorCookie @@ -61,6 +76,37 @@ public: class Type; class Entry; + struct ConfigDescription : public ResTable_config { + ConfigDescription() { + memset(this, 0, sizeof(*this)); + size = sizeof(ResTable_config); + } + ConfigDescription(const ResTable_config&o) { + *static_cast(this) = o; + size = sizeof(ResTable_config); + } + ConfigDescription(const ConfigDescription&o) { + *static_cast(this) = o; + } + + ConfigDescription& operator=(const ResTable_config& o) { + *static_cast(this) = o; + size = sizeof(ResTable_config); + return *this; + } + ConfigDescription& operator=(const ConfigDescription& o) { + *static_cast(this) = o; + return *this; + } + + inline bool operator<(const ConfigDescription& o) const { return compare(o) < 0; } + inline bool operator<=(const ConfigDescription& o) const { return compare(o) <= 0; } + inline bool operator==(const ConfigDescription& o) const { return compare(o) == 0; } + inline bool operator!=(const ConfigDescription& o) const { return compare(o) != 0; } + inline bool operator>=(const ConfigDescription& o) const { return compare(o) >= 0; } + inline bool operator>(const ConfigDescription& o) const { return compare(o) > 0; } + }; + ResourceTable(Bundle* bundle, const String16& assetsPackage); status_t addIncludedResources(Bundle* bundle, const sp& assets); @@ -79,7 +125,8 @@ public: const Vector* style = NULL, const ResTable_config* params = NULL, const bool doSetIndex = false, - const int32_t format = ResTable_map::TYPE_ANY); + const int32_t format = ResTable_map::TYPE_ANY, + const bool overwrite = false); status_t startBag(const SourcePos& pos, const String16& package, @@ -87,6 +134,7 @@ public: const String16& name, const String16& bagParent, const ResTable_config* params = NULL, + bool overlay = false, bool replace = false, bool isId = false); @@ -107,6 +155,11 @@ public: const String16& type, const String16& name) const; + bool hasBagOrEntry(const String16& package, + const String16& type, + const String16& name, + const ResTable_config& config) const; + bool hasBagOrEntry(const String16& ref, const String16* defType = NULL, const String16* defPackage = NULL); @@ -122,6 +175,9 @@ public: const String16& name, const String16& comment); + void canAddEntry(const SourcePos& pos, + const String16& package, const String16& type, const String16& name); + size_t size() const; size_t numLocalResources() const; bool hasResources() const; @@ -142,13 +198,13 @@ public: uint32_t getResId(const String16& package, const String16& type, const String16& name, - bool onlyPublic = false) const; + bool onlyPublic = true) const; uint32_t getResId(const String16& ref, const String16* defType = NULL, const String16* defPackage = NULL, const char** outErrorMsg = NULL, - bool onlyPublic = false) const; + bool onlyPublic = true) const; static bool isValidResourceName(const String16& s); @@ -158,7 +214,9 @@ public: uint32_t attrID, const Vector* style = NULL, String16* outStr = NULL, void* accessorCookie = NULL, - uint32_t attrType = ResTable_map::TYPE_ANY); + uint32_t attrType = ResTable_map::TYPE_ANY, + const String8* configTypeName = NULL, + const ConfigDescription* config = NULL); status_t assignResourceIds(); status_t addSymbols(const sp& outSymbols = NULL); @@ -252,11 +310,14 @@ public: String16 getParent() const { return mParent; } status_t makeItABag(const SourcePos& sourcePos); - + + status_t emptyBag(const SourcePos& sourcePos); + status_t setItem(const SourcePos& pos, const String16& value, const Vector* style = NULL, - int32_t format = ResTable_map::TYPE_ANY); + int32_t format = ResTable_map::TYPE_ANY, + const bool overwrite = false); status_t addToBag(const SourcePos& pos, const String16& key, const String16& value, @@ -277,7 +338,10 @@ public: status_t assignResourceIds(ResourceTable* table, const String16& package); - status_t prepareFlatten(StringPool* strings, ResourceTable* table); + status_t prepareFlatten(StringPool* strings, ResourceTable* table, + const String8* configTypeName, const ConfigDescription* config); + + status_t remapStringValue(StringPool* strings); ssize_t flatten(Bundle*, const sp& data, bool isPublic); @@ -294,37 +358,6 @@ public: uint32_t mParentId; SourcePos mPos; }; - - struct ConfigDescription : public ResTable_config { - ConfigDescription() { - memset(this, 0, sizeof(*this)); - size = sizeof(ResTable_config); - } - ConfigDescription(const ResTable_config&o) { - *static_cast(this) = o; - size = sizeof(ResTable_config); - } - ConfigDescription(const ConfigDescription&o) { - *static_cast(this) = o; - } - - ConfigDescription& operator=(const ResTable_config& o) { - *static_cast(this) = o; - size = sizeof(ResTable_config); - return *this; - } - ConfigDescription& operator=(const ConfigDescription& o) { - *static_cast(this) = o; - return *this; - } - - inline bool operator<(const ConfigDescription& o) const { return compare(o) < 0; } - inline bool operator<=(const ConfigDescription& o) const { return compare(o) <= 0; } - inline bool operator==(const ConfigDescription& o) const { return compare(o) == 0; } - inline bool operator!=(const ConfigDescription& o) const { return compare(o) != 0; } - inline bool operator>=(const ConfigDescription& o) const { return compare(o) >= 0; } - inline bool operator>(const ConfigDescription& o) const { return compare(o) > 0; } - }; class ConfigList : public RefBase { public: @@ -400,12 +433,16 @@ public: status_t addPublic(const SourcePos& pos, const String16& name, const uint32_t ident); - + + void canAddEntry(const String16& name); + String16 getName() const { return mName; } sp getEntry(const String16& entry, const SourcePos& pos, const ResTable_config* config = NULL, - bool doSetIndex = false); + bool doSetIndex = false, + bool overlay = false, + bool autoAddOverlay = false); const SourcePos& getFirstPublicSourcePos() const { return *mFirstPublicSourcePos; } @@ -421,6 +458,8 @@ public: const DefaultKeyedVector >& getConfigs() const { return mConfigs; } const Vector >& getOrderedConfigs() const { return mOrderedConfigs; } + const SortedVector& getCanAddEntries() const { return mCanAddEntries; } + const SourcePos& getPos() const { return mPos; } private: String16 mName; @@ -429,6 +468,7 @@ public: SortedVector mUniqueConfigs; DefaultKeyedVector > mConfigs; Vector > mOrderedConfigs; + SortedVector mCanAddEntries; int32_t mPublicIndex; int32_t mIndex; SourcePos mPos; @@ -489,6 +529,7 @@ private: const String16& type, const String16& name, const SourcePos& pos, + bool overlay, const ResTable_config* config = NULL, bool doSetIndex = false); sp getEntry(uint32_t resID, @@ -513,19 +554,4 @@ private: map > mLocalizations; }; -class ResourceFilter -{ -public: - ResourceFilter() : mData(), mContainsPseudo(false) {} - status_t parse(const char* arg); - bool match(int axis, uint32_t value); - bool match(const ResTable_config& config); - inline bool containsPseudo() { return mContainsPseudo; } - -private: - KeyedVector > mData; - bool mContainsPseudo; -}; - - #endif