- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- Search for |

- File List
- Globals

# unum.h

Go to the documentation of this file.

    00001 /*
    00002 *******************************************************************************
    00003 * Copyright (C) 1997-2007, 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_PATTERN_RULEBASED,
    00166     UNUM_DEFAULT = UNUM_DECIMAL,
    00168     UNUM_IGNORE = UNUM_PATTERN_DECIMAL
    00169 } UNumberFormatStyle;
    00170
    00174 typedef enum UNumberFormatRoundingMode {
    00175     UNUM_ROUND_CEILING,
    00176     UNUM_ROUND_FLOOR,
    00177     UNUM_ROUND_DOWN,
    00178     UNUM_ROUND_UP,
    00183     UNUM_FOUND_HALFEVEN,
    00184     UNUM_ROUND_HALFDOWN,
    00185     UNUM_ROUND_HALFUP,
    00190     UNUM_ROUND_HALFEVEN = UNUM_FOUND_HALFEVEN
    00191 } UNumberFormatRoundingMode;
    00192
    00196 typedef enum UNumberFormatPadPosition {
    00197     UNUM_PAD_BEFORE_PREFIX,
    00198     UNUM_PAD_AFTER_PREFIX,
    00199     UNUM_PAD_BEFORE_SUFFIX,
    00200     UNUM_PAD_AFTER_SUFFIX
    00201 } UNumberFormatPadPosition;
    00202
    00234 U_STABLE UNumberFormat* U_EXPORT2
    00235 unum_open(  UNumberFormatStyle    style,
    00236             const    UChar*    pattern,
    00237             int32_t            patternLength,
    00238             const    char*     locale,
    00239             UParseError*       parseErr,
    00240             UErrorCode*        status);
    00241
    00242
    00249 U_STABLE void U_EXPORT2
    00250 unum_close(UNumberFormat* fmt);
    00251
    00260 U_STABLE UNumberFormat* U_EXPORT2
    00261 unum_clone(const UNumberFormat *fmt,
    00262        UErrorCode *status);
    00263
    00285 U_STABLE int32_t U_EXPORT2
    00286 unum_format(    const    UNumberFormat*    fmt,
    00287         int32_t            number,
    00288         UChar*            result,
    00289         int32_t            resultLength,
    00290         UFieldPosition    *pos,
    00291         UErrorCode*        status);
    00292
    00314 U_STABLE int32_t U_EXPORT2
    00315 unum_formatInt64(const UNumberFormat *fmt,
    00316         int64_t         number,
    00317         UChar*          result,
    00318         int32_t         resultLength,
    00319         UFieldPosition *pos,
    00320         UErrorCode*     status);
    00321
    00343 U_STABLE int32_t U_EXPORT2
    00344 unum_formatDouble(    const    UNumberFormat*  fmt,
    00345             double          number,
    00346             UChar*          result,
    00347             int32_t         resultLength,
    00348             UFieldPosition  *pos, /* 0 if ignore */
    00349             UErrorCode*     status);
    00350
    00372 U_STABLE int32_t U_EXPORT2
    00373 unum_formatDoubleCurrency(const UNumberFormat* fmt,
    00374                           double number,
    00375                           UChar* currency,
    00376                           UChar* result,
    00377                           int32_t resultLength,
    00378                           UFieldPosition* pos, /* ignored if 0 */
    00379                           UErrorCode* status);
    00380
    00398 U_STABLE int32_t U_EXPORT2
    00399 unum_parse(    const   UNumberFormat*  fmt,
    00400         const   UChar*          text,
    00401         int32_t         textLength,
    00402         int32_t         *parsePos /* 0 = start */,
    00403         UErrorCode      *status);
    00404
    00422 U_STABLE int64_t U_EXPORT2
    00423 unum_parseInt64(const UNumberFormat*  fmt,
    00424         const UChar*  text,
    00425         int32_t       textLength,
    00426         int32_t       *parsePos /* 0 = start */,
    00427         UErrorCode    *status);
    00428
    00446 U_STABLE double U_EXPORT2
    00447 unum_parseDouble(    const   UNumberFormat*  fmt,
    00448             const   UChar*          text,
    00449             int32_t         textLength,
    00450             int32_t         *parsePos /* 0 = start */,
    00451             UErrorCode      *status);
    00452
    00472 U_STABLE double U_EXPORT2
    00473 unum_parseDoubleCurrency(const UNumberFormat* fmt,
    00474                          const UChar* text,
    00475                          int32_t textLength,
    00476                          int32_t* parsePos, /* 0 = start */
    00477                          UChar* currency,
    00478                          UErrorCode* status);
    00479
    00496 U_STABLE void U_EXPORT2
    00497 unum_applyPattern(          UNumberFormat  *format,
    00498                             UBool          localized,
    00499                     const   UChar          *pattern,
    00500                             int32_t         patternLength,
    00501                             UParseError    *parseError,
    00502                             UErrorCode     *status
    00503                                     );
    00504
    00515 U_STABLE const char* U_EXPORT2
    00516 unum_getAvailable(int32_t index);
    00517
    00527 U_STABLE int32_t U_EXPORT2
    00528 unum_countAvailable(void);
    00529
    00531 typedef enum UNumberFormatAttribute {
    00533   UNUM_PARSE_INT_ONLY,
    00535   UNUM_GROUPING_USED,
    00537   UNUM_DECIMAL_ALWAYS_SHOWN,
    00539   UNUM_MAX_INTEGER_DIGITS,
    00541   UNUM_MIN_INTEGER_DIGITS,
    00543   UNUM_INTEGER_DIGITS,
    00545   UNUM_MAX_FRACTION_DIGITS,
    00547   UNUM_MIN_FRACTION_DIGITS,
    00549   UNUM_FRACTION_DIGITS,
    00551   UNUM_MULTIPLIER,
    00553   UNUM_GROUPING_SIZE,
    00555   UNUM_ROUNDING_MODE,
    00557   UNUM_ROUNDING_INCREMENT,
    00559   UNUM_FORMAT_WIDTH,
    00561   UNUM_PADDING_POSITION,
    00563   UNUM_SECONDARY_GROUPING_SIZE,
    00566   UNUM_SIGNIFICANT_DIGITS_USED,
    00569   UNUM_MIN_SIGNIFICANT_DIGITS,
    00572   UNUM_MAX_SIGNIFICANT_DIGITS,
    00576   UNUM_LENIENT_PARSE
    00577 } UNumberFormatAttribute;
    00578
    00595 U_STABLE int32_t U_EXPORT2
    00596 unum_getAttribute(const UNumberFormat*          fmt,
    00597           UNumberFormatAttribute  attr);
    00598
    00618 U_STABLE void U_EXPORT2
    00619 unum_setAttribute(    UNumberFormat*          fmt,
    00620             UNumberFormatAttribute  attr,
    00621             int32_t                 newValue);
    00622
    00623
    00638 U_STABLE double U_EXPORT2
    00639 unum_getDoubleAttribute(const UNumberFormat*          fmt,
    00640           UNumberFormatAttribute  attr);
    00641
    00656 U_STABLE void U_EXPORT2
    00657 unum_setDoubleAttribute(    UNumberFormat*          fmt,
    00658             UNumberFormatAttribute  attr,
    00659             double                 newValue);
    00660
    00662 typedef enum UNumberFormatTextAttribute {
    00664   UNUM_POSITIVE_PREFIX,
    00666   UNUM_POSITIVE_SUFFIX,
    00668   UNUM_NEGATIVE_PREFIX,
    00670   UNUM_NEGATIVE_SUFFIX,
    00672   UNUM_PADDING_CHARACTER,
    00674   UNUM_CURRENCY_CODE,
    00679   UNUM_DEFAULT_RULESET,
    00686   UNUM_PUBLIC_RULESETS
    00687 } UNumberFormatTextAttribute;
    00688
    00707 U_STABLE int32_t U_EXPORT2
    00708 unum_getTextAttribute(    const    UNumberFormat*                    fmt,
    00709             UNumberFormatTextAttribute      tag,
    00710             UChar*                            result,
    00711             int32_t                            resultLength,
    00712             UErrorCode*                        status);
    00713
    00730 U_STABLE void U_EXPORT2
    00731 unum_setTextAttribute(    UNumberFormat*                    fmt,
    00732             UNumberFormatTextAttribute      tag,
    00733             const    UChar*                            newValue,
    00734             int32_t                            newValueLength,
    00735             UErrorCode                        *status);
    00736
    00753 U_STABLE int32_t U_EXPORT2
    00754 unum_toPattern(    const    UNumberFormat*          fmt,
    00755         UBool                  isPatternLocalized,
    00756         UChar*                  result,
    00757         int32_t                 resultLength,
    00758         UErrorCode*             status);
    00759
    00760
    00765 typedef enum UNumberFormatSymbol {
    00767   UNUM_DECIMAL_SEPARATOR_SYMBOL = 0,
    00769   UNUM_GROUPING_SEPARATOR_SYMBOL = 1,
    00771   UNUM_PATTERN_SEPARATOR_SYMBOL = 2,
    00773   UNUM_PERCENT_SYMBOL = 3,
    00775   UNUM_ZERO_DIGIT_SYMBOL = 4,
    00777   UNUM_DIGIT_SYMBOL = 5,
    00779   UNUM_MINUS_SIGN_SYMBOL = 6,
    00781   UNUM_PLUS_SIGN_SYMBOL = 7,
    00783   UNUM_CURRENCY_SYMBOL = 8,
    00785   UNUM_INTL_CURRENCY_SYMBOL = 9,
    00787   UNUM_MONETARY_SEPARATOR_SYMBOL = 10,
    00789   UNUM_EXPONENTIAL_SYMBOL = 11,
    00791   UNUM_PERMILL_SYMBOL = 12,
    00793   UNUM_PAD_ESCAPE_SYMBOL = 13,
    00795   UNUM_INFINITY_SYMBOL = 14,
    00797   UNUM_NAN_SYMBOL = 15,
    00800   UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16,
    00804   UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17,
    00806   UNUM_FORMAT_SYMBOL_COUNT = 18
    00807 } UNumberFormatSymbol;
    00808
    00825 U_STABLE int32_t U_EXPORT2
    00826 unum_getSymbol(const UNumberFormat *fmt,
    00827                UNumberFormatSymbol symbol,
    00828                UChar *buffer,
    00829                int32_t size,
    00830                UErrorCode *status);
    00831
    00845 U_STABLE void U_EXPORT2
    00846 unum_setSymbol(UNumberFormat *fmt,
    00847                UNumberFormatSymbol symbol,
    00848                const UChar *value,
    00849                int32_t length,
    00850                UErrorCode *status);
    00851
    00852
    00862 U_STABLE const char* U_EXPORT2
    00863 unum_getLocaleByType(const UNumberFormat *fmt,
    00864                      ULocDataLocaleType type,
    00865                      UErrorCode* status);
    00866
    00867 #endif /* #if !UCONFIG_NO_FORMATTING */
    00868
    00869 #endif