2 *******************************************************************************
4 * Copyright (C) 1999-2000, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
8 * file name: unewdata.h
10 * tab size: 8 (not used)
13 * created on: 1999oct25
14 * created by: Markus W. Scherer
17 #ifndef __UNEWDATA_H__
18 #define __UNEWDATA_H__
20 #include "unicode/utypes.h"
21 #include "unicode/udata.h"
23 /* API for writing data -----------------------------------------------------*/
25 /** @memo Forward declaration of the data memory creation type. */
26 typedef struct UNewDataMemory UNewDataMemory
;
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.
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>.
59 U_CAPI UNewDataMemory
* U_EXPORT2
60 udata_create(const char *dir
, const char *type
, const char *name
,
61 const UDataInfo
*pInfo
,
63 UErrorCode
*pErrorCode
);
65 /** @memo Close a newly written binary file. */
66 U_CAPI
uint32_t U_EXPORT2
67 udata_finish(UNewDataMemory
*pData
, UErrorCode
*pErrorCode
);
69 /** @memo Write an 8-bit byte to the file. */
71 udata_write8(UNewDataMemory
*pData
, uint8_t byte
);
73 /** @memo Write a 16-bit word to the file. */
75 udata_write16(UNewDataMemory
*pData
, uint16_t word
);
77 /** @memo Write a 32-bit word to the file. */
79 udata_write32(UNewDataMemory
*pData
, uint32_t wyde
);
81 /** @memo Write a block of bytes to the file. */
83 udata_writeBlock(UNewDataMemory
*pData
, const void *s
, int32_t length
);
85 /** @memo Write a block of arbitrary padding bytes to the file. */
87 udata_writePadding(UNewDataMemory
*pData
, int32_t length
);
89 /** @memo Write a <code>char*</code> string of platform "invariant characters" to the file. */
91 udata_writeString(UNewDataMemory
*pData
, const char *s
, int32_t length
);
93 /** @memo Write a <code>UChar*</code> string of Unicode character code units to the file. */
95 udata_writeUString(UNewDataMemory
*pData
, const UChar
*s
, int32_t length
);
99 * Hey, Emacs, please set the following:
102 * indent-tabs-mode: nil