ICU 73.2  73.2
unumberrangeformatter.h
Go to the documentation of this file.
00001 // © 2020 and later: Unicode, Inc. and others.
00002 // License & terms of use: http://www.unicode.org/copyright.html
00003 
00004 #ifndef __UNUMBERRANGEFORMATTER_H__
00005 #define __UNUMBERRANGEFORMATTER_H__
00006 
00007 #include "unicode/utypes.h"
00008 
00009 #if !UCONFIG_NO_FORMATTING
00010 
00011 #include "unicode/parseerr.h"
00012 #include "unicode/ufieldpositer.h"
00013 #include "unicode/umisc.h"
00014 #include "unicode/uformattedvalue.h"
00015 #include "unicode/uformattable.h"
00016 
00017 
00083 typedef enum UNumberRangeCollapse {
00092     UNUM_RANGE_COLLAPSE_AUTO,
00093 
00099     UNUM_RANGE_COLLAPSE_NONE,
00100 
00107     UNUM_RANGE_COLLAPSE_UNIT,
00108 
00115     UNUM_RANGE_COLLAPSE_ALL
00116 } UNumberRangeCollapse;
00117 
00125 typedef enum UNumberRangeIdentityFallback {
00131     UNUM_IDENTITY_FALLBACK_SINGLE_VALUE,
00132 
00139     UNUM_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE,
00140 
00147     UNUM_IDENTITY_FALLBACK_APPROXIMATELY,
00148 
00155     UNUM_IDENTITY_FALLBACK_RANGE
00156 } UNumberRangeIdentityFallback;
00157 
00165 typedef enum UNumberRangeIdentityResult {
00172     UNUM_IDENTITY_RESULT_EQUAL_BEFORE_ROUNDING,
00173 
00180     UNUM_IDENTITY_RESULT_EQUAL_AFTER_ROUNDING,
00181 
00188     UNUM_IDENTITY_RESULT_NOT_EQUAL,
00189 
00190 #ifndef U_HIDE_INTERNAL_API
00191 
00195     UNUM_IDENTITY_RESULT_COUNT
00196 #endif  /* U_HIDE_INTERNAL_API */
00197 
00198 } UNumberRangeIdentityResult;
00199 
00200 
00201 struct UNumberRangeFormatter;
00209 typedef struct UNumberRangeFormatter UNumberRangeFormatter;
00210 
00211 
00212 struct UFormattedNumberRange;
00220 typedef struct UFormattedNumberRange UFormattedNumberRange;
00221 
00222 
00244 U_CAPI UNumberRangeFormatter* U_EXPORT2
00245 unumrf_openForSkeletonWithCollapseAndIdentityFallback(
00246     const UChar* skeleton,
00247     int32_t skeletonLen,
00248     UNumberRangeCollapse collapse,
00249     UNumberRangeIdentityFallback identityFallback,
00250     const char* locale,
00251     UParseError* perror,
00252     UErrorCode* ec);
00253 
00254 
00263 U_CAPI UFormattedNumberRange* U_EXPORT2
00264 unumrf_openResult(UErrorCode* ec);
00265 
00266 
00282 U_CAPI void U_EXPORT2
00283 unumrf_formatDoubleRange(
00284     const UNumberRangeFormatter* uformatter,
00285     double first,
00286     double second,
00287     UFormattedNumberRange* uresult,
00288     UErrorCode* ec);
00289 
00290 
00310 U_CAPI void U_EXPORT2
00311 unumrf_formatDecimalRange(
00312     const UNumberRangeFormatter* uformatter,
00313     const char* first,
00314     int32_t firstLen,
00315     const char* second,
00316     int32_t secondLen,
00317     UFormattedNumberRange* uresult,
00318     UErrorCode* ec);
00319 
00320 
00335 U_CAPI const UFormattedValue* U_EXPORT2
00336 unumrf_resultAsValue(const UFormattedNumberRange* uresult, UErrorCode* ec);
00337 
00338 
00349 U_CAPI UNumberRangeIdentityResult U_EXPORT2
00350 unumrf_resultGetIdentityResult(
00351     const UFormattedNumberRange* uresult,
00352     UErrorCode* ec);
00353 
00354 
00374 U_CAPI int32_t U_EXPORT2
00375 unumrf_resultGetFirstDecimalNumber(
00376     const UFormattedNumberRange* uresult,
00377     char* dest,
00378     int32_t destCapacity,
00379     UErrorCode* ec);
00380 
00381 
00401 U_CAPI int32_t U_EXPORT2
00402 unumrf_resultGetSecondDecimalNumber(
00403     const UFormattedNumberRange* uresult,
00404     char* dest,
00405     int32_t destCapacity,
00406     UErrorCode* ec);
00407 
00408 
00415 U_CAPI void U_EXPORT2
00416 unumrf_close(UNumberRangeFormatter* uformatter);
00417 
00418 
00425 U_CAPI void U_EXPORT2
00426 unumrf_closeResult(UFormattedNumberRange* uresult);
00427 
00428 
00429 #if U_SHOW_CPLUSPLUS_API
00430 U_NAMESPACE_BEGIN
00431 
00448 U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberRangeFormatterPointer, UNumberRangeFormatter, unumrf_close);
00449 
00465 U_DEFINE_LOCAL_OPEN_POINTER(LocalUFormattedNumberRangePointer, UFormattedNumberRange, unumrf_closeResult);
00466 
00467 U_NAMESPACE_END
00468 #endif // U_SHOW_CPLUSPLUS_API
00469 
00470 #endif /* #if !UCONFIG_NO_FORMATTING */
00471 #endif //__UNUMBERRANGEFORMATTER_H__