X-Git-Url: https://git.saurik.com/android/aapt.git/blobdiff_plain/dadd9c1fc18bd05c84a357b56e945b5829b3bd95..f1f3915b08588cb11eaca5b9d0b5bae293646fdc:/ResourceTable.h diff --git a/ResourceTable.h b/ResourceTable.h index b36234d..bbb8140 100644 --- a/ResourceTable.h +++ b/ResourceTable.h @@ -10,6 +10,12 @@ #include "StringPool.h" #include "SourcePos.h" +#include +#include + +using namespace std; + +class XMLNode; class ResourceTable; enum { @@ -18,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 @@ -29,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 @@ -74,7 +94,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, @@ -82,6 +103,7 @@ public: const String16& name, const String16& bagParent, const ResTable_config* params = NULL, + bool overlay = false, bool replace = false, bool isId = false); @@ -117,6 +139,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; @@ -136,12 +161,14 @@ public: uint32_t getResId(const String16& package, const String16& type, - const String16& name) const; + const String16& name, + bool onlyPublic = false) const; uint32_t getResId(const String16& ref, const String16* defType = NULL, const String16* defPackage = NULL, - const char** outErrorMsg = NULL) const; + const char** outErrorMsg = NULL, + bool onlyPublic = false) const; static bool isValidResourceName(const String16& s); @@ -155,6 +182,8 @@ public: status_t assignResourceIds(); status_t addSymbols(const sp& outSymbols = NULL); + void addLocalization(const String16& name, const String8& locale); + status_t validateLocalizations(void); status_t flatten(Bundle*, const sp& dest); @@ -243,11 +272,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, @@ -391,12 +423,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; } @@ -412,6 +448,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; @@ -420,6 +458,7 @@ public: SortedVector mUniqueConfigs; DefaultKeyedVector > mConfigs; Vector > mOrderedConfigs; + SortedVector mCanAddEntries; int32_t mPublicIndex; int32_t mIndex; SourcePos mPos; @@ -480,6 +519,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, @@ -491,7 +531,6 @@ private: String16 mAssetsPackage; sp mAssets; - DefaultKeyedVector > mPublicNames; DefaultKeyedVector > mPackages; Vector > mOrderedPackages; uint32_t mNextPackageId; @@ -500,6 +539,9 @@ private: size_t mNumLocal; SourcePos mCurrentXmlPos; Bundle* mBundle; + + // key = string resource name, value = set of locales in which that name is defined + map > mLocalizations; }; class ResourceFilter @@ -507,9 +549,9 @@ 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; } + bool match(int axis, uint32_t value) const; + bool match(const ResTable_config& config) const; + inline bool containsPseudo() const { return mContainsPseudo; } private: KeyedVector > mData;