ICU 49.1.1
49.1.1
|
00001 /* 00002 ******************************************************************************* 00003 * Copyright (C) 1997-2012, 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_ROUND_HALFEVEN, 00227 #ifndef U_HIDE_DEPRECATED_API 00228 00232 UNUM_FOUND_HALFEVEN = UNUM_ROUND_HALFEVEN, 00233 #endif /* U_HIDE_DEPRECATED_API */ 00234 UNUM_ROUND_HALFDOWN, 00235 UNUM_ROUND_HALFUP, 00240 UNUM_ROUND_UNNECESSARY 00241 } UNumberFormatRoundingMode; 00242 00246 typedef enum UNumberFormatPadPosition { 00247 UNUM_PAD_BEFORE_PREFIX, 00248 UNUM_PAD_AFTER_PREFIX, 00249 UNUM_PAD_BEFORE_SUFFIX, 00250 UNUM_PAD_AFTER_SUFFIX 00251 } UNumberFormatPadPosition; 00252 00257 enum UCurrencySpacing { 00259 UNUM_CURRENCY_MATCH, 00261 UNUM_CURRENCY_SURROUNDING_MATCH, 00263 UNUM_CURRENCY_INSERT, 00265 UNUM_CURRENCY_SPACING_COUNT 00266 }; 00267 typedef enum UCurrencySpacing UCurrencySpacing; 00275 typedef enum UNumberFormatFields { 00277 UNUM_INTEGER_FIELD, 00279 UNUM_FRACTION_FIELD, 00281 UNUM_DECIMAL_SEPARATOR_FIELD, 00283 UNUM_EXPONENT_SYMBOL_FIELD, 00285 UNUM_EXPONENT_SIGN_FIELD, 00287 UNUM_EXPONENT_FIELD, 00289 UNUM_GROUPING_SEPARATOR_FIELD, 00291 UNUM_CURRENCY_FIELD, 00293 UNUM_PERCENT_FIELD, 00295 UNUM_PERMILL_FIELD, 00297 UNUM_SIGN_FIELD, 00299 UNUM_FIELD_COUNT 00300 } UNumberFormatFields; 00301 00302 00334 U_STABLE UNumberFormat* U_EXPORT2 00335 unum_open( UNumberFormatStyle style, 00336 const UChar* pattern, 00337 int32_t patternLength, 00338 const char* locale, 00339 UParseError* parseErr, 00340 UErrorCode* status); 00341 00342 00349 U_STABLE void U_EXPORT2 00350 unum_close(UNumberFormat* fmt); 00351 00352 #if U_SHOW_CPLUSPLUS_API 00353 00354 U_NAMESPACE_BEGIN 00355 00365 U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberFormatPointer, UNumberFormat, unum_close); 00366 00367 U_NAMESPACE_END 00368 00369 #endif 00370 00379 U_STABLE UNumberFormat* U_EXPORT2 00380 unum_clone(const UNumberFormat *fmt, 00381 UErrorCode *status); 00382 00404 U_STABLE int32_t U_EXPORT2 00405 unum_format( const UNumberFormat* fmt, 00406 int32_t number, 00407 UChar* result, 00408 int32_t resultLength, 00409 UFieldPosition *pos, 00410 UErrorCode* status); 00411 00433 U_STABLE int32_t U_EXPORT2 00434 unum_formatInt64(const UNumberFormat *fmt, 00435 int64_t number, 00436 UChar* result, 00437 int32_t resultLength, 00438 UFieldPosition *pos, 00439 UErrorCode* status); 00440 00462 U_STABLE int32_t U_EXPORT2 00463 unum_formatDouble( const UNumberFormat* fmt, 00464 double number, 00465 UChar* result, 00466 int32_t resultLength, 00467 UFieldPosition *pos, /* 0 if ignore */ 00468 UErrorCode* status); 00469 00495 U_STABLE int32_t U_EXPORT2 00496 unum_formatDecimal( const UNumberFormat* fmt, 00497 const char * number, 00498 int32_t length, 00499 UChar* result, 00500 int32_t resultLength, 00501 UFieldPosition *pos, /* 0 if ignore */ 00502 UErrorCode* status); 00503 00525 U_STABLE int32_t U_EXPORT2 00526 unum_formatDoubleCurrency(const UNumberFormat* fmt, 00527 double number, 00528 UChar* currency, 00529 UChar* result, 00530 int32_t resultLength, 00531 UFieldPosition* pos, /* ignored if 0 */ 00532 UErrorCode* status); 00533 00551 U_STABLE int32_t U_EXPORT2 00552 unum_parse( const UNumberFormat* fmt, 00553 const UChar* text, 00554 int32_t textLength, 00555 int32_t *parsePos /* 0 = start */, 00556 UErrorCode *status); 00557 00575 U_STABLE int64_t U_EXPORT2 00576 unum_parseInt64(const UNumberFormat* fmt, 00577 const UChar* text, 00578 int32_t textLength, 00579 int32_t *parsePos /* 0 = start */, 00580 UErrorCode *status); 00581 00599 U_STABLE double U_EXPORT2 00600 unum_parseDouble( const UNumberFormat* fmt, 00601 const UChar* text, 00602 int32_t textLength, 00603 int32_t *parsePos /* 0 = start */, 00604 UErrorCode *status); 00605 00606 00632 U_STABLE int32_t U_EXPORT2 00633 unum_parseDecimal(const UNumberFormat* fmt, 00634 const UChar* text, 00635 int32_t textLength, 00636 int32_t *parsePos /* 0 = start */, 00637 char *outBuf, 00638 int32_t outBufLength, 00639 UErrorCode *status); 00640 00660 U_STABLE double U_EXPORT2 00661 unum_parseDoubleCurrency(const UNumberFormat* fmt, 00662 const UChar* text, 00663 int32_t textLength, 00664 int32_t* parsePos, /* 0 = start */ 00665 UChar* currency, 00666 UErrorCode* status); 00667 00684 U_STABLE void U_EXPORT2 00685 unum_applyPattern( UNumberFormat *format, 00686 UBool localized, 00687 const UChar *pattern, 00688 int32_t patternLength, 00689 UParseError *parseError, 00690 UErrorCode *status 00691 ); 00692 00703 U_STABLE const char* U_EXPORT2 00704 unum_getAvailable(int32_t localeIndex); 00705 00715 U_STABLE int32_t U_EXPORT2 00716 unum_countAvailable(void); 00717 00719 typedef enum UNumberFormatAttribute { 00721 UNUM_PARSE_INT_ONLY, 00723 UNUM_GROUPING_USED, 00725 UNUM_DECIMAL_ALWAYS_SHOWN, 00727 UNUM_MAX_INTEGER_DIGITS, 00729 UNUM_MIN_INTEGER_DIGITS, 00731 UNUM_INTEGER_DIGITS, 00733 UNUM_MAX_FRACTION_DIGITS, 00735 UNUM_MIN_FRACTION_DIGITS, 00737 UNUM_FRACTION_DIGITS, 00739 UNUM_MULTIPLIER, 00741 UNUM_GROUPING_SIZE, 00743 UNUM_ROUNDING_MODE, 00745 UNUM_ROUNDING_INCREMENT, 00747 UNUM_FORMAT_WIDTH, 00749 UNUM_PADDING_POSITION, 00751 UNUM_SECONDARY_GROUPING_SIZE, 00754 UNUM_SIGNIFICANT_DIGITS_USED, 00757 UNUM_MIN_SIGNIFICANT_DIGITS, 00760 UNUM_MAX_SIGNIFICANT_DIGITS, 00764 UNUM_LENIENT_PARSE 00765 } UNumberFormatAttribute; 00766 00783 U_STABLE int32_t U_EXPORT2 00784 unum_getAttribute(const UNumberFormat* fmt, 00785 UNumberFormatAttribute attr); 00786 00806 U_STABLE void U_EXPORT2 00807 unum_setAttribute( UNumberFormat* fmt, 00808 UNumberFormatAttribute attr, 00809 int32_t newValue); 00810 00811 00826 U_STABLE double U_EXPORT2 00827 unum_getDoubleAttribute(const UNumberFormat* fmt, 00828 UNumberFormatAttribute attr); 00829 00844 U_STABLE void U_EXPORT2 00845 unum_setDoubleAttribute( UNumberFormat* fmt, 00846 UNumberFormatAttribute attr, 00847 double newValue); 00848 00850 typedef enum UNumberFormatTextAttribute { 00852 UNUM_POSITIVE_PREFIX, 00854 UNUM_POSITIVE_SUFFIX, 00856 UNUM_NEGATIVE_PREFIX, 00858 UNUM_NEGATIVE_SUFFIX, 00860 UNUM_PADDING_CHARACTER, 00862 UNUM_CURRENCY_CODE, 00867 UNUM_DEFAULT_RULESET, 00874 UNUM_PUBLIC_RULESETS 00875 } UNumberFormatTextAttribute; 00876 00895 U_STABLE int32_t U_EXPORT2 00896 unum_getTextAttribute( const UNumberFormat* fmt, 00897 UNumberFormatTextAttribute tag, 00898 UChar* result, 00899 int32_t resultLength, 00900 UErrorCode* status); 00901 00918 U_STABLE void U_EXPORT2 00919 unum_setTextAttribute( UNumberFormat* fmt, 00920 UNumberFormatTextAttribute tag, 00921 const UChar* newValue, 00922 int32_t newValueLength, 00923 UErrorCode *status); 00924 00941 U_STABLE int32_t U_EXPORT2 00942 unum_toPattern( const UNumberFormat* fmt, 00943 UBool isPatternLocalized, 00944 UChar* result, 00945 int32_t resultLength, 00946 UErrorCode* status); 00947 00948 00953 typedef enum UNumberFormatSymbol { 00955 UNUM_DECIMAL_SEPARATOR_SYMBOL = 0, 00957 UNUM_GROUPING_SEPARATOR_SYMBOL = 1, 00959 UNUM_PATTERN_SEPARATOR_SYMBOL = 2, 00961 UNUM_PERCENT_SYMBOL = 3, 00963 UNUM_ZERO_DIGIT_SYMBOL = 4, 00965 UNUM_DIGIT_SYMBOL = 5, 00967 UNUM_MINUS_SIGN_SYMBOL = 6, 00969 UNUM_PLUS_SIGN_SYMBOL = 7, 00971 UNUM_CURRENCY_SYMBOL = 8, 00973 UNUM_INTL_CURRENCY_SYMBOL = 9, 00975 UNUM_MONETARY_SEPARATOR_SYMBOL = 10, 00977 UNUM_EXPONENTIAL_SYMBOL = 11, 00979 UNUM_PERMILL_SYMBOL = 12, 00981 UNUM_PAD_ESCAPE_SYMBOL = 13, 00983 UNUM_INFINITY_SYMBOL = 14, 00985 UNUM_NAN_SYMBOL = 15, 00988 UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16, 00992 UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17, 00996 UNUM_ONE_DIGIT_SYMBOL = 18, 01000 UNUM_TWO_DIGIT_SYMBOL = 19, 01004 UNUM_THREE_DIGIT_SYMBOL = 20, 01008 UNUM_FOUR_DIGIT_SYMBOL = 21, 01012 UNUM_FIVE_DIGIT_SYMBOL = 22, 01016 UNUM_SIX_DIGIT_SYMBOL = 23, 01020 UNUM_SEVEN_DIGIT_SYMBOL = 24, 01024 UNUM_EIGHT_DIGIT_SYMBOL = 25, 01028 UNUM_NINE_DIGIT_SYMBOL = 26, 01030 UNUM_FORMAT_SYMBOL_COUNT = 27 01031 } UNumberFormatSymbol; 01032 01049 U_STABLE int32_t U_EXPORT2 01050 unum_getSymbol(const UNumberFormat *fmt, 01051 UNumberFormatSymbol symbol, 01052 UChar *buffer, 01053 int32_t size, 01054 UErrorCode *status); 01055 01069 U_STABLE void U_EXPORT2 01070 unum_setSymbol(UNumberFormat *fmt, 01071 UNumberFormatSymbol symbol, 01072 const UChar *value, 01073 int32_t length, 01074 UErrorCode *status); 01075 01076 01086 U_STABLE const char* U_EXPORT2 01087 unum_getLocaleByType(const UNumberFormat *fmt, 01088 ULocDataLocaleType type, 01089 UErrorCode* status); 01090 01091 #endif /* #if !UCONFIG_NO_FORMATTING */ 01092 01093 #endif