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_SCIENTIFIC,
00129 UNUM_SPELLOUT,
00131 UNUM_DEFAULT = UNUM_DECIMAL
00132 };
00133 typedef enum UNumberFormatStyle UNumberFormatStyle;
00134
00135 enum UNumberFormatRoundingMode {
00136 UNUM_ROUND_CEILING,
00137 UNUM_ROUND_FLOOR,
00138 UNUM_ROUND_DOWN,
00139 UNUM_ROUND_UP,
00140 UNUM_FOUND_HALFEVEN,
00141 UNUM_ROUND_HALFDOWN,
00142 UNUM_ROUND_HALFUP
00143 };
00144 typedef enum UNumberFormatRoundingMode UNumberFormatRoundingMode;
00145
00146 enum UNumberFormatPadPosition {
00147 UNUM_PAD_BEFORE_PREFIX,
00148 UNUM_PAD_AFTER_PREFIX,
00149 UNUM_PAD_BEFORE_SUFFIX,
00150 UNUM_PAD_AFTER_SUFFIX
00151 };
00152 typedef enum UNumberFormatPadPosition UNumberFormatPadPosition;
00153
00173 U_CAPI UNumberFormat* U_EXPORT2
00174 unum_open( UNumberFormatStyle style,
00175 const UChar* pattern,
00176 int32_t patternLength,
00177 const char* locale,
00178 UParseError* parseErr,
00179 UErrorCode* status);
00180
00181
00188 U_CAPI void U_EXPORT2
00189 unum_close(UNumberFormat* fmt);
00190
00199 U_CAPI UNumberFormat* U_EXPORT2
00200 unum_clone(const UNumberFormat *fmt,
00201 UErrorCode *status);
00202
00222 U_CAPI int32_t U_EXPORT2
00223 unum_format( const UNumberFormat* fmt,
00224 int32_t number,
00225 UChar* result,
00226 int32_t resultLength,
00227 UFieldPosition *pos,
00228 UErrorCode* status);
00229
00249 U_CAPI int32_t U_EXPORT2
00250 unum_formatDouble( const UNumberFormat* fmt,
00251 double number,
00252 UChar* result,
00253 int32_t resultLength,
00254 UFieldPosition *pos,
00255 UErrorCode* status);
00256
00272 U_CAPI int32_t U_EXPORT2
00273 unum_parse( const UNumberFormat* fmt,
00274 const UChar* text,
00275 int32_t textLength,
00276 int32_t *parsePos ,
00277 UErrorCode *status);
00278
00294 U_CAPI double U_EXPORT2
00295 unum_parseDouble( const UNumberFormat* fmt,
00296 const UChar* text,
00297 int32_t textLength,
00298 int32_t *parsePos ,
00299 UErrorCode *status);
00300
00331 U_CAPI void U_EXPORT2
00332 unum_applyPattern( UNumberFormat *format,
00333 UBool localized,
00334 const UChar *pattern,
00335 int32_t patternLength,
00336 UParseError *parseError,
00337 UErrorCode *status
00338 );
00339
00349 U_CAPI const char* U_EXPORT2
00350 unum_getAvailable(int32_t index);
00351
00360 U_CAPI int32_t U_EXPORT2
00361 unum_countAvailable(void);
00362
00364 enum UNumberFormatAttribute {
00366 UNUM_PARSE_INT_ONLY,
00368 UNUM_GROUPING_USED,
00370 UNUM_DECIMAL_ALWAYS_SHOWN,
00372 UNUM_MAX_INTEGER_DIGITS,
00374 UNUM_MIN_INTEGER_DIGITS,
00376 UNUM_INTEGER_DIGITS,
00378 UNUM_MAX_FRACTION_DIGITS,
00380 UNUM_MIN_FRACTION_DIGITS,
00382 UNUM_FRACTION_DIGITS,
00384 UNUM_MULTIPLIER,
00386 UNUM_GROUPING_SIZE,
00388 UNUM_ROUNDING_MODE,
00390 UNUM_ROUNDING_INCREMENT,
00392 UNUM_FORMAT_WIDTH,
00394 UNUM_PADDING_POSITION,
00396 UNUM_SECONDARY_GROUPING_SIZE
00397 };
00398 typedef enum UNumberFormatAttribute UNumberFormatAttribute;
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00427 U_CAPI int32_t U_EXPORT2
00428 unum_getAttribute(const UNumberFormat* fmt,
00429 UNumberFormatAttribute attr);
00430
00447 U_CAPI void U_EXPORT2
00448 unum_setAttribute( UNumberFormat* fmt,
00449 UNumberFormatAttribute attr,
00450 int32_t newValue);
00451
00452
00466 U_CAPI double U_EXPORT2
00467 unum_getDoubleAttribute(const UNumberFormat* fmt,
00468 UNumberFormatAttribute attr);
00469
00483 U_CAPI void U_EXPORT2
00484 unum_setDoubleAttribute( UNumberFormat* fmt,
00485 UNumberFormatAttribute attr,
00486 double newValue);
00487
00489 enum UNumberFormatTextAttribute{
00491 UNUM_POSITIVE_PREFIX,
00493 UNUM_POSITIVE_SUFFIX,
00495 UNUM_NEGATIVE_PREFIX,
00497 UNUM_NEGATIVE_SUFFIX,
00499 UNUM_PADDING_CHARACTER,
00501 UNUM_CURRENCY_CODE
00502 };
00503 typedef enum UNumberFormatTextAttribute UNumberFormatTextAttribute;
00504
00520 U_CAPI int32_t U_EXPORT2
00521 unum_getTextAttribute( const UNumberFormat* fmt,
00522 UNumberFormatTextAttribute tag,
00523 UChar* result,
00524 int32_t resultLength,
00525 UErrorCode* status);
00526
00541 U_CAPI void U_EXPORT2
00542 unum_setTextAttribute( UNumberFormat* fmt,
00543 UNumberFormatTextAttribute tag,
00544 const UChar* newValue,
00545 int32_t newValueLength,
00546 UErrorCode *status);
00547
00559 U_CAPI int32_t U_EXPORT2
00560 unum_toPattern( const UNumberFormat* fmt,
00561 UBool isPatternLocalized,
00562 UChar* result,
00563 int32_t resultLength,
00564 UErrorCode* status);
00565
00566
00567 #define UNFSYMBOLSMAXSIZE 10
00568
00573 enum UNumberFormatSymbol {
00575 UNUM_DECIMAL_SEPARATOR_SYMBOL,
00577 UNUM_GROUPING_SEPARATOR_SYMBOL,
00579 UNUM_PATTERN_SEPARATOR_SYMBOL,
00581 UNUM_PERCENT_SYMBOL,
00583 UNUM_ZERO_DIGIT_SYMBOL,
00585 UNUM_DIGIT_SYMBOL,
00587 UNUM_MINUS_SIGN_SYMBOL,
00589 UNUM_PLUS_SIGN_SYMBOL,
00591 UNUM_CURRENCY_SYMBOL,
00593 UNUM_INTL_CURRENCY_SYMBOL,
00595 UNUM_MONETARY_SEPARATOR_SYMBOL,
00597 UNUM_EXPONENTIAL_SYMBOL,
00599 UNUM_PERMILL_SYMBOL,
00601 UNUM_PAD_ESCAPE_SYMBOL,
00603 UNUM_INFINITY_SYMBOL,
00605 UNUM_NAN_SYMBOL,
00607 UNUM_FORMAT_SYMBOL_COUNT
00608 };
00609 typedef enum UNumberFormatSymbol UNumberFormatSymbol;
00610
00625 U_CAPI int32_t U_EXPORT2
00626 unum_getSymbol(UNumberFormat *fmt,
00627 UNumberFormatSymbol symbol,
00628 UChar *buffer,
00629 int32_t size,
00630 UErrorCode *status);
00631
00644 U_CAPI void U_EXPORT2
00645 unum_setSymbol(UNumberFormat *fmt,
00646 UNumberFormatSymbol symbol,
00647 const UChar *value,
00648 int32_t length,
00649 UErrorCode *status);
00650
00651
00652
00656 #ifdef U_USE_DEPRECATED_FORMAT_API
00657
00658 #if ((U_ICU_VERSION_MAJOR_NUM != 2) || (U_ICU_VERSION_MINOR_NUM != 2))
00659 # error "ICU version has changed. Please redefine the macros under U_USE_DEPRECATED_FORMAT_API pre-processor definition"
00660 #else
00661 static UNumberFormat*
00662 unum_openPattern(const UChar* pattern, int32_t patternLength,const char* locale,UErrorCode* status)
00663 {
00664 return unum_open(0,pattern,patternLength,locale,NULL,status);
00665 }
00666
00667 # define unum_open_2_2(style,locale,status) unum_open(style, NULL, 0, locale, NULL, status)
00668 # define unum_applyPattern_2_2(format,localized,pattern,patternLength) unum_applyPattern(format,localized,pattern,patternLength,NULL,NULL)
00669 #endif
00670
00671 #endif
00672
00673
00674 #endif