unum.h

Go to the documentation of this file.
00001 /*
00002 *******************************************************************************
00003 * Copyright (C) 1997-2009, International Business Machines Corporation and others.
00004 * All Rights Reserved.
00005 * Modification History:
00006 *
00007 *   Date        Name        Description
00008 *   06/24/99    helena      Integrated Alan's NF enhancements and Java2 bug fixes
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/uloc.h"
00020 #include "unicode/umisc.h"
00021 #include "unicode/parseerr.h"
00129 typedef void* UNumberFormat;
00130 
00134 typedef enum UNumberFormatStyle {
00139     UNUM_PATTERN_DECIMAL=0,
00141     UNUM_DECIMAL=1,
00143     UNUM_CURRENCY,
00145     UNUM_PERCENT,
00147     UNUM_SCIENTIFIC,
00149     UNUM_SPELLOUT,
00154     UNUM_ORDINAL,
00159     UNUM_DURATION,
00164     UNUM_NUMBERING_SYSTEM,
00169     UNUM_PATTERN_RULEBASED,
00171     UNUM_DEFAULT = UNUM_DECIMAL,
00173     UNUM_IGNORE = UNUM_PATTERN_DECIMAL
00174 } UNumberFormatStyle;
00175 
00179 typedef enum UNumberFormatRoundingMode {
00180     UNUM_ROUND_CEILING,
00181     UNUM_ROUND_FLOOR,
00182     UNUM_ROUND_DOWN,
00183     UNUM_ROUND_UP,
00188     UNUM_FOUND_HALFEVEN,
00189     UNUM_ROUND_HALFDOWN,
00190     UNUM_ROUND_HALFUP,
00195     UNUM_ROUND_HALFEVEN = UNUM_FOUND_HALFEVEN
00196 } UNumberFormatRoundingMode;
00197 
00201 typedef enum UNumberFormatPadPosition {
00202     UNUM_PAD_BEFORE_PREFIX,
00203     UNUM_PAD_AFTER_PREFIX,
00204     UNUM_PAD_BEFORE_SUFFIX,
00205     UNUM_PAD_AFTER_SUFFIX
00206 } UNumberFormatPadPosition;
00207 
00239 U_STABLE UNumberFormat* U_EXPORT2 
00240 unum_open(  UNumberFormatStyle    style,
00241             const    UChar*    pattern,
00242             int32_t            patternLength,
00243             const    char*     locale,
00244             UParseError*       parseErr,
00245             UErrorCode*        status);
00246 
00247 
00254 U_STABLE void U_EXPORT2 
00255 unum_close(UNumberFormat* fmt);
00256 
00265 U_STABLE UNumberFormat* U_EXPORT2 
00266 unum_clone(const UNumberFormat *fmt,
00267        UErrorCode *status);
00268 
00290 U_STABLE int32_t U_EXPORT2 
00291 unum_format(    const    UNumberFormat*    fmt,
00292         int32_t            number,
00293         UChar*            result,
00294         int32_t            resultLength,
00295         UFieldPosition    *pos,
00296         UErrorCode*        status);
00297 
00319 U_STABLE int32_t U_EXPORT2 
00320 unum_formatInt64(const UNumberFormat *fmt,
00321         int64_t         number,
00322         UChar*          result,
00323         int32_t         resultLength,
00324         UFieldPosition *pos,
00325         UErrorCode*     status);
00326 
00348 U_STABLE int32_t U_EXPORT2 
00349 unum_formatDouble(    const    UNumberFormat*  fmt,
00350             double          number,
00351             UChar*          result,
00352             int32_t         resultLength,
00353             UFieldPosition  *pos, /* 0 if ignore */
00354             UErrorCode*     status);
00355 
00377 U_STABLE int32_t U_EXPORT2 
00378 unum_formatDoubleCurrency(const UNumberFormat* fmt,
00379                           double number,
00380                           UChar* currency,
00381                           UChar* result,
00382                           int32_t resultLength,
00383                           UFieldPosition* pos, /* ignored if 0 */
00384                           UErrorCode* status);
00385 
00403 U_STABLE int32_t U_EXPORT2 
00404 unum_parse(    const   UNumberFormat*  fmt,
00405         const   UChar*          text,
00406         int32_t         textLength,
00407         int32_t         *parsePos /* 0 = start */,
00408         UErrorCode      *status);
00409 
00427 U_STABLE int64_t U_EXPORT2 
00428 unum_parseInt64(const UNumberFormat*  fmt,
00429         const UChar*  text,
00430         int32_t       textLength,
00431         int32_t       *parsePos /* 0 = start */,
00432         UErrorCode    *status);
00433 
00451 U_STABLE double U_EXPORT2 
00452 unum_parseDouble(    const   UNumberFormat*  fmt,
00453             const   UChar*          text,
00454             int32_t         textLength,
00455             int32_t         *parsePos /* 0 = start */,
00456             UErrorCode      *status);
00457 
00477 U_STABLE double U_EXPORT2
00478 unum_parseDoubleCurrency(const UNumberFormat* fmt,
00479                          const UChar* text,
00480                          int32_t textLength,
00481                          int32_t* parsePos, /* 0 = start */
00482                          UChar* currency,
00483                          UErrorCode* status);
00484 
00501 U_STABLE void U_EXPORT2 
00502 unum_applyPattern(          UNumberFormat  *format,
00503                             UBool          localized,
00504                     const   UChar          *pattern,
00505                             int32_t         patternLength,
00506                             UParseError    *parseError,
00507                             UErrorCode     *status
00508                                     );
00509 
00520 U_STABLE const char* U_EXPORT2 
00521 unum_getAvailable(int32_t localeIndex);
00522 
00532 U_STABLE int32_t U_EXPORT2 
00533 unum_countAvailable(void);
00534 
00536 typedef enum UNumberFormatAttribute {
00538   UNUM_PARSE_INT_ONLY,
00540   UNUM_GROUPING_USED,
00542   UNUM_DECIMAL_ALWAYS_SHOWN,
00544   UNUM_MAX_INTEGER_DIGITS,
00546   UNUM_MIN_INTEGER_DIGITS,
00548   UNUM_INTEGER_DIGITS,
00550   UNUM_MAX_FRACTION_DIGITS,
00552   UNUM_MIN_FRACTION_DIGITS,
00554   UNUM_FRACTION_DIGITS,
00556   UNUM_MULTIPLIER,
00558   UNUM_GROUPING_SIZE,
00560   UNUM_ROUNDING_MODE,
00562   UNUM_ROUNDING_INCREMENT,
00564   UNUM_FORMAT_WIDTH,
00566   UNUM_PADDING_POSITION,
00568   UNUM_SECONDARY_GROUPING_SIZE,
00571   UNUM_SIGNIFICANT_DIGITS_USED,
00574   UNUM_MIN_SIGNIFICANT_DIGITS,
00577   UNUM_MAX_SIGNIFICANT_DIGITS,
00581   UNUM_LENIENT_PARSE
00582 } UNumberFormatAttribute;
00583 
00600 U_STABLE int32_t U_EXPORT2 
00601 unum_getAttribute(const UNumberFormat*          fmt,
00602           UNumberFormatAttribute  attr);
00603 
00623 U_STABLE void U_EXPORT2 
00624 unum_setAttribute(    UNumberFormat*          fmt,
00625             UNumberFormatAttribute  attr,
00626             int32_t                 newValue);
00627 
00628 
00643 U_STABLE double U_EXPORT2 
00644 unum_getDoubleAttribute(const UNumberFormat*          fmt,
00645           UNumberFormatAttribute  attr);
00646 
00661 U_STABLE void U_EXPORT2 
00662 unum_setDoubleAttribute(    UNumberFormat*          fmt,
00663             UNumberFormatAttribute  attr,
00664             double                 newValue);
00665 
00667 typedef enum UNumberFormatTextAttribute {
00669   UNUM_POSITIVE_PREFIX,
00671   UNUM_POSITIVE_SUFFIX,
00673   UNUM_NEGATIVE_PREFIX,
00675   UNUM_NEGATIVE_SUFFIX,
00677   UNUM_PADDING_CHARACTER,
00679   UNUM_CURRENCY_CODE,
00684   UNUM_DEFAULT_RULESET,
00691   UNUM_PUBLIC_RULESETS
00692 } UNumberFormatTextAttribute;
00693 
00712 U_STABLE int32_t U_EXPORT2 
00713 unum_getTextAttribute(    const    UNumberFormat*                    fmt,
00714             UNumberFormatTextAttribute      tag,
00715             UChar*                            result,
00716             int32_t                            resultLength,
00717             UErrorCode*                        status);
00718 
00735 U_STABLE void U_EXPORT2 
00736 unum_setTextAttribute(    UNumberFormat*                    fmt,
00737             UNumberFormatTextAttribute      tag,
00738             const    UChar*                            newValue,
00739             int32_t                            newValueLength,
00740             UErrorCode                        *status);
00741 
00758 U_STABLE int32_t U_EXPORT2 
00759 unum_toPattern(    const    UNumberFormat*          fmt,
00760         UBool                  isPatternLocalized,
00761         UChar*                  result,
00762         int32_t                 resultLength,
00763         UErrorCode*             status);
00764 
00765 
00770 typedef enum UNumberFormatSymbol {
00772   UNUM_DECIMAL_SEPARATOR_SYMBOL = 0,
00774   UNUM_GROUPING_SEPARATOR_SYMBOL = 1,
00776   UNUM_PATTERN_SEPARATOR_SYMBOL = 2,
00778   UNUM_PERCENT_SYMBOL = 3,
00780   UNUM_ZERO_DIGIT_SYMBOL = 4,
00782   UNUM_DIGIT_SYMBOL = 5,
00784   UNUM_MINUS_SIGN_SYMBOL = 6,
00786   UNUM_PLUS_SIGN_SYMBOL = 7,
00788   UNUM_CURRENCY_SYMBOL = 8,
00790   UNUM_INTL_CURRENCY_SYMBOL = 9,
00792   UNUM_MONETARY_SEPARATOR_SYMBOL = 10,
00794   UNUM_EXPONENTIAL_SYMBOL = 11,
00796   UNUM_PERMILL_SYMBOL = 12,
00798   UNUM_PAD_ESCAPE_SYMBOL = 13,
00800   UNUM_INFINITY_SYMBOL = 14,
00802   UNUM_NAN_SYMBOL = 15,
00805   UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16,
00809   UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17,  
00811   UNUM_FORMAT_SYMBOL_COUNT = 18
00812 } UNumberFormatSymbol;
00813 
00830 U_STABLE int32_t U_EXPORT2
00831 unum_getSymbol(const UNumberFormat *fmt,
00832                UNumberFormatSymbol symbol,
00833                UChar *buffer,
00834                int32_t size,
00835                UErrorCode *status);
00836 
00850 U_STABLE void U_EXPORT2
00851 unum_setSymbol(UNumberFormat *fmt,
00852                UNumberFormatSymbol symbol,
00853                const UChar *value,
00854                int32_t length,
00855                UErrorCode *status);
00856 
00857 
00867 U_STABLE const char* U_EXPORT2
00868 unum_getLocaleByType(const UNumberFormat *fmt,
00869                      ULocDataLocaleType type,
00870                      UErrorCode* status); 
00871 
00872 #endif /* #if !UCONFIG_NO_FORMATTING */
00873 
00874 #endif

Generated on 18 Sep 2013 for ICU 4.2.1 by  doxygen 1.4.7