]>
git.saurik.com Git - apple/icu.git/blob - icuSources/tools/toolutil/package.h
2 *******************************************************************************
4 * Copyright (C) 2005-2006, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
10 * tab size: 8 (not used)
13 * created on: 2005aug25
14 * created by: Markus W. Scherer
16 * Read, modify, and write ICU .dat data package files.
22 #include "unicode/utypes.h"
26 // .dat package file representation ---------------------------------------- ***
28 #define STRING_STORE_SIZE 100000
29 #define MAX_FILE_COUNT 2000
30 #define MAX_PKG_NAME_LENGTH 32
42 class U_TOOLUTIL_API Package
{
46 * Prepare this object for a new, empty package.
54 * Read an existing .dat package file.
55 * The header and item name strings are swapped into this object,
56 * but the items are left unswapped.
58 void readPackage(const char *filename
);
60 * Write a .dat package file with the items in this object.
61 * Swap all pieces to the desired output platform properties.
62 * The package becomes unusable:
63 * The item names are swapped and sorted in the outCharset rather than the local one.
64 * Also, the items themselves are swapped in-place
66 void writePackage(const char *filename
, char outType
, const char *comment
);
69 * Return the input data type letter (l, b, or e).
73 // find the item in items[], return the non-negative index if found, else the binary-not of the insertion point
74 int32_t findItem(const char *name
, int32_t length
=-1);
77 * Set internal state for following calls to findNextItem() which will return
78 * indexes for items whose names match the pattern.
80 void findItems(const char *pattern
);
81 int32_t findNextItem();
83 * Set the match mode for findItems() & findNextItem().
84 * @param mode 0=default
85 * MATCH_NOSLASH * does not match a '/'
87 void setMatchMode(uint32_t mode
);
93 void addItem(const char *name
);
94 void addItem(const char *name
, uint8_t *data
, int32_t length
, UBool isDataOwned
, char type
);
95 void addFile(const char *filesPath
, const char *name
);
96 void addItems(const Package
&listPkg
);
98 void removeItem(int32_t index
);
99 void removeItems(const char *pattern
);
100 void removeItems(const Package
&listPkg
);
102 /* The extractItem() functions accept outputType=0 to mean "don't swap the item". */
103 void extractItem(const char *filesPath
, int32_t index
, char outType
);
104 void extractItems(const char *filesPath
, const char *pattern
, char outType
);
105 void extractItems(const char *filesPath
, const Package
&listPkg
, char outType
);
107 /* This variant extracts an item to a specific filename. */
108 void extractItem(const char *filesPath
, const char *outName
, int32_t index
, char outType
);
110 void listItems(FILE *file
);
113 * Check dependencies and return TRUE if all dependencies are fulfilled.
115 UBool
checkDependencies();
118 void enumDependencies(Item
*pItem
);
120 static void checkDependency(void *context
, const char *itemName
, const char *targetName
);
123 * Allocate a string in inStrings or outStrings.
124 * The length does not include the terminating NUL.
126 char *allocString(UBool in
, int32_t length
);
131 char inPkgName
[MAX_PKG_NAME_LENGTH
];
134 uint8_t header
[1024];
135 int32_t inLength
, headerLength
;
140 Item items
[MAX_FILE_COUNT
];
142 int32_t inStringTop
, outStringTop
;
143 char inStrings
[STRING_STORE_SIZE
], outStrings
[STRING_STORE_SIZE
];
145 // match mode for findItems(pattern) and findNextItem()
148 // state for findItems(pattern) and findNextItem()
149 const char *findPrefix
, *findSuffix
;
150 int32_t findPrefixLength
, findSuffixLength
;
151 int32_t findNextIndex
;
153 // state for checkDependencies()
154 UBool isMissingItems
;