intl/icu/source/i18n/winnmfmt.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/i18n/winnmfmt.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,162 @@
     1.4 +/*
     1.5 +********************************************************************************
     1.6 +*   Copyright (C) 2005-2013, International Business Machines
     1.7 +*   Corporation and others.  All Rights Reserved.
     1.8 +********************************************************************************
     1.9 +*
    1.10 +* File WINNMFMT.H
    1.11 +*
    1.12 +********************************************************************************
    1.13 +*/
    1.14 +
    1.15 +#ifndef __WINNMFMT
    1.16 +#define __WINNMFMT
    1.17 +
    1.18 +#include "unicode/utypes.h"
    1.19 +
    1.20 +#if U_PLATFORM_USES_ONLY_WIN32_API
    1.21 +
    1.22 +#include "unicode/format.h"
    1.23 +#include "unicode/datefmt.h"
    1.24 +#include "unicode/calendar.h"
    1.25 +#include "unicode/ustring.h"
    1.26 +#include "unicode/locid.h"
    1.27 +
    1.28 +#if !UCONFIG_NO_FORMATTING
    1.29 +
    1.30 +/**
    1.31 + * \file 
    1.32 + * \brief C++ API: Format numbers using Windows API.
    1.33 + */
    1.34 +
    1.35 +U_NAMESPACE_BEGIN
    1.36 +
    1.37 +union FormatInfo;
    1.38 +
    1.39 +class Win32NumberFormat : public NumberFormat
    1.40 +{
    1.41 +public:
    1.42 +    Win32NumberFormat(const Locale &locale, UBool currency, UErrorCode &status);
    1.43 +
    1.44 +    Win32NumberFormat(const Win32NumberFormat &other);
    1.45 +
    1.46 +    virtual ~Win32NumberFormat();
    1.47 +
    1.48 +    virtual Format *clone(void) const;
    1.49 +
    1.50 +    Win32NumberFormat &operator=(const Win32NumberFormat &other);
    1.51 +
    1.52 +    /**
    1.53 +     * Format a double number. Concrete subclasses must implement
    1.54 +     * these pure virtual methods.
    1.55 +     *
    1.56 +     * @param number    The value to be formatted.
    1.57 +     * @param appendTo  Output parameter to receive result.
    1.58 +     *                  Result is appended to existing contents.
    1.59 +     * @param pos       On input: an alignment field, if desired.
    1.60 +     *                  On output: the offsets of the alignment field.
    1.61 +     * @return          Reference to 'appendTo' parameter.
    1.62 +     */
    1.63 +    virtual UnicodeString& format(double number,
    1.64 +                                  UnicodeString& appendTo,
    1.65 +                                  FieldPosition& pos) const;
    1.66 +    /**
    1.67 +     * Format a long number. Concrete subclasses must implement
    1.68 +     * these pure virtual methods.
    1.69 +     *
    1.70 +     * @param number    The value to be formatted.
    1.71 +     * @param appendTo  Output parameter to receive result.
    1.72 +     *                  Result is appended to existing contents.
    1.73 +     * @param pos       On input: an alignment field, if desired.
    1.74 +     *                  On output: the offsets of the alignment field.
    1.75 +     * @return          Reference to 'appendTo' parameter.
    1.76 +    */
    1.77 +    virtual UnicodeString& format(int32_t number,
    1.78 +                                  UnicodeString& appendTo,
    1.79 +                                  FieldPosition& pos) const;
    1.80 +
    1.81 +    /**
    1.82 +     * Format an int64 number.
    1.83 +     *
    1.84 +     * @param number    The value to be formatted.
    1.85 +     * @param appendTo  Output parameter to receive result.
    1.86 +     *                  Result is appended to existing contents.
    1.87 +     * @param pos       On input: an alignment field, if desired.
    1.88 +     *                  On output: the offsets of the alignment field.
    1.89 +     * @return          Reference to 'appendTo' parameter.
    1.90 +    */
    1.91 +    virtual UnicodeString& format(int64_t number,
    1.92 +                                  UnicodeString& appendTo,
    1.93 +                                  FieldPosition& pos) const;
    1.94 +
    1.95 +// Use the default behavior for the following.
    1.96 +//    virtual UnicodeString &format(double number, UnicodeString &appendTo) const;
    1.97 +//    virtual UnicodeString &format(int32_t number, UnicodeString &appendTo) const;
    1.98 +//    virtual UnicodeString &format(int64_t number, UnicodeString &appendTo) const;
    1.99 +
   1.100 +    virtual void parse(const UnicodeString& text, Formattable& result, ParsePosition& parsePosition) const;
   1.101 +
   1.102 +    /**
   1.103 +     * Sets the maximum number of digits allowed in the fraction portion of a
   1.104 +     * number. maximumFractionDigits must be >= minimumFractionDigits.  If the
   1.105 +     * new value for maximumFractionDigits is less than the current value
   1.106 +     * of minimumFractionDigits, then minimumFractionDigits will also be set to
   1.107 +     * the new value.
   1.108 +     * @param newValue    the new value to be set.
   1.109 +     * @see getMaximumFractionDigits
   1.110 +     */
   1.111 +    virtual void setMaximumFractionDigits(int32_t newValue);
   1.112 +
   1.113 +    /**
   1.114 +     * Sets the minimum number of digits allowed in the fraction portion of a
   1.115 +     * number. minimumFractionDigits must be <= maximumFractionDigits.   If the
   1.116 +     * new value for minimumFractionDigits exceeds the current value
   1.117 +     * of maximumFractionDigits, then maximumIntegerDigits will also be set to
   1.118 +     * the new value
   1.119 +     * @param newValue    the new value to be set.
   1.120 +     * @see getMinimumFractionDigits
   1.121 +     */
   1.122 +    virtual void setMinimumFractionDigits(int32_t newValue);
   1.123 +
   1.124 +    /**
   1.125 +     * Return the class ID for this class. This is useful only for comparing to
   1.126 +     * a return value from getDynamicClassID(). For example:
   1.127 +     * <pre>
   1.128 +     * .   Base* polymorphic_pointer = createPolymorphicObject();
   1.129 +     * .   if (polymorphic_pointer->getDynamicClassID() ==
   1.130 +     * .       erived::getStaticClassID()) ...
   1.131 +     * </pre>
   1.132 +     * @return          The class ID for all objects of this class.
   1.133 +     */
   1.134 +    U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
   1.135 +
   1.136 +    /**
   1.137 +     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
   1.138 +     * method is to implement a simple version of RTTI, since not all C++
   1.139 +     * compilers support genuine RTTI. Polymorphic operator==() and clone()
   1.140 +     * methods call this method.
   1.141 +     *
   1.142 +     * @return          The class ID for this object. All objects of a
   1.143 +     *                  given class have the same class ID.  Objects of
   1.144 +     *                  other classes have different class IDs.
   1.145 +     */
   1.146 +    virtual UClassID getDynamicClassID(void) const;
   1.147 +
   1.148 +private:
   1.149 +    UnicodeString &format(int32_t numDigits, UnicodeString &appendTo, wchar_t *format, ...) const;
   1.150 +
   1.151 +    UBool fCurrency;
   1.152 +    Locale fLocale;
   1.153 +    int32_t fLCID;
   1.154 +    FormatInfo *fFormatInfo;
   1.155 +    UBool fFractionDigitsSet;
   1.156 +
   1.157 +};
   1.158 +
   1.159 +U_NAMESPACE_END
   1.160 +
   1.161 +#endif /* #if !UCONFIG_NO_FORMATTING */
   1.162 +
   1.163 +#endif // U_PLATFORM_USES_ONLY_WIN32_API
   1.164 +
   1.165 +#endif // __WINNMFMT

mercurial