unumberrangeformatter.h
Go to the documentation of this file.
// © 2020 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
#ifndef __UNUMBERRANGEFORMATTER_H__
#define __UNUMBERRANGEFORMATTER_H__
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
#include "unicode/parseerr.h"
#include "unicode/ufieldpositer.h"
#include "unicode/umisc.h"
#include "unicode/uformattedvalue.h"
#include "unicode/uformattable.h"
typedef enum UNumberRangeCollapse {
UNUM_RANGE_COLLAPSE_AUTO,
UNUM_RANGE_COLLAPSE_NONE,
UNUM_RANGE_COLLAPSE_UNIT,
UNUM_RANGE_COLLAPSE_ALL
} UNumberRangeCollapse;
typedef enum UNumberRangeIdentityFallback {
UNUM_IDENTITY_FALLBACK_SINGLE_VALUE,
UNUM_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE,
UNUM_IDENTITY_FALLBACK_APPROXIMATELY,
UNUM_IDENTITY_FALLBACK_RANGE
} UNumberRangeIdentityFallback;
typedef enum UNumberRangeIdentityResult {
UNUM_IDENTITY_RESULT_EQUAL_BEFORE_ROUNDING,
UNUM_IDENTITY_RESULT_EQUAL_AFTER_ROUNDING,
UNUM_IDENTITY_RESULT_NOT_EQUAL,
#ifndef U_HIDE_INTERNAL_API
UNUM_IDENTITY_RESULT_COUNT
#endif /* U_HIDE_INTERNAL_API */
} UNumberRangeIdentityResult;
struct UNumberRangeFormatter;
typedef struct UNumberRangeFormatter UNumberRangeFormatter;
struct UFormattedNumberRange;
typedef struct UFormattedNumberRange UFormattedNumberRange;
U_CAPI UNumberRangeFormatter* U_EXPORT2
unumrf_openForSkeletonWithCollapseAndIdentityFallback(
const UChar* skeleton,
int32_t skeletonLen,
UNumberRangeCollapse collapse,
UNumberRangeIdentityFallback identityFallback,
const char* locale,
UParseError* perror,
UErrorCode* ec);
U_CAPI UFormattedNumberRange* U_EXPORT2
unumrf_openResult(UErrorCode* ec);
U_CAPI void U_EXPORT2
unumrf_formatDoubleRange(
const UNumberRangeFormatter* uformatter,
double first,
double second,
UFormattedNumberRange* uresult,
UErrorCode* ec);
U_CAPI void U_EXPORT2
unumrf_formatDecimalRange(
const UNumberRangeFormatter* uformatter,
const char* first,
int32_t firstLen,
const char* second,
int32_t secondLen,
UFormattedNumberRange* uresult,
UErrorCode* ec);
U_CAPI const UFormattedValue* U_EXPORT2
unumrf_resultAsValue(const UFormattedNumberRange* uresult, UErrorCode* ec);
U_CAPI UNumberRangeIdentityResult U_EXPORT2
unumrf_resultGetIdentityResult(
const UFormattedNumberRange* uresult,
UErrorCode* ec);
U_CAPI int32_t U_EXPORT2
unumrf_resultGetFirstDecimalNumber(
const UFormattedNumberRange* uresult,
char* dest,
int32_t destCapacity,
UErrorCode* ec);
U_CAPI int32_t U_EXPORT2
unumrf_resultGetSecondDecimalNumber(
const UFormattedNumberRange* uresult,
char* dest,
int32_t destCapacity,
UErrorCode* ec);
U_CAPI void U_EXPORT2
unumrf_close(UNumberRangeFormatter* uformatter);
U_CAPI void U_EXPORT2
unumrf_closeResult(UFormattedNumberRange* uresult);
#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberRangeFormatterPointer, UNumberRangeFormatter, unumrf_close);
U_DEFINE_LOCAL_OPEN_POINTER(LocalUFormattedNumberRangePointer, UFormattedNumberRange, unumrf_closeResult);
U_NAMESPACE_END
#endif // U_SHOW_CPLUSPLUS_API
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif //__UNUMBERRANGEFORMATTER_H__
LocalUNumberRangeFormatterPointer
"Smart pointer" class; closes a UNumberFormatter via unumf_close().
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
parseerr.h
C API: Parse Error Information.
UParseError
A UParseError struct is used to returned detailed information about parsing errors.
Definition parseerr.h:58
ufieldpositer.h
C API: UFieldPositionIterator for use with format APIs.
uformattable.h
C API: UFormattable is a thin wrapper for primitive types used for formatting and parsing.
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
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:378
umisc.h
C API: Miscellaneous definitions.
UNumberRangeIdentityResult
UNumberRangeIdentityResult
Used in the result class FormattedNumberRange to indicate to the user whether the numbers formatted i...
Definition unumberrangeformatter.h:165
UNUM_IDENTITY_RESULT_EQUAL_BEFORE_ROUNDING
@ UNUM_IDENTITY_RESULT_EQUAL_BEFORE_ROUNDING
Used to indicate that the two numbers in the range were equal, even before any rounding rules were ap...
Definition unumberrangeformatter.h:172
UNUM_IDENTITY_RESULT_NOT_EQUAL
@ UNUM_IDENTITY_RESULT_NOT_EQUAL
Used to indicate that the two numbers in the range were not equal, even after rounding rules were app...
Definition unumberrangeformatter.h:188
UNUM_IDENTITY_RESULT_EQUAL_AFTER_ROUNDING
@ UNUM_IDENTITY_RESULT_EQUAL_AFTER_ROUNDING
Used to indicate that the two numbers in the range were equal, but only after rounding rules were app...
Definition unumberrangeformatter.h:180
UNUM_IDENTITY_RESULT_COUNT
@ UNUM_IDENTITY_RESULT_COUNT
The number of entries in this enum.
Definition unumberrangeformatter.h:195
unumrf_formatDoubleRange
U_CAPI void unumrf_formatDoubleRange(const UNumberRangeFormatter *uformatter, double first, double second, UFormattedNumberRange *uresult, UErrorCode *ec)
Uses a UNumberRangeFormatter to format a range of doubles.
unumrf_resultGetFirstDecimalNumber
U_CAPI int32_t unumrf_resultGetFirstDecimalNumber(const UFormattedNumberRange *uresult, char *dest, int32_t destCapacity, UErrorCode *ec)
Extracts the first formatted number as a decimal number.
unumrf_openForSkeletonWithCollapseAndIdentityFallback
U_CAPI UNumberRangeFormatter * unumrf_openForSkeletonWithCollapseAndIdentityFallback(const UChar *skeleton, int32_t skeletonLen, UNumberRangeCollapse collapse, UNumberRangeIdentityFallback identityFallback, const char *locale, UParseError *perror, UErrorCode *ec)
Creates a new UNumberFormatter for the given skeleton string, collapse option, identity fallback opti...
unumrf_openResult
U_CAPI UFormattedNumberRange * unumrf_openResult(UErrorCode *ec)
Creates an object to hold the result of a UNumberRangeFormatter operation.
unumrf_closeResult
U_CAPI void unumrf_closeResult(UFormattedNumberRange *uresult)
Releases the UFormattedNumber created by unumf_openResult().
UNumberRangeIdentityFallback
UNumberRangeIdentityFallback
Defines the behavior when the two numbers in the range are identical after rounding.
Definition unumberrangeformatter.h:125
UNUM_IDENTITY_FALLBACK_APPROXIMATELY
@ UNUM_IDENTITY_FALLBACK_APPROXIMATELY
Show the number using a locale-sensitive approximation pattern.
Definition unumberrangeformatter.h:147
UNUM_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE
@ UNUM_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE
Show the number using a locale-sensitive approximation pattern.
Definition unumberrangeformatter.h:139
UNUM_IDENTITY_FALLBACK_SINGLE_VALUE
@ UNUM_IDENTITY_FALLBACK_SINGLE_VALUE
Show the number as a single value rather than a range.
Definition unumberrangeformatter.h:131
UNUM_IDENTITY_FALLBACK_RANGE
@ UNUM_IDENTITY_FALLBACK_RANGE
Show the number as the range of two equal values.
Definition unumberrangeformatter.h:155
unumrf_close
U_CAPI void unumrf_close(UNumberRangeFormatter *uformatter)
Releases the UNumberFormatter created by unumf_openForSkeletonAndLocale().
UFormattedNumberRange
struct UFormattedNumberRange UFormattedNumberRange
C-compatible version of icu::number::FormattedNumberRange.
Definition unumberrangeformatter.h:220
unumrf_resultGetIdentityResult
U_CAPI UNumberRangeIdentityResult unumrf_resultGetIdentityResult(const UFormattedNumberRange *uresult, UErrorCode *ec)
Extracts the identity result from a UFormattedNumberRange.
unumrf_formatDecimalRange
U_CAPI void unumrf_formatDecimalRange(const UNumberRangeFormatter *uformatter, const char *first, int32_t firstLen, const char *second, int32_t secondLen, UFormattedNumberRange *uresult, UErrorCode *ec)
Uses a UNumberRangeFormatter to format a range of decimal numbers.
UNumberRangeCollapse
UNumberRangeCollapse
Defines how to merge fields that are identical across the range sign.
Definition unumberrangeformatter.h:83
UNUM_RANGE_COLLAPSE_ALL
@ UNUM_RANGE_COLLAPSE_ALL
Collapse any field that is equal across the range sign.
Definition unumberrangeformatter.h:115
UNUM_RANGE_COLLAPSE_AUTO
@ UNUM_RANGE_COLLAPSE_AUTO
Use locale data and heuristics to determine how much of the string to collapse.
Definition unumberrangeformatter.h:92
UNUM_RANGE_COLLAPSE_UNIT
@ UNUM_RANGE_COLLAPSE_UNIT
Collapse the unit part of the number, but not the notation, if present.
Definition unumberrangeformatter.h:107
UNUM_RANGE_COLLAPSE_NONE
@ UNUM_RANGE_COLLAPSE_NONE
Do not collapse any part of the number.
Definition unumberrangeformatter.h:99
unumrf_resultGetSecondDecimalNumber
U_CAPI int32_t unumrf_resultGetSecondDecimalNumber(const UFormattedNumberRange *uresult, char *dest, int32_t destCapacity, UErrorCode *ec)
Extracts the second formatted number as a decimal number.
UNumberRangeFormatter
struct UNumberRangeFormatter UNumberRangeFormatter
C-compatible version of icu::number::LocalizedNumberRangeFormatter.
Definition unumberrangeformatter.h:209
unumrf_resultAsValue
U_CAPI const UFormattedValue * unumrf_resultAsValue(const UFormattedNumberRange *uresult, UErrorCode *ec)
Returns a representation of a UFormattedNumberRange as a UFormattedValue, which can be subsequently p...
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:430