~ubuntu-branches/ubuntu/jaunty/texlive-bin/jaunty-security

« back to all changes in this revision

Viewing changes to build/source/libs/icu-xetex/i18n/unicode/dcfmtsym.h

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2008-06-26 23:14:59 UTC
  • mfrom: (2.1.30 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080626231459-y02rjsrgtafu83yr
Tags: 2007.dfsg.2-3
add missing source roadmap.fig of roadmap.eps in fontinst documentation
(Closes: #482915) (urgency medium due to RC bug)
(new patch add-missing-fontinst-source)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
********************************************************************************
 
3
*   Copyright (C) 1997-2005, International Business Machines
 
4
*   Corporation and others.  All Rights Reserved.
 
5
********************************************************************************
 
6
*
 
7
* File DCFMTSYM.H
 
8
*
 
9
* Modification History:
 
10
 
11
*   Date        Name        Description
 
12
*   02/19/97    aliu        Converted from java.
 
13
*   03/18/97    clhuang     Updated per C++ implementation.
 
14
*   03/27/97    helena      Updated to pass the simple test after code review.
 
15
*   08/26/97    aliu        Added currency/intl currency symbol support.
 
16
*   07/22/98    stephen     Changed to match C++ style 
 
17
*                            currencySymbol -> fCurrencySymbol
 
18
*                            Constants changed from CAPS to kCaps
 
19
*   06/24/99    helena      Integrated Alan's NF enhancements and Java2 bug fixes
 
20
*   09/22/00    grhoten     Marked deprecation tags with a pointer to replacement
 
21
*                            functions.
 
22
********************************************************************************
 
23
*/
 
24
 
 
25
#ifndef DCFMTSYM_H
 
26
#define DCFMTSYM_H
 
27
 
 
28
#include "unicode/utypes.h"
 
29
 
 
30
#if !UCONFIG_NO_FORMATTING
 
31
 
 
32
#include "unicode/uobject.h"
 
33
#include "unicode/locid.h"
 
34
 
 
35
/**
 
36
 * \file 
 
37
 * \brief C++ API: Symbols for formatting numbers.
 
38
 */
 
39
 
 
40
 
 
41
U_NAMESPACE_BEGIN
 
42
 
 
43
/**
 
44
 * This class represents the set of symbols needed by DecimalFormat
 
45
 * to format numbers. DecimalFormat creates for itself an instance of
 
46
 * DecimalFormatSymbols from its locale data.  If you need to change any
 
47
 * of these symbols, you can get the DecimalFormatSymbols object from
 
48
 * your DecimalFormat and modify it.
 
49
 * <P>
 
50
 * Here are the special characters used in the parts of the
 
51
 * subpattern, with notes on their usage.
 
52
 * <pre>
 
53
 * \code
 
54
 *        Symbol   Meaning
 
55
 *          0      a digit
 
56
 *          #      a digit, zero shows as absent
 
57
 *          .      placeholder for decimal separator
 
58
 *          ,      placeholder for grouping separator.
 
59
 *          ;      separates formats.
 
60
 *          -      default negative prefix.
 
61
 *          %      divide by 100 and show as percentage
 
62
 *          X      any other characters can be used in the prefix or suffix
 
63
 *          '      used to quote special characters in a prefix or suffix.
 
64
 * \endcode
 
65
 *  </pre>
 
66
 * [Notes]
 
67
 * <P>
 
68
 * If there is no explicit negative subpattern, - is prefixed to the
 
69
 * positive form. That is, "0.00" alone is equivalent to "0.00;-0.00".
 
70
 * <P>
 
71
 * The grouping separator is commonly used for thousands, but in some
 
72
 * countries for ten-thousands. The interval is a constant number of
 
73
 * digits between the grouping characters, such as 100,000,000 or 1,0000,0000.
 
74
 * If you supply a pattern with multiple grouping characters, the interval
 
75
 * between the last one and the end of the integer is the one that is
 
76
 * used. So "#,##,###,####" == "######,####" == "##,####,####".
 
77
 * <P>
 
78
 * This class only handles localized digits where the 10 digits are
 
79
 * contiguous in Unicode, from 0 to 9. Other digits sets (such as
 
80
 * superscripts) would need a different subclass.
 
81
 */
 
82
class U_I18N_API DecimalFormatSymbols : public UObject {
 
83
public:
 
84
    /**
 
85
     * Constants for specifying a number format symbol.
 
86
     * @stable ICU 2.0
 
87
     */
 
88
    enum ENumberFormatSymbol {
 
89
        /** The decimal separator */
 
90
        kDecimalSeparatorSymbol,
 
91
        /** The grouping separator */
 
92
        kGroupingSeparatorSymbol,
 
93
        /** The pattern separator */
 
94
        kPatternSeparatorSymbol,
 
95
        /** The percent sign */
 
96
        kPercentSymbol,
 
97
        /** Zero*/
 
98
        kZeroDigitSymbol,
 
99
        /** Character representing a digit in the pattern */
 
100
        kDigitSymbol,
 
101
        /** The minus sign */
 
102
        kMinusSignSymbol,
 
103
        /** The plus sign */
 
104
        kPlusSignSymbol,
 
105
        /** The currency symbol */
 
106
        kCurrencySymbol,
 
107
        /** The international currency symbol */
 
108
        kIntlCurrencySymbol,
 
109
        /** The monetary separator */
 
110
        kMonetarySeparatorSymbol,
 
111
        /** The exponential symbol */
 
112
        kExponentialSymbol,
 
113
        /** Per mill symbol - replaces kPermillSymbol */
 
114
        kPerMillSymbol,
 
115
        /** Escape padding character */
 
116
        kPadEscapeSymbol,
 
117
        /** Infinity symbol */
 
118
        kInfinitySymbol,
 
119
        /** Nan symbol */
 
120
        kNaNSymbol,
 
121
        /** Significant digit symbol
 
122
         * @draft ICU 3.0 */
 
123
        kSignificantDigitSymbol,
 
124
        /** count symbol constants */
 
125
        kFormatSymbolCount
 
126
    };
 
127
 
 
128
    /**
 
129
     * Create a DecimalFormatSymbols object for the given locale.
 
130
     *
 
131
     * @param locale    The locale to get symbols for.
 
132
     * @param status    Input/output parameter, set to success or
 
133
     *                  failure code upon return.
 
134
     * @stable ICU 2.0
 
135
     */
 
136
    DecimalFormatSymbols(const Locale& locale, UErrorCode& status);
 
137
 
 
138
    /**
 
139
     * Create a DecimalFormatSymbols object for the default locale.
 
140
     * This constructor will not fail.  If the resource file data is
 
141
     * not available, it will use hard-coded last-resort data and
 
142
     * set status to U_USING_FALLBACK_ERROR.
 
143
     *
 
144
     * @param status    Input/output parameter, set to success or
 
145
     *                  failure code upon return.
 
146
     * @stable ICU 2.0
 
147
     */
 
148
    DecimalFormatSymbols( UErrorCode& status);
 
149
 
 
150
    /**
 
151
     * Copy constructor.
 
152
     * @stable ICU 2.0
 
153
     */
 
154
    DecimalFormatSymbols(const DecimalFormatSymbols&);
 
155
 
 
156
    /**
 
157
     * Assignment operator.
 
158
     * @stable ICU 2.0
 
159
     */
 
160
    DecimalFormatSymbols& operator=(const DecimalFormatSymbols&);
 
161
 
 
162
    /**
 
163
     * Destructor.
 
164
     * @stable ICU 2.0
 
165
     */
 
166
    virtual ~DecimalFormatSymbols();
 
167
 
 
168
    /**
 
169
     * Return true if another object is semantically equal to this one.
 
170
     *
 
171
     * @param other    the object to be compared with.
 
172
     * @return         true if another object is semantically equal to this one.
 
173
     * @stable ICU 2.0
 
174
     */
 
175
    UBool operator==(const DecimalFormatSymbols& other) const;
 
176
 
 
177
    /**
 
178
     * Return true if another object is semantically unequal to this one.
 
179
     *
 
180
     * @param other    the object to be compared with.
 
181
     * @return         true if another object is semantically unequal to this one.
 
182
     * @stable ICU 2.0
 
183
     */
 
184
    UBool operator!=(const DecimalFormatSymbols& other) const { return !operator==(other); }
 
185
 
 
186
    /**
 
187
     * Get one of the format symbols by its enum constant.
 
188
     * Each symbol is stored as a string so that graphemes
 
189
     * (characters with modifyer letters) can be used.
 
190
     *
 
191
     * @param symbol    Constant to indicate a number format symbol.
 
192
     * @return    the format symbols by the param 'symbol'
 
193
     * @stable ICU 2.0
 
194
     */
 
195
    inline UnicodeString getSymbol(ENumberFormatSymbol symbol) const;
 
196
 
 
197
    /**
 
198
     * Set one of the format symbols by its enum constant.
 
199
     * Each symbol is stored as a string so that graphemes
 
200
     * (characters with modifyer letters) can be used.
 
201
     *
 
202
     * @param symbol    Constant to indicate a number format symbol.
 
203
     * @param value     value of the format sybmol
 
204
     * @stable ICU 2.0
 
205
     */
 
206
    void setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value);
 
207
 
 
208
    /**
 
209
     * Returns the locale for which this object was constructed.
 
210
     * @stable ICU 2.6
 
211
     */
 
212
    inline Locale getLocale() const;
 
213
 
 
214
    /**
 
215
     * Returns the locale for this object. Two flavors are available:
 
216
     * valid and actual locale.
 
217
     * @draft ICU 2.8 likely to change after ICU 3.0, based on feedback
 
218
     */
 
219
    Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
 
220
 
 
221
    /**
 
222
     * ICU "poor man's RTTI", returns a UClassID for the actual class.
 
223
     *
 
224
     * @stable ICU 2.2
 
225
     */
 
226
    virtual UClassID getDynamicClassID() const;
 
227
 
 
228
    /**
 
229
     * ICU "poor man's RTTI", returns a UClassID for this class.
 
230
     *
 
231
     * @stable ICU 2.2
 
232
     */
 
233
    static UClassID U_EXPORT2 getStaticClassID();
 
234
 
 
235
private:
 
236
    DecimalFormatSymbols(); // default constructor not implemented
 
237
 
 
238
    /**
 
239
     * Initializes the symbols from the LocaleElements resource bundle.
 
240
     * Note: The organization of LocaleElements badly needs to be
 
241
     * cleaned up.
 
242
     *
 
243
     * @param locale               The locale to get symbols for.
 
244
     * @param success              Input/output parameter, set to success or
 
245
     *                             failure code upon return.
 
246
     * @param useLastResortData    determine if use last resort data
 
247
     */
 
248
    void initialize(const Locale& locale, UErrorCode& success, UBool useLastResortData = FALSE);
 
249
 
 
250
    /**
 
251
     * Initialize the symbols from the given array of UnicodeStrings.
 
252
     * The array must be of the correct size.
 
253
     * 
 
254
     * @param numberElements    the number format symbols
 
255
     * @param numberElementsLength length of numberElements
 
256
     */
 
257
    void initialize(const UChar** numberElements, int32_t *numberElementsStrLen, int32_t numberElementsLength);
 
258
 
 
259
    /**
 
260
     * Initialize the symbols with default values.
 
261
     */
 
262
    void initialize();
 
263
 
 
264
    void setCurrencyForSymbols();
 
265
 
 
266
public:
 
267
    /**
 
268
     * _Internal_ function - more efficient version of getSymbol,
 
269
     * returning a const reference to one of the symbol strings.
 
270
     * The returned reference becomes invalid when the symbol is changed
 
271
     * or when the DecimalFormatSymbols are destroyed.
 
272
     * ### TODO markus 2002oct11: Consider proposing getConstSymbol() to be really public.
 
273
     *
 
274
     * @param symbol Constant to indicate a number format symbol.
 
275
     * @return the format symbol by the param 'symbol'
 
276
     * @internal
 
277
     */
 
278
    inline const UnicodeString &getConstSymbol(ENumberFormatSymbol symbol) const;
 
279
 
 
280
private:
 
281
    /**
 
282
     * Private symbol strings.
 
283
     * They are either loaded from a resource bundle or otherwise owned.
 
284
     * setSymbol() clones the symbol string.
 
285
     * Readonly aliases can only come from a resource bundle, so that we can always
 
286
     * use fastCopyFrom() with them.
 
287
     *
 
288
     * If DecimalFormatSymbols becomes subclassable and the status of fSymbols changes
 
289
     * from private to protected,
 
290
     * or when fSymbols can be set any other way that allows them to be readonly aliases
 
291
     * to non-resource bundle strings,
 
292
     * then regular UnicodeString copies must be used instead of fastCopyFrom().
 
293
     *
 
294
     * @internal
 
295
     */
 
296
    UnicodeString fSymbols[kFormatSymbolCount];
 
297
 
 
298
    /**
 
299
     * Non-symbol variable for getConstSymbol(). Always empty.
 
300
     * @internal
 
301
     */
 
302
    UnicodeString fNoSymbol;
 
303
 
 
304
    Locale locale;
 
305
 
 
306
    char actualLocale[ULOC_FULLNAME_CAPACITY];
 
307
    char validLocale[ULOC_FULLNAME_CAPACITY];
 
308
};
 
309
 
 
310
// -------------------------------------
 
311
 
 
312
inline UnicodeString
 
313
DecimalFormatSymbols::getSymbol(ENumberFormatSymbol symbol) const {
 
314
    const UnicodeString *strPtr;
 
315
    if(symbol < kFormatSymbolCount) {
 
316
        strPtr = &fSymbols[symbol];
 
317
    } else {
 
318
        strPtr = &fNoSymbol;
 
319
    }
 
320
    return *strPtr;
 
321
}
 
322
 
 
323
inline const UnicodeString &
 
324
DecimalFormatSymbols::getConstSymbol(ENumberFormatSymbol symbol) const {
 
325
    const UnicodeString *strPtr;
 
326
    if(symbol < kFormatSymbolCount) {
 
327
        strPtr = &fSymbols[symbol];
 
328
    } else {
 
329
        strPtr = &fNoSymbol;
 
330
    }
 
331
    return *strPtr;
 
332
}
 
333
 
 
334
// -------------------------------------
 
335
 
 
336
inline void
 
337
DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value) {
 
338
    if(symbol<kFormatSymbolCount) {
 
339
        fSymbols[symbol]=value;
 
340
    }
 
341
}
 
342
 
 
343
// -------------------------------------
 
344
 
 
345
inline Locale
 
346
DecimalFormatSymbols::getLocale() const {
 
347
    return locale;
 
348
}
 
349
 
 
350
 
 
351
U_NAMESPACE_END
 
352
 
 
353
#endif /* #if !UCONFIG_NO_FORMATTING */
 
354
 
 
355
#endif // _DCFMTSYM
 
356
//eof