00001 /* 00002 ******************************************************************************* 00003 * Copyright © {1997-1999}, International Business Machines Corporation and others. All Rights Reserved. 00004 * Modification History: 00005 * 00006 * Date Name Description 00007 * 06/24/99 helena Integrated Alan's NF enhancements and Java2 bug fixes 00008 ******************************************************************************* 00009 */ 00010 00011 #ifndef _UNUM 00012 #define _UNUM 00013 00014 #include "unicode/utypes.h" 00015 #include "unicode/umisc.h" 00016 00105 typedef void* UNumberFormat; 00106 00108 enum UNumberFormatStyle { 00110 UNUM_DECIMAL, 00112 UNUM_CURRENCY, 00114 UNUM_PERCENT, 00116 UNUM_SPELLOUT, 00118 UNUM_DEFAULT = UNUM_DECIMAL 00119 }; 00120 typedef enum UNumberFormatStyle UNumberFormatStyle; 00121 00122 enum UNumberFormatRoundingMode { 00123 UNUM_ROUND_CEILING, 00124 UNUM_ROUND_FLOOR, 00125 UNUM_ROUND_DOWN, 00126 UNUM_ROUND_UP, 00127 UNUM_FOUND_HALFEVEN, 00128 UNUM_ROUND_HALFDOWN, 00129 UNUM_ROUND_HALFUP 00130 }; 00131 typedef enum UNumberFormatRoundingMode UNumberFormatRoundingMode; 00132 00133 enum UNumberFormatPadPosition { 00134 UNUM_PAD_BEFORE_PREFIX, 00135 UNUM_PAD_AFTER_PREFIX, 00136 UNUM_PAD_BEFORE_SUFFIX, 00137 UNUM_PAD_AFTER_SUFFIX 00138 }; 00139 typedef enum UNumberFormatPadPosition UNumberFormatPadPosition; 00140 00154 U_CAPI UNumberFormat* 00155 unum_open(UNumberFormatStyle style, 00156 const char* locale, 00157 UErrorCode* status); 00158 00172 U_CAPI UNumberFormat* 00173 unum_openPattern( const UChar* pattern, 00174 int32_t patternLength, 00175 const char* locale, 00176 UErrorCode* status); 00177 00184 U_CAPI void 00185 unum_close(UNumberFormat* fmt); 00186 00195 U_CAPI UNumberFormat* 00196 unum_clone(const UNumberFormat *fmt, 00197 UErrorCode *status); 00198 00214 U_CAPI int32_t 00215 unum_format( const UNumberFormat* fmt, 00216 int32_t number, 00217 UChar* result, 00218 int32_t resultLength, 00219 UFieldPosition *pos, 00220 UErrorCode* status); 00221 00237 U_CAPI int32_t 00238 unum_formatDouble( const UNumberFormat* fmt, 00239 double number, 00240 UChar* result, 00241 int32_t resultLength, 00242 UFieldPosition *pos, /* 0 if ignore */ 00243 UErrorCode* status); 00244 00260 U_CAPI int32_t 00261 unum_parse( const UNumberFormat* fmt, 00262 const UChar* text, 00263 int32_t textLength, 00264 int32_t *parsePos /* 0 = start */, 00265 UErrorCode *status); 00266 00282 U_CAPI double 00283 unum_parseDouble( const UNumberFormat* fmt, 00284 const UChar* text, 00285 int32_t textLength, 00286 int32_t *parsePos /* 0 = start */, 00287 UErrorCode *status); 00288 00299 U_CAPI void 00300 unum_applyPattern( UNumberFormat *format, 00301 UBool localized, 00302 const UChar *pattern, 00303 int32_t patternLength); 00313 U_CAPI const char* 00314 unum_getAvailable(int32_t index); 00315 00324 U_CAPI int32_t 00325 unum_countAvailable(void); 00326 00328 enum UNumberFormatAttribute { 00330 UNUM_PARSE_INT_ONLY, 00332 UNUM_GROUPING_USED, 00334 UNUM_DECIMAL_ALWAYS_SHOWN, 00336 UNUM_MAX_INTEGER_DIGITS, 00338 UNUM_MIN_INTEGER_DIGITS, 00340 UNUM_INTEGER_DIGITS, 00342 UNUM_MAX_FRACTION_DIGITS, 00344 UNUM_MIN_FRACTION_DIGITS, 00346 UNUM_FRACTION_DIGITS, 00348 UNUM_MULTIPLIER, 00350 UNUM_GROUPING_SIZE, 00352 UNUM_ROUNDING_MODE, 00354 UNUM_ROUNDING_INCREMENT, 00356 UNUM_FORMAT_WIDTH, 00358 UNUM_PADDING_POSITION, 00360 UNUM_SECONDARY_GROUPING_SIZE 00361 }; 00362 typedef enum UNumberFormatAttribute UNumberFormatAttribute; 00363 00364 /*==================================================== 00365 ====================================================== 00366 ---> Add to UErrorCode !!!! ---> 00367 typedef enum { 00368 AttributeNotSupported, 00369 PropertyNotSupported 00370 } UErrorCode; 00371 ---> Add to UErrorCode !!!! ---> 00372 ====================================================== 00373 ====================================================*/ 00374 00391 U_CAPI int32_t 00392 unum_getAttribute(const UNumberFormat* fmt, 00393 UNumberFormatAttribute attr); 00394 00411 U_CAPI void 00412 unum_setAttribute( UNumberFormat* fmt, 00413 UNumberFormatAttribute attr, 00414 int32_t newValue); 00415 00416 00430 U_CAPI double 00431 unum_getDoubleAttribute(const UNumberFormat* fmt, 00432 UNumberFormatAttribute attr); 00433 00447 U_CAPI void 00448 unum_setDoubleAttribute( UNumberFormat* fmt, 00449 UNumberFormatAttribute attr, 00450 double newValue); 00451 00453 enum UNumberFormatTextAttribute{ 00455 UNUM_POSITIVE_PREFIX, 00457 UNUM_POSITIVE_SUFFIX, 00459 UNUM_NEGATIVE_PREFIX, 00461 UNUM_NEGATIVE_SUFFIX, 00463 UNUM_PADDING_CHARACTER 00464 }; 00465 typedef enum UNumberFormatTextAttribute UNumberFormatTextAttribute; 00466 00482 U_CAPI int32_t 00483 unum_getTextAttribute( const UNumberFormat* fmt, 00484 UNumberFormatTextAttribute tag, 00485 UChar* result, 00486 int32_t resultLength, 00487 UErrorCode* status); 00488 00503 U_CAPI void 00504 unum_setTextAttribute( UNumberFormat* fmt, 00505 UNumberFormatTextAttribute tag, 00506 const UChar* newValue, 00507 int32_t newValueLength, 00508 UErrorCode *status); 00509 00521 U_CAPI int32_t 00522 unum_toPattern( const UNumberFormat* fmt, 00523 UBool isPatternLocalized, 00524 UChar* result, 00525 int32_t resultLength, 00526 UErrorCode* status); 00527 00528 /* The maximum size for a textual number format symbol. */ 00529 #define UNFSYMBOLSMAXSIZE 10 00530 00534 struct UNumberFormatSymbols{ 00536 UChar decimalSeparator; 00538 UChar groupingSeparator; 00540 UChar patternSeparator; 00542 UChar percent; 00544 UChar zeroDigit; 00546 UChar digit; 00548 UChar minusSign; 00550 UChar plusSign; 00552 UChar currency [UNFSYMBOLSMAXSIZE]; 00554 UChar intlCurrency [UNFSYMBOLSMAXSIZE]; 00556 UChar monetarySeparator; 00558 UChar exponential; 00560 UChar perMill; 00562 UChar padEscape; 00564 UChar infinity [UNFSYMBOLSMAXSIZE]; 00566 UChar naN [UNFSYMBOLSMAXSIZE]; 00567 }; 00568 typedef struct UNumberFormatSymbols UNumberFormatSymbols; 00569 00579 U_CAPI void 00580 unum_getSymbols( const UNumberFormat *fmt, 00581 UNumberFormatSymbols *syms); 00582 00593 U_CAPI void 00594 unum_setSymbols( UNumberFormat* fmt, 00595 const UNumberFormatSymbols* symbolsToSet, 00596 UErrorCode *status); 00597 00602 enum UNumberFormatSymbol { 00604 UNUM_DECIMAL_SEPARATOR_SYMBOL, 00606 UNUM_GROUPING_SEPARATOR_SYMBOL, 00608 UNUM_PATTERN_SEPARATOR_SYMBOL, 00610 UNUM_PERCENT_SYMBOL, 00612 UNUM_ZERO_DIGIT_SYMBOL, 00614 UNUM_DIGIT_SYMBOL, 00616 UNUM_MINUS_SIGN_SYMBOL, 00618 UNUM_PLUS_SIGN_SYMBOL, 00620 UNUM_CURRENCY_SYMBOL, 00622 UNUM_INTL_CURRENCY_SYMBOL, 00624 UNUM_MONETARY_SEPARATOR_SYMBOL, 00626 UNUM_EXPONENTIAL_SYMBOL, 00628 UNUM_PERMILL_SYMBOL, 00630 UNUM_PAD_ESCAPE_SYMBOL, 00632 UNUM_INFINITY_SYMBOL, 00634 UNUM_NAN_SYMBOL, 00636 UNUM_FORMAT_SYMBOL_COUNT 00637 }; 00638 typedef enum UNumberFormatSymbol UNumberFormatSymbol; 00639 00654 U_CAPI int32_t U_EXPORT2 00655 unum_getSymbol(UNumberFormat *fmt, 00656 UNumberFormatSymbol symbol, 00657 UChar *buffer, 00658 int32_t size, 00659 UErrorCode *status); 00660 00673 U_CAPI void U_EXPORT2 00674 unum_setSymbol(UNumberFormat *fmt, 00675 UNumberFormatSymbol symbol, 00676 const UChar *value, 00677 int32_t length, 00678 UErrorCode *status); 00679 00680 #endif