00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _UNUM
00012 #define _UNUM
00013
00014 #include "unicode/utypes.h"
00015
00016 #if !UCONFIG_NO_FORMATTING
00017
00018 #include "unicode/umisc.h"
00019 #include "unicode/parseerr.h"
00123 typedef void* UNumberFormat;
00124
00128 typedef enum UNumberFormatStyle {
00130 UNUM_IGNORE=0,
00132 UNUM_DECIMAL=1,
00134 UNUM_CURRENCY,
00136 UNUM_PERCENT,
00138 UNUM_SCIENTIFIC,
00140 UNUM_SPELLOUT,
00142 UNUM_DEFAULT = UNUM_DECIMAL
00143 } UNumberFormatStyle;
00144
00148 typedef enum UNumberFormatRoundingMode {
00149 UNUM_ROUND_CEILING,
00150 UNUM_ROUND_FLOOR,
00151 UNUM_ROUND_DOWN,
00152 UNUM_ROUND_UP,
00153 UNUM_FOUND_HALFEVEN,
00154 UNUM_ROUND_HALFDOWN,
00155 UNUM_ROUND_HALFUP
00156 } UNumberFormatRoundingMode;
00157
00161 typedef enum UNumberFormatPadPosition {
00162 UNUM_PAD_BEFORE_PREFIX,
00163 UNUM_PAD_AFTER_PREFIX,
00164 UNUM_PAD_BEFORE_SUFFIX,
00165 UNUM_PAD_AFTER_SUFFIX
00166 } UNumberFormatPadPosition;
00167
00187 U_CAPI UNumberFormat* U_EXPORT2
00188 unum_open( UNumberFormatStyle style,
00189 const UChar* pattern,
00190 int32_t patternLength,
00191 const char* locale,
00192 UParseError* parseErr,
00193 UErrorCode* status);
00194
00195
00202 U_CAPI void U_EXPORT2
00203 unum_close(UNumberFormat* fmt);
00204
00213 U_CAPI UNumberFormat* U_EXPORT2
00214 unum_clone(const UNumberFormat *fmt,
00215 UErrorCode *status);
00216
00236 U_CAPI int32_t U_EXPORT2
00237 unum_format( const UNumberFormat* fmt,
00238 int32_t number,
00239 UChar* result,
00240 int32_t resultLength,
00241 UFieldPosition *pos,
00242 UErrorCode* status);
00243
00263 U_CAPI int32_t U_EXPORT2
00264 unum_formatDouble( const UNumberFormat* fmt,
00265 double number,
00266 UChar* result,
00267 int32_t resultLength,
00268 UFieldPosition *pos,
00269 UErrorCode* status);
00270
00286 U_CAPI int32_t U_EXPORT2
00287 unum_parse( const UNumberFormat* fmt,
00288 const UChar* text,
00289 int32_t textLength,
00290 int32_t *parsePos ,
00291 UErrorCode *status);
00292
00308 U_CAPI double U_EXPORT2
00309 unum_parseDouble( const UNumberFormat* fmt,
00310 const UChar* text,
00311 int32_t textLength,
00312 int32_t *parsePos ,
00313 UErrorCode *status);
00314
00328 U_CAPI void U_EXPORT2
00329 unum_applyPattern( UNumberFormat *format,
00330 UBool localized,
00331 const UChar *pattern,
00332 int32_t patternLength,
00333 UParseError *parseError,
00334 UErrorCode *status
00335 );
00336
00346 U_CAPI const char* U_EXPORT2
00347 unum_getAvailable(int32_t index);
00348
00357 U_CAPI int32_t U_EXPORT2
00358 unum_countAvailable(void);
00359
00361 typedef enum UNumberFormatAttribute {
00363 UNUM_PARSE_INT_ONLY,
00365 UNUM_GROUPING_USED,
00367 UNUM_DECIMAL_ALWAYS_SHOWN,
00369 UNUM_MAX_INTEGER_DIGITS,
00371 UNUM_MIN_INTEGER_DIGITS,
00373 UNUM_INTEGER_DIGITS,
00375 UNUM_MAX_FRACTION_DIGITS,
00377 UNUM_MIN_FRACTION_DIGITS,
00379 UNUM_FRACTION_DIGITS,
00381 UNUM_MULTIPLIER,
00383 UNUM_GROUPING_SIZE,
00385 UNUM_ROUNDING_MODE,
00387 UNUM_ROUNDING_INCREMENT,
00389 UNUM_FORMAT_WIDTH,
00391 UNUM_PADDING_POSITION,
00393 UNUM_SECONDARY_GROUPING_SIZE
00394 } UNumberFormatAttribute;
00395
00412 U_CAPI int32_t U_EXPORT2
00413 unum_getAttribute(const UNumberFormat* fmt,
00414 UNumberFormatAttribute attr);
00415
00432 U_CAPI void U_EXPORT2
00433 unum_setAttribute( UNumberFormat* fmt,
00434 UNumberFormatAttribute attr,
00435 int32_t newValue);
00436
00437
00451 U_CAPI double U_EXPORT2
00452 unum_getDoubleAttribute(const UNumberFormat* fmt,
00453 UNumberFormatAttribute attr);
00454
00468 U_CAPI void U_EXPORT2
00469 unum_setDoubleAttribute( UNumberFormat* fmt,
00470 UNumberFormatAttribute attr,
00471 double newValue);
00472
00474 typedef enum UNumberFormatTextAttribute {
00476 UNUM_POSITIVE_PREFIX,
00478 UNUM_POSITIVE_SUFFIX,
00480 UNUM_NEGATIVE_PREFIX,
00482 UNUM_NEGATIVE_SUFFIX,
00484 UNUM_PADDING_CHARACTER,
00486 UNUM_CURRENCY_CODE
00487 } UNumberFormatTextAttribute;
00488
00504 U_CAPI int32_t U_EXPORT2
00505 unum_getTextAttribute( const UNumberFormat* fmt,
00506 UNumberFormatTextAttribute tag,
00507 UChar* result,
00508 int32_t resultLength,
00509 UErrorCode* status);
00510
00525 U_CAPI void U_EXPORT2
00526 unum_setTextAttribute( UNumberFormat* fmt,
00527 UNumberFormatTextAttribute tag,
00528 const UChar* newValue,
00529 int32_t newValueLength,
00530 UErrorCode *status);
00531
00543 U_CAPI int32_t U_EXPORT2
00544 unum_toPattern( const UNumberFormat* fmt,
00545 UBool isPatternLocalized,
00546 UChar* result,
00547 int32_t resultLength,
00548 UErrorCode* status);
00549
00551 #define UNFSYMBOLSMAXSIZE 10
00552
00557 typedef enum UNumberFormatSymbol {
00559 UNUM_DECIMAL_SEPARATOR_SYMBOL,
00561 UNUM_GROUPING_SEPARATOR_SYMBOL,
00563 UNUM_PATTERN_SEPARATOR_SYMBOL,
00565 UNUM_PERCENT_SYMBOL,
00567 UNUM_ZERO_DIGIT_SYMBOL,
00569 UNUM_DIGIT_SYMBOL,
00571 UNUM_MINUS_SIGN_SYMBOL,
00573 UNUM_PLUS_SIGN_SYMBOL,
00575 UNUM_CURRENCY_SYMBOL,
00577 UNUM_INTL_CURRENCY_SYMBOL,
00579 UNUM_MONETARY_SEPARATOR_SYMBOL,
00581 UNUM_EXPONENTIAL_SYMBOL,
00583 UNUM_PERMILL_SYMBOL,
00585 UNUM_PAD_ESCAPE_SYMBOL,
00587 UNUM_INFINITY_SYMBOL,
00589 UNUM_NAN_SYMBOL,
00591 UNUM_FORMAT_SYMBOL_COUNT
00592 } UNumberFormatSymbol;
00593
00609 U_CAPI int32_t U_EXPORT2
00610 unum_getSymbol(UNumberFormat *fmt,
00611 UNumberFormatSymbol symbol,
00612 UChar *buffer,
00613 int32_t size,
00614 UErrorCode *status);
00615
00628 U_CAPI void U_EXPORT2
00629 unum_setSymbol(UNumberFormat *fmt,
00630 UNumberFormatSymbol symbol,
00631 const UChar *value,
00632 int32_t length,
00633 UErrorCode *status);
00634
00635
00636
00640 #ifdef U_USE_DEPRECATED_FORMAT_API
00641
00642 #if ((U_ICU_VERSION_MAJOR_NUM != 2) || (U_ICU_VERSION_MINOR_NUM != 2))
00643 # error "ICU version has changed. Please redefine the macros under U_USE_DEPRECATED_FORMAT_API pre-processor definition"
00644 #else
00645 static UNumberFormat*
00646 unum_openPattern(const UChar* pattern, int32_t patternLength,const char* locale,UErrorCode* status)
00647 {
00648 return unum_open(0,pattern,patternLength,locale,NULL,status);
00649 }
00650
00651 # define unum_open_2_2(style,locale,status) unum_open(style, NULL, 0, locale, NULL, status)
00652 # define unum_applyPattern_2_2(format,localized,pattern,patternLength) unum_applyPattern(format,localized,pattern,patternLength,NULL,NULL)
00653 #endif
00654
00655 #endif
00656
00657
00658 #endif
00659
00660 #endif