michael@0: /* michael@0: ******************************************************************************** michael@0: * Copyright (C) 2005-2013, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: ******************************************************************************** michael@0: * michael@0: * File WINNMFMT.H michael@0: * michael@0: ******************************************************************************** michael@0: */ michael@0: michael@0: #ifndef __WINNMFMT michael@0: #define __WINNMFMT michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if U_PLATFORM_USES_ONLY_WIN32_API michael@0: michael@0: #include "unicode/format.h" michael@0: #include "unicode/datefmt.h" michael@0: #include "unicode/calendar.h" michael@0: #include "unicode/ustring.h" michael@0: #include "unicode/locid.h" michael@0: michael@0: #if !UCONFIG_NO_FORMATTING michael@0: michael@0: /** michael@0: * \file michael@0: * \brief C++ API: Format numbers using Windows API. michael@0: */ michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: union FormatInfo; michael@0: michael@0: class Win32NumberFormat : public NumberFormat michael@0: { michael@0: public: michael@0: Win32NumberFormat(const Locale &locale, UBool currency, UErrorCode &status); michael@0: michael@0: Win32NumberFormat(const Win32NumberFormat &other); michael@0: michael@0: virtual ~Win32NumberFormat(); michael@0: michael@0: virtual Format *clone(void) const; michael@0: michael@0: Win32NumberFormat &operator=(const Win32NumberFormat &other); michael@0: michael@0: /** michael@0: * Format a double number. Concrete subclasses must implement michael@0: * these pure virtual methods. michael@0: * michael@0: * @param number The value to be formatted. michael@0: * @param appendTo Output parameter to receive result. michael@0: * Result is appended to existing contents. michael@0: * @param pos On input: an alignment field, if desired. michael@0: * On output: the offsets of the alignment field. michael@0: * @return Reference to 'appendTo' parameter. michael@0: */ michael@0: virtual UnicodeString& format(double number, michael@0: UnicodeString& appendTo, michael@0: FieldPosition& pos) const; michael@0: /** michael@0: * Format a long number. Concrete subclasses must implement michael@0: * these pure virtual methods. michael@0: * michael@0: * @param number The value to be formatted. michael@0: * @param appendTo Output parameter to receive result. michael@0: * Result is appended to existing contents. michael@0: * @param pos On input: an alignment field, if desired. michael@0: * On output: the offsets of the alignment field. michael@0: * @return Reference to 'appendTo' parameter. michael@0: */ michael@0: virtual UnicodeString& format(int32_t number, michael@0: UnicodeString& appendTo, michael@0: FieldPosition& pos) const; michael@0: michael@0: /** michael@0: * Format an int64 number. michael@0: * michael@0: * @param number The value to be formatted. michael@0: * @param appendTo Output parameter to receive result. michael@0: * Result is appended to existing contents. michael@0: * @param pos On input: an alignment field, if desired. michael@0: * On output: the offsets of the alignment field. michael@0: * @return Reference to 'appendTo' parameter. michael@0: */ michael@0: virtual UnicodeString& format(int64_t number, michael@0: UnicodeString& appendTo, michael@0: FieldPosition& pos) const; michael@0: michael@0: // Use the default behavior for the following. michael@0: // virtual UnicodeString &format(double number, UnicodeString &appendTo) const; michael@0: // virtual UnicodeString &format(int32_t number, UnicodeString &appendTo) const; michael@0: // virtual UnicodeString &format(int64_t number, UnicodeString &appendTo) const; michael@0: michael@0: virtual void parse(const UnicodeString& text, Formattable& result, ParsePosition& parsePosition) const; michael@0: michael@0: /** michael@0: * Sets the maximum number of digits allowed in the fraction portion of a michael@0: * number. maximumFractionDigits must be >= minimumFractionDigits. If the michael@0: * new value for maximumFractionDigits is less than the current value michael@0: * of minimumFractionDigits, then minimumFractionDigits will also be set to michael@0: * the new value. michael@0: * @param newValue the new value to be set. michael@0: * @see getMaximumFractionDigits michael@0: */ michael@0: virtual void setMaximumFractionDigits(int32_t newValue); michael@0: michael@0: /** michael@0: * Sets the minimum number of digits allowed in the fraction portion of a michael@0: * number. minimumFractionDigits must be <= maximumFractionDigits. If the michael@0: * new value for minimumFractionDigits exceeds the current value michael@0: * of maximumFractionDigits, then maximumIntegerDigits will also be set to michael@0: * the new value michael@0: * @param newValue the new value to be set. michael@0: * @see getMinimumFractionDigits michael@0: */ michael@0: virtual void setMinimumFractionDigits(int32_t newValue); michael@0: michael@0: /** michael@0: * Return the class ID for this class. This is useful only for comparing to michael@0: * a return value from getDynamicClassID(). For example: michael@0: *
michael@0:      * .   Base* polymorphic_pointer = createPolymorphicObject();
michael@0:      * .   if (polymorphic_pointer->getDynamicClassID() ==
michael@0:      * .       erived::getStaticClassID()) ...
michael@0:      * 
michael@0: * @return The class ID for all objects of this class. michael@0: */ michael@0: U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void); michael@0: michael@0: /** michael@0: * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This michael@0: * method is to implement a simple version of RTTI, since not all C++ michael@0: * compilers support genuine RTTI. Polymorphic operator==() and clone() michael@0: * methods call this method. michael@0: * michael@0: * @return The class ID for this object. All objects of a michael@0: * given class have the same class ID. Objects of michael@0: * other classes have different class IDs. michael@0: */ michael@0: virtual UClassID getDynamicClassID(void) const; michael@0: michael@0: private: michael@0: UnicodeString &format(int32_t numDigits, UnicodeString &appendTo, wchar_t *format, ...) const; michael@0: michael@0: UBool fCurrency; michael@0: Locale fLocale; michael@0: int32_t fLCID; michael@0: FormatInfo *fFormatInfo; michael@0: UBool fFractionDigitsSet; michael@0: michael@0: }; michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif /* #if !UCONFIG_NO_FORMATTING */ michael@0: michael@0: #endif // U_PLATFORM_USES_ONLY_WIN32_API michael@0: michael@0: #endif // __WINNMFMT