00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef _UNUM
00013 #define _UNUM
00014
00015 #include "unicode/utypes.h"
00016
00017 #if !UCONFIG_NO_FORMATTING
00018
00019 #include "unicode/uloc.h"
00020 #include "unicode/umisc.h"
00021 #include "unicode/parseerr.h"
00129 typedef void* UNumberFormat;
00130
00134 typedef enum UNumberFormatStyle {
00139 UNUM_PATTERN_DECIMAL=0,
00141 UNUM_DECIMAL=1,
00143 UNUM_CURRENCY,
00145 UNUM_PERCENT,
00147 UNUM_SCIENTIFIC,
00149 UNUM_SPELLOUT,
00154 UNUM_ORDINAL,
00159 UNUM_DURATION,
00164 UNUM_PATTERN_RULEBASED,
00166 UNUM_DEFAULT = UNUM_DECIMAL,
00168 UNUM_IGNORE = UNUM_PATTERN_DECIMAL
00169 } UNumberFormatStyle;
00170
00174 typedef enum UNumberFormatRoundingMode {
00175 UNUM_ROUND_CEILING,
00176 UNUM_ROUND_FLOOR,
00177 UNUM_ROUND_DOWN,
00178 UNUM_ROUND_UP,
00179 UNUM_FOUND_HALFEVEN,
00180 UNUM_ROUND_HALFDOWN,
00181 UNUM_ROUND_HALFUP
00182 } UNumberFormatRoundingMode;
00183
00187 typedef enum UNumberFormatPadPosition {
00188 UNUM_PAD_BEFORE_PREFIX,
00189 UNUM_PAD_AFTER_PREFIX,
00190 UNUM_PAD_BEFORE_SUFFIX,
00191 UNUM_PAD_AFTER_SUFFIX
00192 } UNumberFormatPadPosition;
00193
00225 U_STABLE UNumberFormat* U_EXPORT2
00226 unum_open( UNumberFormatStyle style,
00227 const UChar* pattern,
00228 int32_t patternLength,
00229 const char* locale,
00230 UParseError* parseErr,
00231 UErrorCode* status);
00232
00233
00240 U_STABLE void U_EXPORT2
00241 unum_close(UNumberFormat* fmt);
00242
00251 U_STABLE UNumberFormat* U_EXPORT2
00252 unum_clone(const UNumberFormat *fmt,
00253 UErrorCode *status);
00254
00276 U_STABLE int32_t U_EXPORT2
00277 unum_format( const UNumberFormat* fmt,
00278 int32_t number,
00279 UChar* result,
00280 int32_t resultLength,
00281 UFieldPosition *pos,
00282 UErrorCode* status);
00283
00305 U_STABLE int32_t U_EXPORT2
00306 unum_formatInt64(const UNumberFormat *fmt,
00307 int64_t number,
00308 UChar* result,
00309 int32_t resultLength,
00310 UFieldPosition *pos,
00311 UErrorCode* status);
00312
00334 U_STABLE int32_t U_EXPORT2
00335 unum_formatDouble( const UNumberFormat* fmt,
00336 double number,
00337 UChar* result,
00338 int32_t resultLength,
00339 UFieldPosition *pos,
00340 UErrorCode* status);
00341
00363 U_STABLE int32_t U_EXPORT2
00364 unum_formatDoubleCurrency(const UNumberFormat* fmt,
00365 double number,
00366 UChar* currency,
00367 UChar* result,
00368 int32_t resultLength,
00369 UFieldPosition* pos,
00370 UErrorCode* status);
00371
00389 U_STABLE int32_t U_EXPORT2
00390 unum_parse( const UNumberFormat* fmt,
00391 const UChar* text,
00392 int32_t textLength,
00393 int32_t *parsePos ,
00394 UErrorCode *status);
00395
00413 U_STABLE int64_t U_EXPORT2
00414 unum_parseInt64(const UNumberFormat* fmt,
00415 const UChar* text,
00416 int32_t textLength,
00417 int32_t *parsePos ,
00418 UErrorCode *status);
00419
00437 U_STABLE double U_EXPORT2
00438 unum_parseDouble( const UNumberFormat* fmt,
00439 const UChar* text,
00440 int32_t textLength,
00441 int32_t *parsePos ,
00442 UErrorCode *status);
00443
00463 U_STABLE double U_EXPORT2
00464 unum_parseDoubleCurrency(const UNumberFormat* fmt,
00465 const UChar* text,
00466 int32_t textLength,
00467 int32_t* parsePos,
00468 UChar* currency,
00469 UErrorCode* status);
00470
00487 U_STABLE void U_EXPORT2
00488 unum_applyPattern( UNumberFormat *format,
00489 UBool localized,
00490 const UChar *pattern,
00491 int32_t patternLength,
00492 UParseError *parseError,
00493 UErrorCode *status
00494 );
00495
00506 U_STABLE const char* U_EXPORT2
00507 unum_getAvailable(int32_t index);
00508
00518 U_STABLE int32_t U_EXPORT2
00519 unum_countAvailable(void);
00520
00522 typedef enum UNumberFormatAttribute {
00524 UNUM_PARSE_INT_ONLY,
00526 UNUM_GROUPING_USED,
00528 UNUM_DECIMAL_ALWAYS_SHOWN,
00530 UNUM_MAX_INTEGER_DIGITS,
00532 UNUM_MIN_INTEGER_DIGITS,
00534 UNUM_INTEGER_DIGITS,
00536 UNUM_MAX_FRACTION_DIGITS,
00538 UNUM_MIN_FRACTION_DIGITS,
00540 UNUM_FRACTION_DIGITS,
00542 UNUM_MULTIPLIER,
00544 UNUM_GROUPING_SIZE,
00546 UNUM_ROUNDING_MODE,
00548 UNUM_ROUNDING_INCREMENT,
00550 UNUM_FORMAT_WIDTH,
00552 UNUM_PADDING_POSITION,
00554 UNUM_SECONDARY_GROUPING_SIZE,
00557 UNUM_SIGNIFICANT_DIGITS_USED,
00560 UNUM_MIN_SIGNIFICANT_DIGITS,
00563 UNUM_MAX_SIGNIFICANT_DIGITS,
00567 UNUM_LENIENT_PARSE
00568 } UNumberFormatAttribute;
00569
00586 U_STABLE int32_t U_EXPORT2
00587 unum_getAttribute(const UNumberFormat* fmt,
00588 UNumberFormatAttribute attr);
00589
00609 U_STABLE void U_EXPORT2
00610 unum_setAttribute( UNumberFormat* fmt,
00611 UNumberFormatAttribute attr,
00612 int32_t newValue);
00613
00614
00629 U_STABLE double U_EXPORT2
00630 unum_getDoubleAttribute(const UNumberFormat* fmt,
00631 UNumberFormatAttribute attr);
00632
00647 U_STABLE void U_EXPORT2
00648 unum_setDoubleAttribute( UNumberFormat* fmt,
00649 UNumberFormatAttribute attr,
00650 double newValue);
00651
00653 typedef enum UNumberFormatTextAttribute {
00655 UNUM_POSITIVE_PREFIX,
00657 UNUM_POSITIVE_SUFFIX,
00659 UNUM_NEGATIVE_PREFIX,
00661 UNUM_NEGATIVE_SUFFIX,
00663 UNUM_PADDING_CHARACTER,
00665 UNUM_CURRENCY_CODE,
00670 UNUM_DEFAULT_RULESET,
00677 UNUM_PUBLIC_RULESETS
00678 } UNumberFormatTextAttribute;
00679
00698 U_STABLE int32_t U_EXPORT2
00699 unum_getTextAttribute( const UNumberFormat* fmt,
00700 UNumberFormatTextAttribute tag,
00701 UChar* result,
00702 int32_t resultLength,
00703 UErrorCode* status);
00704
00721 U_STABLE void U_EXPORT2
00722 unum_setTextAttribute( UNumberFormat* fmt,
00723 UNumberFormatTextAttribute tag,
00724 const UChar* newValue,
00725 int32_t newValueLength,
00726 UErrorCode *status);
00727
00744 U_STABLE int32_t U_EXPORT2
00745 unum_toPattern( const UNumberFormat* fmt,
00746 UBool isPatternLocalized,
00747 UChar* result,
00748 int32_t resultLength,
00749 UErrorCode* status);
00750
00751
00756 typedef enum UNumberFormatSymbol {
00758 UNUM_DECIMAL_SEPARATOR_SYMBOL = 0,
00760 UNUM_GROUPING_SEPARATOR_SYMBOL = 1,
00762 UNUM_PATTERN_SEPARATOR_SYMBOL = 2,
00764 UNUM_PERCENT_SYMBOL = 3,
00766 UNUM_ZERO_DIGIT_SYMBOL = 4,
00768 UNUM_DIGIT_SYMBOL = 5,
00770 UNUM_MINUS_SIGN_SYMBOL = 6,
00772 UNUM_PLUS_SIGN_SYMBOL = 7,
00774 UNUM_CURRENCY_SYMBOL = 8,
00776 UNUM_INTL_CURRENCY_SYMBOL = 9,
00778 UNUM_MONETARY_SEPARATOR_SYMBOL = 10,
00780 UNUM_EXPONENTIAL_SYMBOL = 11,
00782 UNUM_PERMILL_SYMBOL = 12,
00784 UNUM_PAD_ESCAPE_SYMBOL = 13,
00786 UNUM_INFINITY_SYMBOL = 14,
00788 UNUM_NAN_SYMBOL = 15,
00791 UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16,
00792
00793 #ifndef U_HIDE_DRAFT_API
00794
00797 UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17,
00798 #endif
00799
00801 UNUM_FORMAT_SYMBOL_COUNT = 18
00802 } UNumberFormatSymbol;
00803
00820 U_STABLE int32_t U_EXPORT2
00821 unum_getSymbol(const UNumberFormat *fmt,
00822 UNumberFormatSymbol symbol,
00823 UChar *buffer,
00824 int32_t size,
00825 UErrorCode *status);
00826
00840 U_STABLE void U_EXPORT2
00841 unum_setSymbol(UNumberFormat *fmt,
00842 UNumberFormatSymbol symbol,
00843 const UChar *value,
00844 int32_t length,
00845 UErrorCode *status);
00846
00847
00857 U_STABLE const char* U_EXPORT2
00858 unum_getLocaleByType(const UNumberFormat *fmt,
00859 ULocDataLocaleType type,
00860 UErrorCode* status);
00861
00862 #endif
00863
00864 #endif