00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _UNUM
00012 #define _UNUM
00013
00014 #include "unicode/utypes.h"
00015 #include "unicode/umisc.h"
00016 #include "unicode/parseerr.h"
00114 typedef void* UNumberFormat;
00115
00117 enum UNumberFormatStyle {
00119 UNUM_IGNORE=0,
00121 UNUM_DECIMAL=1,
00123 UNUM_CURRENCY,
00125 UNUM_PERCENT,
00127 UNUM_SPELLOUT,
00129 UNUM_DEFAULT = UNUM_DECIMAL
00130 };
00131 typedef enum UNumberFormatStyle UNumberFormatStyle;
00132
00133 enum UNumberFormatRoundingMode {
00134 UNUM_ROUND_CEILING,
00135 UNUM_ROUND_FLOOR,
00136 UNUM_ROUND_DOWN,
00137 UNUM_ROUND_UP,
00138 UNUM_FOUND_HALFEVEN,
00139 UNUM_ROUND_HALFDOWN,
00140 UNUM_ROUND_HALFUP
00141 };
00142 typedef enum UNumberFormatRoundingMode UNumberFormatRoundingMode;
00143
00144 enum UNumberFormatPadPosition {
00145 UNUM_PAD_BEFORE_PREFIX,
00146 UNUM_PAD_AFTER_PREFIX,
00147 UNUM_PAD_BEFORE_SUFFIX,
00148 UNUM_PAD_AFTER_SUFFIX
00149 };
00150 typedef enum UNumberFormatPadPosition UNumberFormatPadPosition;
00151
00168 U_CAPI UNumberFormat* U_EXPORT2
00169 unum_open( UNumberFormatStyle style,
00170 const UChar* pattern,
00171 int32_t patternLength,
00172 const char* locale,
00173 UParseError* parseErr,
00174 UErrorCode* status);
00175
00176
00183 U_CAPI void U_EXPORT2
00184 unum_close(UNumberFormat* fmt);
00185
00194 U_CAPI UNumberFormat* U_EXPORT2
00195 unum_clone(const UNumberFormat *fmt,
00196 UErrorCode *status);
00197
00217 U_CAPI int32_t U_EXPORT2
00218 unum_format( const UNumberFormat* fmt,
00219 int32_t number,
00220 UChar* result,
00221 int32_t resultLength,
00222 UFieldPosition *pos,
00223 UErrorCode* status);
00224
00244 U_CAPI int32_t U_EXPORT2
00245 unum_formatDouble( const UNumberFormat* fmt,
00246 double number,
00247 UChar* result,
00248 int32_t resultLength,
00249 UFieldPosition *pos,
00250 UErrorCode* status);
00251
00267 U_CAPI int32_t U_EXPORT2
00268 unum_parse( const UNumberFormat* fmt,
00269 const UChar* text,
00270 int32_t textLength,
00271 int32_t *parsePos ,
00272 UErrorCode *status);
00273
00289 U_CAPI double U_EXPORT2
00290 unum_parseDouble( const UNumberFormat* fmt,
00291 const UChar* text,
00292 int32_t textLength,
00293 int32_t *parsePos ,
00294 UErrorCode *status);
00295
00326 U_CAPI void U_EXPORT2
00327 unum_applyPattern( UNumberFormat *format,
00328 UBool localized,
00329 const UChar *pattern,
00330 int32_t patternLength,
00331 UParseError *parseError,
00332 UErrorCode *status
00333 );
00334
00344 U_CAPI const char* U_EXPORT2
00345 unum_getAvailable(int32_t index);
00346
00355 U_CAPI int32_t U_EXPORT2
00356 unum_countAvailable(void);
00357
00359 enum UNumberFormatAttribute {
00361 UNUM_PARSE_INT_ONLY,
00363 UNUM_GROUPING_USED,
00365 UNUM_DECIMAL_ALWAYS_SHOWN,
00367 UNUM_MAX_INTEGER_DIGITS,
00369 UNUM_MIN_INTEGER_DIGITS,
00371 UNUM_INTEGER_DIGITS,
00373 UNUM_MAX_FRACTION_DIGITS,
00375 UNUM_MIN_FRACTION_DIGITS,
00377 UNUM_FRACTION_DIGITS,
00379 UNUM_MULTIPLIER,
00381 UNUM_GROUPING_SIZE,
00383 UNUM_ROUNDING_MODE,
00385 UNUM_ROUNDING_INCREMENT,
00387 UNUM_FORMAT_WIDTH,
00389 UNUM_PADDING_POSITION,
00391 UNUM_SECONDARY_GROUPING_SIZE
00392 };
00393 typedef enum UNumberFormatAttribute UNumberFormatAttribute;
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00422 U_CAPI int32_t U_EXPORT2
00423 unum_getAttribute(const UNumberFormat* fmt,
00424 UNumberFormatAttribute attr);
00425
00442 U_CAPI void U_EXPORT2
00443 unum_setAttribute( UNumberFormat* fmt,
00444 UNumberFormatAttribute attr,
00445 int32_t newValue);
00446
00447
00461 U_CAPI double U_EXPORT2
00462 unum_getDoubleAttribute(const UNumberFormat* fmt,
00463 UNumberFormatAttribute attr);
00464
00478 U_CAPI void U_EXPORT2
00479 unum_setDoubleAttribute( UNumberFormat* fmt,
00480 UNumberFormatAttribute attr,
00481 double newValue);
00482
00484 enum UNumberFormatTextAttribute{
00486 UNUM_POSITIVE_PREFIX,
00488 UNUM_POSITIVE_SUFFIX,
00490 UNUM_NEGATIVE_PREFIX,
00492 UNUM_NEGATIVE_SUFFIX,
00494 UNUM_PADDING_CHARACTER
00495 };
00496 typedef enum UNumberFormatTextAttribute UNumberFormatTextAttribute;
00497
00513 U_CAPI int32_t U_EXPORT2
00514 unum_getTextAttribute( const UNumberFormat* fmt,
00515 UNumberFormatTextAttribute tag,
00516 UChar* result,
00517 int32_t resultLength,
00518 UErrorCode* status);
00519
00534 U_CAPI void U_EXPORT2
00535 unum_setTextAttribute( UNumberFormat* fmt,
00536 UNumberFormatTextAttribute tag,
00537 const UChar* newValue,
00538 int32_t newValueLength,
00539 UErrorCode *status);
00540
00552 U_CAPI int32_t U_EXPORT2
00553 unum_toPattern( const UNumberFormat* fmt,
00554 UBool isPatternLocalized,
00555 UChar* result,
00556 int32_t resultLength,
00557 UErrorCode* status);
00558
00559
00560 #define UNFSYMBOLSMAXSIZE 10
00561
00562 #ifdef ICU_DECIMALFORMATSYMBOLS_USE_DEPRECATES
00563
00566 struct UNumberFormatSymbols{
00568 UChar decimalSeparator;
00570 UChar groupingSeparator;
00572 UChar patternSeparator;
00574 UChar percent;
00576 UChar zeroDigit;
00578 UChar digit;
00580 UChar minusSign;
00582 UChar plusSign;
00584 UChar currency [UNFSYMBOLSMAXSIZE];
00586 UChar intlCurrency [UNFSYMBOLSMAXSIZE];
00588 UChar monetarySeparator;
00590 UChar exponential;
00592 UChar perMill;
00594 UChar padEscape;
00596 UChar infinity [UNFSYMBOLSMAXSIZE];
00598 UChar naN [UNFSYMBOLSMAXSIZE];
00599 };
00600 typedef struct UNumberFormatSymbols UNumberFormatSymbols;
00601
00611 U_CAPI void U_EXPORT2
00612 unum_getSymbols( const UNumberFormat *fmt,
00613 UNumberFormatSymbols *syms);
00614
00625 U_CAPI void U_EXPORT2
00626 unum_setSymbols( UNumberFormat* fmt,
00627 const UNumberFormatSymbols* symbolsToSet,
00628 UErrorCode *status);
00629 #endif
00630
00635 enum UNumberFormatSymbol {
00637 UNUM_DECIMAL_SEPARATOR_SYMBOL,
00639 UNUM_GROUPING_SEPARATOR_SYMBOL,
00641 UNUM_PATTERN_SEPARATOR_SYMBOL,
00643 UNUM_PERCENT_SYMBOL,
00645 UNUM_ZERO_DIGIT_SYMBOL,
00647 UNUM_DIGIT_SYMBOL,
00649 UNUM_MINUS_SIGN_SYMBOL,
00651 UNUM_PLUS_SIGN_SYMBOL,
00653 UNUM_CURRENCY_SYMBOL,
00655 UNUM_INTL_CURRENCY_SYMBOL,
00657 UNUM_MONETARY_SEPARATOR_SYMBOL,
00659 UNUM_EXPONENTIAL_SYMBOL,
00661 UNUM_PERMILL_SYMBOL,
00663 UNUM_PAD_ESCAPE_SYMBOL,
00665 UNUM_INFINITY_SYMBOL,
00667 UNUM_NAN_SYMBOL,
00669 UNUM_FORMAT_SYMBOL_COUNT
00670 };
00671 typedef enum UNumberFormatSymbol UNumberFormatSymbol;
00672
00687 U_CAPI int32_t U_EXPORT2
00688 unum_getSymbol(UNumberFormat *fmt,
00689 UNumberFormatSymbol symbol,
00690 UChar *buffer,
00691 int32_t size,
00692 UErrorCode *status);
00693
00706 U_CAPI void U_EXPORT2
00707 unum_setSymbol(UNumberFormat *fmt,
00708 UNumberFormatSymbol symbol,
00709 const UChar *value,
00710 int32_t length,
00711 UErrorCode *status);
00712
00713
00714
00718 #ifdef U_USE_DEPRECATED_FORMAT_API
00719
00720 #if ((U_ICU_VERSION_MAJOR_NUM != 2) || (U_ICU_VERSION_MINOR_NUM !=0))
00721 # error "ICU version has changed. Please redefine the macros under U_USE_DEPRECATED_FORMAT_API pre-processor definition"
00722 #else
00723 static UNumberFormat*
00724 unum_openPattern(const UChar* pattern, int32_t patternLength,const char* locale,UErrorCode* status)
00725 {
00726 return unum_open(0,pattern,patternLength,locale,NULL,status);
00727 }
00728
00729 # define unum_open_2_0(style,locale,status) unum_open(style, NULL, 0, locale, NULL, status)
00730 # define unum_applyPattern_2_0(format,localized,pattern,patternLength) unum_applyPattern(format,localized,pattern,patternLength,NULL,NULL)
00731 #endif
00732
00733 #endif
00734
00735
00736 #endif