ICU 69.1  69.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
197 
199 
200 
201 #ifndef U_HIDE_DRAFT_API
202 
203 struct UNumberRangeFormatter;
212 
213 
214 struct UFormattedNumberRange;
223 
224 
246 U_CAPI UNumberRangeFormatter* U_EXPORT2
248  const UChar* skeleton,
249  int32_t skeletonLen,
250  UNumberRangeCollapse collapse,
251  UNumberRangeIdentityFallback identityFallback,
252  const char* locale,
253  UParseError* perror,
254  UErrorCode* ec);
255 
256 
265 U_CAPI UFormattedNumberRange* U_EXPORT2
267 
268 
284 U_CAPI void U_EXPORT2
286  const UNumberRangeFormatter* uformatter,
287  double first,
288  double second,
289  UFormattedNumberRange* uresult,
290  UErrorCode* ec);
291 
292 
312 U_CAPI void U_EXPORT2
314  const UNumberRangeFormatter* uformatter,
315  const char* first,
316  int32_t firstLen,
317  const char* second,
318  int32_t secondLen,
319  UFormattedNumberRange* uresult,
320  UErrorCode* ec);
321 
322 
337 U_CAPI const UFormattedValue* U_EXPORT2
339 
340 
353  const UFormattedNumberRange* uresult,
354  UErrorCode* ec);
355 
356 
376 U_CAPI int32_t U_EXPORT2
378  const UFormattedNumberRange* uresult,
379  char* dest,
380  int32_t destCapacity,
381  UErrorCode* ec);
382 
383 
403 U_CAPI int32_t U_EXPORT2
405  const UFormattedNumberRange* uresult,
406  char* dest,
407  int32_t destCapacity,
408  UErrorCode* ec);
409 
410 
417 U_CAPI void U_EXPORT2
419 
420 
427 U_CAPI void U_EXPORT2
429 
430 
431 #if U_SHOW_CPLUSPLUS_API
432 U_NAMESPACE_BEGIN
433 
451 
467 U_DEFINE_LOCAL_OPEN_POINTER(LocalUFormattedNumberRangePointer, UFormattedNumberRange, unumrf_closeResult);
468 
469 U_NAMESPACE_END
470 #endif // U_SHOW_CPLUSPLUS_API
471 
472 #endif // U_HIDE_DRAFT_API
473 
474 #endif /* #if !UCONFIG_NO_FORMATTING */
475 #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:misc 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:418
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...