]> git.saurik.com Git - apple/icu.git/blob - icuSources/extra/ustdio/sprintf.h
ICU-3.13.tar.gz
[apple/icu.git] / icuSources / extra / ustdio / sprintf.h
1 /*
2 ******************************************************************************
3 *
4 * Copyright (C) 2000-2001, International Business Machines
5 * Corporation and others. All Rights Reserved.
6 *
7 ******************************************************************************
8 *
9 * File sprintf.h
10 *
11 * Modification History:
12 *
13 * Date Name Description
14 * 02/08/00 george Creation. Copied from uprintf.h
15 ******************************************************************************
16 */
17
18 #ifndef USPRINTF_H
19 #define USPRINTF_H
20
21 #include "unicode/utypes.h"
22
23 #if !UCONFIG_NO_FORMATTING
24
25 #include "unicode/ustdio.h"
26 #include "ufmt_cmn.h"
27 #include "locbund.h"
28
29 /**
30 * Struct encapsulating a single uprintf format specification.
31 */
32 struct u_sprintf_spec_info {
33 UChar fSpec; /* Conversion specification */
34
35 int32_t fPrecision; /* Precision */
36 int32_t fWidth; /* Width */
37
38 UChar fPadChar; /* Padding character */
39
40 UBool fAlt; /* # flag */
41 UBool fSpace; /* Space flag */
42 UBool fLeft; /* - flag */
43 UBool fShowSign; /* + flag */
44 UBool fZero; /* 0 flag */
45
46 UBool fIsLongDouble; /* L flag */
47 UBool fIsShort; /* h flag */
48 UBool fIsLong; /* l flag */
49 UBool fIsLongLong; /* ll flag */
50 };
51 typedef struct u_sprintf_spec_info u_sprintf_spec_info;
52
53 struct u_localized_string {
54 UChar *str; /* Place to write the string */
55 int32_t available;/* Number of codeunits available to write to */
56 int32_t len; /* Maximum number of code units that can be written to output */
57
58 ULocaleBundle *fBundle; /* formatters */
59 UBool fOwnBundle; /* TRUE if fBundle should be deleted */
60 };
61 typedef struct u_localized_string u_localized_string;
62
63 /**
64 * A u_printf handler function.
65 * A u_printf handler is responsible for handling a single u_printf
66 * format specification, for example 'd' or 's'.
67 * @param info A pointer to a <TT>u_printf_spec_info</TT> struct containing
68 * information on the format specification.
69 * @param args A pointer to the argument data
70 * @return The number of Unicode characters written to <TT>stream</TT>.
71 */
72 typedef int32_t (*u_sprintf_handler) (u_localized_string *output,
73 const u_sprintf_spec_info *info,
74 const ufmt_args *args);
75
76 #endif /* #if !UCONFIG_NO_FORMATTING */
77
78 #endif