2 *****************************************************************************************
3 * Copyright (C) 2015-2016, 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
15 #include "unicode/localpointer.h"
19 * \brief C API: Format a list in a locale-appropriate way.
21 * A UListFormatter is used to format a list of items in a locale-appropriate way,
22 * using data from CLDR.
23 * Example: Input data ["Alice", "Bob", "Charlie", "Delta"] will be formatted
24 * as "Alice, Bob, Charlie, and Delta" in English.
28 * Opaque UListFormatter object for use in C
31 struct UListFormatter
;
32 typedef struct UListFormatter UListFormatter
; /**< C typedef for struct UListFormatter. @stable ICU 55 */
35 * Open a new UListFormatter object using the rules for a given locale.
37 * The locale whose rules should be used; may be NULL for
40 * A pointer to a standard ICU UErrorCode (input/output parameter).
41 * Its input value must pass the U_SUCCESS() test, or else the
42 * function returns immediately. The caller should check its output
43 * value with U_FAILURE(), or use with function chaining (see User
46 * A pointer to a UListFormatter object for the specified locale,
47 * or NULL if an error occurred.
50 U_STABLE UListFormatter
* U_EXPORT2
51 ulistfmt_open(const char* locale
,
55 * Close a UListFormatter object. Once closed it may no longer be used.
57 * The UListFormatter object to close.
60 U_STABLE
void U_EXPORT2
61 ulistfmt_close(UListFormatter
*listfmt
);
64 #if U_SHOW_CPLUSPLUS_API
69 * \class LocalUListFormatterPointer
70 * "Smart pointer" class, closes a UListFormatter via ulistfmt_close().
71 * For most methods see the LocalPointerBase base class.
73 * @see LocalPointerBase
77 U_DEFINE_LOCAL_OPEN_POINTER(LocalUListFormatterPointer
, UListFormatter
, ulistfmt_close
);
84 * Formats a list of strings using the conventions established for the
85 * UListFormatter object.
87 * The UListFormatter object specifying the list conventions.
89 * An array of pointers to UChar strings; the array length is
90 * specified by stringCount. Must be non-NULL if stringCount > 0.
91 * @param stringLengths
92 * An array of string lengths corresponding to the strings[]
93 * parameter; any individual length value may be negative to indicate
94 * that the corresponding strings[] entry is 0-terminated, or
95 * stringLengths itself may be NULL if all of the strings are
96 * 0-terminated. If non-NULL, the stringLengths array must have
97 * stringCount entries.
99 * the number of entries in strings[], and the number of entries
100 * in the stringLengths array if it is not NULL. Must be >= 0.
102 * A pointer to a buffer to receive the formatted list.
103 * @param resultCapacity
104 * The maximum size of result.
106 * A pointer to a standard ICU UErrorCode (input/output parameter).
107 * Its input value must pass the U_SUCCESS() test, or else the
108 * function returns immediately. The caller should check its output
109 * value with U_FAILURE(), or use with function chaining (see User
110 * Guide for details).
112 * The total buffer size needed; if greater than resultLength, the
113 * output was truncated. May be <=0 if unable to determine the
114 * total buffer size needed (e.g. for illegal arguments).
117 U_DRAFT
int32_t U_EXPORT2
118 ulistfmt_format(const UListFormatter
* listfmt
,
119 const UChar
* const strings
[],
120 const int32_t * stringLengths
,
123 int32_t resultCapacity
,
126 #endif /* #if !UCONFIG_NO_FORMATTING */