Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

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 
00114 typedef void* UNumberFormat;
00115 
00117 enum UNumberFormatStyle {
00119     UNUM_DECIMAL,
00121     UNUM_CURRENCY,
00123     UNUM_PERCENT,
00125     UNUM_SPELLOUT,
00127     UNUM_DEFAULT = UNUM_DECIMAL
00128 };
00129 typedef enum UNumberFormatStyle UNumberFormatStyle;
00130 
00131 enum UNumberFormatRoundingMode {
00132     UNUM_ROUND_CEILING,
00133     UNUM_ROUND_FLOOR,
00134     UNUM_ROUND_DOWN,
00135     UNUM_ROUND_UP,
00136     UNUM_FOUND_HALFEVEN,
00137     UNUM_ROUND_HALFDOWN,
00138     UNUM_ROUND_HALFUP
00139 };
00140 typedef enum UNumberFormatRoundingMode UNumberFormatRoundingMode;
00141 
00142 enum UNumberFormatPadPosition {
00143     UNUM_PAD_BEFORE_PREFIX,
00144     UNUM_PAD_AFTER_PREFIX,
00145     UNUM_PAD_BEFORE_SUFFIX,
00146     UNUM_PAD_AFTER_SUFFIX
00147 };
00148 typedef enum UNumberFormatPadPosition UNumberFormatPadPosition;
00149 
00163 U_CAPI UNumberFormat*
00164 unum_open(UNumberFormatStyle    style,
00165       const   char*        locale,
00166       UErrorCode*        status);
00167 
00181 U_CAPI UNumberFormat*
00182 unum_openPattern(    const    UChar*        pattern,
00183             int32_t            patternLength,
00184             const    char*        locale,
00185             UErrorCode*        status);
00186 
00193 U_CAPI void
00194 unum_close(UNumberFormat* fmt);
00195 
00204 U_CAPI UNumberFormat*
00205 unum_clone(const UNumberFormat *fmt,
00206        UErrorCode *status);
00207 
00227 U_CAPI int32_t
00228 unum_format(    const    UNumberFormat*    fmt,
00229         int32_t            number,
00230         UChar*            result,
00231         int32_t            resultLength,
00232         UFieldPosition    *pos,
00233         UErrorCode*        status);
00234 
00254 U_CAPI int32_t
00255 unum_formatDouble(    const    UNumberFormat*  fmt,
00256             double          number,
00257             UChar*          result,
00258             int32_t         resultLength,
00259             UFieldPosition  *pos, /* 0 if ignore */
00260             UErrorCode*     status);
00261 
00277 U_CAPI int32_t
00278 unum_parse(    const   UNumberFormat*  fmt,
00279         const   UChar*          text,
00280         int32_t         textLength,
00281         int32_t         *parsePos /* 0 = start */,
00282         UErrorCode      *status);
00283 
00299 U_CAPI double
00300 unum_parseDouble(    const   UNumberFormat*  fmt,
00301             const   UChar*          text,
00302             int32_t         textLength,
00303             int32_t         *parsePos /* 0 = start */,
00304             UErrorCode      *status);
00305 
00316 U_CAPI void
00317 unum_applyPattern(          UNumberFormat  *format,
00318                             UBool          localized,
00319                     const   UChar          *pattern,
00320                             int32_t         patternLength);
00330 U_CAPI const char*
00331 unum_getAvailable(int32_t index);
00332 
00341 U_CAPI int32_t
00342 unum_countAvailable(void);
00343 
00345 enum UNumberFormatAttribute {
00347   UNUM_PARSE_INT_ONLY,
00349   UNUM_GROUPING_USED,
00351   UNUM_DECIMAL_ALWAYS_SHOWN,
00353   UNUM_MAX_INTEGER_DIGITS,
00355   UNUM_MIN_INTEGER_DIGITS,
00357   UNUM_INTEGER_DIGITS,
00359   UNUM_MAX_FRACTION_DIGITS,
00361   UNUM_MIN_FRACTION_DIGITS,
00363   UNUM_FRACTION_DIGITS,
00365   UNUM_MULTIPLIER,
00367   UNUM_GROUPING_SIZE,
00369   UNUM_ROUNDING_MODE,
00371   UNUM_ROUNDING_INCREMENT,
00373   UNUM_FORMAT_WIDTH,
00375   UNUM_PADDING_POSITION,
00377   UNUM_SECONDARY_GROUPING_SIZE
00378 };
00379 typedef enum UNumberFormatAttribute UNumberFormatAttribute;
00380 
00381 /*====================================================
00382 ======================================================
00383     ---> Add to UErrorCode !!!! --->
00384 typedef enum {
00385     AttributeNotSupported,
00386     PropertyNotSupported
00387 } UErrorCode;
00388     ---> Add to UErrorCode !!!! --->
00389 ======================================================
00390 ====================================================*/
00391 
00408 U_CAPI int32_t
00409 unum_getAttribute(const UNumberFormat*          fmt,
00410           UNumberFormatAttribute  attr);
00411 
00428 U_CAPI void
00429 unum_setAttribute(    UNumberFormat*          fmt,
00430             UNumberFormatAttribute  attr,
00431             int32_t                 newValue);
00432 
00433 
00447 U_CAPI double
00448 unum_getDoubleAttribute(const UNumberFormat*          fmt,
00449           UNumberFormatAttribute  attr);
00450 
00464 U_CAPI void
00465 unum_setDoubleAttribute(    UNumberFormat*          fmt,
00466             UNumberFormatAttribute  attr,
00467             double                 newValue);
00468 
00470 enum UNumberFormatTextAttribute{
00472   UNUM_POSITIVE_PREFIX,
00474   UNUM_POSITIVE_SUFFIX,
00476   UNUM_NEGATIVE_PREFIX,
00478   UNUM_NEGATIVE_SUFFIX,
00480   UNUM_PADDING_CHARACTER
00481 };
00482 typedef enum UNumberFormatTextAttribute UNumberFormatTextAttribute;
00483 
00499 U_CAPI int32_t
00500 unum_getTextAttribute(    const    UNumberFormat*                    fmt,
00501             UNumberFormatTextAttribute      tag,
00502             UChar*                            result,
00503             int32_t                            resultLength,
00504             UErrorCode*                        status);
00505 
00520 U_CAPI void
00521 unum_setTextAttribute(    UNumberFormat*                    fmt,
00522             UNumberFormatTextAttribute      tag,
00523             const    UChar*                            newValue,
00524             int32_t                            newValueLength,
00525             UErrorCode                        *status);
00526 
00538 U_CAPI int32_t
00539 unum_toPattern(    const    UNumberFormat*          fmt,
00540         UBool                  isPatternLocalized,
00541         UChar*                  result,
00542         int32_t                 resultLength,
00543         UErrorCode*             status);
00544 
00545 /* The maximum size for a textual number format symbol. */
00546 #define UNFSYMBOLSMAXSIZE 10
00547 
00551 struct UNumberFormatSymbols{
00553   UChar decimalSeparator;
00555   UChar groupingSeparator;
00557   UChar patternSeparator;
00559   UChar percent;
00561   UChar zeroDigit;
00563   UChar digit;
00565   UChar minusSign;
00567   UChar plusSign;
00569   UChar currency      [UNFSYMBOLSMAXSIZE];
00571   UChar intlCurrency  [UNFSYMBOLSMAXSIZE];
00573   UChar monetarySeparator;
00575   UChar exponential;
00577   UChar perMill;
00579   UChar padEscape;
00581   UChar infinity      [UNFSYMBOLSMAXSIZE];
00583   UChar naN           [UNFSYMBOLSMAXSIZE];
00584 };
00585 typedef struct UNumberFormatSymbols UNumberFormatSymbols;
00586 
00596 U_CAPI void
00597 unum_getSymbols(    const    UNumberFormat            *fmt,
00598             UNumberFormatSymbols    *syms);
00599 
00610 U_CAPI void
00611 unum_setSymbols(    UNumberFormat*          fmt,
00612             const   UNumberFormatSymbols*   symbolsToSet,
00613             UErrorCode                *status);
00614 
00619 enum UNumberFormatSymbol {
00621   UNUM_DECIMAL_SEPARATOR_SYMBOL,
00623   UNUM_GROUPING_SEPARATOR_SYMBOL,
00625   UNUM_PATTERN_SEPARATOR_SYMBOL,
00627   UNUM_PERCENT_SYMBOL,
00629   UNUM_ZERO_DIGIT_SYMBOL,
00631   UNUM_DIGIT_SYMBOL,
00633   UNUM_MINUS_SIGN_SYMBOL,
00635   UNUM_PLUS_SIGN_SYMBOL,
00637   UNUM_CURRENCY_SYMBOL,
00639   UNUM_INTL_CURRENCY_SYMBOL,
00641   UNUM_MONETARY_SEPARATOR_SYMBOL,
00643   UNUM_EXPONENTIAL_SYMBOL,
00645   UNUM_PERMILL_SYMBOL,
00647   UNUM_PAD_ESCAPE_SYMBOL,
00649   UNUM_INFINITY_SYMBOL,
00651   UNUM_NAN_SYMBOL,
00653   UNUM_FORMAT_SYMBOL_COUNT
00654 };
00655 typedef enum UNumberFormatSymbol UNumberFormatSymbol;
00656 
00671 U_CAPI int32_t U_EXPORT2
00672 unum_getSymbol(UNumberFormat *fmt,
00673                UNumberFormatSymbol symbol,
00674                UChar *buffer,
00675                int32_t size,
00676                UErrorCode *status);
00677 
00690 U_CAPI void U_EXPORT2
00691 unum_setSymbol(UNumberFormat *fmt,
00692                UNumberFormatSymbol symbol,
00693                const UChar *value,
00694                int32_t length,
00695                UErrorCode *status);
00696 
00697 #endif

Generated at Tue Jun 12 14:04:03 2001 for ICU 1.8.1 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000