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
00141 typedef void* UNumberFormat;
00142
00146 typedef enum UNumberFormatStyle {
00151 UNUM_PATTERN_DECIMAL=0,
00156 UNUM_DECIMAL=1,
00165 UNUM_CURRENCY=2,
00170 UNUM_PERCENT=3,
00175 UNUM_SCIENTIFIC=4,
00182 UNUM_SPELLOUT=5,
00189 UNUM_ORDINAL=6,
00194 UNUM_DURATION=7,
00199 UNUM_NUMBERING_SYSTEM=8,
00204 UNUM_PATTERN_RULEBASED=9,
00209 UNUM_CURRENCY_ISO=10,
00215 UNUM_CURRENCY_PLURAL=11,
00222 UNUM_CURRENCY_ACCOUNTING=12,
00228 UNUM_CASH_CURRENCY=13,
00235 UNUM_DECIMAL_COMPACT_SHORT=14,
00242 UNUM_DECIMAL_COMPACT_LONG=15,
00249 UNUM_CURRENCY_STANDARD=16,
00250
00251 #ifndef U_HIDE_DEPRECATED_API
00252
00256 UNUM_FORMAT_STYLE_COUNT=17,
00257 #endif
00258
00263 UNUM_DEFAULT = UNUM_DECIMAL,
00268 UNUM_IGNORE = UNUM_PATTERN_DECIMAL
00269 } UNumberFormatStyle;
00270
00279 typedef enum UNumberFormatRoundingMode {
00280 UNUM_ROUND_CEILING,
00281 UNUM_ROUND_FLOOR,
00282 UNUM_ROUND_DOWN,
00283 UNUM_ROUND_UP,
00288 UNUM_ROUND_HALFEVEN,
00289 #ifndef U_HIDE_DEPRECATED_API
00290
00294 UNUM_FOUND_HALFEVEN = UNUM_ROUND_HALFEVEN,
00295 #endif
00296 UNUM_ROUND_HALFDOWN = UNUM_ROUND_HALFEVEN + 1,
00297 UNUM_ROUND_HALFUP,
00302 UNUM_ROUND_UNNECESSARY
00303 } UNumberFormatRoundingMode;
00304
00308 typedef enum UNumberFormatPadPosition {
00309 UNUM_PAD_BEFORE_PREFIX,
00310 UNUM_PAD_AFTER_PREFIX,
00311 UNUM_PAD_BEFORE_SUFFIX,
00312 UNUM_PAD_AFTER_SUFFIX
00313 } UNumberFormatPadPosition;
00314
00319 typedef enum UNumberCompactStyle {
00321 UNUM_SHORT,
00323 UNUM_LONG
00325 } UNumberCompactStyle;
00326
00331 enum UCurrencySpacing {
00333 UNUM_CURRENCY_MATCH,
00335 UNUM_CURRENCY_SURROUNDING_MATCH,
00337 UNUM_CURRENCY_INSERT,
00338
00339
00340
00345 UNUM_CURRENCY_SPACING_COUNT
00346 };
00347 typedef enum UCurrencySpacing UCurrencySpacing;
00355 typedef enum UNumberFormatFields {
00357 UNUM_INTEGER_FIELD,
00359 UNUM_FRACTION_FIELD,
00361 UNUM_DECIMAL_SEPARATOR_FIELD,
00363 UNUM_EXPONENT_SYMBOL_FIELD,
00365 UNUM_EXPONENT_SIGN_FIELD,
00367 UNUM_EXPONENT_FIELD,
00369 UNUM_GROUPING_SEPARATOR_FIELD,
00371 UNUM_CURRENCY_FIELD,
00373 UNUM_PERCENT_FIELD,
00375 UNUM_PERMILL_FIELD,
00377 UNUM_SIGN_FIELD,
00378 #ifndef U_HIDE_DEPRECATED_API
00379
00383 UNUM_FIELD_COUNT
00384 #endif
00385 } UNumberFormatFields;
00386
00387
00425 U_STABLE UNumberFormat* U_EXPORT2
00426 unum_open( UNumberFormatStyle style,
00427 const UChar* pattern,
00428 int32_t patternLength,
00429 const char* locale,
00430 UParseError* parseErr,
00431 UErrorCode* status);
00432
00433
00440 U_STABLE void U_EXPORT2
00441 unum_close(UNumberFormat* fmt);
00442
00443 #if U_SHOW_CPLUSPLUS_API
00444
00445 U_NAMESPACE_BEGIN
00446
00456 U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberFormatPointer, UNumberFormat, unum_close);
00457
00458 U_NAMESPACE_END
00459
00460 #endif
00461
00470 U_STABLE UNumberFormat* U_EXPORT2
00471 unum_clone(const UNumberFormat *fmt,
00472 UErrorCode *status);
00473
00498 U_STABLE int32_t U_EXPORT2
00499 unum_format( const UNumberFormat* fmt,
00500 int32_t number,
00501 UChar* result,
00502 int32_t resultLength,
00503 UFieldPosition *pos,
00504 UErrorCode* status);
00505
00530 U_STABLE int32_t U_EXPORT2
00531 unum_formatInt64(const UNumberFormat *fmt,
00532 int64_t number,
00533 UChar* result,
00534 int32_t resultLength,
00535 UFieldPosition *pos,
00536 UErrorCode* status);
00537
00562 U_STABLE int32_t U_EXPORT2
00563 unum_formatDouble( const UNumberFormat* fmt,
00564 double number,
00565 UChar* result,
00566 int32_t resultLength,
00567 UFieldPosition *pos,
00568 UErrorCode* status);
00569
00612 U_STABLE int32_t U_EXPORT2
00613 unum_formatDoubleForFields(const UNumberFormat* format,
00614 double number,
00615 UChar* result,
00616 int32_t resultLength,
00617 UFieldPositionIterator* fpositer,
00618 UErrorCode* status);
00619
00620
00649 U_STABLE int32_t U_EXPORT2
00650 unum_formatDecimal( const UNumberFormat* fmt,
00651 const char * number,
00652 int32_t length,
00653 UChar* result,
00654 int32_t resultLength,
00655 UFieldPosition *pos,
00656 UErrorCode* status);
00657
00682 U_STABLE int32_t U_EXPORT2
00683 unum_formatDoubleCurrency(const UNumberFormat* fmt,
00684 double number,
00685 UChar* currency,
00686 UChar* result,
00687 int32_t resultLength,
00688 UFieldPosition* pos,
00689 UErrorCode* status);
00690
00711 U_STABLE int32_t U_EXPORT2
00712 unum_formatUFormattable(const UNumberFormat* fmt,
00713 const UFormattable *number,
00714 UChar *result,
00715 int32_t resultLength,
00716 UFieldPosition *pos,
00717 UErrorCode *status);
00718
00738 U_STABLE int32_t U_EXPORT2
00739 unum_parse( const UNumberFormat* fmt,
00740 const UChar* text,
00741 int32_t textLength,
00742 int32_t *parsePos ,
00743 UErrorCode *status);
00744
00764 U_STABLE int64_t U_EXPORT2
00765 unum_parseInt64(const UNumberFormat* fmt,
00766 const UChar* text,
00767 int32_t textLength,
00768 int32_t *parsePos ,
00769 UErrorCode *status);
00770
00790 U_STABLE double U_EXPORT2
00791 unum_parseDouble( const UNumberFormat* fmt,
00792 const UChar* text,
00793 int32_t textLength,
00794 int32_t *parsePos ,
00795 UErrorCode *status);
00796
00797
00825 U_STABLE int32_t U_EXPORT2
00826 unum_parseDecimal(const UNumberFormat* fmt,
00827 const UChar* text,
00828 int32_t textLength,
00829 int32_t *parsePos ,
00830 char *outBuf,
00831 int32_t outBufLength,
00832 UErrorCode *status);
00833
00853 U_STABLE double U_EXPORT2
00854 unum_parseDoubleCurrency(const UNumberFormat* fmt,
00855 const UChar* text,
00856 int32_t textLength,
00857 int32_t* parsePos,
00858 UChar* currency,
00859 UErrorCode* status);
00860
00881 U_STABLE UFormattable* U_EXPORT2
00882 unum_parseToUFormattable(const UNumberFormat* fmt,
00883 UFormattable *result,
00884 const UChar* text,
00885 int32_t textLength,
00886 int32_t* parsePos,
00887 UErrorCode* status);
00888
00905 U_STABLE void U_EXPORT2
00906 unum_applyPattern( UNumberFormat *format,
00907 UBool localized,
00908 const UChar *pattern,
00909 int32_t patternLength,
00910 UParseError *parseError,
00911 UErrorCode *status
00912 );
00913
00924 U_STABLE const char* U_EXPORT2
00925 unum_getAvailable(int32_t localeIndex);
00926
00936 U_STABLE int32_t U_EXPORT2
00937 unum_countAvailable(void);
00938
00939 #if UCONFIG_HAVE_PARSEALLINPUT
00940
00944 typedef enum UNumberFormatAttributeValue {
00945 #ifndef U_HIDE_INTERNAL_API
00946
00947 UNUM_NO = 0,
00949 UNUM_YES = 1,
00951 UNUM_MAYBE = 2
00952 #else
00953
00954 UNUM_FORMAT_ATTRIBUTE_VALUE_HIDDEN
00955 #endif
00956 } UNumberFormatAttributeValue;
00957 #endif
00958
00960 typedef enum UNumberFormatAttribute {
00962 UNUM_PARSE_INT_ONLY,
00964 UNUM_GROUPING_USED,
00966 UNUM_DECIMAL_ALWAYS_SHOWN,
00968 UNUM_MAX_INTEGER_DIGITS,
00970 UNUM_MIN_INTEGER_DIGITS,
00972 UNUM_INTEGER_DIGITS,
00974 UNUM_MAX_FRACTION_DIGITS,
00976 UNUM_MIN_FRACTION_DIGITS,
00978 UNUM_FRACTION_DIGITS,
00980 UNUM_MULTIPLIER,
00982 UNUM_GROUPING_SIZE,
00984 UNUM_ROUNDING_MODE,
00986 UNUM_ROUNDING_INCREMENT,
00988 UNUM_FORMAT_WIDTH,
00990 UNUM_PADDING_POSITION,
00992 UNUM_SECONDARY_GROUPING_SIZE,
00995 UNUM_SIGNIFICANT_DIGITS_USED,
00998 UNUM_MIN_SIGNIFICANT_DIGITS,
01001 UNUM_MAX_SIGNIFICANT_DIGITS,
01005 UNUM_LENIENT_PARSE,
01006 #if UCONFIG_HAVE_PARSEALLINPUT
01007
01011 UNUM_PARSE_ALL_INPUT = 20,
01012 #endif
01013
01024 UNUM_SCALE = 21,
01025 #ifndef U_HIDE_INTERNAL_API
01026
01032 UNUM_MINIMUM_GROUPING_DIGITS = 22,
01033
01034 #endif
01035
01042 UNUM_CURRENCY_USAGE = 23,
01043
01044
01048 UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 0x0FFF,
01049
01055 UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS = 0x1000,
01062 UNUM_PARSE_NO_EXPONENT = 0x1001,
01063
01072 UNUM_PARSE_DECIMAL_MARK_REQUIRED = 0x1002,
01073
01074
01077 UNUM_LIMIT_BOOLEAN_ATTRIBUTE = 0x1003,
01078
01084 UNUM_PARSE_CASE_SENSITIVE = 0x1004,
01085
01091 UNUM_SIGN_ALWAYS_SHOWN = 0x1005,
01092 } UNumberFormatAttribute;
01093
01111 U_STABLE int32_t U_EXPORT2
01112 unum_getAttribute(const UNumberFormat* fmt,
01113 UNumberFormatAttribute attr);
01114
01134 U_STABLE void U_EXPORT2
01135 unum_setAttribute( UNumberFormat* fmt,
01136 UNumberFormatAttribute attr,
01137 int32_t newValue);
01138
01139
01154 U_STABLE double U_EXPORT2
01155 unum_getDoubleAttribute(const UNumberFormat* fmt,
01156 UNumberFormatAttribute attr);
01157
01172 U_STABLE void U_EXPORT2
01173 unum_setDoubleAttribute( UNumberFormat* fmt,
01174 UNumberFormatAttribute attr,
01175 double newValue);
01176
01178 typedef enum UNumberFormatTextAttribute {
01180 UNUM_POSITIVE_PREFIX,
01182 UNUM_POSITIVE_SUFFIX,
01184 UNUM_NEGATIVE_PREFIX,
01186 UNUM_NEGATIVE_SUFFIX,
01188 UNUM_PADDING_CHARACTER,
01190 UNUM_CURRENCY_CODE,
01199 UNUM_DEFAULT_RULESET,
01208 UNUM_PUBLIC_RULESETS
01209 } UNumberFormatTextAttribute;
01210
01229 U_STABLE int32_t U_EXPORT2
01230 unum_getTextAttribute( const UNumberFormat* fmt,
01231 UNumberFormatTextAttribute tag,
01232 UChar* result,
01233 int32_t resultLength,
01234 UErrorCode* status);
01235
01252 U_STABLE void U_EXPORT2
01253 unum_setTextAttribute( UNumberFormat* fmt,
01254 UNumberFormatTextAttribute tag,
01255 const UChar* newValue,
01256 int32_t newValueLength,
01257 UErrorCode *status);
01258
01275 U_STABLE int32_t U_EXPORT2
01276 unum_toPattern( const UNumberFormat* fmt,
01277 UBool isPatternLocalized,
01278 UChar* result,
01279 int32_t resultLength,
01280 UErrorCode* status);
01281
01282
01287 typedef enum UNumberFormatSymbol {
01289 UNUM_DECIMAL_SEPARATOR_SYMBOL = 0,
01291 UNUM_GROUPING_SEPARATOR_SYMBOL = 1,
01293 UNUM_PATTERN_SEPARATOR_SYMBOL = 2,
01295 UNUM_PERCENT_SYMBOL = 3,
01297 UNUM_ZERO_DIGIT_SYMBOL = 4,
01299 UNUM_DIGIT_SYMBOL = 5,
01301 UNUM_MINUS_SIGN_SYMBOL = 6,
01303 UNUM_PLUS_SIGN_SYMBOL = 7,
01305 UNUM_CURRENCY_SYMBOL = 8,
01307 UNUM_INTL_CURRENCY_SYMBOL = 9,
01309 UNUM_MONETARY_SEPARATOR_SYMBOL = 10,
01311 UNUM_EXPONENTIAL_SYMBOL = 11,
01313 UNUM_PERMILL_SYMBOL = 12,
01315 UNUM_PAD_ESCAPE_SYMBOL = 13,
01317 UNUM_INFINITY_SYMBOL = 14,
01319 UNUM_NAN_SYMBOL = 15,
01322 UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16,
01326 UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17,
01330 UNUM_ONE_DIGIT_SYMBOL = 18,
01334 UNUM_TWO_DIGIT_SYMBOL = 19,
01338 UNUM_THREE_DIGIT_SYMBOL = 20,
01342 UNUM_FOUR_DIGIT_SYMBOL = 21,
01346 UNUM_FIVE_DIGIT_SYMBOL = 22,
01350 UNUM_SIX_DIGIT_SYMBOL = 23,
01354 UNUM_SEVEN_DIGIT_SYMBOL = 24,
01358 UNUM_EIGHT_DIGIT_SYMBOL = 25,
01362 UNUM_NINE_DIGIT_SYMBOL = 26,
01363
01367 UNUM_EXPONENT_MULTIPLICATION_SYMBOL = 27,
01368
01369 #ifndef U_HIDE_DEPRECATED_API
01370
01374 UNUM_FORMAT_SYMBOL_COUNT = 28
01375 #endif
01376 } UNumberFormatSymbol;
01377
01394 U_STABLE int32_t U_EXPORT2
01395 unum_getSymbol(const UNumberFormat *fmt,
01396 UNumberFormatSymbol symbol,
01397 UChar *buffer,
01398 int32_t size,
01399 UErrorCode *status);
01400
01414 U_STABLE void U_EXPORT2
01415 unum_setSymbol(UNumberFormat *fmt,
01416 UNumberFormatSymbol symbol,
01417 const UChar *value,
01418 int32_t length,
01419 UErrorCode *status);
01420
01421
01431 U_STABLE const char* U_EXPORT2
01432 unum_getLocaleByType(const UNumberFormat *fmt,
01433 ULocDataLocaleType type,
01434 UErrorCode* status);
01435
01444 U_STABLE void U_EXPORT2
01445 unum_setContext(UNumberFormat* fmt, UDisplayContext value, UErrorCode* status);
01446
01456 U_STABLE UDisplayContext U_EXPORT2
01457 unum_getContext(const UNumberFormat *fmt, UDisplayContextType type, UErrorCode* status);
01458
01459 #endif
01460
01461 #endif