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"
00118 typedef void* UNumberFormat;
00119
00123 typedef enum UNumberFormatStyle {
00125 UNUM_IGNORE=0,
00127 UNUM_DECIMAL=1,
00129 UNUM_CURRENCY,
00131 UNUM_PERCENT,
00133 UNUM_SCIENTIFIC,
00135 UNUM_SPELLOUT,
00137 UNUM_DEFAULT = UNUM_DECIMAL
00138 } UNumberFormatStyle;
00139
00143 typedef enum UNumberFormatRoundingMode {
00144 UNUM_ROUND_CEILING,
00145 UNUM_ROUND_FLOOR,
00146 UNUM_ROUND_DOWN,
00147 UNUM_ROUND_UP,
00148 UNUM_FOUND_HALFEVEN,
00149 UNUM_ROUND_HALFDOWN,
00150 UNUM_ROUND_HALFUP
00151 } UNumberFormatRoundingMode;
00152
00156 typedef enum UNumberFormatPadPosition {
00157 UNUM_PAD_BEFORE_PREFIX,
00158 UNUM_PAD_AFTER_PREFIX,
00159 UNUM_PAD_BEFORE_SUFFIX,
00160 UNUM_PAD_AFTER_SUFFIX
00161 } UNumberFormatPadPosition;
00162
00182 U_CAPI UNumberFormat* U_EXPORT2
00183 unum_open( UNumberFormatStyle style,
00184 const UChar* pattern,
00185 int32_t patternLength,
00186 const char* locale,
00187 UParseError* parseErr,
00188 UErrorCode* status);
00189
00190
00197 U_CAPI void U_EXPORT2
00198 unum_close(UNumberFormat* fmt);
00199
00208 U_CAPI UNumberFormat* U_EXPORT2
00209 unum_clone(const UNumberFormat *fmt,
00210 UErrorCode *status);
00211
00231 U_CAPI int32_t U_EXPORT2
00232 unum_format( const UNumberFormat* fmt,
00233 int32_t number,
00234 UChar* result,
00235 int32_t resultLength,
00236 UFieldPosition *pos,
00237 UErrorCode* status);
00238
00258 U_CAPI int32_t U_EXPORT2
00259 unum_formatDouble( const UNumberFormat* fmt,
00260 double number,
00261 UChar* result,
00262 int32_t resultLength,
00263 UFieldPosition *pos,
00264 UErrorCode* status);
00265
00281 U_CAPI int32_t U_EXPORT2
00282 unum_parse( const UNumberFormat* fmt,
00283 const UChar* text,
00284 int32_t textLength,
00285 int32_t *parsePos ,
00286 UErrorCode *status);
00287
00303 U_CAPI double U_EXPORT2
00304 unum_parseDouble( const UNumberFormat* fmt,
00305 const UChar* text,
00306 int32_t textLength,
00307 int32_t *parsePos ,
00308 UErrorCode *status);
00309
00322 U_CAPI void U_EXPORT2
00323 unum_applyPattern( UNumberFormat *format,
00324 UBool localized,
00325 const UChar *pattern,
00326 int32_t patternLength,
00327 UParseError *parseError,
00328 UErrorCode *status
00329 );
00330
00340 U_CAPI const char* U_EXPORT2
00341 unum_getAvailable(int32_t index);
00342
00351 U_CAPI int32_t U_EXPORT2
00352 unum_countAvailable(void);
00353
00355 typedef enum UNumberFormatAttribute {
00357 UNUM_PARSE_INT_ONLY,
00359 UNUM_GROUPING_USED,
00361 UNUM_DECIMAL_ALWAYS_SHOWN,
00363 UNUM_MAX_INTEGER_DIGITS,
00365 UNUM_MIN_INTEGER_DIGITS,
00367 UNUM_INTEGER_DIGITS,
00369 UNUM_MAX_FRACTION_DIGITS,
00371 UNUM_MIN_FRACTION_DIGITS,
00373 UNUM_FRACTION_DIGITS,
00375 UNUM_MULTIPLIER,
00377 UNUM_GROUPING_SIZE,
00379 UNUM_ROUNDING_MODE,
00381 UNUM_ROUNDING_INCREMENT,
00383 UNUM_FORMAT_WIDTH,
00385 UNUM_PADDING_POSITION,
00387 UNUM_SECONDARY_GROUPING_SIZE
00388 } UNumberFormatAttribute;
00389
00406 U_CAPI int32_t U_EXPORT2
00407 unum_getAttribute(const UNumberFormat* fmt,
00408 UNumberFormatAttribute attr);
00409
00426 U_CAPI void U_EXPORT2
00427 unum_setAttribute( UNumberFormat* fmt,
00428 UNumberFormatAttribute attr,
00429 int32_t newValue);
00430
00431
00445 U_CAPI double U_EXPORT2
00446 unum_getDoubleAttribute(const UNumberFormat* fmt,
00447 UNumberFormatAttribute attr);
00448
00462 U_CAPI void U_EXPORT2
00463 unum_setDoubleAttribute( UNumberFormat* fmt,
00464 UNumberFormatAttribute attr,
00465 double newValue);
00466
00468 typedef enum UNumberFormatTextAttribute {
00470 UNUM_POSITIVE_PREFIX,
00472 UNUM_POSITIVE_SUFFIX,
00474 UNUM_NEGATIVE_PREFIX,
00476 UNUM_NEGATIVE_SUFFIX,
00478 UNUM_PADDING_CHARACTER,
00480 UNUM_CURRENCY_CODE
00481 } UNumberFormatTextAttribute;
00482
00498 U_CAPI int32_t U_EXPORT2
00499 unum_getTextAttribute( const UNumberFormat* fmt,
00500 UNumberFormatTextAttribute tag,
00501 UChar* result,
00502 int32_t resultLength,
00503 UErrorCode* status);
00504
00519 U_CAPI void U_EXPORT2
00520 unum_setTextAttribute( UNumberFormat* fmt,
00521 UNumberFormatTextAttribute tag,
00522 const UChar* newValue,
00523 int32_t newValueLength,
00524 UErrorCode *status);
00525
00537 U_CAPI int32_t U_EXPORT2
00538 unum_toPattern( const UNumberFormat* fmt,
00539 UBool isPatternLocalized,
00540 UChar* result,
00541 int32_t resultLength,
00542 UErrorCode* status);
00543
00545 #define UNFSYMBOLSMAXSIZE 10
00546
00551 typedef enum UNumberFormatSymbol {
00553 UNUM_DECIMAL_SEPARATOR_SYMBOL,
00555 UNUM_GROUPING_SEPARATOR_SYMBOL,
00557 UNUM_PATTERN_SEPARATOR_SYMBOL,
00559 UNUM_PERCENT_SYMBOL,
00561 UNUM_ZERO_DIGIT_SYMBOL,
00563 UNUM_DIGIT_SYMBOL,
00565 UNUM_MINUS_SIGN_SYMBOL,
00567 UNUM_PLUS_SIGN_SYMBOL,
00569 UNUM_CURRENCY_SYMBOL,
00571 UNUM_INTL_CURRENCY_SYMBOL,
00573 UNUM_MONETARY_SEPARATOR_SYMBOL,
00575 UNUM_EXPONENTIAL_SYMBOL,
00577 UNUM_PERMILL_SYMBOL,
00579 UNUM_PAD_ESCAPE_SYMBOL,
00581 UNUM_INFINITY_SYMBOL,
00583 UNUM_NAN_SYMBOL,
00585 UNUM_FORMAT_SYMBOL_COUNT
00586 } UNumberFormatSymbol;
00587
00602 U_CAPI int32_t U_EXPORT2
00603 unum_getSymbol(UNumberFormat *fmt,
00604 UNumberFormatSymbol symbol,
00605 UChar *buffer,
00606 int32_t size,
00607 UErrorCode *status);
00608
00621 U_CAPI void U_EXPORT2
00622 unum_setSymbol(UNumberFormat *fmt,
00623 UNumberFormatSymbol symbol,
00624 const UChar *value,
00625 int32_t length,
00626 UErrorCode *status);
00627
00628
00629
00633 #ifdef U_USE_DEPRECATED_FORMAT_API
00634
00635 #if ((U_ICU_VERSION_MAJOR_NUM != 2) || (U_ICU_VERSION_MINOR_NUM != 2))
00636 # error "ICU version has changed. Please redefine the macros under U_USE_DEPRECATED_FORMAT_API pre-processor definition"
00637 #else
00638 static UNumberFormat*
00639 unum_openPattern(const UChar* pattern, int32_t patternLength,const char* locale,UErrorCode* status)
00640 {
00641 return unum_open(0,pattern,patternLength,locale,NULL,status);
00642 }
00643
00644 # define unum_open_2_2(style,locale,status) unum_open(style, NULL, 0, locale, NULL, status)
00645 # define unum_applyPattern_2_2(format,localized,pattern,patternLength) unum_applyPattern(format,localized,pattern,patternLength,NULL,NULL)
00646 #endif
00647
00648 #endif
00649
00650
00651 #endif
00652
00653 #endif