]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/winnmfmt.h
ICU-64232.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / winnmfmt.h
CommitLineData
f3c0d7a5
A
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
73c04bcf
A
3/*
4********************************************************************************
2ca993e8 5* Copyright (C) 2005-2015, International Business Machines
73c04bcf
A
6* Corporation and others. All Rights Reserved.
7********************************************************************************
8*
9* File WINNMFMT.H
10*
11********************************************************************************
12*/
13
14#ifndef __WINNMFMT
15#define __WINNMFMT
16
17#include "unicode/utypes.h"
18
4388f060 19#if U_PLATFORM_USES_ONLY_WIN32_API
73c04bcf
A
20
21#include "unicode/format.h"
22#include "unicode/datefmt.h"
23#include "unicode/calendar.h"
24#include "unicode/ustring.h"
25#include "unicode/locid.h"
26
27#if !UCONFIG_NO_FORMATTING
28
29/**
30 * \file
31 * \brief C++ API: Format numbers using Windows API.
32 */
33
34U_NAMESPACE_BEGIN
35
36union FormatInfo;
37
38class Win32NumberFormat : public NumberFormat
39{
40public:
41 Win32NumberFormat(const Locale &locale, UBool currency, UErrorCode &status);
42
43 Win32NumberFormat(const Win32NumberFormat &other);
44
45 virtual ~Win32NumberFormat();
46
47 virtual Format *clone(void) const;
48
49 Win32NumberFormat &operator=(const Win32NumberFormat &other);
50
51 /**
52 * Format a double number. Concrete subclasses must implement
53 * these pure virtual methods.
54 *
55 * @param number The value to be formatted.
56 * @param appendTo Output parameter to receive result.
57 * Result is appended to existing contents.
58 * @param pos On input: an alignment field, if desired.
59 * On output: the offsets of the alignment field.
60 * @return Reference to 'appendTo' parameter.
73c04bcf
A
61 */
62 virtual UnicodeString& format(double number,
63 UnicodeString& appendTo,
64 FieldPosition& pos) const;
65 /**
66 * Format a long number. Concrete subclasses must implement
67 * these pure virtual methods.
68 *
69 * @param number The value to be formatted.
70 * @param appendTo Output parameter to receive result.
71 * Result is appended to existing contents.
72 * @param pos On input: an alignment field, if desired.
73 * On output: the offsets of the alignment field.
74 * @return Reference to 'appendTo' parameter.
73c04bcf
A
75 */
76 virtual UnicodeString& format(int32_t number,
77 UnicodeString& appendTo,
78 FieldPosition& pos) const;
79
80 /**
81 * Format an int64 number.
82 *
83 * @param number The value to be formatted.
84 * @param appendTo Output parameter to receive result.
85 * Result is appended to existing contents.
86 * @param pos On input: an alignment field, if desired.
87 * On output: the offsets of the alignment field.
88 * @return Reference to 'appendTo' parameter.
73c04bcf
A
89 */
90 virtual UnicodeString& format(int64_t number,
91 UnicodeString& appendTo,
92 FieldPosition& pos) const;
93
2ca993e8
A
94 using NumberFormat::format;
95
73c04bcf
A
96// Use the default behavior for the following.
97// virtual UnicodeString &format(double number, UnicodeString &appendTo) const;
98// virtual UnicodeString &format(int32_t number, UnicodeString &appendTo) const;
99// virtual UnicodeString &format(int64_t number, UnicodeString &appendTo) const;
100
101 virtual void parse(const UnicodeString& text, Formattable& result, ParsePosition& parsePosition) const;
102
103 /**
104 * Sets the maximum number of digits allowed in the fraction portion of a
105 * number. maximumFractionDigits must be >= minimumFractionDigits. If the
106 * new value for maximumFractionDigits is less than the current value
107 * of minimumFractionDigits, then minimumFractionDigits will also be set to
108 * the new value.
109 * @param newValue the new value to be set.
110 * @see getMaximumFractionDigits
73c04bcf
A
111 */
112 virtual void setMaximumFractionDigits(int32_t newValue);
113
114 /**
115 * Sets the minimum number of digits allowed in the fraction portion of a
116 * number. minimumFractionDigits must be <= maximumFractionDigits. If the
117 * new value for minimumFractionDigits exceeds the current value
118 * of maximumFractionDigits, then maximumIntegerDigits will also be set to
119 * the new value
120 * @param newValue the new value to be set.
121 * @see getMinimumFractionDigits
73c04bcf
A
122 */
123 virtual void setMinimumFractionDigits(int32_t newValue);
124
125 /**
126 * Return the class ID for this class. This is useful only for comparing to
127 * a return value from getDynamicClassID(). For example:
128 * <pre>
129 * . Base* polymorphic_pointer = createPolymorphicObject();
130 * . if (polymorphic_pointer->getDynamicClassID() ==
f3c0d7a5 131 * . derived::getStaticClassID()) ...
73c04bcf
A
132 * </pre>
133 * @return The class ID for all objects of this class.
73c04bcf 134 */
46f4442e 135 U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
73c04bcf
A
136
137 /**
138 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
139 * method is to implement a simple version of RTTI, since not all C++
140 * compilers support genuine RTTI. Polymorphic operator==() and clone()
141 * methods call this method.
142 *
143 * @return The class ID for this object. All objects of a
144 * given class have the same class ID. Objects of
145 * other classes have different class IDs.
73c04bcf
A
146 */
147 virtual UClassID getDynamicClassID(void) const;
148
149private:
b331163b 150 UnicodeString &format(int32_t numDigits, UnicodeString &appendTo, const wchar_t *format, ...) const;
73c04bcf
A
151
152 UBool fCurrency;
57a6839d 153 Locale fLocale;
73c04bcf
A
154 int32_t fLCID;
155 FormatInfo *fFormatInfo;
156 UBool fFractionDigitsSet;
157
f3c0d7a5 158 UnicodeString* fWindowsLocaleName; // Stores the equivalent Windows locale name.
73c04bcf
A
159};
160
161U_NAMESPACE_END
162
163#endif /* #if !UCONFIG_NO_FORMATTING */
164
4388f060 165#endif // U_PLATFORM_USES_ONLY_WIN32_API
73c04bcf
A
166
167#endif // __WINNMFMT