ulistformatter.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*****************************************************************************************
* Copyright (C) 2015-2016, International Business Machines
* Corporation and others. All Rights Reserved.
*****************************************************************************************
*/
#ifndef ULISTFORMATTER_H
#define ULISTFORMATTER_H
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
#include "unicode/uformattedvalue.h"
#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
#endif // U_SHOW_CPLUSPLUS_API
struct UListFormatter;
typedef struct UListFormatter UListFormatter;
struct UFormattedList;
typedef struct UFormattedList UFormattedList;
typedef enum UListFormatterField {
ULISTFMT_LITERAL_FIELD,
ULISTFMT_ELEMENT_FIELD
} UListFormatterField;
typedef enum UListFormatterType {
ULISTFMT_TYPE_AND,
ULISTFMT_TYPE_OR,
ULISTFMT_TYPE_UNITS
} UListFormatterType;
typedef enum UListFormatterWidth {
ULISTFMT_WIDTH_WIDE,
ULISTFMT_WIDTH_SHORT,
ULISTFMT_WIDTH_NARROW,
} UListFormatterWidth;
U_CAPI UListFormatter* U_EXPORT2
ulistfmt_open(const char* locale,
UErrorCode* status);
U_CAPI UListFormatter* U_EXPORT2
ulistfmt_openForType(const char* locale, UListFormatterType type,
UListFormatterWidth width, UErrorCode* status);
U_CAPI void U_EXPORT2
ulistfmt_close(UListFormatter *listfmt);
U_CAPI UFormattedList* U_EXPORT2
ulistfmt_openResult(UErrorCode* ec);
U_CAPI const UFormattedValue* U_EXPORT2
ulistfmt_resultAsValue(const UFormattedList* uresult, UErrorCode* ec);
U_CAPI void U_EXPORT2
ulistfmt_closeResult(UFormattedList* uresult);
#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
U_DEFINE_LOCAL_OPEN_POINTER(LocalUListFormatterPointer, UListFormatter, ulistfmt_close);
U_DEFINE_LOCAL_OPEN_POINTER(LocalUFormattedListPointer, UFormattedList, ulistfmt_closeResult);
U_NAMESPACE_END
#endif
U_CAPI int32_t U_EXPORT2
ulistfmt_format(const UListFormatter* listfmt,
const UChar* const strings[],
const int32_t * stringLengths,
int32_t stringCount,
UChar* result,
int32_t resultCapacity,
UErrorCode* status);
U_CAPI void U_EXPORT2
ulistfmt_formatStringsToResult(
const UListFormatter* listfmt,
const UChar* const strings[],
const int32_t * stringLengths,
int32_t stringCount,
UFormattedList* uresult,
UErrorCode* status);
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif
LocalUFormattedListPointer
"Smart pointer" class, closes a UFormattedList via ulistfmt_closeResult().
Definition: ulistformatter.h:236
LocalUListFormatterPointer
"Smart pointer" class, closes a UListFormatter via ulistfmt_close().
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
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
uformattedvalue.h
C API: Abstract operations for localized strings.
UFormattedValue
struct UFormattedValue UFormattedValue
An abstract formatted value: a string with associated field attributes.
Definition: uformattedvalue.h:368
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_openForType
U_CAPI 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_closeResult
U_CAPI void ulistfmt_closeResult(UFormattedList *uresult)
Releases the UFormattedList created by ulistfmt_openResult().
ulistfmt_openResult
U_CAPI UFormattedList * ulistfmt_openResult(UErrorCode *ec)
Creates an object to hold the result of a UListFormatter operation.
UListFormatter
struct UListFormatter UListFormatter
C typedef for struct UListFormatter.
Definition: ulistformatter.h:38
ulistfmt_open
U_CAPI UListFormatter * ulistfmt_open(const char *locale, UErrorCode *status)
Open a new UListFormatter object using the rules for a given locale.
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...
UFormattedList
struct UFormattedList UFormattedList
Opaque struct to contain the results of a UListFormatter operation.
Definition: ulistformatter.h:45
UListFormatterWidth
UListFormatterWidth
Verbosity level of the list patterns.
Definition: ulistformatter.h:99
ULISTFMT_WIDTH_NARROW
@ ULISTFMT_WIDTH_NARROW
Use list formatting of the shortest possible length.
Definition: ulistformatter.h:117
ULISTFMT_WIDTH_WIDE
@ ULISTFMT_WIDTH_WIDE
Use list formatting with full words (no abbreviations) when possible.
Definition: ulistformatter.h:105
ULISTFMT_WIDTH_SHORT
@ ULISTFMT_WIDTH_SHORT
Use list formatting of typical length.
Definition: ulistformatter.h:111
UListFormatterField
UListFormatterField
FieldPosition and UFieldPosition selectors for format fields defined by ListFormatter.
Definition: ulistformatter.h:52
ULISTFMT_ELEMENT_FIELD
@ ULISTFMT_ELEMENT_FIELD
The element text in the result which came from the input strings.
Definition: ulistformatter.h:62
ULISTFMT_LITERAL_FIELD
@ ULISTFMT_LITERAL_FIELD
The literal text in the result which came from the resources.
Definition: ulistformatter.h:57
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.
UListFormatterType
UListFormatterType
Type of meaning expressed by the list.
Definition: ulistformatter.h:70
ULISTFMT_TYPE_OR
@ ULISTFMT_TYPE_OR
Disjunction (or alternative, or simply one of) formatting, e.g.
Definition: ulistformatter.h:84
ULISTFMT_TYPE_AND
@ ULISTFMT_TYPE_AND
Conjunction formatting, e.g.
Definition: ulistformatter.h:76
ULISTFMT_TYPE_UNITS
@ ULISTFMT_TYPE_UNITS
Formatting of a list of values with units, e.g.
Definition: ulistformatter.h:91
ulistfmt_close
U_CAPI void ulistfmt_close(UListFormatter *listfmt)
Close a UListFormatter object.
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition: umachine.h:110
UChar
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:386
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415