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 00298 U_CAPI const char* 00299 unum_getAvailable(int32_t index); 00300 00309 U_CAPI int32_t 00310 unum_countAvailable(void); 00311 00313 enum UNumberFormatAttribute { 00315 UNUM_PARSE_INT_ONLY, 00317 UNUM_GROUPING_USED, 00319 UNUM_DECIMAL_ALWAYS_SHOWN, 00321 UNUM_MAX_INTEGER_DIGITS, 00323 UNUM_MIN_INTEGER_DIGITS, 00325 UNUM_INTEGER_DIGITS, 00327 UNUM_MAX_FRACTION_DIGITS, 00329 UNUM_MIN_FRACTION_DIGITS, 00331 UNUM_FRACTION_DIGITS, 00333 UNUM_MULTIPLIER, 00335 UNUM_GROUPING_SIZE, 00337 UNUM_ROUNDING_MODE, 00339 UNUM_ROUNDING_INCREMENT, 00341 UNUM_FORMAT_WIDTH, 00343 UNUM_PADDING_POSITION 00344 }; 00345 typedef enum UNumberFormatAttribute UNumberFormatAttribute; 00346 00347 /*==================================================== 00348 ====================================================== 00349 ---> Add to UErrorCode !!!! ---> 00350 typedef enum { 00351 AttributeNotSupported, 00352 PropertyNotSupported 00353 } UErrorCode; 00354 ---> Add to UErrorCode !!!! ---> 00355 ====================================================== 00356 ====================================================*/ 00357 00374 U_CAPI int32_t 00375 unum_getAttribute(const UNumberFormat* fmt, 00376 UNumberFormatAttribute attr); 00377 00394 U_CAPI void 00395 unum_setAttribute( UNumberFormat* fmt, 00396 UNumberFormatAttribute attr, 00397 int32_t newValue); 00398 00399 00413 U_CAPI double 00414 unum_getDoubleAttribute(const UNumberFormat* fmt, 00415 UNumberFormatAttribute attr); 00416 00430 U_CAPI void 00431 unum_setDoubleAttribute( UNumberFormat* fmt, 00432 UNumberFormatAttribute attr, 00433 double newValue); 00434 00436 enum UNumberFormatTextAttribute{ 00438 UNUM_POSITIVE_PREFIX, 00440 UNUM_POSITIVE_SUFFIX, 00442 UNUM_NEGATIVE_PREFIX, 00444 UNUM_NEGATIVE_SUFFIX, 00446 UNUM_PADDING_CHARACTER 00447 }; 00448 typedef enum UNumberFormatTextAttribute UNumberFormatTextAttribute; 00449 00465 U_CAPI int32_t 00466 unum_getTextAttribute( const UNumberFormat* fmt, 00467 UNumberFormatTextAttribute tag, 00468 UChar* result, 00469 int32_t resultLength, 00470 UErrorCode* status); 00471 00486 U_CAPI void 00487 unum_setTextAttribute( UNumberFormat* fmt, 00488 UNumberFormatTextAttribute tag, 00489 const UChar* newValue, 00490 int32_t newValueLength, 00491 UErrorCode *status); 00492 00504 U_CAPI int32_t 00505 unum_toPattern( const UNumberFormat* fmt, 00506 UBool isPatternLocalized, 00507 UChar* result, 00508 int32_t resultLength, 00509 UErrorCode* status); 00510 00511 /* The maximum size for a textual number format symbol. */ 00512 #define UNFSYMBOLSMAXSIZE 10 00513 00517 struct UNumberFormatSymbols{ 00519 UChar decimalSeparator; 00521 UChar groupingSeparator; 00523 UChar patternSeparator; 00525 UChar percent; 00527 UChar zeroDigit; 00529 UChar digit; 00531 UChar minusSign; 00533 UChar plusSign; 00535 UChar currency [UNFSYMBOLSMAXSIZE]; 00537 UChar intlCurrency [UNFSYMBOLSMAXSIZE]; 00539 UChar monetarySeparator; 00541 UChar exponential; 00543 UChar perMill; 00545 UChar padEscape; 00547 UChar infinity [UNFSYMBOLSMAXSIZE]; 00549 UChar naN [UNFSYMBOLSMAXSIZE]; 00550 }; 00551 typedef struct UNumberFormatSymbols UNumberFormatSymbols; 00552 00562 U_CAPI void 00563 unum_getSymbols( const UNumberFormat *fmt, 00564 UNumberFormatSymbols *syms); 00565 00576 U_CAPI void 00577 unum_setSymbols( UNumberFormat* fmt, 00578 const UNumberFormatSymbols* symbolsToSet, 00579 UErrorCode *status); 00580 00585 enum UNumberFormatSymbol { 00587 UNUM_DECIMAL_SEPARATOR_SYMBOL, 00589 UNUM_GROUPING_SEPARATOR_SYMBOL, 00591 UNUM_PATTERN_SEPARATOR_SYMBOL, 00593 UNUM_PERCENT_SYMBOL, 00595 UNUM_ZERO_DIGIT_SYMBOL, 00597 UNUM_DIGIT_SYMBOL, 00599 UNUM_MINUS_SIGN_SYMBOL, 00601 UNUM_PLUS_SIGN_SYMBOL, 00603 UNUM_CURRENCY_SYMBOL, 00605 UNUM_INTL_CURRENCY_SYMBOL, 00607 UNUM_MONETARY_SEPARATOR_SYMBOL, 00609 UNUM_EXPONENTIAL_SYMBOL, 00611 UNUM_PERMILL_SYMBOL, 00613 UNUM_PAD_ESCAPE_SYMBOL, 00615 UNUM_INFINITY_SYMBOL, 00617 UNUM_NAN_SYMBOL, 00619 UNUM_FORMAT_SYMBOL_COUNT 00620 }; 00621 typedef enum UNumberFormatSymbol UNumberFormatSymbol; 00622 00637 U_CAPI int32_t U_EXPORT2 00638 unum_getSymbol(UNumberFormat *fmt, 00639 UNumberFormatSymbol symbol, 00640 UChar *buffer, 00641 int32_t size, 00642 UErrorCode *status); 00643 00656 U_CAPI void U_EXPORT2 00657 unum_setSymbol(UNumberFormat *fmt, 00658 UNumberFormatSymbol symbol, 00659 const UChar *value, 00660 int32_t length, 00661 UErrorCode *status); 00662 00663 #endif