ICU 72.1  72.1
unumberrangeformatter.h
Go to the documentation of this file.
1 // © 2020 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 
4 #ifndef __UNUMBERRANGEFORMATTER_H__
5 #define __UNUMBERRANGEFORMATTER_H__
6 
7 #include "unicode/utypes.h"
8 
9 #if !UCONFIG_NO_FORMATTING
10 
11 #include "unicode/parseerr.h"
12 #include "unicode/ufieldpositer.h"
13 #include "unicode/umisc.h"
15 #include "unicode/uformattable.h"
16 
17 
83 typedef enum UNumberRangeCollapse {
93 
100 
108 
117 
132 
140 
148 
157 
173 
181 
189 
190 #ifndef U_HIDE_INTERNAL_API
191 
196 #endif /* U_HIDE_INTERNAL_API */
197 
199 
200 
201 struct UNumberRangeFormatter;
210 
211 
212 struct UFormattedNumberRange;
221 
222 
244 U_CAPI UNumberRangeFormatter* U_EXPORT2
246  const UChar* skeleton,
247  int32_t skeletonLen,
248  UNumberRangeCollapse collapse,
249  UNumberRangeIdentityFallback identityFallback,
250  const char* locale,
251  UParseError* perror,
252  UErrorCode* ec);
253 
254 
263 U_CAPI UFormattedNumberRange* U_EXPORT2
265 
266 
282 U_CAPI void U_EXPORT2
284  const UNumberRangeFormatter* uformatter,
285  double first,
286  double second,
287  UFormattedNumberRange* uresult,
288  UErrorCode* ec);
289 
290 
310 U_CAPI void U_EXPORT2
312  const UNumberRangeFormatter* uformatter,
313  const char* first,
314  int32_t firstLen,
315  const char* second,
316  int32_t secondLen,
317  UFormattedNumberRange* uresult,
318  UErrorCode* ec);
319 
320 
335 U_CAPI const UFormattedValue* U_EXPORT2
337 
338 
351  const UFormattedNumberRange* uresult,
352  UErrorCode* ec);
353 
354 
374 U_CAPI int32_t U_EXPORT2
376  const UFormattedNumberRange* uresult,
377  char* dest,
378  int32_t destCapacity,
379  UErrorCode* ec);
380 
381 
401 U_CAPI int32_t U_EXPORT2
403  const UFormattedNumberRange* uresult,
404  char* dest,
405  int32_t destCapacity,
406  UErrorCode* ec);
407 
408 
415 U_CAPI void U_EXPORT2
417 
418 
425 U_CAPI void U_EXPORT2
427 
428 
429 #if U_SHOW_CPLUSPLUS_API
430 U_NAMESPACE_BEGIN
431 
449 
465 U_DEFINE_LOCAL_OPEN_POINTER(LocalUFormattedNumberRangePointer, UFormattedNumberRange, unumrf_closeResult);
466 
467 U_NAMESPACE_END
468 #endif // U_SHOW_CPLUSPLUS_API
469 
470 #endif /* #if !UCONFIG_NO_FORMATTING */
471 #endif //__UNUMBERRANGEFORMATTER_H__
C API: UFormattable is a thin wrapper for primitive types used for formatting and parsing...
C API: Abstract operations for localized strings.
U_CAPI UNumberRangeIdentityResult unumrf_resultGetIdentityResult(const UFormattedNumberRange *uresult, UErrorCode *ec)
Extracts the identity result from a UFormattedNumberRange.
Used to indicate that the two numbers in the range were not equal, even after rounding rules were app...
"Smart pointer" class; closes a UNumberFormatter via unumf_close().
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition: umachine.h:110
struct UFormattedNumberRange UFormattedNumberRange
C-compatible version of icu::number::FormattedNumberRange.
Show the number as the range of two equal values.
Collapse the unit part of the number, but not the notation, if present.
C API: Miscellaneous definitions.
Show the number as a single value rather than a range.
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.
Used to indicate that the two numbers in the range were equal, but only after rounding rules were app...
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:550
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...
UNumberRangeIdentityResult
Used in the result class FormattedNumberRange to indicate to the user whether the numbers formatted i...
U_CAPI void unumrf_close(UNumberRangeFormatter *uformatter)
Releases the UNumberFormatter created by unumf_openForSkeletonAndLocale().
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.
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.
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.
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:412
Show the number using a locale-sensitive approximation pattern.
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...
C API: Parse Error Information.
Use locale data and heuristics to determine how much of the string to collapse.
Collapse any field that is equal across the range sign.
UNumberRangeCollapse
Defines how to merge fields that are identical across the range sign.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
C API: UFieldPositionIterator for use with format APIs.
Do not collapse any part of the number.
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:58
Basic definitions for ICU, for both C and C++ APIs.
U_CAPI UFormattedNumberRange * unumrf_openResult(UErrorCode *ec)
Creates an object to hold the result of a UNumberRangeFormatter operation.
U_CAPI void unumrf_closeResult(UFormattedNumberRange *uresult)
Releases the UFormattedNumber created by unumf_openResult().
struct UNumberRangeFormatter UNumberRangeFormatter
C-compatible version of icu::number::LocalizedNumberRangeFormatter.
The number of entries in this enum.
struct UFormattedValue UFormattedValue
An abstract formatted value: a string with associated field attributes.
Show the number using a locale-sensitive approximation pattern.
UNumberRangeIdentityFallback
Defines the behavior when the two numbers in the range are identical after rounding.
Used to indicate that the two numbers in the range were equal, even before any rounding rules were ap...