/* ******************************************************************************* * Copyright © {1997-1999}, International Business Machines Corporation and others. All Rights Reserved. * Modification History: * * Date Name Description * 06/24/99 helena Integrated Alan's NF enhancements and Java2 bug fixes ******************************************************************************* */ #ifndef _UNUM #define _UNUM #include "unicode/utypes.h" #include "unicode/umisc.h" typedef void* UNumberFormat; enum UNumberFormatStyle { UNUM_DECIMAL, UNUM_CURRENCY, UNUM_PERCENT, UNUM_SPELLOUT, UNUM_DEFAULT = UNUM_DECIMAL }; typedef enum UNumberFormatStyle UNumberFormatStyle; enum UNumberFormatRoundingMode { UNUM_ROUND_CEILING, UNUM_ROUND_FLOOR, UNUM_ROUND_DOWN, UNUM_ROUND_UP, UNUM_FOUND_HALFEVEN, UNUM_ROUND_HALFDOWN, UNUM_ROUND_HALFUP }; typedef enum UNumberFormatRoundingMode UNumberFormatRoundingMode; enum UNumberFormatPadPosition { UNUM_PAD_BEFORE_PREFIX, UNUM_PAD_AFTER_PREFIX, UNUM_PAD_BEFORE_SUFFIX, UNUM_PAD_AFTER_SUFFIX }; typedef enum UNumberFormatPadPosition UNumberFormatPadPosition; U_CAPI UNumberFormat* unum_open(UNumberFormatStyle style, const char* locale, UErrorCode* status); U_CAPI UNumberFormat* unum_openPattern( const UChar* pattern, int32_t patternLength, const char* locale, UErrorCode* status); U_CAPI void unum_close(UNumberFormat* fmt); U_CAPI UNumberFormat* unum_clone(const UNumberFormat *fmt, UErrorCode *status); U_CAPI int32_t unum_format( const UNumberFormat* fmt, int32_t number, UChar* result, int32_t resultLength, UFieldPosition *pos, UErrorCode* status); U_CAPI int32_t unum_formatDouble( const UNumberFormat* fmt, double number, UChar* result, int32_t resultLength, UFieldPosition *pos, /* 0 if ignore */ UErrorCode* status); U_CAPI int32_t unum_parse( const UNumberFormat* fmt, const UChar* text, int32_t textLength, int32_t *parsePos /* 0 = start */, UErrorCode *status); U_CAPI double unum_parseDouble( const UNumberFormat* fmt, const UChar* text, int32_t textLength, int32_t *parsePos /* 0 = start */, UErrorCode *status); U_CAPI void unum_applyPattern( UNumberFormat *format, UBool localized, const UChar *pattern, int32_t patternLength); U_CAPI const char* unum_getAvailable(int32_t index); U_CAPI int32_t unum_countAvailable(void); enum UNumberFormatAttribute { UNUM_PARSE_INT_ONLY, UNUM_GROUPING_USED, UNUM_DECIMAL_ALWAYS_SHOWN, UNUM_MAX_INTEGER_DIGITS, UNUM_MIN_INTEGER_DIGITS, UNUM_INTEGER_DIGITS, UNUM_MAX_FRACTION_DIGITS, UNUM_MIN_FRACTION_DIGITS, UNUM_FRACTION_DIGITS, UNUM_MULTIPLIER, UNUM_GROUPING_SIZE, UNUM_ROUNDING_MODE, UNUM_ROUNDING_INCREMENT, UNUM_FORMAT_WIDTH, UNUM_PADDING_POSITION, UNUM_SECONDARY_GROUPING_SIZE }; typedef enum UNumberFormatAttribute UNumberFormatAttribute; /*==================================================== ====================================================== ---> Add to UErrorCode !!!! ---> typedef enum { AttributeNotSupported, PropertyNotSupported } UErrorCode; ---> Add to UErrorCode !!!! ---> ====================================================== ====================================================*/ U_CAPI int32_t unum_getAttribute(const UNumberFormat* fmt, UNumberFormatAttribute attr); U_CAPI void unum_setAttribute( UNumberFormat* fmt, UNumberFormatAttribute attr, int32_t newValue); U_CAPI double unum_getDoubleAttribute(const UNumberFormat* fmt, UNumberFormatAttribute attr); U_CAPI void unum_setDoubleAttribute( UNumberFormat* fmt, UNumberFormatAttribute attr, double newValue); enum UNumberFormatTextAttribute{ UNUM_POSITIVE_PREFIX, UNUM_POSITIVE_SUFFIX, UNUM_NEGATIVE_PREFIX, UNUM_NEGATIVE_SUFFIX, UNUM_PADDING_CHARACTER }; typedef enum UNumberFormatTextAttribute UNumberFormatTextAttribute; U_CAPI int32_t unum_getTextAttribute( const UNumberFormat* fmt, UNumberFormatTextAttribute tag, UChar* result, int32_t resultLength, UErrorCode* status); U_CAPI void unum_setTextAttribute( UNumberFormat* fmt, UNumberFormatTextAttribute tag, const UChar* newValue, int32_t newValueLength, UErrorCode *status); U_CAPI int32_t unum_toPattern( const UNumberFormat* fmt, UBool isPatternLocalized, UChar* result, int32_t resultLength, UErrorCode* status); /* The maximum size for a textual number format symbol. */ #define UNFSYMBOLSMAXSIZE 10 struct UNumberFormatSymbols{ UChar decimalSeparator; UChar groupingSeparator; UChar patternSeparator; UChar percent; UChar zeroDigit; UChar digit; UChar minusSign; UChar plusSign; UChar currency [UNFSYMBOLSMAXSIZE]; UChar intlCurrency [UNFSYMBOLSMAXSIZE]; UChar monetarySeparator; UChar exponential; UChar perMill; UChar padEscape; UChar infinity [UNFSYMBOLSMAXSIZE]; UChar naN [UNFSYMBOLSMAXSIZE]; }; typedef struct UNumberFormatSymbols UNumberFormatSymbols; U_CAPI void unum_getSymbols( const UNumberFormat *fmt, UNumberFormatSymbols *syms); U_CAPI void unum_setSymbols( UNumberFormat* fmt, const UNumberFormatSymbols* symbolsToSet, UErrorCode *status); enum UNumberFormatSymbol { UNUM_DECIMAL_SEPARATOR_SYMBOL, UNUM_GROUPING_SEPARATOR_SYMBOL, UNUM_PATTERN_SEPARATOR_SYMBOL, UNUM_PERCENT_SYMBOL, UNUM_ZERO_DIGIT_SYMBOL, UNUM_DIGIT_SYMBOL, UNUM_MINUS_SIGN_SYMBOL, UNUM_PLUS_SIGN_SYMBOL, UNUM_CURRENCY_SYMBOL, UNUM_INTL_CURRENCY_SYMBOL, UNUM_MONETARY_SEPARATOR_SYMBOL, UNUM_EXPONENTIAL_SYMBOL, UNUM_PERMILL_SYMBOL, UNUM_PAD_ESCAPE_SYMBOL, UNUM_INFINITY_SYMBOL, UNUM_NAN_SYMBOL, UNUM_FORMAT_SYMBOL_COUNT }; typedef enum UNumberFormatSymbol UNumberFormatSymbol; U_CAPI int32_t U_EXPORT2 unum_getSymbol(UNumberFormat *fmt, UNumberFormatSymbol symbol, UChar *buffer, int32_t size, UErrorCode *status); U_CAPI void U_EXPORT2 unum_setSymbol(UNumberFormat *fmt, UNumberFormatSymbol symbol, const UChar *value, int32_t length, UErrorCode *status); #endif