1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
6 * Copyright (C) 1999-2010, International Business Machines
7 * Corporation and others. All Rights Reserved.
9 *******************************************************************************
10 * file name: unewdata.h
12 * tab size: 8 (not used)
15 * created on: 1999oct25
16 * created by: Markus W. Scherer
19 #ifndef __UNEWDATA_H__
20 #define __UNEWDATA_H__
22 #include "unicode/utypes.h"
23 #include "unicode/udata.h"
25 /* API for writing data -----------------------------------------------------*/
27 /** @memo Forward declaration of the data memory creation type. */
28 typedef struct UNewDataMemory UNewDataMemory
;
31 * Create a new binary data file.
32 * The file-writing <code>udata_</code> functions facilitate writing
33 * binary data files that can be read by ICU's <code>udata</code> API.
34 * This function opens a new file with a filename determined from its
35 * parameters - of the form "name.type".
36 * It then writes a short header, followed by the <code>UDataInfo</code>
37 * structure and, optionally, by the comment string.
38 * It then writes padding bytes to round up to a multiple of 16 bytes.
39 * Subsequent write operations will thus start at an offset in the file
40 * that is a multiple of 16. <code>udata_getMemory()</code> will return
41 * a pointer to this same starting offset.
45 * @param dir A string that specifies the directory where the data will be
46 * written. If <code>NULL</code>, then
47 * <code>u_getDataDirectory</code> is used.
48 * @param type A string that specifies the type of data to be written.
49 * For example, resource bundles are written with type "res",
50 * conversion tables with type "cnv".
51 * This may be <code>NULL</code> or empty.
52 * @param name A string that specifies the name of the data.
53 * @param pInfo A pointer to a correctly filled <code>UDataInfo</code>
54 * structure that will be copied into the file.
55 * @param comment A string (e.g., a copyright statement) that will be
56 * copied into the file if it is not <code>NULL</code>
57 * or empty. This string serves only as a comment in the binary
58 * file. It will not be accessible by any API.
59 * @param pErrorCode An ICU UErrorCode parameter. It must not be <code>NULL</code>.
61 U_CAPI UNewDataMemory
* U_EXPORT2
62 udata_create(const char *dir
, const char *type
, const char *name
,
63 const UDataInfo
*pInfo
,
65 UErrorCode
*pErrorCode
);
67 /** @memo Close a newly written binary file. */
68 U_CAPI
uint32_t U_EXPORT2
69 udata_finish(UNewDataMemory
*pData
, UErrorCode
*pErrorCode
);
71 /** @memo Write a dummy data file. */
73 udata_createDummy(const char *dir
, const char *type
, const char *name
, UErrorCode
*pErrorCode
);
75 /** @memo Write an 8-bit byte to the file. */
77 udata_write8(UNewDataMemory
*pData
, uint8_t byte
);
79 /** @memo Write a 16-bit word to the file. */
81 udata_write16(UNewDataMemory
*pData
, uint16_t word
);
83 /** @memo Write a 32-bit word to the file. */
85 udata_write32(UNewDataMemory
*pData
, uint32_t wyde
);
87 /** @memo Write a block of bytes to the file. */
89 udata_writeBlock(UNewDataMemory
*pData
, const void *s
, int32_t length
);
91 /** @memo Write a block of arbitrary padding bytes to the file. */
93 udata_writePadding(UNewDataMemory
*pData
, int32_t length
);
95 /** @memo Write a <code>char*</code> string of platform "invariant characters" to the file. */
97 udata_writeString(UNewDataMemory
*pData
, const char *s
, int32_t length
);
99 /** @memo Write a <code>UChar*</code> string of Unicode character code units to the file. */
100 U_CAPI
void U_EXPORT2
101 udata_writeUString(UNewDataMemory
*pData
, const UChar
*s
, int32_t length
);
105 * Hey, Emacs, please set the following:
108 * indent-tabs-mode: nil