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/umisc.h"
00022 #include "unicode/parseerr.h"
00130 typedef void* UNumberFormat;
00131
00135 typedef enum UNumberFormatStyle {
00140 UNUM_PATTERN_DECIMAL=0,
00142 UNUM_DECIMAL=1,
00144 UNUM_CURRENCY,
00146 UNUM_PERCENT,
00148 UNUM_SCIENTIFIC,
00150 UNUM_SPELLOUT,
00155 UNUM_ORDINAL,
00160 UNUM_DURATION,
00165 UNUM_NUMBERING_SYSTEM,
00170 UNUM_PATTERN_RULEBASED,
00172 UNUM_DEFAULT = UNUM_DECIMAL,
00174 UNUM_IGNORE = UNUM_PATTERN_DECIMAL
00175 } UNumberFormatStyle;
00176
00180 typedef enum UNumberFormatRoundingMode {
00181 UNUM_ROUND_CEILING,
00182 UNUM_ROUND_FLOOR,
00183 UNUM_ROUND_DOWN,
00184 UNUM_ROUND_UP,
00189 UNUM_FOUND_HALFEVEN,
00190 UNUM_ROUND_HALFDOWN,
00191 UNUM_ROUND_HALFUP,
00196 UNUM_ROUND_HALFEVEN = UNUM_FOUND_HALFEVEN
00197 } UNumberFormatRoundingMode;
00198
00202 typedef enum UNumberFormatPadPosition {
00203 UNUM_PAD_BEFORE_PREFIX,
00204 UNUM_PAD_AFTER_PREFIX,
00205 UNUM_PAD_BEFORE_SUFFIX,
00206 UNUM_PAD_AFTER_SUFFIX
00207 } UNumberFormatPadPosition;
00208
00240 U_STABLE UNumberFormat* U_EXPORT2
00241 unum_open( UNumberFormatStyle style,
00242 const UChar* pattern,
00243 int32_t patternLength,
00244 const char* locale,
00245 UParseError* parseErr,
00246 UErrorCode* status);
00247
00248
00255 U_STABLE void U_EXPORT2
00256 unum_close(UNumberFormat* fmt);
00257
00258 #if U_SHOW_CPLUSPLUS_API
00259
00260 U_NAMESPACE_BEGIN
00261
00271 U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberFormatPointer, UNumberFormat, unum_close);
00272
00273 U_NAMESPACE_END
00274
00275 #endif
00276
00285 U_STABLE UNumberFormat* U_EXPORT2
00286 unum_clone(const UNumberFormat *fmt,
00287 UErrorCode *status);
00288
00310 U_STABLE int32_t U_EXPORT2
00311 unum_format( const UNumberFormat* fmt,
00312 int32_t number,
00313 UChar* result,
00314 int32_t resultLength,
00315 UFieldPosition *pos,
00316 UErrorCode* status);
00317
00339 U_STABLE int32_t U_EXPORT2
00340 unum_formatInt64(const UNumberFormat *fmt,
00341 int64_t number,
00342 UChar* result,
00343 int32_t resultLength,
00344 UFieldPosition *pos,
00345 UErrorCode* status);
00346
00368 U_STABLE int32_t U_EXPORT2
00369 unum_formatDouble( const UNumberFormat* fmt,
00370 double number,
00371 UChar* result,
00372 int32_t resultLength,
00373 UFieldPosition *pos,
00374 UErrorCode* status);
00375
00401 U_STABLE int32_t U_EXPORT2
00402 unum_formatDecimal( const UNumberFormat* fmt,
00403 const char * number,
00404 int32_t length,
00405 UChar* result,
00406 int32_t resultLength,
00407 UFieldPosition *pos,
00408 UErrorCode* status);
00409
00431 U_STABLE int32_t U_EXPORT2
00432 unum_formatDoubleCurrency(const UNumberFormat* fmt,
00433 double number,
00434 UChar* currency,
00435 UChar* result,
00436 int32_t resultLength,
00437 UFieldPosition* pos,
00438 UErrorCode* status);
00439
00457 U_STABLE int32_t U_EXPORT2
00458 unum_parse( const UNumberFormat* fmt,
00459 const UChar* text,
00460 int32_t textLength,
00461 int32_t *parsePos ,
00462 UErrorCode *status);
00463
00481 U_STABLE int64_t U_EXPORT2
00482 unum_parseInt64(const UNumberFormat* fmt,
00483 const UChar* text,
00484 int32_t textLength,
00485 int32_t *parsePos ,
00486 UErrorCode *status);
00487
00505 U_STABLE double U_EXPORT2
00506 unum_parseDouble( const UNumberFormat* fmt,
00507 const UChar* text,
00508 int32_t textLength,
00509 int32_t *parsePos ,
00510 UErrorCode *status);
00511
00512
00538 U_STABLE int32_t U_EXPORT2
00539 unum_parseDecimal(const UNumberFormat* fmt,
00540 const UChar* text,
00541 int32_t textLength,
00542 int32_t *parsePos ,
00543 char *outBuf,
00544 int32_t outBufLength,
00545 UErrorCode *status);
00546
00566 U_STABLE double U_EXPORT2
00567 unum_parseDoubleCurrency(const UNumberFormat* fmt,
00568 const UChar* text,
00569 int32_t textLength,
00570 int32_t* parsePos,
00571 UChar* currency,
00572 UErrorCode* status);
00573
00590 U_STABLE void U_EXPORT2
00591 unum_applyPattern( UNumberFormat *format,
00592 UBool localized,
00593 const UChar *pattern,
00594 int32_t patternLength,
00595 UParseError *parseError,
00596 UErrorCode *status
00597 );
00598
00609 U_STABLE const char* U_EXPORT2
00610 unum_getAvailable(int32_t localeIndex);
00611
00621 U_STABLE int32_t U_EXPORT2
00622 unum_countAvailable(void);
00623
00625 typedef enum UNumberFormatAttribute {
00627 UNUM_PARSE_INT_ONLY,
00629 UNUM_GROUPING_USED,
00631 UNUM_DECIMAL_ALWAYS_SHOWN,
00633 UNUM_MAX_INTEGER_DIGITS,
00635 UNUM_MIN_INTEGER_DIGITS,
00637 UNUM_INTEGER_DIGITS,
00639 UNUM_MAX_FRACTION_DIGITS,
00641 UNUM_MIN_FRACTION_DIGITS,
00643 UNUM_FRACTION_DIGITS,
00645 UNUM_MULTIPLIER,
00647 UNUM_GROUPING_SIZE,
00649 UNUM_ROUNDING_MODE,
00651 UNUM_ROUNDING_INCREMENT,
00653 UNUM_FORMAT_WIDTH,
00655 UNUM_PADDING_POSITION,
00657 UNUM_SECONDARY_GROUPING_SIZE,
00660 UNUM_SIGNIFICANT_DIGITS_USED,
00663 UNUM_MIN_SIGNIFICANT_DIGITS,
00666 UNUM_MAX_SIGNIFICANT_DIGITS,
00670 UNUM_LENIENT_PARSE
00671 } UNumberFormatAttribute;
00672
00689 U_STABLE int32_t U_EXPORT2
00690 unum_getAttribute(const UNumberFormat* fmt,
00691 UNumberFormatAttribute attr);
00692
00712 U_STABLE void U_EXPORT2
00713 unum_setAttribute( UNumberFormat* fmt,
00714 UNumberFormatAttribute attr,
00715 int32_t newValue);
00716
00717
00732 U_STABLE double U_EXPORT2
00733 unum_getDoubleAttribute(const UNumberFormat* fmt,
00734 UNumberFormatAttribute attr);
00735
00750 U_STABLE void U_EXPORT2
00751 unum_setDoubleAttribute( UNumberFormat* fmt,
00752 UNumberFormatAttribute attr,
00753 double newValue);
00754
00756 typedef enum UNumberFormatTextAttribute {
00758 UNUM_POSITIVE_PREFIX,
00760 UNUM_POSITIVE_SUFFIX,
00762 UNUM_NEGATIVE_PREFIX,
00764 UNUM_NEGATIVE_SUFFIX,
00766 UNUM_PADDING_CHARACTER,
00768 UNUM_CURRENCY_CODE,
00773 UNUM_DEFAULT_RULESET,
00780 UNUM_PUBLIC_RULESETS
00781 } UNumberFormatTextAttribute;
00782
00801 U_STABLE int32_t U_EXPORT2
00802 unum_getTextAttribute( const UNumberFormat* fmt,
00803 UNumberFormatTextAttribute tag,
00804 UChar* result,
00805 int32_t resultLength,
00806 UErrorCode* status);
00807
00824 U_STABLE void U_EXPORT2
00825 unum_setTextAttribute( UNumberFormat* fmt,
00826 UNumberFormatTextAttribute tag,
00827 const UChar* newValue,
00828 int32_t newValueLength,
00829 UErrorCode *status);
00830
00847 U_STABLE int32_t U_EXPORT2
00848 unum_toPattern( const UNumberFormat* fmt,
00849 UBool isPatternLocalized,
00850 UChar* result,
00851 int32_t resultLength,
00852 UErrorCode* status);
00853
00854
00859 typedef enum UNumberFormatSymbol {
00861 UNUM_DECIMAL_SEPARATOR_SYMBOL = 0,
00863 UNUM_GROUPING_SEPARATOR_SYMBOL = 1,
00865 UNUM_PATTERN_SEPARATOR_SYMBOL = 2,
00867 UNUM_PERCENT_SYMBOL = 3,
00869 UNUM_ZERO_DIGIT_SYMBOL = 4,
00871 UNUM_DIGIT_SYMBOL = 5,
00873 UNUM_MINUS_SIGN_SYMBOL = 6,
00875 UNUM_PLUS_SIGN_SYMBOL = 7,
00877 UNUM_CURRENCY_SYMBOL = 8,
00879 UNUM_INTL_CURRENCY_SYMBOL = 9,
00881 UNUM_MONETARY_SEPARATOR_SYMBOL = 10,
00883 UNUM_EXPONENTIAL_SYMBOL = 11,
00885 UNUM_PERMILL_SYMBOL = 12,
00887 UNUM_PAD_ESCAPE_SYMBOL = 13,
00889 UNUM_INFINITY_SYMBOL = 14,
00891 UNUM_NAN_SYMBOL = 15,
00894 UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16,
00898 UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17,
00902 UNUM_ONE_DIGIT_SYMBOL = 18,
00906 UNUM_TWO_DIGIT_SYMBOL = 19,
00910 UNUM_THREE_DIGIT_SYMBOL = 20,
00914 UNUM_FOUR_DIGIT_SYMBOL = 21,
00918 UNUM_FIVE_DIGIT_SYMBOL = 22,
00922 UNUM_SIX_DIGIT_SYMBOL = 23,
00926 UNUM_SEVEN_DIGIT_SYMBOL = 24,
00930 UNUM_EIGHT_DIGIT_SYMBOL = 25,
00934 UNUM_NINE_DIGIT_SYMBOL = 26,
00936 UNUM_FORMAT_SYMBOL_COUNT = 27
00937 } UNumberFormatSymbol;
00938
00955 U_STABLE int32_t U_EXPORT2
00956 unum_getSymbol(const UNumberFormat *fmt,
00957 UNumberFormatSymbol symbol,
00958 UChar *buffer,
00959 int32_t size,
00960 UErrorCode *status);
00961
00975 U_STABLE void U_EXPORT2
00976 unum_setSymbol(UNumberFormat *fmt,
00977 UNumberFormatSymbol symbol,
00978 const UChar *value,
00979 int32_t length,
00980 UErrorCode *status);
00981
00982
00992 U_STABLE const char* U_EXPORT2
00993 unum_getLocaleByType(const UNumberFormat *fmt,
00994 ULocDataLocaleType type,
00995 UErrorCode* status);
00996
00997 #endif
00998
00999 #endif