00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef _UNUM
00015 #define _UNUM
00016
00017 #include "unicode/utypes.h"
00018
00019 #if !UCONFIG_NO_FORMATTING
00020
00021 #include "unicode/localpointer.h"
00022 #include "unicode/uloc.h"
00023 #include "unicode/ucurr.h"
00024 #include "unicode/umisc.h"
00025 #include "unicode/parseerr.h"
00026 #include "unicode/uformattable.h"
00027 #include "unicode/udisplaycontext.h"
00028 #include "unicode/ufieldpositer.h"
00029
00137 typedef void* UNumberFormat;
00138
00142 typedef enum UNumberFormatStyle {
00147 UNUM_PATTERN_DECIMAL=0,
00152 UNUM_DECIMAL=1,
00161 UNUM_CURRENCY=2,
00166 UNUM_PERCENT=3,
00171 UNUM_SCIENTIFIC=4,
00178 UNUM_SPELLOUT=5,
00185 UNUM_ORDINAL=6,
00190 UNUM_DURATION=7,
00195 UNUM_NUMBERING_SYSTEM=8,
00200 UNUM_PATTERN_RULEBASED=9,
00205 UNUM_CURRENCY_ISO=10,
00211 UNUM_CURRENCY_PLURAL=11,
00218 UNUM_CURRENCY_ACCOUNTING=12,
00224 UNUM_CASH_CURRENCY=13,
00231 UNUM_DECIMAL_COMPACT_SHORT=14,
00238 UNUM_DECIMAL_COMPACT_LONG=15,
00245 UNUM_CURRENCY_STANDARD=16,
00246
00247 #ifndef U_HIDE_DEPRECATED_API
00248
00252 UNUM_FORMAT_STYLE_COUNT=17,
00253 #endif
00254
00259 UNUM_DEFAULT = UNUM_DECIMAL,
00264 UNUM_IGNORE = UNUM_PATTERN_DECIMAL
00265 } UNumberFormatStyle;
00266
00275 typedef enum UNumberFormatRoundingMode {
00276 UNUM_ROUND_CEILING,
00277 UNUM_ROUND_FLOOR,
00278 UNUM_ROUND_DOWN,
00279 UNUM_ROUND_UP,
00284 UNUM_ROUND_HALFEVEN,
00285 #ifndef U_HIDE_DEPRECATED_API
00286
00290 UNUM_FOUND_HALFEVEN = UNUM_ROUND_HALFEVEN,
00291 #endif
00292 UNUM_ROUND_HALFDOWN = UNUM_ROUND_HALFEVEN + 1,
00293 UNUM_ROUND_HALFUP,
00298 UNUM_ROUND_UNNECESSARY
00299 } UNumberFormatRoundingMode;
00300
00304 typedef enum UNumberFormatPadPosition {
00305 UNUM_PAD_BEFORE_PREFIX,
00306 UNUM_PAD_AFTER_PREFIX,
00307 UNUM_PAD_BEFORE_SUFFIX,
00308 UNUM_PAD_AFTER_SUFFIX
00309 } UNumberFormatPadPosition;
00310
00315 typedef enum UNumberCompactStyle {
00317 UNUM_SHORT,
00319 UNUM_LONG
00321 } UNumberCompactStyle;
00322
00327 enum UCurrencySpacing {
00329 UNUM_CURRENCY_MATCH,
00331 UNUM_CURRENCY_SURROUNDING_MATCH,
00333 UNUM_CURRENCY_INSERT,
00334
00335
00336
00341 UNUM_CURRENCY_SPACING_COUNT
00342 };
00343 typedef enum UCurrencySpacing UCurrencySpacing;
00351 typedef enum UNumberFormatFields {
00353 UNUM_INTEGER_FIELD,
00355 UNUM_FRACTION_FIELD,
00357 UNUM_DECIMAL_SEPARATOR_FIELD,
00359 UNUM_EXPONENT_SYMBOL_FIELD,
00361 UNUM_EXPONENT_SIGN_FIELD,
00363 UNUM_EXPONENT_FIELD,
00365 UNUM_GROUPING_SEPARATOR_FIELD,
00367 UNUM_CURRENCY_FIELD,
00369 UNUM_PERCENT_FIELD,
00371 UNUM_PERMILL_FIELD,
00373 UNUM_SIGN_FIELD,
00374 #ifndef U_HIDE_DEPRECATED_API
00375
00379 UNUM_FIELD_COUNT
00380 #endif
00381 } UNumberFormatFields;
00382
00383
00417 U_STABLE UNumberFormat* U_EXPORT2
00418 unum_open( UNumberFormatStyle style,
00419 const UChar* pattern,
00420 int32_t patternLength,
00421 const char* locale,
00422 UParseError* parseErr,
00423 UErrorCode* status);
00424
00425
00432 U_STABLE void U_EXPORT2
00433 unum_close(UNumberFormat* fmt);
00434
00435 #if U_SHOW_CPLUSPLUS_API
00436
00437 U_NAMESPACE_BEGIN
00438
00448 U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberFormatPointer, UNumberFormat, unum_close);
00449
00450 U_NAMESPACE_END
00451
00452 #endif
00453
00462 U_STABLE UNumberFormat* U_EXPORT2
00463 unum_clone(const UNumberFormat *fmt,
00464 UErrorCode *status);
00465
00490 U_STABLE int32_t U_EXPORT2
00491 unum_format( const UNumberFormat* fmt,
00492 int32_t number,
00493 UChar* result,
00494 int32_t resultLength,
00495 UFieldPosition *pos,
00496 UErrorCode* status);
00497
00522 U_STABLE int32_t U_EXPORT2
00523 unum_formatInt64(const UNumberFormat *fmt,
00524 int64_t number,
00525 UChar* result,
00526 int32_t resultLength,
00527 UFieldPosition *pos,
00528 UErrorCode* status);
00529
00554 U_STABLE int32_t U_EXPORT2
00555 unum_formatDouble( const UNumberFormat* fmt,
00556 double number,
00557 UChar* result,
00558 int32_t resultLength,
00559 UFieldPosition *pos,
00560 UErrorCode* status);
00561
00562 #ifndef U_HIDE_DRAFT_API
00563
00605 U_DRAFT int32_t U_EXPORT2
00606 unum_formatDoubleForFields(const UNumberFormat* format,
00607 double number,
00608 UChar* result,
00609 int32_t resultLength,
00610 UFieldPositionIterator* fpositer,
00611 UErrorCode* status);
00612
00613 #endif
00614
00643 U_STABLE int32_t U_EXPORT2
00644 unum_formatDecimal( const UNumberFormat* fmt,
00645 const char * number,
00646 int32_t length,
00647 UChar* result,
00648 int32_t resultLength,
00649 UFieldPosition *pos,
00650 UErrorCode* status);
00651
00676 U_STABLE int32_t U_EXPORT2
00677 unum_formatDoubleCurrency(const UNumberFormat* fmt,
00678 double number,
00679 UChar* currency,
00680 UChar* result,
00681 int32_t resultLength,
00682 UFieldPosition* pos,
00683 UErrorCode* status);
00684
00705 U_STABLE int32_t U_EXPORT2
00706 unum_formatUFormattable(const UNumberFormat* fmt,
00707 const UFormattable *number,
00708 UChar *result,
00709 int32_t resultLength,
00710 UFieldPosition *pos,
00711 UErrorCode *status);
00712
00732 U_STABLE int32_t U_EXPORT2
00733 unum_parse( const UNumberFormat* fmt,
00734 const UChar* text,
00735 int32_t textLength,
00736 int32_t *parsePos ,
00737 UErrorCode *status);
00738
00758 U_STABLE int64_t U_EXPORT2
00759 unum_parseInt64(const UNumberFormat* fmt,
00760 const UChar* text,
00761 int32_t textLength,
00762 int32_t *parsePos ,
00763 UErrorCode *status);
00764
00784 U_STABLE double U_EXPORT2
00785 unum_parseDouble( const UNumberFormat* fmt,
00786 const UChar* text,
00787 int32_t textLength,
00788 int32_t *parsePos ,
00789 UErrorCode *status);
00790
00791
00819 U_STABLE int32_t U_EXPORT2
00820 unum_parseDecimal(const UNumberFormat* fmt,
00821 const UChar* text,
00822 int32_t textLength,
00823 int32_t *parsePos ,
00824 char *outBuf,
00825 int32_t outBufLength,
00826 UErrorCode *status);
00827
00847 U_STABLE double U_EXPORT2
00848 unum_parseDoubleCurrency(const UNumberFormat* fmt,
00849 const UChar* text,
00850 int32_t textLength,
00851 int32_t* parsePos,
00852 UChar* currency,
00853 UErrorCode* status);
00854
00875 U_STABLE UFormattable* U_EXPORT2
00876 unum_parseToUFormattable(const UNumberFormat* fmt,
00877 UFormattable *result,
00878 const UChar* text,
00879 int32_t textLength,
00880 int32_t* parsePos,
00881 UErrorCode* status);
00882
00899 U_STABLE void U_EXPORT2
00900 unum_applyPattern( UNumberFormat *format,
00901 UBool localized,
00902 const UChar *pattern,
00903 int32_t patternLength,
00904 UParseError *parseError,
00905 UErrorCode *status
00906 );
00907
00918 U_STABLE const char* U_EXPORT2
00919 unum_getAvailable(int32_t localeIndex);
00920
00930 U_STABLE int32_t U_EXPORT2
00931 unum_countAvailable(void);
00932
00933 #if UCONFIG_HAVE_PARSEALLINPUT
00934
00938 typedef enum UNumberFormatAttributeValue {
00939 #ifndef U_HIDE_INTERNAL_API
00940
00941 UNUM_NO = 0,
00943 UNUM_YES = 1,
00945 UNUM_MAYBE = 2
00946 #else
00947
00948 UNUM_FORMAT_ATTRIBUTE_VALUE_HIDDEN
00949 #endif
00950 } UNumberFormatAttributeValue;
00951 #endif
00952
00954 typedef enum UNumberFormatAttribute {
00956 UNUM_PARSE_INT_ONLY,
00958 UNUM_GROUPING_USED,
00960 UNUM_DECIMAL_ALWAYS_SHOWN,
00962 UNUM_MAX_INTEGER_DIGITS,
00964 UNUM_MIN_INTEGER_DIGITS,
00966 UNUM_INTEGER_DIGITS,
00968 UNUM_MAX_FRACTION_DIGITS,
00970 UNUM_MIN_FRACTION_DIGITS,
00972 UNUM_FRACTION_DIGITS,
00974 UNUM_MULTIPLIER,
00976 UNUM_GROUPING_SIZE,
00978 UNUM_ROUNDING_MODE,
00980 UNUM_ROUNDING_INCREMENT,
00982 UNUM_FORMAT_WIDTH,
00984 UNUM_PADDING_POSITION,
00986 UNUM_SECONDARY_GROUPING_SIZE,
00989 UNUM_SIGNIFICANT_DIGITS_USED,
00992 UNUM_MIN_SIGNIFICANT_DIGITS,
00995 UNUM_MAX_SIGNIFICANT_DIGITS,
00999 UNUM_LENIENT_PARSE,
01000 #if UCONFIG_HAVE_PARSEALLINPUT
01001
01005 UNUM_PARSE_ALL_INPUT = 20,
01006 #endif
01007
01016 UNUM_SCALE = 21,
01017 #ifndef U_HIDE_INTERNAL_API
01018
01024 UNUM_MINIMUM_GROUPING_DIGITS = 22,
01025
01026 #endif
01027
01034 UNUM_CURRENCY_USAGE = 23,
01035
01036
01040 UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 0x0FFF,
01041
01047 UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS = 0x1000,
01054 UNUM_PARSE_NO_EXPONENT,
01055
01064 UNUM_PARSE_DECIMAL_MARK_REQUIRED = 0x1002,
01065
01066
01069 UNUM_LIMIT_BOOLEAN_ATTRIBUTE = 0x1003
01070 } UNumberFormatAttribute;
01071
01089 U_STABLE int32_t U_EXPORT2
01090 unum_getAttribute(const UNumberFormat* fmt,
01091 UNumberFormatAttribute attr);
01092
01112 U_STABLE void U_EXPORT2
01113 unum_setAttribute( UNumberFormat* fmt,
01114 UNumberFormatAttribute attr,
01115 int32_t newValue);
01116
01117
01132 U_STABLE double U_EXPORT2
01133 unum_getDoubleAttribute(const UNumberFormat* fmt,
01134 UNumberFormatAttribute attr);
01135
01150 U_STABLE void U_EXPORT2
01151 unum_setDoubleAttribute( UNumberFormat* fmt,
01152 UNumberFormatAttribute attr,
01153 double newValue);
01154
01156 typedef enum UNumberFormatTextAttribute {
01158 UNUM_POSITIVE_PREFIX,
01160 UNUM_POSITIVE_SUFFIX,
01162 UNUM_NEGATIVE_PREFIX,
01164 UNUM_NEGATIVE_SUFFIX,
01166 UNUM_PADDING_CHARACTER,
01168 UNUM_CURRENCY_CODE,
01177 UNUM_DEFAULT_RULESET,
01186 UNUM_PUBLIC_RULESETS
01187 } UNumberFormatTextAttribute;
01188
01207 U_STABLE int32_t U_EXPORT2
01208 unum_getTextAttribute( const UNumberFormat* fmt,
01209 UNumberFormatTextAttribute tag,
01210 UChar* result,
01211 int32_t resultLength,
01212 UErrorCode* status);
01213
01230 U_STABLE void U_EXPORT2
01231 unum_setTextAttribute( UNumberFormat* fmt,
01232 UNumberFormatTextAttribute tag,
01233 const UChar* newValue,
01234 int32_t newValueLength,
01235 UErrorCode *status);
01236
01253 U_STABLE int32_t U_EXPORT2
01254 unum_toPattern( const UNumberFormat* fmt,
01255 UBool isPatternLocalized,
01256 UChar* result,
01257 int32_t resultLength,
01258 UErrorCode* status);
01259
01260
01265 typedef enum UNumberFormatSymbol {
01267 UNUM_DECIMAL_SEPARATOR_SYMBOL = 0,
01269 UNUM_GROUPING_SEPARATOR_SYMBOL = 1,
01271 UNUM_PATTERN_SEPARATOR_SYMBOL = 2,
01273 UNUM_PERCENT_SYMBOL = 3,
01275 UNUM_ZERO_DIGIT_SYMBOL = 4,
01277 UNUM_DIGIT_SYMBOL = 5,
01279 UNUM_MINUS_SIGN_SYMBOL = 6,
01281 UNUM_PLUS_SIGN_SYMBOL = 7,
01283 UNUM_CURRENCY_SYMBOL = 8,
01285 UNUM_INTL_CURRENCY_SYMBOL = 9,
01287 UNUM_MONETARY_SEPARATOR_SYMBOL = 10,
01289 UNUM_EXPONENTIAL_SYMBOL = 11,
01291 UNUM_PERMILL_SYMBOL = 12,
01293 UNUM_PAD_ESCAPE_SYMBOL = 13,
01295 UNUM_INFINITY_SYMBOL = 14,
01297 UNUM_NAN_SYMBOL = 15,
01300 UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16,
01304 UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17,
01308 UNUM_ONE_DIGIT_SYMBOL = 18,
01312 UNUM_TWO_DIGIT_SYMBOL = 19,
01316 UNUM_THREE_DIGIT_SYMBOL = 20,
01320 UNUM_FOUR_DIGIT_SYMBOL = 21,
01324 UNUM_FIVE_DIGIT_SYMBOL = 22,
01328 UNUM_SIX_DIGIT_SYMBOL = 23,
01332 UNUM_SEVEN_DIGIT_SYMBOL = 24,
01336 UNUM_EIGHT_DIGIT_SYMBOL = 25,
01340 UNUM_NINE_DIGIT_SYMBOL = 26,
01341
01345 UNUM_EXPONENT_MULTIPLICATION_SYMBOL = 27,
01346
01347 #ifndef U_HIDE_DEPRECATED_API
01348
01352 UNUM_FORMAT_SYMBOL_COUNT = 28
01353 #endif
01354 } UNumberFormatSymbol;
01355
01372 U_STABLE int32_t U_EXPORT2
01373 unum_getSymbol(const UNumberFormat *fmt,
01374 UNumberFormatSymbol symbol,
01375 UChar *buffer,
01376 int32_t size,
01377 UErrorCode *status);
01378
01392 U_STABLE void U_EXPORT2
01393 unum_setSymbol(UNumberFormat *fmt,
01394 UNumberFormatSymbol symbol,
01395 const UChar *value,
01396 int32_t length,
01397 UErrorCode *status);
01398
01399
01409 U_STABLE const char* U_EXPORT2
01410 unum_getLocaleByType(const UNumberFormat *fmt,
01411 ULocDataLocaleType type,
01412 UErrorCode* status);
01413
01422 U_STABLE void U_EXPORT2
01423 unum_setContext(UNumberFormat* fmt, UDisplayContext value, UErrorCode* status);
01424
01434 U_STABLE UDisplayContext U_EXPORT2
01435 unum_getContext(const UNumberFormat *fmt, UDisplayContextType type, UErrorCode* status);
01436
01437 #endif
01438
01439 #endif