|
1 /* |
|
2 ****************************************************************************** |
|
3 * |
|
4 * Copyright (C) 1998-2006, International Business Machines |
|
5 * Corporation and others. All Rights Reserved. |
|
6 * |
|
7 ****************************************************************************** |
|
8 * |
|
9 * File uprintf.h |
|
10 * |
|
11 * Modification History: |
|
12 * |
|
13 * Date Name Description |
|
14 * 11/19/98 stephen Creation. |
|
15 * 03/12/99 stephen Modified for new C API. |
|
16 ****************************************************************************** |
|
17 */ |
|
18 |
|
19 #ifndef UPRINTF_H |
|
20 #define UPRINTF_H |
|
21 |
|
22 #include "unicode/utypes.h" |
|
23 |
|
24 #if !UCONFIG_NO_FORMATTING |
|
25 |
|
26 #include "unicode/ustdio.h" |
|
27 #include "ufmt_cmn.h" |
|
28 #include "locbund.h" |
|
29 |
|
30 /** |
|
31 * Struct encapsulating a single uprintf format specification. |
|
32 */ |
|
33 typedef struct u_printf_spec_info { |
|
34 int32_t fPrecision; /* Precision */ |
|
35 int32_t fWidth; /* Width */ |
|
36 |
|
37 UChar fOrigSpec; /* Conversion specification */ |
|
38 UChar fSpec; /* Conversion specification */ |
|
39 UChar fPadChar; /* Padding character */ |
|
40 |
|
41 UBool fAlt; /* # flag */ |
|
42 UBool fSpace; /* Space flag */ |
|
43 UBool fLeft; /* - flag */ |
|
44 UBool fShowSign; /* + flag */ |
|
45 UBool fZero; /* 0 flag */ |
|
46 |
|
47 UBool fIsLongDouble; /* L flag */ |
|
48 UBool fIsShort; /* h flag */ |
|
49 UBool fIsLong; /* l flag */ |
|
50 UBool fIsLongLong; /* ll flag */ |
|
51 } u_printf_spec_info; |
|
52 |
|
53 typedef int32_t U_EXPORT2 |
|
54 u_printf_write_stream(void *context, |
|
55 const UChar *str, |
|
56 int32_t count); |
|
57 |
|
58 typedef int32_t U_EXPORT2 |
|
59 u_printf_pad_and_justify_stream(void *context, |
|
60 const u_printf_spec_info *info, |
|
61 const UChar *result, |
|
62 int32_t resultLen); |
|
63 |
|
64 typedef struct u_printf_stream_handler { |
|
65 u_printf_write_stream *write; |
|
66 u_printf_pad_and_justify_stream *pad_and_justify; |
|
67 } u_printf_stream_handler; |
|
68 |
|
69 /* Used by sprintf */ |
|
70 typedef struct u_localized_print_string { |
|
71 UChar *str; /* Place to write the string */ |
|
72 int32_t available;/* Number of codeunits available to write to */ |
|
73 int32_t len; /* Maximum number of code units that can be written to output */ |
|
74 |
|
75 ULocaleBundle fBundle; /* formatters */ |
|
76 } u_localized_print_string; |
|
77 |
|
78 #define UP_PERCENT 0x0025 |
|
79 |
|
80 /** |
|
81 * Parse a single u_printf format string. |
|
82 * @param fmt A pointer to a '%' character in a u_printf format specification. |
|
83 * @param spec A pointer to a <TT>u_printf_spec</TT> to receive the parsed |
|
84 * format specifier. |
|
85 * @param locStringContext If present, will make sure that it will only write |
|
86 * to the buffer when space is available. It's done this way because |
|
87 * va_list sometimes can't be passed by pointer. |
|
88 * @return The number of characters contained in this specifier. |
|
89 */ |
|
90 U_CFUNC int32_t |
|
91 u_printf_parse(const u_printf_stream_handler *streamHandler, |
|
92 const UChar *fmt, |
|
93 void *context, |
|
94 u_localized_print_string *locStringContext, |
|
95 ULocaleBundle *formatBundle, |
|
96 int32_t *written, |
|
97 va_list ap); |
|
98 |
|
99 #endif /* #if !UCONFIG_NO_FORMATTING */ |
|
100 |
|
101 #endif |