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/uloc.h"
00022 #include "unicode/ucurr.h"
00023 #include "unicode/umisc.h"
00024 #include "unicode/parseerr.h"
00025 #include "unicode/uformattable.h"
00026 #include "unicode/udisplaycontext.h"
00027 #include "unicode/ufieldpositer.h"
00028
00029 #if U_SHOW_CPLUSPLUS_API
00030 #include "unicode/localpointer.h"
00031 #endif // U_SHOW_CPLUSPLUS_API
00032
00144 typedef void* UNumberFormat;
00145
00149 typedef enum UNumberFormatStyle {
00154 UNUM_PATTERN_DECIMAL=0,
00159 UNUM_DECIMAL=1,
00168 UNUM_CURRENCY=2,
00173 UNUM_PERCENT=3,
00178 UNUM_SCIENTIFIC=4,
00185 UNUM_SPELLOUT=5,
00192 UNUM_ORDINAL=6,
00197 UNUM_DURATION=7,
00202 UNUM_NUMBERING_SYSTEM=8,
00207 UNUM_PATTERN_RULEBASED=9,
00212 UNUM_CURRENCY_ISO=10,
00218 UNUM_CURRENCY_PLURAL=11,
00225 UNUM_CURRENCY_ACCOUNTING=12,
00231 UNUM_CASH_CURRENCY=13,
00238 UNUM_DECIMAL_COMPACT_SHORT=14,
00245 UNUM_DECIMAL_COMPACT_LONG=15,
00252 UNUM_CURRENCY_STANDARD=16,
00253
00254 #ifndef U_HIDE_DEPRECATED_API
00255
00259 UNUM_FORMAT_STYLE_COUNT=17,
00260 #endif
00261
00266 UNUM_DEFAULT = UNUM_DECIMAL,
00271 UNUM_IGNORE = UNUM_PATTERN_DECIMAL
00272 } UNumberFormatStyle;
00273
00282 typedef enum UNumberFormatRoundingMode {
00283 UNUM_ROUND_CEILING,
00284 UNUM_ROUND_FLOOR,
00285 UNUM_ROUND_DOWN,
00286 UNUM_ROUND_UP,
00291 UNUM_ROUND_HALFEVEN,
00292 #ifndef U_HIDE_DEPRECATED_API
00293
00297 UNUM_FOUND_HALFEVEN = UNUM_ROUND_HALFEVEN,
00298 #endif
00299 UNUM_ROUND_HALFDOWN = UNUM_ROUND_HALFEVEN + 1,
00300 UNUM_ROUND_HALFUP,
00305 UNUM_ROUND_UNNECESSARY,
00310 UNUM_ROUND_HALF_ODD,
00315 UNUM_ROUND_HALF_CEILING,
00320 UNUM_ROUND_HALF_FLOOR,
00321 } UNumberFormatRoundingMode;
00322
00326 typedef enum UNumberFormatPadPosition {
00327 UNUM_PAD_BEFORE_PREFIX,
00328 UNUM_PAD_AFTER_PREFIX,
00329 UNUM_PAD_BEFORE_SUFFIX,
00330 UNUM_PAD_AFTER_SUFFIX
00331 } UNumberFormatPadPosition;
00332
00337 typedef enum UNumberCompactStyle {
00339 UNUM_SHORT,
00341 UNUM_LONG
00343 } UNumberCompactStyle;
00344
00349 enum UCurrencySpacing {
00351 UNUM_CURRENCY_MATCH,
00353 UNUM_CURRENCY_SURROUNDING_MATCH,
00355 UNUM_CURRENCY_INSERT,
00356
00357
00358
00359 #ifndef U_FORCE_HIDE_DEPRECATED_API
00360
00364 UNUM_CURRENCY_SPACING_COUNT
00365 #endif // U_FORCE_HIDE_DEPRECATED_API
00366 };
00367 typedef enum UCurrencySpacing UCurrencySpacing;
00375 typedef enum UNumberFormatFields {
00377 UNUM_INTEGER_FIELD,
00379 UNUM_FRACTION_FIELD,
00381 UNUM_DECIMAL_SEPARATOR_FIELD,
00383 UNUM_EXPONENT_SYMBOL_FIELD,
00385 UNUM_EXPONENT_SIGN_FIELD,
00387 UNUM_EXPONENT_FIELD,
00389 UNUM_GROUPING_SEPARATOR_FIELD,
00391 UNUM_CURRENCY_FIELD,
00393 UNUM_PERCENT_FIELD,
00395 UNUM_PERMILL_FIELD,
00397 UNUM_SIGN_FIELD,
00399 UNUM_MEASURE_UNIT_FIELD,
00401 UNUM_COMPACT_FIELD,
00402 #ifndef U_HIDE_DRAFT_API
00403
00407 UNUM_APPROXIMATELY_SIGN_FIELD,
00408 #endif // U_HIDE_DRAFT_API
00409
00410 #ifndef U_HIDE_DEPRECATED_API
00411
00415 #ifndef U_HIDE_DRAFT_API
00416 UNUM_FIELD_COUNT = UNUM_COMPACT_FIELD + 2
00417 #else // U_HIDE_DRAFT_API (for UNUM_APPROXIMATELY_SIGN_FIELD)
00418 UNUM_FIELD_COUNT = UNUM_COMPACT_FIELD + 1
00419 #endif // U_HIDE_DRAFT_API (for UNUM_APPROXIMATELY_SIGN_FIELD)
00420 #endif
00421 } UNumberFormatFields;
00422
00423
00431 typedef enum UNumberFormatMinimumGroupingDigits {
00436 UNUM_MINIMUM_GROUPING_DIGITS_AUTO = -2,
00443 UNUM_MINIMUM_GROUPING_DIGITS_MIN2 = -3,
00444 } UNumberFormatMinimumGroupingDigits;
00445
00483 U_CAPI UNumberFormat* U_EXPORT2
00484 unum_open( UNumberFormatStyle style,
00485 const UChar* pattern,
00486 int32_t patternLength,
00487 const char* locale,
00488 UParseError* parseErr,
00489 UErrorCode* status);
00490
00491
00498 U_CAPI void U_EXPORT2
00499 unum_close(UNumberFormat* fmt);
00500
00501 #if U_SHOW_CPLUSPLUS_API
00502
00503 U_NAMESPACE_BEGIN
00504
00514 U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberFormatPointer, UNumberFormat, unum_close);
00515
00516 U_NAMESPACE_END
00517
00518 #endif
00519
00528 U_CAPI UNumberFormat* U_EXPORT2
00529 unum_clone(const UNumberFormat *fmt,
00530 UErrorCode *status);
00531
00556 U_CAPI int32_t U_EXPORT2
00557 unum_format( const UNumberFormat* fmt,
00558 int32_t number,
00559 UChar* result,
00560 int32_t resultLength,
00561 UFieldPosition *pos,
00562 UErrorCode* status);
00563
00588 U_CAPI int32_t U_EXPORT2
00589 unum_formatInt64(const UNumberFormat *fmt,
00590 int64_t number,
00591 UChar* result,
00592 int32_t resultLength,
00593 UFieldPosition *pos,
00594 UErrorCode* status);
00595
00620 U_CAPI int32_t U_EXPORT2
00621 unum_formatDouble( const UNumberFormat* fmt,
00622 double number,
00623 UChar* result,
00624 int32_t resultLength,
00625 UFieldPosition *pos,
00626 UErrorCode* status);
00627
00670 U_CAPI int32_t U_EXPORT2
00671 unum_formatDoubleForFields(const UNumberFormat* format,
00672 double number,
00673 UChar* result,
00674 int32_t resultLength,
00675 UFieldPositionIterator* fpositer,
00676 UErrorCode* status);
00677
00678
00707 U_CAPI int32_t U_EXPORT2
00708 unum_formatDecimal( const UNumberFormat* fmt,
00709 const char * number,
00710 int32_t length,
00711 UChar* result,
00712 int32_t resultLength,
00713 UFieldPosition *pos,
00714 UErrorCode* status);
00715
00746 U_CAPI int32_t U_EXPORT2
00747 unum_formatDoubleCurrency(const UNumberFormat* fmt,
00748 double number,
00749 UChar* currency,
00750 UChar* result,
00751 int32_t resultLength,
00752 UFieldPosition* pos,
00753 UErrorCode* status);
00754
00775 U_CAPI int32_t U_EXPORT2
00776 unum_formatUFormattable(const UNumberFormat* fmt,
00777 const UFormattable *number,
00778 UChar *result,
00779 int32_t resultLength,
00780 UFieldPosition *pos,
00781 UErrorCode *status);
00782
00802 U_CAPI int32_t U_EXPORT2
00803 unum_parse( const UNumberFormat* fmt,
00804 const UChar* text,
00805 int32_t textLength,
00806 int32_t *parsePos ,
00807 UErrorCode *status);
00808
00828 U_CAPI int64_t U_EXPORT2
00829 unum_parseInt64(const UNumberFormat* fmt,
00830 const UChar* text,
00831 int32_t textLength,
00832 int32_t *parsePos ,
00833 UErrorCode *status);
00834
00854 U_CAPI double U_EXPORT2
00855 unum_parseDouble( const UNumberFormat* fmt,
00856 const UChar* text,
00857 int32_t textLength,
00858 int32_t *parsePos ,
00859 UErrorCode *status);
00860
00861
00889 U_CAPI int32_t U_EXPORT2
00890 unum_parseDecimal(const UNumberFormat* fmt,
00891 const UChar* text,
00892 int32_t textLength,
00893 int32_t *parsePos ,
00894 char *outBuf,
00895 int32_t outBufLength,
00896 UErrorCode *status);
00897
00917 U_CAPI double U_EXPORT2
00918 unum_parseDoubleCurrency(const UNumberFormat* fmt,
00919 const UChar* text,
00920 int32_t textLength,
00921 int32_t* parsePos,
00922 UChar* currency,
00923 UErrorCode* status);
00924
00945 U_CAPI UFormattable* U_EXPORT2
00946 unum_parseToUFormattable(const UNumberFormat* fmt,
00947 UFormattable *result,
00948 const UChar* text,
00949 int32_t textLength,
00950 int32_t* parsePos,
00951 UErrorCode* status);
00952
00969 U_CAPI void U_EXPORT2
00970 unum_applyPattern( UNumberFormat *format,
00971 UBool localized,
00972 const UChar *pattern,
00973 int32_t patternLength,
00974 UParseError *parseError,
00975 UErrorCode *status
00976 );
00977
00988 U_CAPI const char* U_EXPORT2
00989 unum_getAvailable(int32_t localeIndex);
00990
01000 U_CAPI int32_t U_EXPORT2
01001 unum_countAvailable(void);
01002
01003 #if UCONFIG_HAVE_PARSEALLINPUT
01004
01008 typedef enum UNumberFormatAttributeValue {
01009 #ifndef U_HIDE_INTERNAL_API
01010
01011 UNUM_NO = 0,
01013 UNUM_YES = 1,
01015 UNUM_MAYBE = 2
01016 #else
01017
01018 UNUM_FORMAT_ATTRIBUTE_VALUE_HIDDEN
01019 #endif
01020 } UNumberFormatAttributeValue;
01021 #endif
01022
01024 typedef enum UNumberFormatAttribute {
01026 UNUM_PARSE_INT_ONLY,
01028 UNUM_GROUPING_USED,
01030 UNUM_DECIMAL_ALWAYS_SHOWN,
01032 UNUM_MAX_INTEGER_DIGITS,
01034 UNUM_MIN_INTEGER_DIGITS,
01036 UNUM_INTEGER_DIGITS,
01038 UNUM_MAX_FRACTION_DIGITS,
01040 UNUM_MIN_FRACTION_DIGITS,
01042 UNUM_FRACTION_DIGITS,
01044 UNUM_MULTIPLIER,
01046 UNUM_GROUPING_SIZE,
01048 UNUM_ROUNDING_MODE,
01050 UNUM_ROUNDING_INCREMENT,
01052 UNUM_FORMAT_WIDTH,
01054 UNUM_PADDING_POSITION,
01056 UNUM_SECONDARY_GROUPING_SIZE,
01059 UNUM_SIGNIFICANT_DIGITS_USED,
01062 UNUM_MIN_SIGNIFICANT_DIGITS,
01065 UNUM_MAX_SIGNIFICANT_DIGITS,
01069 UNUM_LENIENT_PARSE,
01070 #if UCONFIG_HAVE_PARSEALLINPUT
01071
01075 UNUM_PARSE_ALL_INPUT = 20,
01076 #endif
01077
01088 UNUM_SCALE = 21,
01089
01098 UNUM_MINIMUM_GROUPING_DIGITS = 22,
01099
01106 UNUM_CURRENCY_USAGE = 23,
01107
01108 #ifndef U_HIDE_INTERNAL_API
01109
01112 UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 0x0FFF,
01113 #endif
01114
01120 UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS = 0x1000,
01127 UNUM_PARSE_NO_EXPONENT = 0x1001,
01128
01137 UNUM_PARSE_DECIMAL_MARK_REQUIRED = 0x1002,
01138
01144 UNUM_PARSE_CASE_SENSITIVE = 0x1003,
01145
01153 UNUM_SIGN_ALWAYS_SHOWN = 0x1004,
01154
01155 #ifndef U_HIDE_INTERNAL_API
01156
01159 UNUM_LIMIT_BOOLEAN_ATTRIBUTE = 0x1005,
01160 #endif
01161
01162 } UNumberFormatAttribute;
01163
01181 U_CAPI int32_t U_EXPORT2
01182 unum_getAttribute(const UNumberFormat* fmt,
01183 UNumberFormatAttribute attr);
01184
01204 U_CAPI void U_EXPORT2
01205 unum_setAttribute( UNumberFormat* fmt,
01206 UNumberFormatAttribute attr,
01207 int32_t newValue);
01208
01209
01224 U_CAPI double U_EXPORT2
01225 unum_getDoubleAttribute(const UNumberFormat* fmt,
01226 UNumberFormatAttribute attr);
01227
01242 U_CAPI void U_EXPORT2
01243 unum_setDoubleAttribute( UNumberFormat* fmt,
01244 UNumberFormatAttribute attr,
01245 double newValue);
01246
01248 typedef enum UNumberFormatTextAttribute {
01250 UNUM_POSITIVE_PREFIX,
01252 UNUM_POSITIVE_SUFFIX,
01254 UNUM_NEGATIVE_PREFIX,
01256 UNUM_NEGATIVE_SUFFIX,
01258 UNUM_PADDING_CHARACTER,
01260 UNUM_CURRENCY_CODE,
01269 UNUM_DEFAULT_RULESET,
01278 UNUM_PUBLIC_RULESETS
01279 } UNumberFormatTextAttribute;
01280
01299 U_CAPI int32_t U_EXPORT2
01300 unum_getTextAttribute( const UNumberFormat* fmt,
01301 UNumberFormatTextAttribute tag,
01302 UChar* result,
01303 int32_t resultLength,
01304 UErrorCode* status);
01305
01322 U_CAPI void U_EXPORT2
01323 unum_setTextAttribute( UNumberFormat* fmt,
01324 UNumberFormatTextAttribute tag,
01325 const UChar* newValue,
01326 int32_t newValueLength,
01327 UErrorCode *status);
01328
01345 U_CAPI int32_t U_EXPORT2
01346 unum_toPattern( const UNumberFormat* fmt,
01347 UBool isPatternLocalized,
01348 UChar* result,
01349 int32_t resultLength,
01350 UErrorCode* status);
01351
01352
01357 typedef enum UNumberFormatSymbol {
01359 UNUM_DECIMAL_SEPARATOR_SYMBOL = 0,
01361 UNUM_GROUPING_SEPARATOR_SYMBOL = 1,
01363 UNUM_PATTERN_SEPARATOR_SYMBOL = 2,
01365 UNUM_PERCENT_SYMBOL = 3,
01367 UNUM_ZERO_DIGIT_SYMBOL = 4,
01369 UNUM_DIGIT_SYMBOL = 5,
01371 UNUM_MINUS_SIGN_SYMBOL = 6,
01373 UNUM_PLUS_SIGN_SYMBOL = 7,
01375 UNUM_CURRENCY_SYMBOL = 8,
01377 UNUM_INTL_CURRENCY_SYMBOL = 9,
01379 UNUM_MONETARY_SEPARATOR_SYMBOL = 10,
01381 UNUM_EXPONENTIAL_SYMBOL = 11,
01383 UNUM_PERMILL_SYMBOL = 12,
01385 UNUM_PAD_ESCAPE_SYMBOL = 13,
01387 UNUM_INFINITY_SYMBOL = 14,
01389 UNUM_NAN_SYMBOL = 15,
01392 UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16,
01396 UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17,
01400 UNUM_ONE_DIGIT_SYMBOL = 18,
01404 UNUM_TWO_DIGIT_SYMBOL = 19,
01408 UNUM_THREE_DIGIT_SYMBOL = 20,
01412 UNUM_FOUR_DIGIT_SYMBOL = 21,
01416 UNUM_FIVE_DIGIT_SYMBOL = 22,
01420 UNUM_SIX_DIGIT_SYMBOL = 23,
01424 UNUM_SEVEN_DIGIT_SYMBOL = 24,
01428 UNUM_EIGHT_DIGIT_SYMBOL = 25,
01432 UNUM_NINE_DIGIT_SYMBOL = 26,
01433
01437 UNUM_EXPONENT_MULTIPLICATION_SYMBOL = 27,
01438
01439 #ifndef U_HIDE_INTERNAL_API
01440
01443 UNUM_APPROXIMATELY_SIGN_SYMBOL = 28,
01444 #endif
01445
01446 #ifndef U_HIDE_DEPRECATED_API
01447
01451 UNUM_FORMAT_SYMBOL_COUNT = 29
01452 #endif
01453 } UNumberFormatSymbol;
01454
01471 U_CAPI int32_t U_EXPORT2
01472 unum_getSymbol(const UNumberFormat *fmt,
01473 UNumberFormatSymbol symbol,
01474 UChar *buffer,
01475 int32_t size,
01476 UErrorCode *status);
01477
01491 U_CAPI void U_EXPORT2
01492 unum_setSymbol(UNumberFormat *fmt,
01493 UNumberFormatSymbol symbol,
01494 const UChar *value,
01495 int32_t length,
01496 UErrorCode *status);
01497
01498
01508 U_CAPI const char* U_EXPORT2
01509 unum_getLocaleByType(const UNumberFormat *fmt,
01510 ULocDataLocaleType type,
01511 UErrorCode* status);
01512
01521 U_CAPI void U_EXPORT2
01522 unum_setContext(UNumberFormat* fmt, UDisplayContext value, UErrorCode* status);
01523
01533 U_CAPI UDisplayContext U_EXPORT2
01534 unum_getContext(const UNumberFormat *fmt, UDisplayContextType type, UErrorCode* status);
01535
01536 #endif
01537
01538 #endif