unum.h

Go to the documentation of this file.
00001 /*
00002 *******************************************************************************
00003 * Copyright (C) 1997-2012, 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/localpointer.h"
00020 #include "unicode/uloc.h"
00021 #include "unicode/umisc.h"
00022 #include "unicode/parseerr.h"
00130 typedef void* UNumberFormat;
00131 
00135 typedef enum UNumberFormatStyle {
00140     UNUM_PATTERN_DECIMAL=0,
00145     UNUM_DECIMAL=1,
00150     UNUM_CURRENCY,
00155     UNUM_PERCENT,
00160     UNUM_SCIENTIFIC,
00165     UNUM_SPELLOUT,
00170     UNUM_ORDINAL,
00175     UNUM_DURATION,
00180     UNUM_NUMBERING_SYSTEM,
00185     UNUM_PATTERN_RULEBASED,
00190     UNUM_CURRENCY_ISO,
00196     UNUM_CURRENCY_PLURAL,
00201     UNUM_FORMAT_STYLE_COUNT,
00206     UNUM_DEFAULT = UNUM_DECIMAL,
00211     UNUM_IGNORE = UNUM_PATTERN_DECIMAL
00212 } UNumberFormatStyle;
00213 
00217 typedef enum UNumberFormatRoundingMode {
00218     UNUM_ROUND_CEILING,
00219     UNUM_ROUND_FLOOR,
00220     UNUM_ROUND_DOWN,
00221     UNUM_ROUND_UP,
00226     UNUM_ROUND_HALFEVEN,
00227 #ifndef U_HIDE_DEPRECATED_API
00228 
00232     UNUM_FOUND_HALFEVEN = UNUM_ROUND_HALFEVEN,
00233 #endif  /* U_HIDE_DEPRECATED_API */
00234     UNUM_ROUND_HALFDOWN,
00235     UNUM_ROUND_HALFUP,
00240     UNUM_ROUND_UNNECESSARY
00241 } UNumberFormatRoundingMode;
00242 
00246 typedef enum UNumberFormatPadPosition {
00247     UNUM_PAD_BEFORE_PREFIX,
00248     UNUM_PAD_AFTER_PREFIX,
00249     UNUM_PAD_BEFORE_SUFFIX,
00250     UNUM_PAD_AFTER_SUFFIX
00251 } UNumberFormatPadPosition;
00252 
00257 enum UCurrencySpacing {
00259     UNUM_CURRENCY_MATCH,
00261     UNUM_CURRENCY_SURROUNDING_MATCH,
00263     UNUM_CURRENCY_INSERT,
00265     UNUM_CURRENCY_SPACING_COUNT
00266 };
00267 typedef enum UCurrencySpacing UCurrencySpacing; 
00275 typedef enum UNumberFormatFields {
00277     UNUM_INTEGER_FIELD,
00279     UNUM_FRACTION_FIELD,
00281     UNUM_DECIMAL_SEPARATOR_FIELD,
00283     UNUM_EXPONENT_SYMBOL_FIELD,
00285     UNUM_EXPONENT_SIGN_FIELD,
00287     UNUM_EXPONENT_FIELD,
00289     UNUM_GROUPING_SEPARATOR_FIELD,
00291     UNUM_CURRENCY_FIELD,
00293     UNUM_PERCENT_FIELD,
00295     UNUM_PERMILL_FIELD,
00297     UNUM_SIGN_FIELD,
00299     UNUM_FIELD_COUNT
00300 } UNumberFormatFields;
00301 
00302 
00334 U_STABLE UNumberFormat* U_EXPORT2 
00335 unum_open(  UNumberFormatStyle    style,
00336             const    UChar*    pattern,
00337             int32_t            patternLength,
00338             const    char*     locale,
00339             UParseError*       parseErr,
00340             UErrorCode*        status);
00341 
00342 
00349 U_STABLE void U_EXPORT2 
00350 unum_close(UNumberFormat* fmt);
00351 
00352 #if U_SHOW_CPLUSPLUS_API
00353 
00354 U_NAMESPACE_BEGIN
00355 
00365 U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberFormatPointer, UNumberFormat, unum_close);
00366 
00367 U_NAMESPACE_END
00368 
00369 #endif
00370 
00379 U_STABLE UNumberFormat* U_EXPORT2 
00380 unum_clone(const UNumberFormat *fmt,
00381        UErrorCode *status);
00382 
00404 U_STABLE int32_t U_EXPORT2 
00405 unum_format(    const    UNumberFormat*    fmt,
00406         int32_t            number,
00407         UChar*            result,
00408         int32_t            resultLength,
00409         UFieldPosition    *pos,
00410         UErrorCode*        status);
00411 
00433 U_STABLE int32_t U_EXPORT2 
00434 unum_formatInt64(const UNumberFormat *fmt,
00435         int64_t         number,
00436         UChar*          result,
00437         int32_t         resultLength,
00438         UFieldPosition *pos,
00439         UErrorCode*     status);
00440 
00462 U_STABLE int32_t U_EXPORT2 
00463 unum_formatDouble(    const    UNumberFormat*  fmt,
00464             double          number,
00465             UChar*          result,
00466             int32_t         resultLength,
00467             UFieldPosition  *pos, /* 0 if ignore */
00468             UErrorCode*     status);
00469 
00495 U_STABLE int32_t U_EXPORT2 
00496 unum_formatDecimal(    const    UNumberFormat*  fmt,
00497             const char *    number,
00498             int32_t         length,
00499             UChar*          result,
00500             int32_t         resultLength,
00501             UFieldPosition  *pos, /* 0 if ignore */
00502             UErrorCode*     status);
00503 
00525 U_STABLE int32_t U_EXPORT2 
00526 unum_formatDoubleCurrency(const UNumberFormat* fmt,
00527                           double number,
00528                           UChar* currency,
00529                           UChar* result,
00530                           int32_t resultLength,
00531                           UFieldPosition* pos, /* ignored if 0 */
00532                           UErrorCode* status);
00533 
00551 U_STABLE int32_t U_EXPORT2 
00552 unum_parse(    const   UNumberFormat*  fmt,
00553         const   UChar*          text,
00554         int32_t         textLength,
00555         int32_t         *parsePos /* 0 = start */,
00556         UErrorCode      *status);
00557 
00575 U_STABLE int64_t U_EXPORT2 
00576 unum_parseInt64(const UNumberFormat*  fmt,
00577         const UChar*  text,
00578         int32_t       textLength,
00579         int32_t       *parsePos /* 0 = start */,
00580         UErrorCode    *status);
00581 
00599 U_STABLE double U_EXPORT2 
00600 unum_parseDouble(    const   UNumberFormat*  fmt,
00601             const   UChar*          text,
00602             int32_t         textLength,
00603             int32_t         *parsePos /* 0 = start */,
00604             UErrorCode      *status);
00605 
00606 
00632 U_STABLE int32_t U_EXPORT2 
00633 unum_parseDecimal(const   UNumberFormat*  fmt,
00634                  const   UChar*          text,
00635                          int32_t         textLength,
00636                          int32_t         *parsePos /* 0 = start */,
00637                          char            *outBuf,
00638                          int32_t         outBufLength,
00639                          UErrorCode      *status);
00640 
00660 U_STABLE double U_EXPORT2
00661 unum_parseDoubleCurrency(const UNumberFormat* fmt,
00662                          const UChar* text,
00663                          int32_t textLength,
00664                          int32_t* parsePos, /* 0 = start */
00665                          UChar* currency,
00666                          UErrorCode* status);
00667 
00684 U_STABLE void U_EXPORT2 
00685 unum_applyPattern(          UNumberFormat  *format,
00686                             UBool          localized,
00687                     const   UChar          *pattern,
00688                             int32_t         patternLength,
00689                             UParseError    *parseError,
00690                             UErrorCode     *status
00691                                     );
00692 
00703 U_STABLE const char* U_EXPORT2 
00704 unum_getAvailable(int32_t localeIndex);
00705 
00715 U_STABLE int32_t U_EXPORT2 
00716 unum_countAvailable(void);
00717 
00718 #if UCONFIG_HAVE_PARSEALLINPUT
00719 
00722 typedef enum UNumberFormatAttributeValue {
00724   UNUM_NO = 0,
00726   UNUM_YES = 1,
00728   UNUM_MAYBE = 2
00729 } UNumberFormatAttributeValue;
00730 #endif
00731 
00733 typedef enum UNumberFormatAttribute {
00735   UNUM_PARSE_INT_ONLY,
00737   UNUM_GROUPING_USED,
00739   UNUM_DECIMAL_ALWAYS_SHOWN,
00741   UNUM_MAX_INTEGER_DIGITS,
00743   UNUM_MIN_INTEGER_DIGITS,
00745   UNUM_INTEGER_DIGITS,
00747   UNUM_MAX_FRACTION_DIGITS,
00749   UNUM_MIN_FRACTION_DIGITS,
00751   UNUM_FRACTION_DIGITS,
00753   UNUM_MULTIPLIER,
00755   UNUM_GROUPING_SIZE,
00757   UNUM_ROUNDING_MODE,
00759   UNUM_ROUNDING_INCREMENT,
00761   UNUM_FORMAT_WIDTH,
00763   UNUM_PADDING_POSITION,
00765   UNUM_SECONDARY_GROUPING_SIZE,
00768   UNUM_SIGNIFICANT_DIGITS_USED,
00771   UNUM_MIN_SIGNIFICANT_DIGITS,
00774   UNUM_MAX_SIGNIFICANT_DIGITS,
00778   UNUM_LENIENT_PARSE,
00779 #if UCONFIG_HAVE_PARSEALLINPUT
00780 
00784   UNUM_PARSE_ALL_INPUT,
00785 #endif
00786 
00789   UNUM_NUMERIC_ATTRIBUTE_COUNT,
00790 
00794   UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 0x0FFF,
00795 
00801   UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS,
00808   UNUM_PARSE_NO_EXPONENT,
00809 
00812   UNUM_LIMIT_BOOLEAN_ATTRIBUTE
00813 } UNumberFormatAttribute;
00814 
00831 U_STABLE int32_t U_EXPORT2 
00832 unum_getAttribute(const UNumberFormat*          fmt,
00833           UNumberFormatAttribute  attr);
00834 
00854 U_STABLE void U_EXPORT2 
00855 unum_setAttribute(    UNumberFormat*          fmt,
00856             UNumberFormatAttribute  attr,
00857             int32_t                 newValue);
00858 
00859 
00874 U_STABLE double U_EXPORT2 
00875 unum_getDoubleAttribute(const UNumberFormat*          fmt,
00876           UNumberFormatAttribute  attr);
00877 
00892 U_STABLE void U_EXPORT2 
00893 unum_setDoubleAttribute(    UNumberFormat*          fmt,
00894             UNumberFormatAttribute  attr,
00895             double                 newValue);
00896 
00898 typedef enum UNumberFormatTextAttribute {
00900   UNUM_POSITIVE_PREFIX,
00902   UNUM_POSITIVE_SUFFIX,
00904   UNUM_NEGATIVE_PREFIX,
00906   UNUM_NEGATIVE_SUFFIX,
00908   UNUM_PADDING_CHARACTER,
00910   UNUM_CURRENCY_CODE,
00915   UNUM_DEFAULT_RULESET,
00922   UNUM_PUBLIC_RULESETS
00923 } UNumberFormatTextAttribute;
00924 
00943 U_STABLE int32_t U_EXPORT2 
00944 unum_getTextAttribute(    const    UNumberFormat*                    fmt,
00945             UNumberFormatTextAttribute      tag,
00946             UChar*                            result,
00947             int32_t                            resultLength,
00948             UErrorCode*                        status);
00949 
00966 U_STABLE void U_EXPORT2 
00967 unum_setTextAttribute(    UNumberFormat*                    fmt,
00968             UNumberFormatTextAttribute      tag,
00969             const    UChar*                            newValue,
00970             int32_t                            newValueLength,
00971             UErrorCode                        *status);
00972 
00989 U_STABLE int32_t U_EXPORT2 
00990 unum_toPattern(    const    UNumberFormat*          fmt,
00991         UBool                  isPatternLocalized,
00992         UChar*                  result,
00993         int32_t                 resultLength,
00994         UErrorCode*             status);
00995 
00996 
01001 typedef enum UNumberFormatSymbol {
01003   UNUM_DECIMAL_SEPARATOR_SYMBOL = 0,
01005   UNUM_GROUPING_SEPARATOR_SYMBOL = 1,
01007   UNUM_PATTERN_SEPARATOR_SYMBOL = 2,
01009   UNUM_PERCENT_SYMBOL = 3,
01011   UNUM_ZERO_DIGIT_SYMBOL = 4,
01013   UNUM_DIGIT_SYMBOL = 5,
01015   UNUM_MINUS_SIGN_SYMBOL = 6,
01017   UNUM_PLUS_SIGN_SYMBOL = 7,
01019   UNUM_CURRENCY_SYMBOL = 8,
01021   UNUM_INTL_CURRENCY_SYMBOL = 9,
01023   UNUM_MONETARY_SEPARATOR_SYMBOL = 10,
01025   UNUM_EXPONENTIAL_SYMBOL = 11,
01027   UNUM_PERMILL_SYMBOL = 12,
01029   UNUM_PAD_ESCAPE_SYMBOL = 13,
01031   UNUM_INFINITY_SYMBOL = 14,
01033   UNUM_NAN_SYMBOL = 15,
01036   UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16,
01040   UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17,
01044   UNUM_ONE_DIGIT_SYMBOL = 18,
01048   UNUM_TWO_DIGIT_SYMBOL = 19,
01052   UNUM_THREE_DIGIT_SYMBOL = 20,
01056   UNUM_FOUR_DIGIT_SYMBOL = 21,
01060   UNUM_FIVE_DIGIT_SYMBOL = 22,
01064   UNUM_SIX_DIGIT_SYMBOL = 23,
01068   UNUM_SEVEN_DIGIT_SYMBOL = 24,
01072   UNUM_EIGHT_DIGIT_SYMBOL = 25,
01076   UNUM_NINE_DIGIT_SYMBOL = 26,
01078   UNUM_FORMAT_SYMBOL_COUNT = 27
01079 } UNumberFormatSymbol;
01080 
01097 U_STABLE int32_t U_EXPORT2
01098 unum_getSymbol(const UNumberFormat *fmt,
01099                UNumberFormatSymbol symbol,
01100                UChar *buffer,
01101                int32_t size,
01102                UErrorCode *status);
01103 
01117 U_STABLE void U_EXPORT2
01118 unum_setSymbol(UNumberFormat *fmt,
01119                UNumberFormatSymbol symbol,
01120                const UChar *value,
01121                int32_t length,
01122                UErrorCode *status);
01123 
01124 
01134 U_STABLE const char* U_EXPORT2
01135 unum_getLocaleByType(const UNumberFormat *fmt,
01136                      ULocDataLocaleType type,
01137                      UErrorCode* status); 
01138 
01139 #endif /* #if !UCONFIG_NO_FORMATTING */
01140 
01141 #endif

Generated on 27 Oct 2013 for ICU 50.1.2 by  doxygen 1.4.7