X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/2ca993e82fb37b597a3c73ecd1586a139a6579c5..HEAD:/icuSources/tools/genrb/reslist.h diff --git a/icuSources/tools/genrb/reslist.h b/icuSources/tools/genrb/reslist.h index 032c0c24..07874fdb 100644 --- a/icuSources/tools/genrb/reslist.h +++ b/icuSources/tools/genrb/reslist.h @@ -1,3 +1,5 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************* * @@ -21,6 +23,8 @@ #define KEY_SPACE_SIZE 65536 #define RESLIST_MAX_INT_VECTOR 2048 +#include + #include "unicode/utypes.h" #include "unicode/unistr.h" #include "unicode/ures.h" @@ -34,7 +38,9 @@ U_CDECL_BEGIN +class PathFilter; class PseudoListResource; +class ResKeyPath; struct ResFile { ResFile() @@ -210,6 +216,19 @@ struct SResource { void write(UNewDataMemory *mem, uint32_t *byteOffset); virtual void handleWrite(UNewDataMemory *mem, uint32_t *byteOffset); + /** + * Applies the given filter with the given base path to this resource. + * Removes child resources rejected by the filter recursively. + * + * @param bundle Needed in order to access the key for this and child resources. + */ + virtual void applyFilter(const PathFilter& filter, ResKeyPath& path, const SRBRoot* bundle); + + /** + * Calls the given function for every key ID present in this tree. + */ + virtual void collectKeys(std::function collector) const; + int8_t fType; /* nominal type: fRes (when != 0xffffffff) may use subtype */ UBool fWritten; /* res_write() can exit early */ uint32_t fRes; /* resource item word; RES_BOGUS=0xffffffff if not known yet */ @@ -229,7 +248,10 @@ public: fCount(0), fFirst(NULL) {} virtual ~ContainerResource(); - virtual void handlePreflightStrings(SRBRoot *bundle, UHashtable *stringSet, UErrorCode &errorCode); + void handlePreflightStrings(SRBRoot *bundle, UHashtable *stringSet, UErrorCode &errorCode) override; + + void collectKeys(std::function collector) const override; + protected: void writeAllRes16(SRBRoot *bundle); void preWriteAllRes(uint32_t *byteOffset); @@ -252,9 +274,11 @@ public: void add(SResource *res, int linenumber, UErrorCode &errorCode); - virtual void handleWrite16(SRBRoot *bundle); - virtual void handlePreWrite(uint32_t *byteOffset); - virtual void handleWrite(UNewDataMemory *mem, uint32_t *byteOffset); + void handleWrite16(SRBRoot *bundle) override; + void handlePreWrite(uint32_t *byteOffset) override; + void handleWrite(UNewDataMemory *mem, uint32_t *byteOffset) override; + + void applyFilter(const PathFilter& filter, ResKeyPath& path, const SRBRoot* bundle) override; int8_t fTableType; // determined by table_write16() for table_preWrite() & table_write() SRBRoot *fRoot; @@ -302,7 +326,7 @@ public: StringBaseResource(int8_t type, const UChar *value, int32_t len, UErrorCode &errorCode); virtual ~StringBaseResource(); - const UChar *getBuffer() const { return fString.getBuffer(); } + const UChar *getBuffer() const { return icu::toUCharPtr(fString.getBuffer()); } int32_t length() const { return fString.length(); } virtual void handlePreWrite(uint32_t *byteOffset);