+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
#define KEY_SPACE_SIZE 65536
#define RESLIST_MAX_INT_VECTOR 2048
+#include <functional>
+
#include "unicode/utypes.h"
#include "unicode/unistr.h"
#include "unicode/ures.h"
U_CDECL_BEGIN
+class PathFilter;
class PseudoListResource;
+class ResKeyPath;
struct ResFile {
ResFile()
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<void(int32_t)> 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 */
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<void(int32_t)> collector) const override;
+
protected:
void writeAllRes16(SRBRoot *bundle);
void preWriteAllRes(uint32_t *byteOffset);
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;
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);