ICU 4.8.1.1
4.8.1.1
|
00001 /* 00002 ******************************************************************************* 00003 * Copyright (C) 1997-2011, International Business Machines Corporation and others. 00004 * All Rights Reserved. 00005 * Modification History: 00006 * 00007 * Date Name Description 00008 * 06/24/99 helena Integrated Alan's NF enhancements and Java2 bug fixes 00009 ******************************************************************************* 00010 */ 00011 00012 #ifndef _UNUM 00013 #define _UNUM 00014 00015 #include "unicode/utypes.h" 00016 00017 #if !UCONFIG_NO_FORMATTING 00018 00019 #include "unicode/localpointer.h" 00020 #include "unicode/uloc.h" 00021 #include "unicode/umisc.h" 00022 #include "unicode/parseerr.h" 00130 typedef void* UNumberFormat; 00131 00135 typedef enum UNumberFormatStyle { 00140 UNUM_PATTERN_DECIMAL=0, 00145 UNUM_DECIMAL=1, 00150 UNUM_CURRENCY, 00155 UNUM_PERCENT, 00160 UNUM_SCIENTIFIC, 00165 UNUM_SPELLOUT, 00170 UNUM_ORDINAL, 00175 UNUM_DURATION, 00180 UNUM_NUMBERING_SYSTEM, 00185 UNUM_PATTERN_RULEBASED, 00190 UNUM_CURRENCY_ISO, 00196 UNUM_CURRENCY_PLURAL, 00201 UNUM_FORMAT_STYLE_COUNT, 00206 UNUM_DEFAULT = UNUM_DECIMAL, 00211 UNUM_IGNORE = UNUM_PATTERN_DECIMAL 00212 } UNumberFormatStyle; 00213 00217 typedef enum UNumberFormatRoundingMode { 00218 UNUM_ROUND_CEILING, 00219 UNUM_ROUND_FLOOR, 00220 UNUM_ROUND_DOWN, 00221 UNUM_ROUND_UP, 00226 UNUM_FOUND_HALFEVEN, 00227 UNUM_ROUND_HALFDOWN, 00228 UNUM_ROUND_HALFUP, 00233 UNUM_ROUND_UNNECESSARY, 00238 UNUM_ROUND_HALFEVEN = UNUM_FOUND_HALFEVEN 00239 } UNumberFormatRoundingMode; 00240 00244 typedef enum UNumberFormatPadPosition { 00245 UNUM_PAD_BEFORE_PREFIX, 00246 UNUM_PAD_AFTER_PREFIX, 00247 UNUM_PAD_BEFORE_SUFFIX, 00248 UNUM_PAD_AFTER_SUFFIX 00249 } UNumberFormatPadPosition; 00250 00255 enum UCurrencySpacing { 00256 UNUM_CURRENCY_MATCH, 00257 UNUM_CURRENCY_SURROUNDING_MATCH, 00258 UNUM_CURRENCY_INSERT, 00259 UNUM_CURRENCY_SPACING_COUNT 00260 }; 00261 typedef enum UCurrencySpacing UCurrencySpacing; 00294 U_STABLE UNumberFormat* U_EXPORT2 00295 unum_open( UNumberFormatStyle style, 00296 const UChar* pattern, 00297 int32_t patternLength, 00298 const char* locale, 00299 UParseError* parseErr, 00300 UErrorCode* status); 00301 00302 00309 U_STABLE void U_EXPORT2 00310 unum_close(UNumberFormat* fmt); 00311 00312 #if U_SHOW_CPLUSPLUS_API 00313 00314 U_NAMESPACE_BEGIN 00315 00325 U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberFormatPointer, UNumberFormat, unum_close); 00326 00327 U_NAMESPACE_END 00328 00329 #endif 00330 00339 U_STABLE UNumberFormat* U_EXPORT2 00340 unum_clone(const UNumberFormat *fmt, 00341 UErrorCode *status); 00342 00364 U_STABLE int32_t U_EXPORT2 00365 unum_format( const UNumberFormat* fmt, 00366 int32_t number, 00367 UChar* result, 00368 int32_t resultLength, 00369 UFieldPosition *pos, 00370 UErrorCode* status); 00371 00393 U_STABLE int32_t U_EXPORT2 00394 unum_formatInt64(const UNumberFormat *fmt, 00395 int64_t number, 00396 UChar* result, 00397 int32_t resultLength, 00398 UFieldPosition *pos, 00399 UErrorCode* status); 00400 00422 U_STABLE int32_t U_EXPORT2 00423 unum_formatDouble( const UNumberFormat* fmt, 00424 double number, 00425 UChar* result, 00426 int32_t resultLength, 00427 UFieldPosition *pos, /* 0 if ignore */ 00428 UErrorCode* status); 00429 00455 U_STABLE int32_t U_EXPORT2 00456 unum_formatDecimal( const UNumberFormat* fmt, 00457 const char * number, 00458 int32_t length, 00459 UChar* result, 00460 int32_t resultLength, 00461 UFieldPosition *pos, /* 0 if ignore */ 00462 UErrorCode* status); 00463 00485 U_STABLE int32_t U_EXPORT2 00486 unum_formatDoubleCurrency(const UNumberFormat* fmt, 00487 double number, 00488 UChar* currency, 00489 UChar* result, 00490 int32_t resultLength, 00491 UFieldPosition* pos, /* ignored if 0 */ 00492 UErrorCode* status); 00493 00511 U_STABLE int32_t U_EXPORT2 00512 unum_parse( const UNumberFormat* fmt, 00513 const UChar* text, 00514 int32_t textLength, 00515 int32_t *parsePos /* 0 = start */, 00516 UErrorCode *status); 00517 00535 U_STABLE int64_t U_EXPORT2 00536 unum_parseInt64(const UNumberFormat* fmt, 00537 const UChar* text, 00538 int32_t textLength, 00539 int32_t *parsePos /* 0 = start */, 00540 UErrorCode *status); 00541 00559 U_STABLE double U_EXPORT2 00560 unum_parseDouble( const UNumberFormat* fmt, 00561 const UChar* text, 00562 int32_t textLength, 00563 int32_t *parsePos /* 0 = start */, 00564 UErrorCode *status); 00565 00566 00592 U_STABLE int32_t U_EXPORT2 00593 unum_parseDecimal(const UNumberFormat* fmt, 00594 const UChar* text, 00595 int32_t textLength, 00596 int32_t *parsePos /* 0 = start */, 00597 char *outBuf, 00598 int32_t outBufLength, 00599 UErrorCode *status); 00600 00620 U_STABLE double U_EXPORT2 00621 unum_parseDoubleCurrency(const UNumberFormat* fmt, 00622 const UChar* text, 00623 int32_t textLength, 00624 int32_t* parsePos, /* 0 = start */ 00625 UChar* currency, 00626 UErrorCode* status); 00627 00644 U_STABLE void U_EXPORT2 00645 unum_applyPattern( UNumberFormat *format, 00646 UBool localized, 00647 const UChar *pattern, 00648 int32_t patternLength, 00649 UParseError *parseError, 00650 UErrorCode *status 00651 ); 00652 00663 U_STABLE const char* U_EXPORT2 00664 unum_getAvailable(int32_t localeIndex); 00665 00675 U_STABLE int32_t U_EXPORT2 00676 unum_countAvailable(void); 00677 00679 typedef enum UNumberFormatAttribute { 00681 UNUM_PARSE_INT_ONLY, 00683 UNUM_GROUPING_USED, 00685 UNUM_DECIMAL_ALWAYS_SHOWN, 00687 UNUM_MAX_INTEGER_DIGITS, 00689 UNUM_MIN_INTEGER_DIGITS, 00691 UNUM_INTEGER_DIGITS, 00693 UNUM_MAX_FRACTION_DIGITS, 00695 UNUM_MIN_FRACTION_DIGITS, 00697 UNUM_FRACTION_DIGITS, 00699 UNUM_MULTIPLIER, 00701 UNUM_GROUPING_SIZE, 00703 UNUM_ROUNDING_MODE, 00705 UNUM_ROUNDING_INCREMENT, 00707 UNUM_FORMAT_WIDTH, 00709 UNUM_PADDING_POSITION, 00711 UNUM_SECONDARY_GROUPING_SIZE, 00714 UNUM_SIGNIFICANT_DIGITS_USED, 00717 UNUM_MIN_SIGNIFICANT_DIGITS, 00720 UNUM_MAX_SIGNIFICANT_DIGITS, 00724 UNUM_LENIENT_PARSE 00725 } UNumberFormatAttribute; 00726 00743 U_STABLE int32_t U_EXPORT2 00744 unum_getAttribute(const UNumberFormat* fmt, 00745 UNumberFormatAttribute attr); 00746 00766 U_STABLE void U_EXPORT2 00767 unum_setAttribute( UNumberFormat* fmt, 00768 UNumberFormatAttribute attr, 00769 int32_t newValue); 00770 00771 00786 U_STABLE double U_EXPORT2 00787 unum_getDoubleAttribute(const UNumberFormat* fmt, 00788 UNumberFormatAttribute attr); 00789 00804 U_STABLE void U_EXPORT2 00805 unum_setDoubleAttribute( UNumberFormat* fmt, 00806 UNumberFormatAttribute attr, 00807 double newValue); 00808 00810 typedef enum UNumberFormatTextAttribute { 00812 UNUM_POSITIVE_PREFIX, 00814 UNUM_POSITIVE_SUFFIX, 00816 UNUM_NEGATIVE_PREFIX, 00818 UNUM_NEGATIVE_SUFFIX, 00820 UNUM_PADDING_CHARACTER, 00822 UNUM_CURRENCY_CODE, 00827 UNUM_DEFAULT_RULESET, 00834 UNUM_PUBLIC_RULESETS 00835 } UNumberFormatTextAttribute; 00836 00855 U_STABLE int32_t U_EXPORT2 00856 unum_getTextAttribute( const UNumberFormat* fmt, 00857 UNumberFormatTextAttribute tag, 00858 UChar* result, 00859 int32_t resultLength, 00860 UErrorCode* status); 00861 00878 U_STABLE void U_EXPORT2 00879 unum_setTextAttribute( UNumberFormat* fmt, 00880 UNumberFormatTextAttribute tag, 00881 const UChar* newValue, 00882 int32_t newValueLength, 00883 UErrorCode *status); 00884 00901 U_STABLE int32_t U_EXPORT2 00902 unum_toPattern( const UNumberFormat* fmt, 00903 UBool isPatternLocalized, 00904 UChar* result, 00905 int32_t resultLength, 00906 UErrorCode* status); 00907 00908 00913 typedef enum UNumberFormatSymbol { 00915 UNUM_DECIMAL_SEPARATOR_SYMBOL = 0, 00917 UNUM_GROUPING_SEPARATOR_SYMBOL = 1, 00919 UNUM_PATTERN_SEPARATOR_SYMBOL = 2, 00921 UNUM_PERCENT_SYMBOL = 3, 00923 UNUM_ZERO_DIGIT_SYMBOL = 4, 00925 UNUM_DIGIT_SYMBOL = 5, 00927 UNUM_MINUS_SIGN_SYMBOL = 6, 00929 UNUM_PLUS_SIGN_SYMBOL = 7, 00931 UNUM_CURRENCY_SYMBOL = 8, 00933 UNUM_INTL_CURRENCY_SYMBOL = 9, 00935 UNUM_MONETARY_SEPARATOR_SYMBOL = 10, 00937 UNUM_EXPONENTIAL_SYMBOL = 11, 00939 UNUM_PERMILL_SYMBOL = 12, 00941 UNUM_PAD_ESCAPE_SYMBOL = 13, 00943 UNUM_INFINITY_SYMBOL = 14, 00945 UNUM_NAN_SYMBOL = 15, 00948 UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16, 00952 UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17, 00956 UNUM_ONE_DIGIT_SYMBOL = 18, 00960 UNUM_TWO_DIGIT_SYMBOL = 19, 00964 UNUM_THREE_DIGIT_SYMBOL = 20, 00968 UNUM_FOUR_DIGIT_SYMBOL = 21, 00972 UNUM_FIVE_DIGIT_SYMBOL = 22, 00976 UNUM_SIX_DIGIT_SYMBOL = 23, 00980 UNUM_SEVEN_DIGIT_SYMBOL = 24, 00984 UNUM_EIGHT_DIGIT_SYMBOL = 25, 00988 UNUM_NINE_DIGIT_SYMBOL = 26, 00990 UNUM_FORMAT_SYMBOL_COUNT = 27 00991 } UNumberFormatSymbol; 00992 01009 U_STABLE int32_t U_EXPORT2 01010 unum_getSymbol(const UNumberFormat *fmt, 01011 UNumberFormatSymbol symbol, 01012 UChar *buffer, 01013 int32_t size, 01014 UErrorCode *status); 01015 01029 U_STABLE void U_EXPORT2 01030 unum_setSymbol(UNumberFormat *fmt, 01031 UNumberFormatSymbol symbol, 01032 const UChar *value, 01033 int32_t length, 01034 UErrorCode *status); 01035 01036 01046 U_STABLE const char* U_EXPORT2 01047 unum_getLocaleByType(const UNumberFormat *fmt, 01048 ULocDataLocaleType type, 01049 UErrorCode* status); 01050 01051 #endif /* #if !UCONFIG_NO_FORMATTING */ 01052 01053 #endif