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/uloc.h"
00019 #include "unicode/umisc.h"
00020 #include "unicode/parseerr.h"
00124 typedef void* UNumberFormat;
00125
00129 typedef enum UNumberFormatStyle {
00131 UNUM_IGNORE=0,
00133 UNUM_DECIMAL=1,
00135 UNUM_CURRENCY,
00137 UNUM_PERCENT,
00139 UNUM_SCIENTIFIC,
00141 UNUM_SPELLOUT,
00143 UNUM_DEFAULT = UNUM_DECIMAL
00144 } UNumberFormatStyle;
00145
00149 typedef enum UNumberFormatRoundingMode {
00150 UNUM_ROUND_CEILING,
00151 UNUM_ROUND_FLOOR,
00152 UNUM_ROUND_DOWN,
00153 UNUM_ROUND_UP,
00154 UNUM_FOUND_HALFEVEN,
00155 UNUM_ROUND_HALFDOWN,
00156 UNUM_ROUND_HALFUP
00157 } UNumberFormatRoundingMode;
00158
00162 typedef enum UNumberFormatPadPosition {
00163 UNUM_PAD_BEFORE_PREFIX,
00164 UNUM_PAD_AFTER_PREFIX,
00165 UNUM_PAD_BEFORE_SUFFIX,
00166 UNUM_PAD_AFTER_SUFFIX
00167 } UNumberFormatPadPosition;
00168
00188 U_CAPI UNumberFormat* U_EXPORT2
00189 unum_open( UNumberFormatStyle style,
00190 const UChar* pattern,
00191 int32_t patternLength,
00192 const char* locale,
00193 UParseError* parseErr,
00194 UErrorCode* status);
00195
00196
00203 U_CAPI void U_EXPORT2
00204 unum_close(UNumberFormat* fmt);
00205
00214 U_CAPI UNumberFormat* U_EXPORT2
00215 unum_clone(const UNumberFormat *fmt,
00216 UErrorCode *status);
00217
00239 U_CAPI int32_t U_EXPORT2
00240 unum_format( const UNumberFormat* fmt,
00241 int32_t number,
00242 UChar* result,
00243 int32_t resultLength,
00244 UFieldPosition *pos,
00245 UErrorCode* status);
00246
00268 U_CAPI int32_t U_EXPORT2
00269 unum_formatInt64(const UNumberFormat *fmt,
00270 int64_t number,
00271 UChar* result,
00272 int32_t resultLength,
00273 UFieldPosition *pos,
00274 UErrorCode* status);
00275
00297 U_CAPI int32_t U_EXPORT2
00298 unum_formatDouble( const UNumberFormat* fmt,
00299 double number,
00300 UChar* result,
00301 int32_t resultLength,
00302 UFieldPosition *pos,
00303 UErrorCode* status);
00304
00322 U_CAPI int32_t U_EXPORT2
00323 unum_parse( const UNumberFormat* fmt,
00324 const UChar* text,
00325 int32_t textLength,
00326 int32_t *parsePos ,
00327 UErrorCode *status);
00328
00346 U_CAPI int64_t U_EXPORT2
00347 unum_parseInt64(const UNumberFormat* fmt,
00348 const UChar* text,
00349 int32_t textLength,
00350 int32_t *parsePos ,
00351 UErrorCode *status);
00352
00370 U_CAPI double U_EXPORT2
00371 unum_parseDouble( const UNumberFormat* fmt,
00372 const UChar* text,
00373 int32_t textLength,
00374 int32_t *parsePos ,
00375 UErrorCode *status);
00376
00390 U_CAPI void U_EXPORT2
00391 unum_applyPattern( UNumberFormat *format,
00392 UBool localized,
00393 const UChar *pattern,
00394 int32_t patternLength,
00395 UParseError *parseError,
00396 UErrorCode *status
00397 );
00398
00408 U_CAPI const char* U_EXPORT2
00409 unum_getAvailable(int32_t index);
00410
00419 U_CAPI int32_t U_EXPORT2
00420 unum_countAvailable(void);
00421
00423 typedef enum UNumberFormatAttribute {
00425 UNUM_PARSE_INT_ONLY,
00427 UNUM_GROUPING_USED,
00429 UNUM_DECIMAL_ALWAYS_SHOWN,
00431 UNUM_MAX_INTEGER_DIGITS,
00433 UNUM_MIN_INTEGER_DIGITS,
00435 UNUM_INTEGER_DIGITS,
00437 UNUM_MAX_FRACTION_DIGITS,
00439 UNUM_MIN_FRACTION_DIGITS,
00441 UNUM_FRACTION_DIGITS,
00443 UNUM_MULTIPLIER,
00445 UNUM_GROUPING_SIZE,
00447 UNUM_ROUNDING_MODE,
00449 UNUM_ROUNDING_INCREMENT,
00451 UNUM_FORMAT_WIDTH,
00453 UNUM_PADDING_POSITION,
00455 UNUM_SECONDARY_GROUPING_SIZE
00456 } UNumberFormatAttribute;
00457
00474 U_CAPI int32_t U_EXPORT2
00475 unum_getAttribute(const UNumberFormat* fmt,
00476 UNumberFormatAttribute attr);
00477
00494 U_CAPI void U_EXPORT2
00495 unum_setAttribute( UNumberFormat* fmt,
00496 UNumberFormatAttribute attr,
00497 int32_t newValue);
00498
00499
00513 U_CAPI double U_EXPORT2
00514 unum_getDoubleAttribute(const UNumberFormat* fmt,
00515 UNumberFormatAttribute attr);
00516
00530 U_CAPI void U_EXPORT2
00531 unum_setDoubleAttribute( UNumberFormat* fmt,
00532 UNumberFormatAttribute attr,
00533 double newValue);
00534
00536 typedef enum UNumberFormatTextAttribute {
00538 UNUM_POSITIVE_PREFIX,
00540 UNUM_POSITIVE_SUFFIX,
00542 UNUM_NEGATIVE_PREFIX,
00544 UNUM_NEGATIVE_SUFFIX,
00546 UNUM_PADDING_CHARACTER,
00548 UNUM_CURRENCY_CODE
00549 } UNumberFormatTextAttribute;
00550
00566 U_CAPI int32_t U_EXPORT2
00567 unum_getTextAttribute( const UNumberFormat* fmt,
00568 UNumberFormatTextAttribute tag,
00569 UChar* result,
00570 int32_t resultLength,
00571 UErrorCode* status);
00572
00587 U_CAPI void U_EXPORT2
00588 unum_setTextAttribute( UNumberFormat* fmt,
00589 UNumberFormatTextAttribute tag,
00590 const UChar* newValue,
00591 int32_t newValueLength,
00592 UErrorCode *status);
00593
00605 U_CAPI int32_t U_EXPORT2
00606 unum_toPattern( const UNumberFormat* fmt,
00607 UBool isPatternLocalized,
00608 UChar* result,
00609 int32_t resultLength,
00610 UErrorCode* status);
00611
00613 #define UNFSYMBOLSMAXSIZE 10
00614
00619 typedef enum UNumberFormatSymbol {
00621 UNUM_DECIMAL_SEPARATOR_SYMBOL,
00623 UNUM_GROUPING_SEPARATOR_SYMBOL,
00625 UNUM_PATTERN_SEPARATOR_SYMBOL,
00627 UNUM_PERCENT_SYMBOL,
00629 UNUM_ZERO_DIGIT_SYMBOL,
00631 UNUM_DIGIT_SYMBOL,
00633 UNUM_MINUS_SIGN_SYMBOL,
00635 UNUM_PLUS_SIGN_SYMBOL,
00637 UNUM_CURRENCY_SYMBOL,
00639 UNUM_INTL_CURRENCY_SYMBOL,
00641 UNUM_MONETARY_SEPARATOR_SYMBOL,
00643 UNUM_EXPONENTIAL_SYMBOL,
00645 UNUM_PERMILL_SYMBOL,
00647 UNUM_PAD_ESCAPE_SYMBOL,
00649 UNUM_INFINITY_SYMBOL,
00651 UNUM_NAN_SYMBOL,
00653 UNUM_FORMAT_SYMBOL_COUNT
00654 } UNumberFormatSymbol;
00655
00671 U_CAPI int32_t U_EXPORT2
00672 unum_getSymbol(UNumberFormat *fmt,
00673 UNumberFormatSymbol symbol,
00674 UChar *buffer,
00675 int32_t size,
00676 UErrorCode *status);
00677
00690 U_CAPI void U_EXPORT2
00691 unum_setSymbol(UNumberFormat *fmt,
00692 UNumberFormatSymbol symbol,
00693 const UChar *value,
00694 int32_t length,
00695 UErrorCode *status);
00696
00697
00707 U_CAPI const char* U_EXPORT2
00708 unum_getLocaleByType(const UNumberFormat *fmt,
00709 ULocDataLocaleType type,
00710 UErrorCode* status);
00711
00712 #endif
00713
00714 #endif