00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef _UNUM
00013 #define _UNUM
00014
00015 #include "unicode/utypes.h"
00016
00017 #if !UCONFIG_NO_FORMATTING
00018
00019 #include "unicode/localpointer.h"
00020 #include "unicode/uloc.h"
00021 #include "unicode/ucurr.h"
00022 #include "unicode/umisc.h"
00023 #include "unicode/parseerr.h"
00024 #include "unicode/uformattable.h"
00025 #include "unicode/udisplaycontext.h"
00026
00134 typedef void* UNumberFormat;
00135
00139 typedef enum UNumberFormatStyle {
00144 UNUM_PATTERN_DECIMAL=0,
00149 UNUM_DECIMAL=1,
00158 UNUM_CURRENCY=2,
00163 UNUM_PERCENT=3,
00168 UNUM_SCIENTIFIC=4,
00175 UNUM_SPELLOUT=5,
00182 UNUM_ORDINAL=6,
00187 UNUM_DURATION=7,
00192 UNUM_NUMBERING_SYSTEM=8,
00197 UNUM_PATTERN_RULEBASED=9,
00202 UNUM_CURRENCY_ISO=10,
00208 UNUM_CURRENCY_PLURAL=11,
00215 UNUM_CURRENCY_ACCOUNTING=12,
00221 UNUM_CASH_CURRENCY=13,
00222 #ifndef U_HIDE_DRAFT_API
00223
00229 UNUM_DECIMAL_COMPACT_SHORT=14,
00236 UNUM_DECIMAL_COMPACT_LONG=15,
00243 UNUM_CURRENCY_STANDARD=16,
00244 #endif
00245
00250 UNUM_FORMAT_STYLE_COUNT=17,
00251
00256 UNUM_DEFAULT = UNUM_DECIMAL,
00261 UNUM_IGNORE = UNUM_PATTERN_DECIMAL
00262 } UNumberFormatStyle;
00263
00267 typedef enum UNumberFormatRoundingMode {
00268 UNUM_ROUND_CEILING,
00269 UNUM_ROUND_FLOOR,
00270 UNUM_ROUND_DOWN,
00271 UNUM_ROUND_UP,
00276 UNUM_ROUND_HALFEVEN,
00277 #ifndef U_HIDE_DEPRECATED_API
00278
00282 UNUM_FOUND_HALFEVEN = UNUM_ROUND_HALFEVEN,
00283 #endif
00284 UNUM_ROUND_HALFDOWN = UNUM_ROUND_HALFEVEN + 1,
00285 UNUM_ROUND_HALFUP,
00290 UNUM_ROUND_UNNECESSARY
00291 } UNumberFormatRoundingMode;
00292
00296 typedef enum UNumberFormatPadPosition {
00297 UNUM_PAD_BEFORE_PREFIX,
00298 UNUM_PAD_AFTER_PREFIX,
00299 UNUM_PAD_BEFORE_SUFFIX,
00300 UNUM_PAD_AFTER_SUFFIX
00301 } UNumberFormatPadPosition;
00302
00307 typedef enum UNumberCompactStyle {
00309 UNUM_SHORT,
00311 UNUM_LONG
00313 } UNumberCompactStyle;
00314
00319 enum UCurrencySpacing {
00321 UNUM_CURRENCY_MATCH,
00323 UNUM_CURRENCY_SURROUNDING_MATCH,
00325 UNUM_CURRENCY_INSERT,
00327 UNUM_CURRENCY_SPACING_COUNT
00328 };
00329 typedef enum UCurrencySpacing UCurrencySpacing;
00337 typedef enum UNumberFormatFields {
00339 UNUM_INTEGER_FIELD,
00341 UNUM_FRACTION_FIELD,
00343 UNUM_DECIMAL_SEPARATOR_FIELD,
00345 UNUM_EXPONENT_SYMBOL_FIELD,
00347 UNUM_EXPONENT_SIGN_FIELD,
00349 UNUM_EXPONENT_FIELD,
00351 UNUM_GROUPING_SEPARATOR_FIELD,
00353 UNUM_CURRENCY_FIELD,
00355 UNUM_PERCENT_FIELD,
00357 UNUM_PERMILL_FIELD,
00359 UNUM_SIGN_FIELD,
00361 UNUM_FIELD_COUNT
00362 } UNumberFormatFields;
00363
00364
00398 U_STABLE UNumberFormat* U_EXPORT2
00399 unum_open( UNumberFormatStyle style,
00400 const UChar* pattern,
00401 int32_t patternLength,
00402 const char* locale,
00403 UParseError* parseErr,
00404 UErrorCode* status);
00405
00406
00413 U_STABLE void U_EXPORT2
00414 unum_close(UNumberFormat* fmt);
00415
00416 #if U_SHOW_CPLUSPLUS_API
00417
00418 U_NAMESPACE_BEGIN
00419
00429 U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberFormatPointer, UNumberFormat, unum_close);
00430
00431 U_NAMESPACE_END
00432
00433 #endif
00434
00443 U_STABLE UNumberFormat* U_EXPORT2
00444 unum_clone(const UNumberFormat *fmt,
00445 UErrorCode *status);
00446
00471 U_STABLE int32_t U_EXPORT2
00472 unum_format( const UNumberFormat* fmt,
00473 int32_t number,
00474 UChar* result,
00475 int32_t resultLength,
00476 UFieldPosition *pos,
00477 UErrorCode* status);
00478
00503 U_STABLE int32_t U_EXPORT2
00504 unum_formatInt64(const UNumberFormat *fmt,
00505 int64_t number,
00506 UChar* result,
00507 int32_t resultLength,
00508 UFieldPosition *pos,
00509 UErrorCode* status);
00510
00535 U_STABLE int32_t U_EXPORT2
00536 unum_formatDouble( const UNumberFormat* fmt,
00537 double number,
00538 UChar* result,
00539 int32_t resultLength,
00540 UFieldPosition *pos,
00541 UErrorCode* status);
00542
00571 U_STABLE int32_t U_EXPORT2
00572 unum_formatDecimal( const UNumberFormat* fmt,
00573 const char * number,
00574 int32_t length,
00575 UChar* result,
00576 int32_t resultLength,
00577 UFieldPosition *pos,
00578 UErrorCode* status);
00579
00604 U_STABLE int32_t U_EXPORT2
00605 unum_formatDoubleCurrency(const UNumberFormat* fmt,
00606 double number,
00607 UChar* currency,
00608 UChar* result,
00609 int32_t resultLength,
00610 UFieldPosition* pos,
00611 UErrorCode* status);
00612
00633 U_STABLE int32_t U_EXPORT2
00634 unum_formatUFormattable(const UNumberFormat* fmt,
00635 const UFormattable *number,
00636 UChar *result,
00637 int32_t resultLength,
00638 UFieldPosition *pos,
00639 UErrorCode *status);
00640
00660 U_STABLE int32_t U_EXPORT2
00661 unum_parse( const UNumberFormat* fmt,
00662 const UChar* text,
00663 int32_t textLength,
00664 int32_t *parsePos ,
00665 UErrorCode *status);
00666
00686 U_STABLE int64_t U_EXPORT2
00687 unum_parseInt64(const UNumberFormat* fmt,
00688 const UChar* text,
00689 int32_t textLength,
00690 int32_t *parsePos ,
00691 UErrorCode *status);
00692
00712 U_STABLE double U_EXPORT2
00713 unum_parseDouble( const UNumberFormat* fmt,
00714 const UChar* text,
00715 int32_t textLength,
00716 int32_t *parsePos ,
00717 UErrorCode *status);
00718
00719
00747 U_STABLE int32_t U_EXPORT2
00748 unum_parseDecimal(const UNumberFormat* fmt,
00749 const UChar* text,
00750 int32_t textLength,
00751 int32_t *parsePos ,
00752 char *outBuf,
00753 int32_t outBufLength,
00754 UErrorCode *status);
00755
00775 U_STABLE double U_EXPORT2
00776 unum_parseDoubleCurrency(const UNumberFormat* fmt,
00777 const UChar* text,
00778 int32_t textLength,
00779 int32_t* parsePos,
00780 UChar* currency,
00781 UErrorCode* status);
00782
00803 U_STABLE UFormattable* U_EXPORT2
00804 unum_parseToUFormattable(const UNumberFormat* fmt,
00805 UFormattable *result,
00806 const UChar* text,
00807 int32_t textLength,
00808 int32_t* parsePos,
00809 UErrorCode* status);
00810
00827 U_STABLE void U_EXPORT2
00828 unum_applyPattern( UNumberFormat *format,
00829 UBool localized,
00830 const UChar *pattern,
00831 int32_t patternLength,
00832 UParseError *parseError,
00833 UErrorCode *status
00834 );
00835
00846 U_STABLE const char* U_EXPORT2
00847 unum_getAvailable(int32_t localeIndex);
00848
00858 U_STABLE int32_t U_EXPORT2
00859 unum_countAvailable(void);
00860
00861 #if UCONFIG_HAVE_PARSEALLINPUT
00862
00866 typedef enum UNumberFormatAttributeValue {
00867 #ifndef U_HIDE_INTERNAL_API
00868
00869 UNUM_NO = 0,
00871 UNUM_YES = 1,
00873 UNUM_MAYBE = 2
00874 #else
00875
00876 UNUM_FORMAT_ATTRIBUTE_VALUE_HIDDEN
00877 #endif
00878 } UNumberFormatAttributeValue;
00879 #endif
00880
00882 typedef enum UNumberFormatAttribute {
00884 UNUM_PARSE_INT_ONLY,
00886 UNUM_GROUPING_USED,
00888 UNUM_DECIMAL_ALWAYS_SHOWN,
00890 UNUM_MAX_INTEGER_DIGITS,
00892 UNUM_MIN_INTEGER_DIGITS,
00894 UNUM_INTEGER_DIGITS,
00896 UNUM_MAX_FRACTION_DIGITS,
00898 UNUM_MIN_FRACTION_DIGITS,
00900 UNUM_FRACTION_DIGITS,
00902 UNUM_MULTIPLIER,
00904 UNUM_GROUPING_SIZE,
00906 UNUM_ROUNDING_MODE,
00908 UNUM_ROUNDING_INCREMENT,
00910 UNUM_FORMAT_WIDTH,
00912 UNUM_PADDING_POSITION,
00914 UNUM_SECONDARY_GROUPING_SIZE,
00917 UNUM_SIGNIFICANT_DIGITS_USED,
00920 UNUM_MIN_SIGNIFICANT_DIGITS,
00923 UNUM_MAX_SIGNIFICANT_DIGITS,
00927 UNUM_LENIENT_PARSE,
00928 #if UCONFIG_HAVE_PARSEALLINPUT
00929
00933 UNUM_PARSE_ALL_INPUT = 20,
00934 #endif
00935
00944 UNUM_SCALE = 21,
00945 #ifndef U_HIDE_INTERNAL_API
00946
00952 UNUM_MINIMUM_GROUPING_DIGITS = 22,
00953
00954 #endif
00955
00962 UNUM_CURRENCY_USAGE = 23,
00963
00964
00968 UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 0x0FFF,
00969
00975 UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS = 0x1000,
00982 UNUM_PARSE_NO_EXPONENT,
00983
00992 UNUM_PARSE_DECIMAL_MARK_REQUIRED = 0x1002,
00993
00994
00997 UNUM_LIMIT_BOOLEAN_ATTRIBUTE = 0x1003
00998 } UNumberFormatAttribute;
00999
01017 U_STABLE int32_t U_EXPORT2
01018 unum_getAttribute(const UNumberFormat* fmt,
01019 UNumberFormatAttribute attr);
01020
01040 U_STABLE void U_EXPORT2
01041 unum_setAttribute( UNumberFormat* fmt,
01042 UNumberFormatAttribute attr,
01043 int32_t newValue);
01044
01045
01060 U_STABLE double U_EXPORT2
01061 unum_getDoubleAttribute(const UNumberFormat* fmt,
01062 UNumberFormatAttribute attr);
01063
01078 U_STABLE void U_EXPORT2
01079 unum_setDoubleAttribute( UNumberFormat* fmt,
01080 UNumberFormatAttribute attr,
01081 double newValue);
01082
01084 typedef enum UNumberFormatTextAttribute {
01086 UNUM_POSITIVE_PREFIX,
01088 UNUM_POSITIVE_SUFFIX,
01090 UNUM_NEGATIVE_PREFIX,
01092 UNUM_NEGATIVE_SUFFIX,
01094 UNUM_PADDING_CHARACTER,
01096 UNUM_CURRENCY_CODE,
01105 UNUM_DEFAULT_RULESET,
01114 UNUM_PUBLIC_RULESETS
01115 } UNumberFormatTextAttribute;
01116
01135 U_STABLE int32_t U_EXPORT2
01136 unum_getTextAttribute( const UNumberFormat* fmt,
01137 UNumberFormatTextAttribute tag,
01138 UChar* result,
01139 int32_t resultLength,
01140 UErrorCode* status);
01141
01158 U_STABLE void U_EXPORT2
01159 unum_setTextAttribute( UNumberFormat* fmt,
01160 UNumberFormatTextAttribute tag,
01161 const UChar* newValue,
01162 int32_t newValueLength,
01163 UErrorCode *status);
01164
01181 U_STABLE int32_t U_EXPORT2
01182 unum_toPattern( const UNumberFormat* fmt,
01183 UBool isPatternLocalized,
01184 UChar* result,
01185 int32_t resultLength,
01186 UErrorCode* status);
01187
01188
01193 typedef enum UNumberFormatSymbol {
01195 UNUM_DECIMAL_SEPARATOR_SYMBOL = 0,
01197 UNUM_GROUPING_SEPARATOR_SYMBOL = 1,
01199 UNUM_PATTERN_SEPARATOR_SYMBOL = 2,
01201 UNUM_PERCENT_SYMBOL = 3,
01203 UNUM_ZERO_DIGIT_SYMBOL = 4,
01205 UNUM_DIGIT_SYMBOL = 5,
01207 UNUM_MINUS_SIGN_SYMBOL = 6,
01209 UNUM_PLUS_SIGN_SYMBOL = 7,
01211 UNUM_CURRENCY_SYMBOL = 8,
01213 UNUM_INTL_CURRENCY_SYMBOL = 9,
01215 UNUM_MONETARY_SEPARATOR_SYMBOL = 10,
01217 UNUM_EXPONENTIAL_SYMBOL = 11,
01219 UNUM_PERMILL_SYMBOL = 12,
01221 UNUM_PAD_ESCAPE_SYMBOL = 13,
01223 UNUM_INFINITY_SYMBOL = 14,
01225 UNUM_NAN_SYMBOL = 15,
01228 UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16,
01232 UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17,
01236 UNUM_ONE_DIGIT_SYMBOL = 18,
01240 UNUM_TWO_DIGIT_SYMBOL = 19,
01244 UNUM_THREE_DIGIT_SYMBOL = 20,
01248 UNUM_FOUR_DIGIT_SYMBOL = 21,
01252 UNUM_FIVE_DIGIT_SYMBOL = 22,
01256 UNUM_SIX_DIGIT_SYMBOL = 23,
01260 UNUM_SEVEN_DIGIT_SYMBOL = 24,
01264 UNUM_EIGHT_DIGIT_SYMBOL = 25,
01268 UNUM_NINE_DIGIT_SYMBOL = 26,
01269
01273 UNUM_EXPONENT_MULTIPLICATION_SYMBOL = 27,
01274
01276 UNUM_FORMAT_SYMBOL_COUNT = 28
01277 } UNumberFormatSymbol;
01278
01295 U_STABLE int32_t U_EXPORT2
01296 unum_getSymbol(const UNumberFormat *fmt,
01297 UNumberFormatSymbol symbol,
01298 UChar *buffer,
01299 int32_t size,
01300 UErrorCode *status);
01301
01315 U_STABLE void U_EXPORT2
01316 unum_setSymbol(UNumberFormat *fmt,
01317 UNumberFormatSymbol symbol,
01318 const UChar *value,
01319 int32_t length,
01320 UErrorCode *status);
01321
01322
01332 U_STABLE const char* U_EXPORT2
01333 unum_getLocaleByType(const UNumberFormat *fmt,
01334 ULocDataLocaleType type,
01335 UErrorCode* status);
01336
01345 U_STABLE void U_EXPORT2
01346 unum_setContext(UNumberFormat* fmt, UDisplayContext value, UErrorCode* status);
01347
01357 U_STABLE UDisplayContext U_EXPORT2
01358 unum_getContext(const UNumberFormat *fmt, UDisplayContextType type, UErrorCode* status);
01359
01360 #endif
01361
01362 #endif