1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 ******************************************************************************
6 * Copyright (C) 1998-2006, International Business Machines
7 * Corporation and others. All Rights Reserved.
9 ******************************************************************************
13 * Modification History:
15 * Date Name Description
16 * 11/19/98 stephen Creation.
17 * 03/12/99 stephen Modified for new C API.
18 ******************************************************************************
24 #include "unicode/utypes.h"
26 #if !UCONFIG_NO_FORMATTING
28 #include "unicode/ustdio.h"
33 * Struct encapsulating a single uprintf format specification.
35 typedef struct u_printf_spec_info {
36 int32_t fPrecision; /* Precision */
37 int32_t fWidth; /* Width */
39 UChar fOrigSpec; /* Conversion specification */
40 UChar fSpec; /* Conversion specification */
41 UChar fPadChar; /* Padding character */
43 UBool fAlt; /* # flag */
44 UBool fSpace; /* Space flag */
45 UBool fLeft; /* - flag */
46 UBool fShowSign; /* + flag */
47 UBool fZero; /* 0 flag */
49 UBool fIsLongDouble; /* L flag */
50 UBool fIsShort; /* h flag */
51 UBool fIsLong; /* l flag */
52 UBool fIsLongLong; /* ll flag */
55 typedef int32_t U_EXPORT2
56 u_printf_write_stream(void *context,
60 typedef int32_t U_EXPORT2
61 u_printf_pad_and_justify_stream(void *context,
62 const u_printf_spec_info *info,
66 typedef struct u_printf_stream_handler {
67 u_printf_write_stream *write;
68 u_printf_pad_and_justify_stream *pad_and_justify;
69 } u_printf_stream_handler;
72 typedef struct u_localized_print_string {
73 UChar *str; /* Place to write the string */
74 int32_t available;/* Number of codeunits available to write to */
75 int32_t len; /* Maximum number of code units that can be written to output */
77 ULocaleBundle fBundle; /* formatters */
78 } u_localized_print_string;
80 #define UP_PERCENT 0x0025
83 * Parse a single u_printf format string.
84 * @param fmt A pointer to a '%' character in a u_printf format specification.
85 * @param spec A pointer to a <TT>u_printf_spec</TT> to receive the parsed
87 * @param locStringContext If present, will make sure that it will only write
88 * to the buffer when space is available. It's done this way because
89 * va_list sometimes can't be passed by pointer.
90 * @return The number of characters contained in this specifier.
93 u_printf_parse(const u_printf_stream_handler *streamHandler,
96 u_localized_print_string *locStringContext,
97 ULocaleBundle *formatBundle,
101 #endif /* #if !UCONFIG_NO_FORMATTING */