]> git.saurik.com Git - apple/icu.git/blob - icuSources/tools/toolutil/unewdata.h
ICU-57131.0.1.tar.gz
[apple/icu.git] / icuSources / tools / toolutil / unewdata.h
1 /*
2 *******************************************************************************
3 *
4 * Copyright (C) 1999-2010, International Business Machines
5 * Corporation and others. All Rights Reserved.
6 *
7 *******************************************************************************
8 * file name: unewdata.h
9 * encoding: US-ASCII
10 * tab size: 8 (not used)
11 * indentation:4
12 *
13 * created on: 1999oct25
14 * created by: Markus W. Scherer
15 */
16
17 #ifndef __UNEWDATA_H__
18 #define __UNEWDATA_H__
19
20 #include "unicode/utypes.h"
21 #include "unicode/udata.h"
22
23 /* API for writing data -----------------------------------------------------*/
24
25 /** @memo Forward declaration of the data memory creation type. */
26 typedef struct UNewDataMemory UNewDataMemory;
27
28 /**
29 * Create a new binary data file.
30 * The file-writing <code>udata_</code> functions facilitate writing
31 * binary data files that can be read by ICU's <code>udata</code> API.
32 * This function opens a new file with a filename determined from its
33 * parameters - of the form "name.type".
34 * It then writes a short header, followed by the <code>UDataInfo</code>
35 * structure and, optionally, by the comment string.
36 * It then writes padding bytes to round up to a multiple of 16 bytes.
37 * Subsequent write operations will thus start at an offset in the file
38 * that is a multiple of 16. <code>udata_getMemory()</code> will return
39 * a pointer to this same starting offset.
40 *
41 * See udata.h .
42 *
43 * @param dir A string that specifies the directory where the data will be
44 * written. If <code>NULL</code>, then
45 * <code>u_getDataDirectory</code> is used.
46 * @param type A string that specifies the type of data to be written.
47 * For example, resource bundles are written with type "res",
48 * conversion tables with type "cnv".
49 * This may be <code>NULL</code> or empty.
50 * @param name A string that specifies the name of the data.
51 * @param pInfo A pointer to a correctly filled <code>UDataInfo</code>
52 * structure that will be copied into the file.
53 * @param comment A string (e.g., a copyright statement) that will be
54 * copied into the file if it is not <code>NULL</code>
55 * or empty. This string serves only as a comment in the binary
56 * file. It will not be accessible by any API.
57 * @param pErrorCode An ICU UErrorCode parameter. It must not be <code>NULL</code>.
58 */
59 U_CAPI UNewDataMemory * U_EXPORT2
60 udata_create(const char *dir, const char *type, const char *name,
61 const UDataInfo *pInfo,
62 const char *comment,
63 UErrorCode *pErrorCode);
64
65 /** @memo Close a newly written binary file. */
66 U_CAPI uint32_t U_EXPORT2
67 udata_finish(UNewDataMemory *pData, UErrorCode *pErrorCode);
68
69 /** @memo Write a dummy data file. */
70 U_CAPI void U_EXPORT2
71 udata_createDummy(const char *dir, const char *type, const char *name, UErrorCode *pErrorCode);
72
73 /** @memo Write an 8-bit byte to the file. */
74 U_CAPI void U_EXPORT2
75 udata_write8(UNewDataMemory *pData, uint8_t byte);
76
77 /** @memo Write a 16-bit word to the file. */
78 U_CAPI void U_EXPORT2
79 udata_write16(UNewDataMemory *pData, uint16_t word);
80
81 /** @memo Write a 32-bit word to the file. */
82 U_CAPI void U_EXPORT2
83 udata_write32(UNewDataMemory *pData, uint32_t wyde);
84
85 /** @memo Write a block of bytes to the file. */
86 U_CAPI void U_EXPORT2
87 udata_writeBlock(UNewDataMemory *pData, const void *s, int32_t length);
88
89 /** @memo Write a block of arbitrary padding bytes to the file. */
90 U_CAPI void U_EXPORT2
91 udata_writePadding(UNewDataMemory *pData, int32_t length);
92
93 /** @memo Write a <code>char*</code> string of platform "invariant characters" to the file. */
94 U_CAPI void U_EXPORT2
95 udata_writeString(UNewDataMemory *pData, const char *s, int32_t length);
96
97 /** @memo Write a <code>UChar*</code> string of Unicode character code units to the file. */
98 U_CAPI void U_EXPORT2
99 udata_writeUString(UNewDataMemory *pData, const UChar *s, int32_t length);
100
101
102 /*
103 * Hey, Emacs, please set the following:
104 *
105 * Local Variables:
106 * indent-tabs-mode: nil
107 * End:
108 *
109 */
110
111 #endif