2 *****************************************************************************************
3 * Copyright (C) 2015, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 *****************************************************************************************
8 #ifndef ULISTFORMATTER_H
9 #define ULISTFORMATTER_H
11 #include "unicode/utypes.h"
13 #if !UCONFIG_NO_FORMATTING
14 #ifndef U_HIDE_DRAFT_API
16 #include "unicode/localpointer.h"
20 * \brief C API: Format a list in a locale-appropriate way.
22 * A UListFormatter is used to format a list of items in a locale-appropriate way,
23 * using data from CLDR.
24 * Example: Input data ["Alice", "Bob", "Charlie", "Delta"] will be formatted
25 * as "Alice, Bob, Charlie, and Delta" in English.
29 * Opaque UListFormatter object for use in C
32 struct UListFormatter
;
33 typedef struct UListFormatter UListFormatter
; /**< C typedef for struct UListFormatter. @draft ICU 55 */
36 * Open a new UListFormatter object using the rules for a given locale.
38 * The locale whose rules should be used; may be NULL for
41 * A pointer to a standard ICU UErrorCode (input/output parameter).
42 * Its input value must pass the U_SUCCESS() test, or else the
43 * function returns immediately. The caller should check its output
44 * value with U_FAILURE(), or use with function chaining (see User
47 * A pointer to a UListFormatter object for the specified locale,
48 * or NULL if an error occurred.
51 U_DRAFT UListFormatter
* U_EXPORT2
52 ulistfmt_open(const char* locale
,
56 * Close a UListFormatter object. Once closed it may no longer be used.
58 * The UListFormatter object to close.
61 U_DRAFT
void U_EXPORT2
62 ulistfmt_close(UListFormatter
*listfmt
);
65 #if U_SHOW_CPLUSPLUS_API
70 * \class LocalUListFormatterPointer
71 * "Smart pointer" class, closes a UListFormatter via ulistfmt_close().
72 * For most methods see the LocalPointerBase base class.
74 * @see LocalPointerBase
78 U_DEFINE_LOCAL_OPEN_POINTER(LocalUListFormatterPointer
, UListFormatter
, ulistfmt_close
);
85 * Formats a list of strings using the conventions established for the
86 * UListFormatter object.
88 * The UListFormatter object specifying the list conventions.
90 * An array of pointers to UChar strings; the array length is
91 * specified by stringCount. Must be non-NULL if stringCount > 0.
92 * @param stringLengths
93 * An array of string lengths corresponding to the strings[]
94 * parameter; any individual length value may be negative to indicate
95 * that the corresponding strings[] entry is 0-terminated, or
96 * stringLengths itself may be NULL if all of the strings are
97 * 0-terminated. If non-NULL, the stringLengths array must have
98 * stringCount entries.
100 * the number of entries in strings[], and the number of entries
101 * in the stringLengths array if it is not NULL. Must be >= 0.
103 * A pointer to a buffer to receive the formatted list.
104 * @param resultCapacity
105 * The maximum size of result.
107 * A pointer to a standard ICU UErrorCode (input/output parameter).
108 * Its input value must pass the U_SUCCESS() test, or else the
109 * function returns immediately. The caller should check its output
110 * value with U_FAILURE(), or use with function chaining (see User
111 * Guide for details).
113 * The total buffer size needed; if greater than resultLength, the
114 * output was truncated. May be <=0 if unable to determine the
115 * total buffer size needed (e.g. for illegal arguments).
118 U_DRAFT
int32_t U_EXPORT2
119 ulistfmt_format(const UListFormatter
* listfmt
,
120 const UChar
* const strings
[],
121 const int32_t * stringLengths
,
124 int32_t resultCapacity
,
127 #endif /* U_HIDE_DRAFT_API */
128 #endif /* #if !UCONFIG_NO_FORMATTING */