ICU 64.2 64.2

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 #ifndef U_HIDE_DRAFT_API
38 struct UFormattedList;
43 typedef struct UFormattedList UFormattedList;
44 #endif /* U_HIDE_DRAFT_API */
45
46 #ifndef U_HIDE_DRAFT_API
47
52 typedef enum UListFormatterField {
57 ULISTFMT_LITERAL_FIELD,
62 ULISTFMT_ELEMENT_FIELD
63 } UListFormatterField;
64 #endif // U_HIDE_DRAFT_API
65
82 U_CAPI UListFormatter* U_EXPORT2
83 ulistfmt_open(const char* locale,
84 UErrorCode* status);
85
92 U_CAPI void U_EXPORT2
93 ulistfmt_close(UListFormatter *listfmt);
94
95 #ifndef U_HIDE_DRAFT_API
96
105 U_CAPI UFormattedList* U_EXPORT2
106 ulistfmt_openResult(UErrorCode* ec);
107
129 U_CAPI const UFormattedValue* U_EXPORT2
130 ulistfmt_resultAsValue(const UFormattedList* uresult, UErrorCode* ec);
131
138 U_CAPI void U_EXPORT2
139 ulistfmt_closeResult(UFormattedList* uresult);
140 #endif /* U_HIDE_DRAFT_API */
141
142
143 #if U_SHOW_CPLUSPLUS_API
144
145 U_NAMESPACE_BEGIN
146
156 U_DEFINE_LOCAL_OPEN_POINTER(LocalUListFormatterPointer, UListFormatter, ulistfmt_close);
157
158 #ifndef U_HIDE_DRAFT_API
159
168 U_DEFINE_LOCAL_OPEN_POINTER(LocalUFormattedListPointer, UFormattedList, ulistfmt_closeResult);
169 #endif /* U_HIDE_DRAFT_API */
170
171 U_NAMESPACE_END
172
173 #endif
174
209 U_CAPI int32_t U_EXPORT2
210 ulistfmt_format(const UListFormatter* listfmt,
211 const UChar* const strings[],
212 const int32_t * stringLengths,
213 int32_t stringCount,
214 UChar* result,
215 int32_t resultCapacity,
216 UErrorCode* status);
217
218 #ifndef U_HIDE_DRAFT_API
219
245 U_CAPI void U_EXPORT2
246 ulistfmt_formatStringsToResult(
247 const UListFormatter* listfmt,
248 const UChar* const strings[],
249 const int32_t * stringLengths,
250 int32_t stringCount,
251 UFormattedList* uresult,
252 UErrorCode* status);
253 #endif /* U_HIDE_DRAFT_API */
254
255 #endif /* #if !UCONFIG_NO_FORMATTING */
256
257 #endif
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.
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:57
UListFormatterField
UListFormatterField
FieldPosition and UFieldPosition selectors for format fields defined by ListFormatter.
Definition: ulistformatter.h:52
ulistfmt_closeResult
U_CAPI void ulistfmt_closeResult(UFormattedList *uresult)
Releases the UFormattedList created by ulistfmt_openResult().
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
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:562
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:156
LocalUListFormatterPointer
"Smart pointer" class, closes a UListFormatter via ulistfmt_close().
UChar
uint16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:342
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
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...
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:401
ULISTFMT_ELEMENT_FIELD
The element text in the result which came from the input strings.
Definition: ulistformatter.h:62
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:43
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:362
UListFormatter
struct UListFormatter UListFormatter
C typedef for struct UListFormatter.
Definition: ulistformatter.h:35