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,
00381 UNUM_MEASURE_UNIT_FIELD,
00383 UNUM_COMPACT_FIELD,
00384
00385 #ifndef U_HIDE_DEPRECATED_API
00386
00390 UNUM_FIELD_COUNT = UNUM_SIGN_FIELD + 3
00391 #endif
00392 } UNumberFormatFields;
00393
00394
00432 U_STABLE UNumberFormat* U_EXPORT2
00433 unum_open( UNumberFormatStyle style,
00434 const UChar* pattern,
00435 int32_t patternLength,
00436 const char* locale,
00437 UParseError* parseErr,
00438 UErrorCode* status);
00439
00440
00447 U_STABLE void U_EXPORT2
00448 unum_close(UNumberFormat* fmt);
00449
00450 #if U_SHOW_CPLUSPLUS_API
00451
00452 U_NAMESPACE_BEGIN
00453
00463 U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberFormatPointer, UNumberFormat, unum_close);
00464
00465 U_NAMESPACE_END
00466
00467 #endif
00468
00477 U_STABLE UNumberFormat* U_EXPORT2
00478 unum_clone(const UNumberFormat *fmt,
00479 UErrorCode *status);
00480
00505 U_STABLE int32_t U_EXPORT2
00506 unum_format( const UNumberFormat* fmt,
00507 int32_t number,
00508 UChar* result,
00509 int32_t resultLength,
00510 UFieldPosition *pos,
00511 UErrorCode* status);
00512
00537 U_STABLE int32_t U_EXPORT2
00538 unum_formatInt64(const UNumberFormat *fmt,
00539 int64_t number,
00540 UChar* result,
00541 int32_t resultLength,
00542 UFieldPosition *pos,
00543 UErrorCode* status);
00544
00569 U_STABLE int32_t U_EXPORT2
00570 unum_formatDouble( const UNumberFormat* fmt,
00571 double number,
00572 UChar* result,
00573 int32_t resultLength,
00574 UFieldPosition *pos,
00575 UErrorCode* status);
00576
00619 U_STABLE int32_t U_EXPORT2
00620 unum_formatDoubleForFields(const UNumberFormat* format,
00621 double number,
00622 UChar* result,
00623 int32_t resultLength,
00624 UFieldPositionIterator* fpositer,
00625 UErrorCode* status);
00626
00627
00656 U_STABLE int32_t U_EXPORT2
00657 unum_formatDecimal( const UNumberFormat* fmt,
00658 const char * number,
00659 int32_t length,
00660 UChar* result,
00661 int32_t resultLength,
00662 UFieldPosition *pos,
00663 UErrorCode* status);
00664
00689 U_STABLE int32_t U_EXPORT2
00690 unum_formatDoubleCurrency(const UNumberFormat* fmt,
00691 double number,
00692 UChar* currency,
00693 UChar* result,
00694 int32_t resultLength,
00695 UFieldPosition* pos,
00696 UErrorCode* status);
00697
00718 U_STABLE int32_t U_EXPORT2
00719 unum_formatUFormattable(const UNumberFormat* fmt,
00720 const UFormattable *number,
00721 UChar *result,
00722 int32_t resultLength,
00723 UFieldPosition *pos,
00724 UErrorCode *status);
00725
00745 U_STABLE int32_t U_EXPORT2
00746 unum_parse( const UNumberFormat* fmt,
00747 const UChar* text,
00748 int32_t textLength,
00749 int32_t *parsePos ,
00750 UErrorCode *status);
00751
00771 U_STABLE int64_t U_EXPORT2
00772 unum_parseInt64(const UNumberFormat* fmt,
00773 const UChar* text,
00774 int32_t textLength,
00775 int32_t *parsePos ,
00776 UErrorCode *status);
00777
00797 U_STABLE double U_EXPORT2
00798 unum_parseDouble( const UNumberFormat* fmt,
00799 const UChar* text,
00800 int32_t textLength,
00801 int32_t *parsePos ,
00802 UErrorCode *status);
00803
00804
00832 U_STABLE int32_t U_EXPORT2
00833 unum_parseDecimal(const UNumberFormat* fmt,
00834 const UChar* text,
00835 int32_t textLength,
00836 int32_t *parsePos ,
00837 char *outBuf,
00838 int32_t outBufLength,
00839 UErrorCode *status);
00840
00860 U_STABLE double U_EXPORT2
00861 unum_parseDoubleCurrency(const UNumberFormat* fmt,
00862 const UChar* text,
00863 int32_t textLength,
00864 int32_t* parsePos,
00865 UChar* currency,
00866 UErrorCode* status);
00867
00888 U_STABLE UFormattable* U_EXPORT2
00889 unum_parseToUFormattable(const UNumberFormat* fmt,
00890 UFormattable *result,
00891 const UChar* text,
00892 int32_t textLength,
00893 int32_t* parsePos,
00894 UErrorCode* status);
00895
00912 U_STABLE void U_EXPORT2
00913 unum_applyPattern( UNumberFormat *format,
00914 UBool localized,
00915 const UChar *pattern,
00916 int32_t patternLength,
00917 UParseError *parseError,
00918 UErrorCode *status
00919 );
00920
00931 U_STABLE const char* U_EXPORT2
00932 unum_getAvailable(int32_t localeIndex);
00933
00943 U_STABLE int32_t U_EXPORT2
00944 unum_countAvailable(void);
00945
00946 #if UCONFIG_HAVE_PARSEALLINPUT
00947
00951 typedef enum UNumberFormatAttributeValue {
00952 #ifndef U_HIDE_INTERNAL_API
00953
00954 UNUM_NO = 0,
00956 UNUM_YES = 1,
00958 UNUM_MAYBE = 2
00959 #else
00960
00961 UNUM_FORMAT_ATTRIBUTE_VALUE_HIDDEN
00962 #endif
00963 } UNumberFormatAttributeValue;
00964 #endif
00965
00967 typedef enum UNumberFormatAttribute {
00969 UNUM_PARSE_INT_ONLY,
00971 UNUM_GROUPING_USED,
00973 UNUM_DECIMAL_ALWAYS_SHOWN,
00975 UNUM_MAX_INTEGER_DIGITS,
00977 UNUM_MIN_INTEGER_DIGITS,
00979 UNUM_INTEGER_DIGITS,
00981 UNUM_MAX_FRACTION_DIGITS,
00983 UNUM_MIN_FRACTION_DIGITS,
00985 UNUM_FRACTION_DIGITS,
00987 UNUM_MULTIPLIER,
00989 UNUM_GROUPING_SIZE,
00991 UNUM_ROUNDING_MODE,
00993 UNUM_ROUNDING_INCREMENT,
00995 UNUM_FORMAT_WIDTH,
00997 UNUM_PADDING_POSITION,
00999 UNUM_SECONDARY_GROUPING_SIZE,
01002 UNUM_SIGNIFICANT_DIGITS_USED,
01005 UNUM_MIN_SIGNIFICANT_DIGITS,
01008 UNUM_MAX_SIGNIFICANT_DIGITS,
01012 UNUM_LENIENT_PARSE,
01013 #if UCONFIG_HAVE_PARSEALLINPUT
01014
01018 UNUM_PARSE_ALL_INPUT = 20,
01019 #endif
01020
01031 UNUM_SCALE = 21,
01032
01041 UNUM_MINIMUM_GROUPING_DIGITS = 22,
01042
01049 UNUM_CURRENCY_USAGE = 23,
01050
01051 #ifndef U_HIDE_INTERNAL_API
01052
01055 UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 0x0FFF,
01056 #endif
01057
01063 UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS = 0x1000,
01070 UNUM_PARSE_NO_EXPONENT = 0x1001,
01071
01080 UNUM_PARSE_DECIMAL_MARK_REQUIRED = 0x1002,
01081
01087 UNUM_PARSE_CASE_SENSITIVE = 0x1003,
01088
01096 UNUM_SIGN_ALWAYS_SHOWN = 0x1004,
01097
01098 #ifndef U_HIDE_INTERNAL_API
01099
01102 UNUM_LIMIT_BOOLEAN_ATTRIBUTE = 0x1005,
01103 #endif
01104
01105 } UNumberFormatAttribute;
01106
01124 U_STABLE int32_t U_EXPORT2
01125 unum_getAttribute(const UNumberFormat* fmt,
01126 UNumberFormatAttribute attr);
01127
01147 U_STABLE void U_EXPORT2
01148 unum_setAttribute( UNumberFormat* fmt,
01149 UNumberFormatAttribute attr,
01150 int32_t newValue);
01151
01152
01167 U_STABLE double U_EXPORT2
01168 unum_getDoubleAttribute(const UNumberFormat* fmt,
01169 UNumberFormatAttribute attr);
01170
01185 U_STABLE void U_EXPORT2
01186 unum_setDoubleAttribute( UNumberFormat* fmt,
01187 UNumberFormatAttribute attr,
01188 double newValue);
01189
01191 typedef enum UNumberFormatTextAttribute {
01193 UNUM_POSITIVE_PREFIX,
01195 UNUM_POSITIVE_SUFFIX,
01197 UNUM_NEGATIVE_PREFIX,
01199 UNUM_NEGATIVE_SUFFIX,
01201 UNUM_PADDING_CHARACTER,
01203 UNUM_CURRENCY_CODE,
01212 UNUM_DEFAULT_RULESET,
01221 UNUM_PUBLIC_RULESETS
01222 } UNumberFormatTextAttribute;
01223
01242 U_STABLE int32_t U_EXPORT2
01243 unum_getTextAttribute( const UNumberFormat* fmt,
01244 UNumberFormatTextAttribute tag,
01245 UChar* result,
01246 int32_t resultLength,
01247 UErrorCode* status);
01248
01265 U_STABLE void U_EXPORT2
01266 unum_setTextAttribute( UNumberFormat* fmt,
01267 UNumberFormatTextAttribute tag,
01268 const UChar* newValue,
01269 int32_t newValueLength,
01270 UErrorCode *status);
01271
01288 U_STABLE int32_t U_EXPORT2
01289 unum_toPattern( const UNumberFormat* fmt,
01290 UBool isPatternLocalized,
01291 UChar* result,
01292 int32_t resultLength,
01293 UErrorCode* status);
01294
01295
01300 typedef enum UNumberFormatSymbol {
01302 UNUM_DECIMAL_SEPARATOR_SYMBOL = 0,
01304 UNUM_GROUPING_SEPARATOR_SYMBOL = 1,
01306 UNUM_PATTERN_SEPARATOR_SYMBOL = 2,
01308 UNUM_PERCENT_SYMBOL = 3,
01310 UNUM_ZERO_DIGIT_SYMBOL = 4,
01312 UNUM_DIGIT_SYMBOL = 5,
01314 UNUM_MINUS_SIGN_SYMBOL = 6,
01316 UNUM_PLUS_SIGN_SYMBOL = 7,
01318 UNUM_CURRENCY_SYMBOL = 8,
01320 UNUM_INTL_CURRENCY_SYMBOL = 9,
01322 UNUM_MONETARY_SEPARATOR_SYMBOL = 10,
01324 UNUM_EXPONENTIAL_SYMBOL = 11,
01326 UNUM_PERMILL_SYMBOL = 12,
01328 UNUM_PAD_ESCAPE_SYMBOL = 13,
01330 UNUM_INFINITY_SYMBOL = 14,
01332 UNUM_NAN_SYMBOL = 15,
01335 UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16,
01339 UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17,
01343 UNUM_ONE_DIGIT_SYMBOL = 18,
01347 UNUM_TWO_DIGIT_SYMBOL = 19,
01351 UNUM_THREE_DIGIT_SYMBOL = 20,
01355 UNUM_FOUR_DIGIT_SYMBOL = 21,
01359 UNUM_FIVE_DIGIT_SYMBOL = 22,
01363 UNUM_SIX_DIGIT_SYMBOL = 23,
01367 UNUM_SEVEN_DIGIT_SYMBOL = 24,
01371 UNUM_EIGHT_DIGIT_SYMBOL = 25,
01375 UNUM_NINE_DIGIT_SYMBOL = 26,
01376
01380 UNUM_EXPONENT_MULTIPLICATION_SYMBOL = 27,
01381
01382 #ifndef U_HIDE_DEPRECATED_API
01383
01387 UNUM_FORMAT_SYMBOL_COUNT = 28
01388 #endif
01389 } UNumberFormatSymbol;
01390
01407 U_STABLE int32_t U_EXPORT2
01408 unum_getSymbol(const UNumberFormat *fmt,
01409 UNumberFormatSymbol symbol,
01410 UChar *buffer,
01411 int32_t size,
01412 UErrorCode *status);
01413
01427 U_STABLE void U_EXPORT2
01428 unum_setSymbol(UNumberFormat *fmt,
01429 UNumberFormatSymbol symbol,
01430 const UChar *value,
01431 int32_t length,
01432 UErrorCode *status);
01433
01434
01444 U_STABLE const char* U_EXPORT2
01445 unum_getLocaleByType(const UNumberFormat *fmt,
01446 ULocDataLocaleType type,
01447 UErrorCode* status);
01448
01457 U_STABLE void U_EXPORT2
01458 unum_setContext(UNumberFormat* fmt, UDisplayContext value, UErrorCode* status);
01459
01469 U_STABLE UDisplayContext U_EXPORT2
01470 unum_getContext(const UNumberFormat *fmt, UDisplayContextType type, UErrorCode* status);
01471
01472 #endif
01473
01474 #endif