• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 *
6 *   Copyright (C) 1999-2010, International Business Machines
7 *   Corporation and others.  All Rights Reserved.
8 *
9 *******************************************************************************
10 *   file name:  unewdata.h
11 *   encoding:   UTF-8
12 *   tab size:   8 (not used)
13 *   indentation:4
14 *
15 *   created on: 1999oct25
16 *   created by: Markus W. Scherer
17 */
18 
19 #ifndef __UNEWDATA_H__
20 #define __UNEWDATA_H__
21 
22 #include "unicode/utypes.h"
23 #include "unicode/udata.h"
24 
25 /* API for writing data -----------------------------------------------------*/
26 
27 /** @memo Forward declaration of the data memory creation type. */
28 typedef struct UNewDataMemory UNewDataMemory;
29 
30 /**
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.
42  *
43  * See udata.h .
44  *
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>.
60  */
61 U_CAPI UNewDataMemory * U_EXPORT2
62 udata_create(const char *dir, const char *type, const char *name,
63              const UDataInfo *pInfo,
64              const char *comment,
65              UErrorCode *pErrorCode);
66 
67 /** @memo Close a newly written binary file. */
68 U_CAPI uint32_t U_EXPORT2
69 udata_finish(UNewDataMemory *pData, UErrorCode *pErrorCode);
70 
71 /** @memo Write a dummy data file. */
72 U_CAPI void U_EXPORT2
73 udata_createDummy(const char *dir, const char *type, const char *name, UErrorCode *pErrorCode);
74 
75 /** @memo Write an 8-bit byte to the file. */
76 U_CAPI void U_EXPORT2
77 udata_write8(UNewDataMemory *pData, uint8_t byte);
78 
79 /** @memo Write a 16-bit word to the file. */
80 U_CAPI void U_EXPORT2
81 udata_write16(UNewDataMemory *pData, uint16_t word);
82 
83 /** @memo Write a 32-bit word to the file. */
84 U_CAPI void U_EXPORT2
85 udata_write32(UNewDataMemory *pData, uint32_t wyde);
86 
87 /** @memo Write a block of bytes to the file. */
88 U_CAPI void U_EXPORT2
89 udata_writeBlock(UNewDataMemory *pData, const void *s, int32_t length);
90 
91 /** @memo Write a block of arbitrary padding bytes to the file. */
92 U_CAPI void U_EXPORT2
93 udata_writePadding(UNewDataMemory *pData, int32_t length);
94 
95 /** @memo Write a <code>char*</code> string of platform "invariant characters" to the file. */
96 U_CAPI void U_EXPORT2
97 udata_writeString(UNewDataMemory *pData, const char *s, int32_t length);
98 
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);
102 
103 
104 /*
105  * Hey, Emacs, please set the following:
106  *
107  * Local Variables:
108  * indent-tabs-mode: nil
109  * End:
110  *
111  */
112 
113 #endif
114