2017-01-20 00:20:31 +00:00
|
|
|
// © 2016 and later: Unicode, Inc. and others.
|
2016-06-15 18:58:17 +00:00
|
|
|
// License & terms of use: http://www.unicode.org/copyright.html
|
1999-08-16 21:50:52 +00:00
|
|
|
/*
|
2001-03-21 22:07:51 +00:00
|
|
|
******************************************************************************
|
2000-01-13 23:54:23 +00:00
|
|
|
*
|
2016-05-31 21:45:07 +00:00
|
|
|
* Copyright (C) 1998-2006, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
2000-01-13 23:54:23 +00:00
|
|
|
*
|
2001-03-21 22:07:51 +00:00
|
|
|
******************************************************************************
|
1999-08-16 21:50:52 +00:00
|
|
|
*
|
|
|
|
* File uprintf.h
|
|
|
|
*
|
|
|
|
* Modification History:
|
|
|
|
*
|
|
|
|
* Date Name Description
|
|
|
|
* 11/19/98 stephen Creation.
|
|
|
|
* 03/12/99 stephen Modified for new C API.
|
2001-03-21 22:07:51 +00:00
|
|
|
******************************************************************************
|
1999-08-16 21:50:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef UPRINTF_H
|
|
|
|
#define UPRINTF_H
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
#include "unicode/utypes.h"
|
2002-10-01 01:26:49 +00:00
|
|
|
|
|
|
|
#if !UCONFIG_NO_FORMATTING
|
|
|
|
|
2000-01-05 19:40:01 +00:00
|
|
|
#include "unicode/ustdio.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
#include "ufmt_cmn.h"
|
2003-08-06 16:18:38 +00:00
|
|
|
#include "locbund.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Struct encapsulating a single uprintf format specification.
|
|
|
|
*/
|
2003-08-06 16:18:38 +00:00
|
|
|
typedef struct u_printf_spec_info {
|
2003-10-02 17:05:26 +00:00
|
|
|
int32_t fPrecision; /* Precision */
|
|
|
|
int32_t fWidth; /* Width */
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2006-06-07 04:42:25 +00:00
|
|
|
UChar fOrigSpec; /* Conversion specification */
|
2003-10-02 17:05:26 +00:00
|
|
|
UChar fSpec; /* Conversion specification */
|
|
|
|
UChar fPadChar; /* Padding character */
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2003-10-02 17:05:26 +00:00
|
|
|
UBool fAlt; /* # flag */
|
|
|
|
UBool fSpace; /* Space flag */
|
|
|
|
UBool fLeft; /* - flag */
|
|
|
|
UBool fShowSign; /* + flag */
|
|
|
|
UBool fZero; /* 0 flag */
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2003-10-02 17:05:26 +00:00
|
|
|
UBool fIsLongDouble; /* L flag */
|
|
|
|
UBool fIsShort; /* h flag */
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool fIsLong; /* l flag */
|
2003-10-02 17:05:26 +00:00
|
|
|
UBool fIsLongLong; /* ll flag */
|
2003-08-06 16:18:38 +00:00
|
|
|
} u_printf_spec_info;
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2003-08-06 16:18:38 +00:00
|
|
|
typedef int32_t U_EXPORT2
|
|
|
|
u_printf_write_stream(void *context,
|
|
|
|
const UChar *str,
|
|
|
|
int32_t count);
|
|
|
|
|
|
|
|
typedef int32_t U_EXPORT2
|
|
|
|
u_printf_pad_and_justify_stream(void *context,
|
|
|
|
const u_printf_spec_info *info,
|
|
|
|
const UChar *result,
|
|
|
|
int32_t resultLen);
|
|
|
|
|
|
|
|
typedef struct u_printf_stream_handler {
|
|
|
|
u_printf_write_stream *write;
|
|
|
|
u_printf_pad_and_justify_stream *pad_and_justify;
|
|
|
|
} u_printf_stream_handler;
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2004-05-25 16:59:00 +00:00
|
|
|
/* Used by sprintf */
|
|
|
|
typedef struct u_localized_print_string {
|
|
|
|
UChar *str; /* Place to write the string */
|
|
|
|
int32_t available;/* Number of codeunits available to write to */
|
|
|
|
int32_t len; /* Maximum number of code units that can be written to output */
|
|
|
|
|
|
|
|
ULocaleBundle fBundle; /* formatters */
|
|
|
|
} u_localized_print_string;
|
|
|
|
|
2004-04-28 22:19:41 +00:00
|
|
|
#define UP_PERCENT 0x0025
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
2004-05-03 06:03:21 +00:00
|
|
|
* Parse a single u_printf format string.
|
2004-04-28 22:19:41 +00:00
|
|
|
* @param fmt A pointer to a '%' character in a u_printf format specification.
|
|
|
|
* @param spec A pointer to a <TT>u_printf_spec</TT> to receive the parsed
|
|
|
|
* format specifier.
|
2004-05-25 16:59:00 +00:00
|
|
|
* @param locStringContext If present, will make sure that it will only write
|
|
|
|
* to the buffer when space is available. It's done this way because
|
|
|
|
* va_list sometimes can't be passed by pointer.
|
2004-04-28 22:19:41 +00:00
|
|
|
* @return The number of characters contained in this specifier.
|
1999-08-16 21:50:52 +00:00
|
|
|
*/
|
2004-05-03 06:03:21 +00:00
|
|
|
U_CFUNC int32_t
|
2004-05-25 16:59:00 +00:00
|
|
|
u_printf_parse(const u_printf_stream_handler *streamHandler,
|
|
|
|
const UChar *fmt,
|
|
|
|
void *context,
|
|
|
|
u_localized_print_string *locStringContext,
|
|
|
|
ULocaleBundle *formatBundle,
|
|
|
|
int32_t *written,
|
|
|
|
va_list ap);
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2002-10-01 01:26:49 +00:00
|
|
|
#endif /* #if !UCONFIG_NO_FORMATTING */
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
#endif
|