Imported Upstream version 58.1
[platform/upstream/icu.git] / source / tools / toolutil / writesrc.h
1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 *
6 *   Copyright (C) 2005-2012, International Business Machines
7 *   Corporation and others.  All Rights Reserved.
8 *
9 *******************************************************************************
10 *   file name:  writesrc.h
11 *   encoding:   US-ASCII
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"
26 #include "utrie2.h"
27
28 /**
29  * Creates a source text file and writes a header comment with the ICU copyright.
30  * Writes a C/Java-style comment with the generator name.
31  */
32 U_CAPI FILE * U_EXPORT2
33 usrc_create(const char *path, const char *filename, const char *generator);
34
35 /**
36  * Creates a source text file and writes a header comment with the ICU copyright.
37  * Writes the comment with # lines, as used in scripts and text data.
38  */
39 U_CAPI FILE * U_EXPORT2
40 usrc_createTextData(const char *path, const char *filename, const char *generator);
41
42 /**
43  * Writes the contents of an array of 8/16/32-bit words.
44  * The prefix and postfix are optional (can be NULL) and are written first/last.
45  * The prefix may contain a %ld or similar field for the array length.
46  * The {} and declaration etc. need to be included in prefix/postfix or
47  * printed before and after the array contents.
48  */
49 U_CAPI void U_EXPORT2
50 usrc_writeArray(FILE *f,
51                 const char *prefix,
52                 const void *p, int32_t width, int32_t length,
53                 const char *postfix);
54
55 /**
56  * Calls usrc_writeArray() for the index and data arrays of a frozen UTrie2.
57  * Only the index array is written for a 16-bit UTrie2. In this case, dataPrefix
58  * is ignored and can be NULL.
59  */
60 U_CAPI void U_EXPORT2
61 usrc_writeUTrie2Arrays(FILE *f,
62                        const char *indexPrefix, const char *dataPrefix,
63                        const UTrie2 *pTrie,
64                        const char *postfix);
65
66 /**
67  * Writes the UTrie2 struct values.
68  * The {} and declaration etc. need to be included in prefix/postfix or
69  * printed before and after the array contents.
70  */
71 U_CAPI void U_EXPORT2
72 usrc_writeUTrie2Struct(FILE *f,
73                        const char *prefix,
74                        const UTrie2 *pTrie,
75                        const char *indexName, const char *dataName,
76                        const char *postfix);
77
78 /**
79  * Writes the contents of an array of mostly invariant characters.
80  * Characters 0..0x1f are printed as numbers,
81  * others as characters with single quotes: '%c'.
82  *
83  * The prefix and postfix are optional (can be NULL) and are written first/last.
84  * The prefix may contain a %ld or similar field for the array length.
85  * The {} and declaration etc. need to be included in prefix/postfix or
86  * printed before and after the array contents.
87  */
88 U_CAPI void U_EXPORT2
89 usrc_writeArrayOfMostlyInvChars(FILE *f,
90                                 const char *prefix,
91                                 const char *p, int32_t length,
92                                 const char *postfix);
93
94 #endif