ICU 67.1 67.1

ulistformatter.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *****************************************************************************************
5 * Copyright (C) 2015-2016, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 *****************************************************************************************
8 */
9
10 #ifndef ULISTFORMATTER_H
11 #define ULISTFORMATTER_H
12
13 #include "unicode/utypes.h"
14
15 #if !UCONFIG_NO_FORMATTING
16
17 #include "unicode/localpointer.h"
18 #include "unicode/uformattedvalue.h"
19
34 struct UListFormatter;
35 typedef struct UListFormatter UListFormatter;
37 struct UFormattedList;
42 typedef struct UFormattedList UFormattedList;
43
49 typedef enum UListFormatterField {
54 ULISTFMT_LITERAL_FIELD,
59 ULISTFMT_ELEMENT_FIELD
60 } UListFormatterField;
61
62 #ifndef U_HIDE_DRAFT_API
63
68 typedef enum UListFormatterType {
74 ULISTFMT_TYPE_AND,
75
82 ULISTFMT_TYPE_OR,
83
89 ULISTFMT_TYPE_UNITS
90 } UListFormatterType;
91
97 typedef enum UListFormatterWidth {
103 ULISTFMT_WIDTH_WIDE,
104
109 ULISTFMT_WIDTH_SHORT,
110
115 ULISTFMT_WIDTH_NARROW,
116 } UListFormatterWidth;
117 #endif /* U_HIDE_DRAFT_API */
118
137 U_CAPI UListFormatter* U_EXPORT2
138 ulistfmt_open(const char* locale,
139 UErrorCode* status);
140
141 #ifndef U_HIDE_DRAFT_API
142
164 U_DRAFT UListFormatter* U_EXPORT2
165 ulistfmt_openForType(const char* locale, UListFormatterType type,
166 UListFormatterWidth width, UErrorCode* status);
167 #endif /* U_HIDE_DRAFT_API */
168
175 U_CAPI void U_EXPORT2
176 ulistfmt_close(UListFormatter *listfmt);
177
187 U_CAPI UFormattedList* U_EXPORT2
188 ulistfmt_openResult(UErrorCode* ec);
189
211 U_CAPI const UFormattedValue* U_EXPORT2
212 ulistfmt_resultAsValue(const UFormattedList* uresult, UErrorCode* ec);
213
220 U_CAPI void U_EXPORT2
221 ulistfmt_closeResult(UFormattedList* uresult);
222
223
224 #if U_SHOW_CPLUSPLUS_API
225
226 U_NAMESPACE_BEGIN
227
237 U_DEFINE_LOCAL_OPEN_POINTER(LocalUListFormatterPointer, UListFormatter, ulistfmt_close);
238
248 U_DEFINE_LOCAL_OPEN_POINTER(LocalUFormattedListPointer, UFormattedList, ulistfmt_closeResult);
249
250 U_NAMESPACE_END
251
252 #endif
253
288 U_CAPI int32_t U_EXPORT2
289 ulistfmt_format(const UListFormatter* listfmt,
290 const UChar* const strings[],
291 const int32_t * stringLengths,
292 int32_t stringCount,
293 UChar* result,
294 int32_t resultCapacity,
295 UErrorCode* status);
296
323 U_CAPI void U_EXPORT2
324 ulistfmt_formatStringsToResult(
325 const UListFormatter* listfmt,
326 const UChar* const strings[],
327 const int32_t * stringLengths,
328 int32_t stringCount,
329 UFormattedList* uresult,
330 UErrorCode* status);
331
332 #endif /* #if !UCONFIG_NO_FORMATTING */
333
334 #endif
ulistfmt_openForType
UListFormatter * ulistfmt_openForType(const char *locale, UListFormatterType type, UListFormatterWidth width, UErrorCode *status)
Open a new UListFormatter object appropriate for the given locale, list type, and style...
ulistfmt_format
U_CAPI int32_t ulistfmt_format(const UListFormatter *listfmt, const UChar *const strings[], const int32_t *stringLengths, int32_t stringCount, UChar *result, int32_t resultCapacity, UErrorCode *status)
Formats a list of strings using the conventions established for the UListFormatter object...
ULISTFMT_TYPE_UNITS
Formatting of a list of values with units, e.g.
Definition: ulistformatter.h:89
uformattedvalue.h
C API: Abstract operations for localized strings.
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition: umachine.h:109
ULISTFMT_LITERAL_FIELD
The literal text in the result which came from the resources.
Definition: ulistformatter.h:54
UListFormatterField
UListFormatterField
FieldPosition and UFieldPosition selectors for format fields defined by ListFormatter.
Definition: ulistformatter.h:49
UListFormatterType
UListFormatterType
Type of meaning expressed by the list.
Definition: ulistformatter.h:68
ulistfmt_closeResult
U_CAPI void ulistfmt_closeResult(UFormattedList *uresult)
Releases the UFormattedList created by ulistfmt_openResult().
ULISTFMT_WIDTH_NARROW
Use list formatting of the shortest possible length.
Definition: ulistformatter.h:115
ulistfmt_openResult
U_CAPI UFormattedList * ulistfmt_openResult(UErrorCode *ec)
Creates an object to hold the result of a UListFormatter operation.
ulistfmt_close
U_CAPI void ulistfmt_close(UListFormatter *listfmt)
Close a UListFormatter object.
U_DEFINE_LOCAL_OPEN_POINTER
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:550
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
LocalUFormattedListPointer
"Smart pointer" class, closes a UFormattedList via ulistfmt_closeResult().
Definition: ulistformatter.h:237
LocalUListFormatterPointer
"Smart pointer" class, closes a UListFormatter via ulistfmt_close().
UChar
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:376
ULISTFMT_TYPE_OR
Disjunction (or alternative, or simply one of) formatting, e.g.
Definition: ulistformatter.h:82
ULISTFMT_TYPE_AND
Conjunction formatting, e.g.
Definition: ulistformatter.h:74
ulistfmt_resultAsValue
U_CAPI const UFormattedValue * ulistfmt_resultAsValue(const UFormattedList *uresult, UErrorCode *ec)
Returns a representation of a UFormattedList as a UFormattedValue, which can be subsequently passed t...
ULISTFMT_WIDTH_WIDE
Use list formatting with full words (no abbreviations) when possible.
Definition: ulistformatter.h:103
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
ULISTFMT_ELEMENT_FIELD
The element text in the result which came from the input strings.
Definition: ulistformatter.h:59
ULISTFMT_WIDTH_SHORT
Use list formatting of typical length.
Definition: ulistformatter.h:109
ulistfmt_open
U_CAPI UListFormatter * ulistfmt_open(const char *locale, UErrorCode *status)
Open a new UListFormatter object using the rules for a given locale.
UFormattedList
struct UFormattedList UFormattedList
Opaque struct to contain the results of a UListFormatter operation.
Definition: ulistformatter.h:42
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
ulistfmt_formatStringsToResult
U_CAPI void ulistfmt_formatStringsToResult(const UListFormatter *listfmt, const UChar *const strings[], const int32_t *stringLengths, int32_t stringCount, UFormattedList *uresult, UErrorCode *status)
Formats a list of strings to a UFormattedList, which exposes more information than the string exporte...
UFormattedValue
struct UFormattedValue UFormattedValue
An abstract formatted value: a string with associated field attributes.
Definition: uformattedvalue.h:361
U_DRAFT
#define U_DRAFT
This is used to declare a function as a draft public ICU C API.
Definition: umachine.h:113
UListFormatterWidth
UListFormatterWidth
Verbosity level of the list patterns.
Definition: ulistformatter.h:97
UListFormatter
struct UListFormatter UListFormatter
C typedef for struct UListFormatter.
Definition: ulistformatter.h:35