]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
73c04bcf A |
3 | /* |
4 | ******************************************************************************* | |
5 | * | |
4388f060 | 6 | * Copyright (C) 2005-2012, International Business Machines |
73c04bcf A |
7 | * Corporation and others. All Rights Reserved. |
8 | * | |
9 | ******************************************************************************* | |
10 | * file name: writesrc.h | |
f3c0d7a5 | 11 | * encoding: UTF-8 |
73c04bcf A |
12 | * tab size: 8 (not used) |
13 | * indentation:4 | |
14 | * | |
15 | * created on: 2005apr23 | |
16 | * created by: Markus W. Scherer | |
17 | * | |
18 | * Helper functions for writing source code for data. | |
19 | */ | |
20 | ||
21 | #ifndef __WRITESRC_H__ | |
22 | #define __WRITESRC_H__ | |
23 | ||
24 | #include <stdio.h> | |
25 | #include "unicode/utypes.h" | |
3d1f044b | 26 | #include "unicode/ucptrie.h" |
729e4ab9 | 27 | #include "utrie2.h" |
73c04bcf A |
28 | |
29 | /** | |
4388f060 A |
30 | * Creates a source text file and writes a header comment with the ICU copyright. |
31 | * Writes a C/Java-style comment with the generator name. | |
73c04bcf A |
32 | */ |
33 | U_CAPI FILE * U_EXPORT2 | |
3d1f044b | 34 | usrc_create(const char *path, const char *filename, int32_t copyrightYear, const char *generator); |
73c04bcf | 35 | |
729e4ab9 | 36 | /** |
4388f060 | 37 | * Creates a source text file and writes a header comment with the ICU copyright. |
729e4ab9 A |
38 | * Writes the comment with # lines, as used in scripts and text data. |
39 | */ | |
40 | U_CAPI FILE * U_EXPORT2 | |
4388f060 | 41 | usrc_createTextData(const char *path, const char *filename, const char *generator); |
729e4ab9 | 42 | |
73c04bcf | 43 | /** |
4388f060 | 44 | * Writes the contents of an array of 8/16/32-bit words. |
73c04bcf A |
45 | * The prefix and postfix are optional (can be NULL) and are written first/last. |
46 | * The prefix may contain a %ld or similar field for the array length. | |
47 | * The {} and declaration etc. need to be included in prefix/postfix or | |
48 | * printed before and after the array contents. | |
49 | */ | |
50 | U_CAPI void U_EXPORT2 | |
51 | usrc_writeArray(FILE *f, | |
52 | const char *prefix, | |
53 | const void *p, int32_t width, int32_t length, | |
54 | const char *postfix); | |
55 | ||
56 | /** | |
729e4ab9 A |
57 | * Calls usrc_writeArray() for the index and data arrays of a frozen UTrie2. |
58 | * Only the index array is written for a 16-bit UTrie2. In this case, dataPrefix | |
73c04bcf A |
59 | * is ignored and can be NULL. |
60 | */ | |
61 | U_CAPI void U_EXPORT2 | |
729e4ab9 A |
62 | usrc_writeUTrie2Arrays(FILE *f, |
63 | const char *indexPrefix, const char *dataPrefix, | |
64 | const UTrie2 *pTrie, | |
65 | const char *postfix); | |
73c04bcf A |
66 | |
67 | /** | |
729e4ab9 | 68 | * Writes the UTrie2 struct values. |
73c04bcf A |
69 | * The {} and declaration etc. need to be included in prefix/postfix or |
70 | * printed before and after the array contents. | |
73c04bcf A |
71 | */ |
72 | U_CAPI void U_EXPORT2 | |
729e4ab9 A |
73 | usrc_writeUTrie2Struct(FILE *f, |
74 | const char *prefix, | |
75 | const UTrie2 *pTrie, | |
76 | const char *indexName, const char *dataName, | |
77 | const char *postfix); | |
73c04bcf | 78 | |
3d1f044b A |
79 | /** |
80 | * Calls usrc_writeArray() for the index and data arrays of a UCPTrie. | |
81 | */ | |
82 | U_CAPI void U_EXPORT2 | |
83 | usrc_writeUCPTrieArrays(FILE *f, | |
84 | const char *indexPrefix, const char *dataPrefix, | |
85 | const UCPTrie *pTrie, | |
86 | const char *postfix); | |
87 | ||
88 | /** | |
89 | * Writes the UCPTrie struct values. | |
90 | * The {} and declaration etc. need to be included in prefix/postfix or | |
91 | * printed before and after the array contents. | |
92 | */ | |
93 | U_CAPI void U_EXPORT2 | |
94 | usrc_writeUCPTrieStruct(FILE *f, | |
95 | const char *prefix, | |
96 | const UCPTrie *pTrie, | |
97 | const char *indexName, const char *dataName, | |
98 | const char *postfix); | |
99 | ||
100 | /** | |
101 | * Writes the UCPTrie arrays and struct values. | |
102 | */ | |
103 | U_CAPI void U_EXPORT2 | |
104 | usrc_writeUCPTrie(FILE *f, const char *name, const UCPTrie *pTrie); | |
105 | ||
4388f060 A |
106 | /** |
107 | * Writes the contents of an array of mostly invariant characters. | |
108 | * Characters 0..0x1f are printed as numbers, | |
109 | * others as characters with single quotes: '%c'. | |
110 | * | |
111 | * The prefix and postfix are optional (can be NULL) and are written first/last. | |
112 | * The prefix may contain a %ld or similar field for the array length. | |
113 | * The {} and declaration etc. need to be included in prefix/postfix or | |
114 | * printed before and after the array contents. | |
115 | */ | |
116 | U_CAPI void U_EXPORT2 | |
117 | usrc_writeArrayOfMostlyInvChars(FILE *f, | |
118 | const char *prefix, | |
119 | const char *p, int32_t length, | |
120 | const char *postfix); | |
121 | ||
73c04bcf | 122 | #endif |