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
00341 #ifndef U_FORCE_HIDE_DEPRECATED_API
00342
00346 UNUM_CURRENCY_SPACING_COUNT
00347 #endif // U_FORCE_HIDE_DEPRECATED_API
00348 };
00349 typedef enum UCurrencySpacing UCurrencySpacing;
00357 typedef enum UNumberFormatFields {
00359 UNUM_INTEGER_FIELD,
00361 UNUM_FRACTION_FIELD,
00363 UNUM_DECIMAL_SEPARATOR_FIELD,
00365 UNUM_EXPONENT_SYMBOL_FIELD,
00367 UNUM_EXPONENT_SIGN_FIELD,
00369 UNUM_EXPONENT_FIELD,
00371 UNUM_GROUPING_SEPARATOR_FIELD,
00373 UNUM_CURRENCY_FIELD,
00375 UNUM_PERCENT_FIELD,
00377 UNUM_PERMILL_FIELD,
00379 UNUM_SIGN_FIELD,
00380 #ifndef U_HIDE_DRAFT_API
00381
00382 UNUM_MEASURE_UNIT_FIELD,
00384 UNUM_COMPACT_FIELD,
00385 #endif
00386
00387 #ifndef U_HIDE_DEPRECATED_API
00388
00392 UNUM_FIELD_COUNT = UNUM_SIGN_FIELD + 3
00393 #endif
00394 } UNumberFormatFields;
00395
00396
00434 U_STABLE UNumberFormat* U_EXPORT2
00435 unum_open( UNumberFormatStyle style,
00436 const UChar* pattern,
00437 int32_t patternLength,
00438 const char* locale,
00439 UParseError* parseErr,
00440 UErrorCode* status);
00441
00442
00449 U_STABLE void U_EXPORT2
00450 unum_close(UNumberFormat* fmt);
00451
00452 #if U_SHOW_CPLUSPLUS_API
00453
00454 U_NAMESPACE_BEGIN
00455
00465 U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberFormatPointer, UNumberFormat, unum_close);
00466
00467 U_NAMESPACE_END
00468
00469 #endif
00470
00479 U_STABLE UNumberFormat* U_EXPORT2
00480 unum_clone(const UNumberFormat *fmt,
00481 UErrorCode *status);
00482
00507 U_STABLE int32_t U_EXPORT2
00508 unum_format( const UNumberFormat* fmt,
00509 int32_t number,
00510 UChar* result,
00511 int32_t resultLength,
00512 UFieldPosition *pos,
00513 UErrorCode* status);
00514
00539 U_STABLE int32_t U_EXPORT2
00540 unum_formatInt64(const UNumberFormat *fmt,
00541 int64_t number,
00542 UChar* result,
00543 int32_t resultLength,
00544 UFieldPosition *pos,
00545 UErrorCode* status);
00546
00571 U_STABLE int32_t U_EXPORT2
00572 unum_formatDouble( const UNumberFormat* fmt,
00573 double number,
00574 UChar* result,
00575 int32_t resultLength,
00576 UFieldPosition *pos,
00577 UErrorCode* status);
00578
00621 U_STABLE int32_t U_EXPORT2
00622 unum_formatDoubleForFields(const UNumberFormat* format,
00623 double number,
00624 UChar* result,
00625 int32_t resultLength,
00626 UFieldPositionIterator* fpositer,
00627 UErrorCode* status);
00628
00629
00658 U_STABLE int32_t U_EXPORT2
00659 unum_formatDecimal( const UNumberFormat* fmt,
00660 const char * number,
00661 int32_t length,
00662 UChar* result,
00663 int32_t resultLength,
00664 UFieldPosition *pos,
00665 UErrorCode* status);
00666
00691 U_STABLE int32_t U_EXPORT2
00692 unum_formatDoubleCurrency(const UNumberFormat* fmt,
00693 double number,
00694 UChar* currency,
00695 UChar* result,
00696 int32_t resultLength,
00697 UFieldPosition* pos,
00698 UErrorCode* status);
00699
00720 U_STABLE int32_t U_EXPORT2
00721 unum_formatUFormattable(const UNumberFormat* fmt,
00722 const UFormattable *number,
00723 UChar *result,
00724 int32_t resultLength,
00725 UFieldPosition *pos,
00726 UErrorCode *status);
00727
00747 U_STABLE int32_t U_EXPORT2
00748 unum_parse( const UNumberFormat* fmt,
00749 const UChar* text,
00750 int32_t textLength,
00751 int32_t *parsePos ,
00752 UErrorCode *status);
00753
00773 U_STABLE int64_t U_EXPORT2
00774 unum_parseInt64(const UNumberFormat* fmt,
00775 const UChar* text,
00776 int32_t textLength,
00777 int32_t *parsePos ,
00778 UErrorCode *status);
00779
00799 U_STABLE double U_EXPORT2
00800 unum_parseDouble( const UNumberFormat* fmt,
00801 const UChar* text,
00802 int32_t textLength,
00803 int32_t *parsePos ,
00804 UErrorCode *status);
00805
00806
00834 U_STABLE int32_t U_EXPORT2
00835 unum_parseDecimal(const UNumberFormat* fmt,
00836 const UChar* text,
00837 int32_t textLength,
00838 int32_t *parsePos ,
00839 char *outBuf,
00840 int32_t outBufLength,
00841 UErrorCode *status);
00842
00862 U_STABLE double U_EXPORT2
00863 unum_parseDoubleCurrency(const UNumberFormat* fmt,
00864 const UChar* text,
00865 int32_t textLength,
00866 int32_t* parsePos,
00867 UChar* currency,
00868 UErrorCode* status);
00869
00890 U_STABLE UFormattable* U_EXPORT2
00891 unum_parseToUFormattable(const UNumberFormat* fmt,
00892 UFormattable *result,
00893 const UChar* text,
00894 int32_t textLength,
00895 int32_t* parsePos,
00896 UErrorCode* status);
00897
00914 U_STABLE void U_EXPORT2
00915 unum_applyPattern( UNumberFormat *format,
00916 UBool localized,
00917 const UChar *pattern,
00918 int32_t patternLength,
00919 UParseError *parseError,
00920 UErrorCode *status
00921 );
00922
00933 U_STABLE const char* U_EXPORT2
00934 unum_getAvailable(int32_t localeIndex);
00935
00945 U_STABLE int32_t U_EXPORT2
00946 unum_countAvailable(void);
00947
00948 #if UCONFIG_HAVE_PARSEALLINPUT
00949
00953 typedef enum UNumberFormatAttributeValue {
00954 #ifndef U_HIDE_INTERNAL_API
00955
00956 UNUM_NO = 0,
00958 UNUM_YES = 1,
00960 UNUM_MAYBE = 2
00961 #else
00962
00963 UNUM_FORMAT_ATTRIBUTE_VALUE_HIDDEN
00964 #endif
00965 } UNumberFormatAttributeValue;
00966 #endif
00967
00969 typedef enum UNumberFormatAttribute {
00971 UNUM_PARSE_INT_ONLY,
00973 UNUM_GROUPING_USED,
00975 UNUM_DECIMAL_ALWAYS_SHOWN,
00977 UNUM_MAX_INTEGER_DIGITS,
00979 UNUM_MIN_INTEGER_DIGITS,
00981 UNUM_INTEGER_DIGITS,
00983 UNUM_MAX_FRACTION_DIGITS,
00985 UNUM_MIN_FRACTION_DIGITS,
00987 UNUM_FRACTION_DIGITS,
00989 UNUM_MULTIPLIER,
00991 UNUM_GROUPING_SIZE,
00993 UNUM_ROUNDING_MODE,
00995 UNUM_ROUNDING_INCREMENT,
00997 UNUM_FORMAT_WIDTH,
00999 UNUM_PADDING_POSITION,
01001 UNUM_SECONDARY_GROUPING_SIZE,
01004 UNUM_SIGNIFICANT_DIGITS_USED,
01007 UNUM_MIN_SIGNIFICANT_DIGITS,
01010 UNUM_MAX_SIGNIFICANT_DIGITS,
01014 UNUM_LENIENT_PARSE,
01015 #if UCONFIG_HAVE_PARSEALLINPUT
01016
01020 UNUM_PARSE_ALL_INPUT = 20,
01021 #endif
01022
01033 UNUM_SCALE = 21,
01034
01035 #ifndef U_HIDE_DRAFT_API
01036
01044 UNUM_MINIMUM_GROUPING_DIGITS = 22,
01045 #endif
01046
01053 UNUM_CURRENCY_USAGE = 23,
01054
01055 #ifndef U_HIDE_INTERNAL_API
01056
01059 UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 0x0FFF,
01060 #endif
01061
01067 UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS = 0x1000,
01074 UNUM_PARSE_NO_EXPONENT = 0x1001,
01075
01084 UNUM_PARSE_DECIMAL_MARK_REQUIRED = 0x1002,
01085
01086 #ifndef U_HIDE_DRAFT_API
01087
01093 UNUM_PARSE_CASE_SENSITIVE = 0x1003,
01094
01102 UNUM_SIGN_ALWAYS_SHOWN = 0x1004,
01103
01104 #endif
01105
01106 #ifndef U_HIDE_INTERNAL_API
01107
01110 UNUM_LIMIT_BOOLEAN_ATTRIBUTE = 0x1005,
01111 #endif
01112
01113 } UNumberFormatAttribute;
01114
01132 U_STABLE int32_t U_EXPORT2
01133 unum_getAttribute(const UNumberFormat* fmt,
01134 UNumberFormatAttribute attr);
01135
01155 U_STABLE void U_EXPORT2
01156 unum_setAttribute( UNumberFormat* fmt,
01157 UNumberFormatAttribute attr,
01158 int32_t newValue);
01159
01160
01175 U_STABLE double U_EXPORT2
01176 unum_getDoubleAttribute(const UNumberFormat* fmt,
01177 UNumberFormatAttribute attr);
01178
01193 U_STABLE void U_EXPORT2
01194 unum_setDoubleAttribute( UNumberFormat* fmt,
01195 UNumberFormatAttribute attr,
01196 double newValue);
01197
01199 typedef enum UNumberFormatTextAttribute {
01201 UNUM_POSITIVE_PREFIX,
01203 UNUM_POSITIVE_SUFFIX,
01205 UNUM_NEGATIVE_PREFIX,
01207 UNUM_NEGATIVE_SUFFIX,
01209 UNUM_PADDING_CHARACTER,
01211 UNUM_CURRENCY_CODE,
01220 UNUM_DEFAULT_RULESET,
01229 UNUM_PUBLIC_RULESETS
01230 } UNumberFormatTextAttribute;
01231
01250 U_STABLE int32_t U_EXPORT2
01251 unum_getTextAttribute( const UNumberFormat* fmt,
01252 UNumberFormatTextAttribute tag,
01253 UChar* result,
01254 int32_t resultLength,
01255 UErrorCode* status);
01256
01273 U_STABLE void U_EXPORT2
01274 unum_setTextAttribute( UNumberFormat* fmt,
01275 UNumberFormatTextAttribute tag,
01276 const UChar* newValue,
01277 int32_t newValueLength,
01278 UErrorCode *status);
01279
01296 U_STABLE int32_t U_EXPORT2
01297 unum_toPattern( const UNumberFormat* fmt,
01298 UBool isPatternLocalized,
01299 UChar* result,
01300 int32_t resultLength,
01301 UErrorCode* status);
01302
01303
01308 typedef enum UNumberFormatSymbol {
01310 UNUM_DECIMAL_SEPARATOR_SYMBOL = 0,
01312 UNUM_GROUPING_SEPARATOR_SYMBOL = 1,
01314 UNUM_PATTERN_SEPARATOR_SYMBOL = 2,
01316 UNUM_PERCENT_SYMBOL = 3,
01318 UNUM_ZERO_DIGIT_SYMBOL = 4,
01320 UNUM_DIGIT_SYMBOL = 5,
01322 UNUM_MINUS_SIGN_SYMBOL = 6,
01324 UNUM_PLUS_SIGN_SYMBOL = 7,
01326 UNUM_CURRENCY_SYMBOL = 8,
01328 UNUM_INTL_CURRENCY_SYMBOL = 9,
01330 UNUM_MONETARY_SEPARATOR_SYMBOL = 10,
01332 UNUM_EXPONENTIAL_SYMBOL = 11,
01334 UNUM_PERMILL_SYMBOL = 12,
01336 UNUM_PAD_ESCAPE_SYMBOL = 13,
01338 UNUM_INFINITY_SYMBOL = 14,
01340 UNUM_NAN_SYMBOL = 15,
01343 UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16,
01347 UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17,
01351 UNUM_ONE_DIGIT_SYMBOL = 18,
01355 UNUM_TWO_DIGIT_SYMBOL = 19,
01359 UNUM_THREE_DIGIT_SYMBOL = 20,
01363 UNUM_FOUR_DIGIT_SYMBOL = 21,
01367 UNUM_FIVE_DIGIT_SYMBOL = 22,
01371 UNUM_SIX_DIGIT_SYMBOL = 23,
01375 UNUM_SEVEN_DIGIT_SYMBOL = 24,
01379 UNUM_EIGHT_DIGIT_SYMBOL = 25,
01383 UNUM_NINE_DIGIT_SYMBOL = 26,
01384
01388 UNUM_EXPONENT_MULTIPLICATION_SYMBOL = 27,
01389
01390 #ifndef U_HIDE_DEPRECATED_API
01391
01395 UNUM_FORMAT_SYMBOL_COUNT = 28
01396 #endif
01397 } UNumberFormatSymbol;
01398
01415 U_STABLE int32_t U_EXPORT2
01416 unum_getSymbol(const UNumberFormat *fmt,
01417 UNumberFormatSymbol symbol,
01418 UChar *buffer,
01419 int32_t size,
01420 UErrorCode *status);
01421
01435 U_STABLE void U_EXPORT2
01436 unum_setSymbol(UNumberFormat *fmt,
01437 UNumberFormatSymbol symbol,
01438 const UChar *value,
01439 int32_t length,
01440 UErrorCode *status);
01441
01442
01452 U_STABLE const char* U_EXPORT2
01453 unum_getLocaleByType(const UNumberFormat *fmt,
01454 ULocDataLocaleType type,
01455 UErrorCode* status);
01456
01465 U_STABLE void U_EXPORT2
01466 unum_setContext(UNumberFormat* fmt, UDisplayContext value, UErrorCode* status);
01467
01477 U_STABLE UDisplayContext U_EXPORT2
01478 unum_getContext(const UNumberFormat *fmt, UDisplayContextType type, UErrorCode* status);
01479
01480 #endif
01481
01482 #endif