11cb0ef41Sopenharmony_ci// © 2016 and later: Unicode, Inc. and others. 21cb0ef41Sopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html 31cb0ef41Sopenharmony_ci/* 41cb0ef41Sopenharmony_ci******************************************************************************** 51cb0ef41Sopenharmony_ci* Copyright (C) 2005-2015, International Business Machines 61cb0ef41Sopenharmony_ci* Corporation and others. All Rights Reserved. 71cb0ef41Sopenharmony_ci******************************************************************************** 81cb0ef41Sopenharmony_ci* 91cb0ef41Sopenharmony_ci* File WINNMFMT.H 101cb0ef41Sopenharmony_ci* 111cb0ef41Sopenharmony_ci******************************************************************************** 121cb0ef41Sopenharmony_ci*/ 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ci#ifndef __WINNMFMT 151cb0ef41Sopenharmony_ci#define __WINNMFMT 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci#include "unicode/utypes.h" 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci#if U_PLATFORM_USES_ONLY_WIN32_API 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci#include "unicode/format.h" 221cb0ef41Sopenharmony_ci#include "unicode/datefmt.h" 231cb0ef41Sopenharmony_ci#include "unicode/calendar.h" 241cb0ef41Sopenharmony_ci#include "unicode/ustring.h" 251cb0ef41Sopenharmony_ci#include "unicode/locid.h" 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci#if !UCONFIG_NO_FORMATTING 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ci/** 301cb0ef41Sopenharmony_ci * \file 311cb0ef41Sopenharmony_ci * \brief C++ API: Format numbers using Windows API. 321cb0ef41Sopenharmony_ci */ 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ciU_NAMESPACE_BEGIN 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ciunion FormatInfo; 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_ciclass Win32NumberFormat : public NumberFormat 391cb0ef41Sopenharmony_ci{ 401cb0ef41Sopenharmony_cipublic: 411cb0ef41Sopenharmony_ci Win32NumberFormat(const Locale &locale, UBool currency, UErrorCode &status); 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci Win32NumberFormat(const Win32NumberFormat &other); 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ci virtual ~Win32NumberFormat(); 461cb0ef41Sopenharmony_ci 471cb0ef41Sopenharmony_ci virtual Win32NumberFormat *clone() const; 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ci Win32NumberFormat &operator=(const Win32NumberFormat &other); 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ci /** 521cb0ef41Sopenharmony_ci * Format a double number. Concrete subclasses must implement 531cb0ef41Sopenharmony_ci * these pure virtual methods. 541cb0ef41Sopenharmony_ci * 551cb0ef41Sopenharmony_ci * @param number The value to be formatted. 561cb0ef41Sopenharmony_ci * @param appendTo Output parameter to receive result. 571cb0ef41Sopenharmony_ci * Result is appended to existing contents. 581cb0ef41Sopenharmony_ci * @param pos On input: an alignment field, if desired. 591cb0ef41Sopenharmony_ci * On output: the offsets of the alignment field. 601cb0ef41Sopenharmony_ci * @return Reference to 'appendTo' parameter. 611cb0ef41Sopenharmony_ci */ 621cb0ef41Sopenharmony_ci virtual UnicodeString& format(double number, 631cb0ef41Sopenharmony_ci UnicodeString& appendTo, 641cb0ef41Sopenharmony_ci FieldPosition& pos) const; 651cb0ef41Sopenharmony_ci /** 661cb0ef41Sopenharmony_ci * Format a long number. Concrete subclasses must implement 671cb0ef41Sopenharmony_ci * these pure virtual methods. 681cb0ef41Sopenharmony_ci * 691cb0ef41Sopenharmony_ci * @param number The value to be formatted. 701cb0ef41Sopenharmony_ci * @param appendTo Output parameter to receive result. 711cb0ef41Sopenharmony_ci * Result is appended to existing contents. 721cb0ef41Sopenharmony_ci * @param pos On input: an alignment field, if desired. 731cb0ef41Sopenharmony_ci * On output: the offsets of the alignment field. 741cb0ef41Sopenharmony_ci * @return Reference to 'appendTo' parameter. 751cb0ef41Sopenharmony_ci */ 761cb0ef41Sopenharmony_ci virtual UnicodeString& format(int32_t number, 771cb0ef41Sopenharmony_ci UnicodeString& appendTo, 781cb0ef41Sopenharmony_ci FieldPosition& pos) const; 791cb0ef41Sopenharmony_ci 801cb0ef41Sopenharmony_ci /** 811cb0ef41Sopenharmony_ci * Format an int64 number. 821cb0ef41Sopenharmony_ci * 831cb0ef41Sopenharmony_ci * @param number The value to be formatted. 841cb0ef41Sopenharmony_ci * @param appendTo Output parameter to receive result. 851cb0ef41Sopenharmony_ci * Result is appended to existing contents. 861cb0ef41Sopenharmony_ci * @param pos On input: an alignment field, if desired. 871cb0ef41Sopenharmony_ci * On output: the offsets of the alignment field. 881cb0ef41Sopenharmony_ci * @return Reference to 'appendTo' parameter. 891cb0ef41Sopenharmony_ci */ 901cb0ef41Sopenharmony_ci virtual UnicodeString& format(int64_t number, 911cb0ef41Sopenharmony_ci UnicodeString& appendTo, 921cb0ef41Sopenharmony_ci FieldPosition& pos) const; 931cb0ef41Sopenharmony_ci 941cb0ef41Sopenharmony_ci using NumberFormat::format; 951cb0ef41Sopenharmony_ci 961cb0ef41Sopenharmony_ci// Use the default behavior for the following. 971cb0ef41Sopenharmony_ci// virtual UnicodeString &format(double number, UnicodeString &appendTo) const; 981cb0ef41Sopenharmony_ci// virtual UnicodeString &format(int32_t number, UnicodeString &appendTo) const; 991cb0ef41Sopenharmony_ci// virtual UnicodeString &format(int64_t number, UnicodeString &appendTo) const; 1001cb0ef41Sopenharmony_ci 1011cb0ef41Sopenharmony_ci virtual void parse(const UnicodeString& text, Formattable& result, ParsePosition& parsePosition) const; 1021cb0ef41Sopenharmony_ci 1031cb0ef41Sopenharmony_ci /** 1041cb0ef41Sopenharmony_ci * Sets the maximum number of digits allowed in the fraction portion of a 1051cb0ef41Sopenharmony_ci * number. maximumFractionDigits must be >= minimumFractionDigits. If the 1061cb0ef41Sopenharmony_ci * new value for maximumFractionDigits is less than the current value 1071cb0ef41Sopenharmony_ci * of minimumFractionDigits, then minimumFractionDigits will also be set to 1081cb0ef41Sopenharmony_ci * the new value. 1091cb0ef41Sopenharmony_ci * @param newValue the new value to be set. 1101cb0ef41Sopenharmony_ci * @see getMaximumFractionDigits 1111cb0ef41Sopenharmony_ci */ 1121cb0ef41Sopenharmony_ci virtual void setMaximumFractionDigits(int32_t newValue); 1131cb0ef41Sopenharmony_ci 1141cb0ef41Sopenharmony_ci /** 1151cb0ef41Sopenharmony_ci * Sets the minimum number of digits allowed in the fraction portion of a 1161cb0ef41Sopenharmony_ci * number. minimumFractionDigits must be <= maximumFractionDigits. If the 1171cb0ef41Sopenharmony_ci * new value for minimumFractionDigits exceeds the current value 1181cb0ef41Sopenharmony_ci * of maximumFractionDigits, then maximumIntegerDigits will also be set to 1191cb0ef41Sopenharmony_ci * the new value 1201cb0ef41Sopenharmony_ci * @param newValue the new value to be set. 1211cb0ef41Sopenharmony_ci * @see getMinimumFractionDigits 1221cb0ef41Sopenharmony_ci */ 1231cb0ef41Sopenharmony_ci virtual void setMinimumFractionDigits(int32_t newValue); 1241cb0ef41Sopenharmony_ci 1251cb0ef41Sopenharmony_ci /** 1261cb0ef41Sopenharmony_ci * Return the class ID for this class. This is useful only for comparing to 1271cb0ef41Sopenharmony_ci * a return value from getDynamicClassID(). For example: 1281cb0ef41Sopenharmony_ci * <pre> 1291cb0ef41Sopenharmony_ci * . Base* polymorphic_pointer = createPolymorphicObject(); 1301cb0ef41Sopenharmony_ci * . if (polymorphic_pointer->getDynamicClassID() == 1311cb0ef41Sopenharmony_ci * . derived::getStaticClassID()) ... 1321cb0ef41Sopenharmony_ci * </pre> 1331cb0ef41Sopenharmony_ci * @return The class ID for all objects of this class. 1341cb0ef41Sopenharmony_ci */ 1351cb0ef41Sopenharmony_ci U_I18N_API static UClassID U_EXPORT2 getStaticClassID(); 1361cb0ef41Sopenharmony_ci 1371cb0ef41Sopenharmony_ci /** 1381cb0ef41Sopenharmony_ci * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This 1391cb0ef41Sopenharmony_ci * method is to implement a simple version of RTTI, since not all C++ 1401cb0ef41Sopenharmony_ci * compilers support genuine RTTI. Polymorphic operator==() and clone() 1411cb0ef41Sopenharmony_ci * methods call this method. 1421cb0ef41Sopenharmony_ci * 1431cb0ef41Sopenharmony_ci * @return The class ID for this object. All objects of a 1441cb0ef41Sopenharmony_ci * given class have the same class ID. Objects of 1451cb0ef41Sopenharmony_ci * other classes have different class IDs. 1461cb0ef41Sopenharmony_ci */ 1471cb0ef41Sopenharmony_ci virtual UClassID getDynamicClassID() const; 1481cb0ef41Sopenharmony_ci 1491cb0ef41Sopenharmony_ciprivate: 1501cb0ef41Sopenharmony_ci UnicodeString &format(int32_t numDigits, UnicodeString &appendTo, const wchar_t *format, ...) const; 1511cb0ef41Sopenharmony_ci 1521cb0ef41Sopenharmony_ci UBool fCurrency; 1531cb0ef41Sopenharmony_ci Locale fLocale; 1541cb0ef41Sopenharmony_ci int32_t fLCID; 1551cb0ef41Sopenharmony_ci FormatInfo *fFormatInfo; 1561cb0ef41Sopenharmony_ci UBool fFractionDigitsSet; 1571cb0ef41Sopenharmony_ci 1581cb0ef41Sopenharmony_ci UnicodeString* fWindowsLocaleName; // Stores the equivalent Windows locale name. 1591cb0ef41Sopenharmony_ci}; 1601cb0ef41Sopenharmony_ci 1611cb0ef41Sopenharmony_ciU_NAMESPACE_END 1621cb0ef41Sopenharmony_ci 1631cb0ef41Sopenharmony_ci#endif /* #if !UCONFIG_NO_FORMATTING */ 1641cb0ef41Sopenharmony_ci 1651cb0ef41Sopenharmony_ci#endif // U_PLATFORM_USES_ONLY_WIN32_API 1661cb0ef41Sopenharmony_ci 1671cb0ef41Sopenharmony_ci#endif // __WINNMFMT 168