Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

unum.h

Go to the documentation of this file.
00001 /* 00002 ******************************************************************************* 00003 * Copyright (C) 1997-2001, 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 #include "unicode/parseerr.h" 00114 typedef void* UNumberFormat; 00115 00117 enum UNumberFormatStyle { 00119 UNUM_IGNORE=0, 00121 UNUM_DECIMAL=1, 00123 UNUM_CURRENCY, 00125 UNUM_PERCENT, 00127 UNUM_SCIENTIFIC, 00129 UNUM_SPELLOUT, 00131 UNUM_DEFAULT = UNUM_DECIMAL 00132 }; 00133 typedef enum UNumberFormatStyle UNumberFormatStyle; 00134 00135 enum UNumberFormatRoundingMode { 00136 UNUM_ROUND_CEILING, 00137 UNUM_ROUND_FLOOR, 00138 UNUM_ROUND_DOWN, 00139 UNUM_ROUND_UP, 00140 UNUM_FOUND_HALFEVEN, 00141 UNUM_ROUND_HALFDOWN, 00142 UNUM_ROUND_HALFUP 00143 }; 00144 typedef enum UNumberFormatRoundingMode UNumberFormatRoundingMode; 00145 00146 enum UNumberFormatPadPosition { 00147 UNUM_PAD_BEFORE_PREFIX, 00148 UNUM_PAD_AFTER_PREFIX, 00149 UNUM_PAD_BEFORE_SUFFIX, 00150 UNUM_PAD_AFTER_SUFFIX 00151 }; 00152 typedef enum UNumberFormatPadPosition UNumberFormatPadPosition; 00153 00170 U_CAPI UNumberFormat* U_EXPORT2 00171 unum_open( UNumberFormatStyle style, 00172 const UChar* pattern, 00173 int32_t patternLength, 00174 const char* locale, 00175 UParseError* parseErr, 00176 UErrorCode* status); 00177 00178 00185 U_CAPI void U_EXPORT2 00186 unum_close(UNumberFormat* fmt); 00187 00196 U_CAPI UNumberFormat* U_EXPORT2 00197 unum_clone(const UNumberFormat *fmt, 00198 UErrorCode *status); 00199 00219 U_CAPI int32_t U_EXPORT2 00220 unum_format( const UNumberFormat* fmt, 00221 int32_t number, 00222 UChar* result, 00223 int32_t resultLength, 00224 UFieldPosition *pos, 00225 UErrorCode* status); 00226 00246 U_CAPI int32_t U_EXPORT2 00247 unum_formatDouble( const UNumberFormat* fmt, 00248 double number, 00249 UChar* result, 00250 int32_t resultLength, 00251 UFieldPosition *pos, /* 0 if ignore */ 00252 UErrorCode* status); 00253 00269 U_CAPI int32_t U_EXPORT2 00270 unum_parse( const UNumberFormat* fmt, 00271 const UChar* text, 00272 int32_t textLength, 00273 int32_t *parsePos /* 0 = start */, 00274 UErrorCode *status); 00275 00291 U_CAPI double U_EXPORT2 00292 unum_parseDouble( const UNumberFormat* fmt, 00293 const UChar* text, 00294 int32_t textLength, 00295 int32_t *parsePos /* 0 = start */, 00296 UErrorCode *status); 00297 00328 U_CAPI void U_EXPORT2 00329 unum_applyPattern( UNumberFormat *format, 00330 UBool localized, 00331 const UChar *pattern, 00332 int32_t patternLength, 00333 UParseError *parseError, 00334 UErrorCode *status 00335 ); 00336 00346 U_CAPI const char* U_EXPORT2 00347 unum_getAvailable(int32_t index); 00348 00357 U_CAPI int32_t U_EXPORT2 00358 unum_countAvailable(void); 00359 00361 enum UNumberFormatAttribute { 00363 UNUM_PARSE_INT_ONLY, 00365 UNUM_GROUPING_USED, 00367 UNUM_DECIMAL_ALWAYS_SHOWN, 00369 UNUM_MAX_INTEGER_DIGITS, 00371 UNUM_MIN_INTEGER_DIGITS, 00373 UNUM_INTEGER_DIGITS, 00375 UNUM_MAX_FRACTION_DIGITS, 00377 UNUM_MIN_FRACTION_DIGITS, 00379 UNUM_FRACTION_DIGITS, 00381 UNUM_MULTIPLIER, 00383 UNUM_GROUPING_SIZE, 00385 UNUM_ROUNDING_MODE, 00387 UNUM_ROUNDING_INCREMENT, 00389 UNUM_FORMAT_WIDTH, 00391 UNUM_PADDING_POSITION, 00393 UNUM_SECONDARY_GROUPING_SIZE 00394 }; 00395 typedef enum UNumberFormatAttribute UNumberFormatAttribute; 00396 00397 /*==================================================== 00398 ====================================================== 00399 ---> Add to UErrorCode !!!! ---> 00400 typedef enum { 00401 AttributeNotSupported, 00402 PropertyNotSupported 00403 } UErrorCode; 00404 ---> Add to UErrorCode !!!! ---> 00405 ====================================================== 00406 ====================================================*/ 00407 00424 U_CAPI int32_t U_EXPORT2 00425 unum_getAttribute(const UNumberFormat* fmt, 00426 UNumberFormatAttribute attr); 00427 00444 U_CAPI void U_EXPORT2 00445 unum_setAttribute( UNumberFormat* fmt, 00446 UNumberFormatAttribute attr, 00447 int32_t newValue); 00448 00449 00463 U_CAPI double U_EXPORT2 00464 unum_getDoubleAttribute(const UNumberFormat* fmt, 00465 UNumberFormatAttribute attr); 00466 00480 U_CAPI void U_EXPORT2 00481 unum_setDoubleAttribute( UNumberFormat* fmt, 00482 UNumberFormatAttribute attr, 00483 double newValue); 00484 00486 enum UNumberFormatTextAttribute{ 00488 UNUM_POSITIVE_PREFIX, 00490 UNUM_POSITIVE_SUFFIX, 00492 UNUM_NEGATIVE_PREFIX, 00494 UNUM_NEGATIVE_SUFFIX, 00496 UNUM_PADDING_CHARACTER 00497 }; 00498 typedef enum UNumberFormatTextAttribute UNumberFormatTextAttribute; 00499 00515 U_CAPI int32_t U_EXPORT2 00516 unum_getTextAttribute( const UNumberFormat* fmt, 00517 UNumberFormatTextAttribute tag, 00518 UChar* result, 00519 int32_t resultLength, 00520 UErrorCode* status); 00521 00536 U_CAPI void U_EXPORT2 00537 unum_setTextAttribute( UNumberFormat* fmt, 00538 UNumberFormatTextAttribute tag, 00539 const UChar* newValue, 00540 int32_t newValueLength, 00541 UErrorCode *status); 00542 00554 U_CAPI int32_t U_EXPORT2 00555 unum_toPattern( const UNumberFormat* fmt, 00556 UBool isPatternLocalized, 00557 UChar* result, 00558 int32_t resultLength, 00559 UErrorCode* status); 00560 00561 /* The maximum size for a textual number format symbol. */ 00562 #define UNFSYMBOLSMAXSIZE 10 00563 00564 #ifdef ICU_DECIMALFORMATSYMBOLS_USE_DEPRECATES 00565 00568 struct UNumberFormatSymbols{ 00570 UChar decimalSeparator; 00572 UChar groupingSeparator; 00574 UChar patternSeparator; 00576 UChar percent; 00578 UChar zeroDigit; 00580 UChar digit; 00582 UChar minusSign; 00584 UChar plusSign; 00586 UChar currency [UNFSYMBOLSMAXSIZE]; 00588 UChar intlCurrency [UNFSYMBOLSMAXSIZE]; 00590 UChar monetarySeparator; 00592 UChar exponential; 00594 UChar perMill; 00596 UChar padEscape; 00598 UChar infinity [UNFSYMBOLSMAXSIZE]; 00600 UChar naN [UNFSYMBOLSMAXSIZE]; 00601 }; 00602 typedef struct UNumberFormatSymbols UNumberFormatSymbols; 00603 00613 U_CAPI void U_EXPORT2 00614 unum_getSymbols( const UNumberFormat *fmt, 00615 UNumberFormatSymbols *syms); 00616 00627 U_CAPI void U_EXPORT2 00628 unum_setSymbols( UNumberFormat* fmt, 00629 const UNumberFormatSymbols* symbolsToSet, 00630 UErrorCode *status); 00631 #endif /* ICU_DECIMALFORMATSYMBOLS_USE_DEPRECATES */ 00632 00637 enum UNumberFormatSymbol { 00639 UNUM_DECIMAL_SEPARATOR_SYMBOL, 00641 UNUM_GROUPING_SEPARATOR_SYMBOL, 00643 UNUM_PATTERN_SEPARATOR_SYMBOL, 00645 UNUM_PERCENT_SYMBOL, 00647 UNUM_ZERO_DIGIT_SYMBOL, 00649 UNUM_DIGIT_SYMBOL, 00651 UNUM_MINUS_SIGN_SYMBOL, 00653 UNUM_PLUS_SIGN_SYMBOL, 00655 UNUM_CURRENCY_SYMBOL, 00657 UNUM_INTL_CURRENCY_SYMBOL, 00659 UNUM_MONETARY_SEPARATOR_SYMBOL, 00661 UNUM_EXPONENTIAL_SYMBOL, 00663 UNUM_PERMILL_SYMBOL, 00665 UNUM_PAD_ESCAPE_SYMBOL, 00667 UNUM_INFINITY_SYMBOL, 00669 UNUM_NAN_SYMBOL, 00671 UNUM_FORMAT_SYMBOL_COUNT 00672 }; 00673 typedef enum UNumberFormatSymbol UNumberFormatSymbol; 00674 00689 U_CAPI int32_t U_EXPORT2 00690 unum_getSymbol(UNumberFormat *fmt, 00691 UNumberFormatSymbol symbol, 00692 UChar *buffer, 00693 int32_t size, 00694 UErrorCode *status); 00695 00708 U_CAPI void U_EXPORT2 00709 unum_setSymbol(UNumberFormat *fmt, 00710 UNumberFormatSymbol symbol, 00711 const UChar *value, 00712 int32_t length, 00713 UErrorCode *status); 00714 00715 00716 /******************* Deprecated API ***************************/ 00720 #ifdef U_USE_DEPRECATED_FORMAT_API 00721 00722 #if ((U_ICU_VERSION_MAJOR_NUM != 2) || (U_ICU_VERSION_MINOR_NUM !=1)) 00723 # error "ICU version has changed. Please redefine the macros under U_USE_DEPRECATED_FORMAT_API pre-processor definition" 00724 #else 00725 static UNumberFormat* 00726 unum_openPattern(const UChar* pattern, int32_t patternLength,const char* locale,UErrorCode* status) 00727 { 00728 return unum_open(0,pattern,patternLength,locale,NULL,status); 00729 } 00730 00731 # define unum_open_2_1(style,locale,status) unum_open(style, NULL, 0, locale, NULL, status) 00732 # define unum_applyPattern_2_1(format,localized,pattern,patternLength) unum_applyPattern(format,localized,pattern,patternLength,NULL,NULL) 00733 #endif 00734 00735 #endif 00736 /******************** End ************************************/ 00737 00738 #endif

Generated on Wed Jul 28 05:45:13 2004 for ICU 2.1 by doxygen 1.3.7