+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
-* Copyright (C) 2005-2006, International Business Machines
+* Copyright (C) 2005-2014, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: package.h
-* encoding: US-ASCII
+* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
// .dat package file representation ---------------------------------------- ***
#define STRING_STORE_SIZE 100000
-#define MAX_FILE_COUNT 2000
-#define MAX_PKG_NAME_LENGTH 32
+#define MAX_PKG_NAME_LENGTH 64
+
+typedef void CheckDependency(void *context, const char *itemName, const char *targetName);
U_NAMESPACE_BEGIN
/* Destructor. */
~Package();
+ /**
+ * Uses the prefix of the first entry of the package in readPackage(),
+ * rather than the package basename.
+ */
+ void setAutoPrefix() { doAutoPrefix=TRUE; }
+ /**
+ * Same as setAutoPrefix(), plus the prefix must end with the platform type letter.
+ */
+ void setAutoPrefixWithType() {
+ doAutoPrefix=TRUE;
+ prefixEndsWithType=TRUE;
+ }
+ void setPrefix(const char *p);
+
/*
* Read an existing .dat package file.
* The header and item name strings are swapped into this object,
char getInType();
// find the item in items[], return the non-negative index if found, else the binary-not of the insertion point
- int32_t findItem(const char *name, int32_t length=-1);
+ int32_t findItem(const char *name, int32_t length=-1) const;
/*
* Set internal state for following calls to findNextItem() which will return
void addFile(const char *filesPath, const char *name);
void addItems(const Package &listPkg);
- void removeItem(int32_t index);
+ void removeItem(int32_t itemIndex);
void removeItems(const char *pattern);
void removeItems(const Package &listPkg);
/* The extractItem() functions accept outputType=0 to mean "don't swap the item". */
- void extractItem(const char *filesPath, int32_t index, char outType);
+ void extractItem(const char *filesPath, int32_t itemIndex, char outType);
void extractItems(const char *filesPath, const char *pattern, char outType);
void extractItems(const char *filesPath, const Package &listPkg, char outType);
/* This variant extracts an item to a specific filename. */
- void extractItem(const char *filesPath, const char *outName, int32_t index, char outType);
+ void extractItem(const char *filesPath, const char *outName, int32_t itemIndex, char outType);
- void listItems(FILE *file);
+ int32_t getItemCount() const;
+ const Item *getItem(int32_t idx) const;
/*
* Check dependencies and return TRUE if all dependencies are fulfilled.
*/
UBool checkDependencies();
+ /*
+ * Enumerate all the dependencies and give the results to context and call CheckDependency callback
+ * @param context user context (will be passed to check function)
+ * @param check will be called with context and any missing items
+ */
+ void enumDependencies(void *context, CheckDependency check);
+
private:
- void enumDependencies(Item *pItem);
+ void enumDependencies(Item *pItem, void *context, CheckDependency check);
+ /**
+ * Default CheckDependency function used by checkDependencies()
+ */
static void checkDependency(void *context, const char *itemName, const char *targetName);
/*
// data fields
char inPkgName[MAX_PKG_NAME_LENGTH];
+ char pkgPrefix[MAX_PKG_NAME_LENGTH];
uint8_t *inData;
uint8_t header[1024];
int32_t inLength, headerLength;
uint8_t inCharset;
UBool inIsBigEndian;
+ UBool doAutoPrefix;
+ UBool prefixEndsWithType;
int32_t itemCount;
- Item items[MAX_FILE_COUNT];
+ int32_t itemMax;
+ Item *items;
int32_t inStringTop, outStringTop;
char inStrings[STRING_STORE_SIZE], outStrings[STRING_STORE_SIZE];
// state for checkDependencies()
UBool isMissingItems;
+
+ /**
+ * Grow itemMax to new value
+ */
+ void setItemCapacity(int32_t max);
+
+ /**
+ * Grow itemMax to at least itemCount+1
+ */
+ void ensureItemCapacity();
};
U_NAMESPACE_END
#endif
+
+