]>
Commit | Line | Data |
---|---|---|
374ca955 A |
1 | /* |
2 | ****************************************************************************** | |
3 | * | |
4 | * Copyright (C) 1998-2004, 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 fSpec; /* Conversion specification */ | |
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 | } u_printf_spec_info; | |
51 | ||
52 | typedef int32_t U_EXPORT2 | |
53 | u_printf_write_stream(void *context, | |
54 | const UChar *str, | |
55 | int32_t count); | |
56 | ||
57 | typedef int32_t U_EXPORT2 | |
58 | u_printf_pad_and_justify_stream(void *context, | |
59 | const u_printf_spec_info *info, | |
60 | const UChar *result, | |
61 | int32_t resultLen); | |
62 | ||
63 | typedef struct u_printf_stream_handler { | |
64 | u_printf_write_stream *write; | |
65 | u_printf_pad_and_justify_stream *pad_and_justify; | |
66 | } u_printf_stream_handler; | |
67 | ||
68 | /* Used by sprintf */ | |
69 | typedef struct u_localized_print_string { | |
70 | UChar *str; /* Place to write the string */ | |
71 | int32_t available;/* Number of codeunits available to write to */ | |
72 | int32_t len; /* Maximum number of code units that can be written to output */ | |
73 | ||
74 | ULocaleBundle fBundle; /* formatters */ | |
75 | } u_localized_print_string; | |
76 | ||
77 | #define UP_PERCENT 0x0025 | |
78 | ||
79 | /** | |
80 | * Parse a single u_printf format string. | |
81 | * @param fmt A pointer to a '%' character in a u_printf format specification. | |
82 | * @param spec A pointer to a <TT>u_printf_spec</TT> to receive the parsed | |
83 | * format specifier. | |
84 | * @param locStringContext If present, will make sure that it will only write | |
85 | * to the buffer when space is available. It's done this way because | |
86 | * va_list sometimes can't be passed by pointer. | |
87 | * @return The number of characters contained in this specifier. | |
88 | */ | |
89 | U_CFUNC int32_t | |
90 | u_printf_parse(const u_printf_stream_handler *streamHandler, | |
91 | const UChar *fmt, | |
92 | void *context, | |
93 | u_localized_print_string *locStringContext, | |
94 | ULocaleBundle *formatBundle, | |
95 | int32_t *written, | |
96 | va_list ap); | |
97 | ||
98 | #endif /* #if !UCONFIG_NO_FORMATTING */ | |
99 | ||
100 | #endif |