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
00116 typedef void* UNumberFormat;
00117
00119 enum UNumberFormatStyle {
00121 UNUM_DECIMAL,
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
00165 U_CAPI UNumberFormat*
00166 unum_open(UNumberFormatStyle style,
00167 const char* locale,
00168 UErrorCode* status);
00169
00183 U_CAPI UNumberFormat*
00184 unum_openPattern( const UChar* pattern,
00185 int32_t patternLength,
00186 const char* locale,
00187 UErrorCode* status);
00188
00195 U_CAPI void
00196 unum_close(UNumberFormat* fmt);
00197
00206 U_CAPI UNumberFormat*
00207 unum_clone(const UNumberFormat *fmt,
00208 UErrorCode *status);
00209
00225 U_CAPI int32_t
00226 unum_format( const UNumberFormat* fmt,
00227 int32_t number,
00228 UChar* result,
00229 int32_t resultLength,
00230 UFieldPosition *pos,
00231 UErrorCode* status);
00232
00248 U_CAPI int32_t
00249 unum_formatDouble( const UNumberFormat* fmt,
00250 double number,
00251 UChar* result,
00252 int32_t resultLength,
00253 UFieldPosition *pos,
00254 UErrorCode* status);
00255
00271 U_CAPI int32_t
00272 unum_parse( const UNumberFormat* fmt,
00273 const UChar* text,
00274 int32_t textLength,
00275 int32_t *parsePos ,
00276 UErrorCode *status);
00277
00293 U_CAPI double
00294 unum_parseDouble( const UNumberFormat* fmt,
00295 const UChar* text,
00296 int32_t textLength,
00297 int32_t *parsePos ,
00298 UErrorCode *status);
00299
00310 U_CAPI void
00311 unum_applyPattern( UNumberFormat *format,
00312 UBool localized,
00313 const UChar *pattern,
00314 int32_t patternLength);
00324 U_CAPI const char*
00325 unum_getAvailable(int32_t index);
00326
00335 U_CAPI int32_t
00336 unum_countAvailable(void);
00337
00339 enum UNumberFormatAttribute {
00341 UNUM_PARSE_INT_ONLY,
00343 UNUM_GROUPING_USED,
00345 UNUM_DECIMAL_ALWAYS_SHOWN,
00347 UNUM_MAX_INTEGER_DIGITS,
00349 UNUM_MIN_INTEGER_DIGITS,
00351 UNUM_INTEGER_DIGITS,
00353 UNUM_MAX_FRACTION_DIGITS,
00355 UNUM_MIN_FRACTION_DIGITS,
00357 UNUM_FRACTION_DIGITS,
00359 UNUM_MULTIPLIER,
00361 UNUM_GROUPING_SIZE,
00363 UNUM_ROUNDING_MODE,
00365 UNUM_ROUNDING_INCREMENT,
00367 UNUM_FORMAT_WIDTH,
00369 UNUM_PADDING_POSITION,
00371 UNUM_SECONDARY_GROUPING_SIZE
00372 };
00373 typedef enum UNumberFormatAttribute UNumberFormatAttribute;
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00402 U_CAPI int32_t
00403 unum_getAttribute(const UNumberFormat* fmt,
00404 UNumberFormatAttribute attr);
00405
00422 U_CAPI void
00423 unum_setAttribute( UNumberFormat* fmt,
00424 UNumberFormatAttribute attr,
00425 int32_t newValue);
00426
00427
00441 U_CAPI double
00442 unum_getDoubleAttribute(const UNumberFormat* fmt,
00443 UNumberFormatAttribute attr);
00444
00458 U_CAPI void
00459 unum_setDoubleAttribute( UNumberFormat* fmt,
00460 UNumberFormatAttribute attr,
00461 double newValue);
00462
00464 enum UNumberFormatTextAttribute{
00466 UNUM_POSITIVE_PREFIX,
00468 UNUM_POSITIVE_SUFFIX,
00470 UNUM_NEGATIVE_PREFIX,
00472 UNUM_NEGATIVE_SUFFIX,
00474 UNUM_PADDING_CHARACTER
00475 };
00476 typedef enum UNumberFormatTextAttribute UNumberFormatTextAttribute;
00477
00493 U_CAPI int32_t
00494 unum_getTextAttribute( const UNumberFormat* fmt,
00495 UNumberFormatTextAttribute tag,
00496 UChar* result,
00497 int32_t resultLength,
00498 UErrorCode* status);
00499
00514 U_CAPI void
00515 unum_setTextAttribute( UNumberFormat* fmt,
00516 UNumberFormatTextAttribute tag,
00517 const UChar* newValue,
00518 int32_t newValueLength,
00519 UErrorCode *status);
00520
00532 U_CAPI int32_t
00533 unum_toPattern( const UNumberFormat* fmt,
00534 UBool isPatternLocalized,
00535 UChar* result,
00536 int32_t resultLength,
00537 UErrorCode* status);
00538
00539
00540 #define UNFSYMBOLSMAXSIZE 10
00541
00545 struct UNumberFormatSymbols{
00547 UChar decimalSeparator;
00549 UChar groupingSeparator;
00551 UChar patternSeparator;
00553 UChar percent;
00555 UChar zeroDigit;
00557 UChar digit;
00559 UChar minusSign;
00561 UChar plusSign;
00563 UChar currency [UNFSYMBOLSMAXSIZE];
00565 UChar intlCurrency [UNFSYMBOLSMAXSIZE];
00567 UChar monetarySeparator;
00569 UChar exponential;
00571 UChar perMill;
00573 UChar padEscape;
00575 UChar infinity [UNFSYMBOLSMAXSIZE];
00577 UChar naN [UNFSYMBOLSMAXSIZE];
00578 };
00579 typedef struct UNumberFormatSymbols UNumberFormatSymbols;
00580
00590 U_CAPI void
00591 unum_getSymbols( const UNumberFormat *fmt,
00592 UNumberFormatSymbols *syms);
00593
00604 U_CAPI void
00605 unum_setSymbols( UNumberFormat* fmt,
00606 const UNumberFormatSymbols* symbolsToSet,
00607 UErrorCode *status);
00608
00613 enum UNumberFormatSymbol {
00615 UNUM_DECIMAL_SEPARATOR_SYMBOL,
00617 UNUM_GROUPING_SEPARATOR_SYMBOL,
00619 UNUM_PATTERN_SEPARATOR_SYMBOL,
00621 UNUM_PERCENT_SYMBOL,
00623 UNUM_ZERO_DIGIT_SYMBOL,
00625 UNUM_DIGIT_SYMBOL,
00627 UNUM_MINUS_SIGN_SYMBOL,
00629 UNUM_PLUS_SIGN_SYMBOL,
00631 UNUM_CURRENCY_SYMBOL,
00633 UNUM_INTL_CURRENCY_SYMBOL,
00635 UNUM_MONETARY_SEPARATOR_SYMBOL,
00637 UNUM_EXPONENTIAL_SYMBOL,
00639 UNUM_PERMILL_SYMBOL,
00641 UNUM_PAD_ESCAPE_SYMBOL,
00643 UNUM_INFINITY_SYMBOL,
00645 UNUM_NAN_SYMBOL,
00647 UNUM_FORMAT_SYMBOL_COUNT
00648 };
00649 typedef enum UNumberFormatSymbol UNumberFormatSymbol;
00650
00665 U_CAPI int32_t U_EXPORT2
00666 unum_getSymbol(UNumberFormat *fmt,
00667 UNumberFormatSymbol symbol,
00668 UChar *buffer,
00669 int32_t size,
00670 UErrorCode *status);
00671
00684 U_CAPI void U_EXPORT2
00685 unum_setSymbol(UNumberFormat *fmt,
00686 UNumberFormatSymbol symbol,
00687 const UChar *value,
00688 int32_t length,
00689 UErrorCode *status);
00690
00691 #endif