00001
00002
00003
00004 #ifndef __UNUMBERFORMATTER_H__
00005 #define __UNUMBERFORMATTER_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
00016
00119 typedef enum UNumberRoundingPriority {
00125 UNUM_ROUNDING_PRIORITY_RELAXED,
00126
00132 UNUM_ROUNDING_PRIORITY_STRICT,
00133 } UNumberRoundingPriority;
00134
00153 typedef enum UNumberUnitWidth {
00165 UNUM_UNIT_WIDTH_NARROW = 0,
00166
00181 UNUM_UNIT_WIDTH_SHORT = 1,
00182
00192 UNUM_UNIT_WIDTH_FULL_NAME = 2,
00193
00203 UNUM_UNIT_WIDTH_ISO_CODE = 3,
00204
00214 UNUM_UNIT_WIDTH_FORMAL = 4,
00215
00225 UNUM_UNIT_WIDTH_VARIANT = 5,
00226
00234 UNUM_UNIT_WIDTH_HIDDEN = 6,
00235
00236
00237
00243 UNUM_UNIT_WIDTH_COUNT = 7
00244 } UNumberUnitWidth;
00245
00272 typedef enum UNumberGroupingStrategy {
00278 UNUM_GROUPING_OFF,
00279
00294 UNUM_GROUPING_MIN2,
00295
00309 UNUM_GROUPING_AUTO,
00310
00325 UNUM_GROUPING_ON_ALIGNED,
00326
00333 UNUM_GROUPING_THOUSANDS
00334
00335 #ifndef U_HIDE_INTERNAL_API
00336 ,
00342 UNUM_GROUPING_COUNT
00343 #endif
00344
00345 } UNumberGroupingStrategy;
00346
00366 typedef enum UNumberSignDisplay {
00376 UNUM_SIGN_AUTO,
00377
00384 UNUM_SIGN_ALWAYS,
00385
00391 UNUM_SIGN_NEVER,
00392
00407 UNUM_SIGN_ACCOUNTING,
00408
00417 UNUM_SIGN_ACCOUNTING_ALWAYS,
00418
00425 UNUM_SIGN_EXCEPT_ZERO,
00426
00434 UNUM_SIGN_ACCOUNTING_EXCEPT_ZERO,
00435
00441 UNUM_SIGN_NEGATIVE,
00442
00448 UNUM_SIGN_ACCOUNTING_NEGATIVE,
00449
00450
00451
00457 UNUM_SIGN_COUNT = 9,
00458 } UNumberSignDisplay;
00459
00471 typedef enum UNumberDecimalSeparatorDisplay {
00478 UNUM_DECIMAL_SEPARATOR_AUTO,
00479
00485 UNUM_DECIMAL_SEPARATOR_ALWAYS,
00486
00487
00488
00494 UNUM_DECIMAL_SEPARATOR_COUNT
00495 } UNumberDecimalSeparatorDisplay;
00496
00505 typedef enum UNumberTrailingZeroDisplay {
00511 UNUM_TRAILING_ZERO_AUTO,
00512
00518 UNUM_TRAILING_ZERO_HIDE_IF_WHOLE,
00519 } UNumberTrailingZeroDisplay;
00520
00521 struct UNumberFormatter;
00529 typedef struct UNumberFormatter UNumberFormatter;
00530
00531 struct UFormattedNumber;
00539 typedef struct UFormattedNumber UFormattedNumber;
00540
00541
00562 U_CAPI UNumberFormatter* U_EXPORT2
00563 unumf_openForSkeletonAndLocale(const UChar* skeleton, int32_t skeletonLen, const char* locale,
00564 UErrorCode* ec);
00565
00566
00582 U_CAPI UNumberFormatter* U_EXPORT2
00583 unumf_openForSkeletonAndLocaleWithError(
00584 const UChar* skeleton, int32_t skeletonLen, const char* locale, UParseError* perror, UErrorCode* ec);
00585
00586
00595 U_CAPI UFormattedNumber* U_EXPORT2
00596 unumf_openResult(UErrorCode* ec);
00597
00598
00614 U_CAPI void U_EXPORT2
00615 unumf_formatInt(const UNumberFormatter* uformatter, int64_t value, UFormattedNumber* uresult,
00616 UErrorCode* ec);
00617
00618
00634 U_CAPI void U_EXPORT2
00635 unumf_formatDouble(const UNumberFormatter* uformatter, double value, UFormattedNumber* uresult,
00636 UErrorCode* ec);
00637
00638
00658 U_CAPI void U_EXPORT2
00659 unumf_formatDecimal(const UNumberFormatter* uformatter, const char* value, int32_t valueLen,
00660 UFormattedNumber* uresult, UErrorCode* ec);
00661
00676 U_CAPI const UFormattedValue* U_EXPORT2
00677 unumf_resultAsValue(const UFormattedNumber* uresult, UErrorCode* ec);
00678
00679
00699 U_CAPI int32_t U_EXPORT2
00700 unumf_resultToString(const UFormattedNumber* uresult, UChar* buffer, int32_t bufferCapacity,
00701 UErrorCode* ec);
00702
00703
00737 U_CAPI UBool U_EXPORT2
00738 unumf_resultNextFieldPosition(const UFormattedNumber* uresult, UFieldPosition* ufpos, UErrorCode* ec);
00739
00740
00762 U_CAPI void U_EXPORT2
00763 unumf_resultGetAllFieldPositions(const UFormattedNumber* uresult, UFieldPositionIterator* ufpositer,
00764 UErrorCode* ec);
00765
00766
00785 U_CAPI int32_t U_EXPORT2
00786 unumf_resultToDecimalNumber(
00787 const UFormattedNumber* uresult,
00788 char* dest,
00789 int32_t destCapacity,
00790 UErrorCode* ec);
00791
00792
00799 U_CAPI void U_EXPORT2
00800 unumf_close(UNumberFormatter* uformatter);
00801
00802
00809 U_CAPI void U_EXPORT2
00810 unumf_closeResult(UFormattedNumber* uresult);
00811
00812
00813 #if U_SHOW_CPLUSPLUS_API
00814 U_NAMESPACE_BEGIN
00815
00831 U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberFormatterPointer, UNumberFormatter, unumf_close);
00832
00848 U_DEFINE_LOCAL_OPEN_POINTER(LocalUFormattedNumberPointer, UFormattedNumber, unumf_closeResult);
00849
00850 U_NAMESPACE_END
00851 #endif // U_SHOW_CPLUSPLUS_API
00852
00853 #endif
00854 #endif //__UNUMBERFORMATTER_H__