1b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*
2b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru********************************************************************************
38393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius*   Copyright (C) 1997-2013, International Business Machines
4b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   Corporation and others.  All Rights Reserved.
5b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru********************************************************************************
6b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*
7b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* File FMTABLE.H
8b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*
9b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* Modification History:
10b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*
11b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   Date        Name        Description
12b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*   02/29/97    aliu        Creation.
13b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru********************************************************************************
14b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*/
15b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifndef FMTABLE_H
16b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define FMTABLE_H
17b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
18b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/utypes.h"
1950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
20b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
2159d709d503bab6e2b61931737e662dd293b40578ccornelius * \file
2259d709d503bab6e2b61931737e662dd293b40578ccornelius * \brief C++ API: Formattable is a thin wrapper for primitive types used for formatting and parsing
23b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
24b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
25b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
26b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
2759d709d503bab6e2b61931737e662dd293b40578ccornelius#include "unicode/unistr.h"
2859d709d503bab6e2b61931737e662dd293b40578ccornelius#include "unicode/stringpiece.h"
2959d709d503bab6e2b61931737e662dd293b40578ccornelius#include "unicode/uformattable.h"
3059d709d503bab6e2b61931737e662dd293b40578ccornelius
31b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_NAMESPACE_BEGIN
32b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
3327f654740f2a26ad62a5c155af9199af9e69b889clairehoclass CharString;
3427f654740f2a26ad62a5c155af9199af9e69b889clairehoclass DigitList;
3550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
36b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
3754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * \def UNUM_INTERNAL_STACKARRAY_SIZE
3854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * @internal
3954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius */
4054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius#if U_PLATFORM == U_PF_OS400
4154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius#define UNUM_INTERNAL_STACKARRAY_SIZE 144
4254dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius#else
4354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius#define UNUM_INTERNAL_STACKARRAY_SIZE 128
4454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius#endif
4554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius
4654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius/**
47b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Formattable objects can be passed to the Format class or
48b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * its subclasses for formatting.  Formattable is a thin wrapper
49b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * class which interconverts between the primitive numeric types
50b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * (double, long, etc.) as well as UDate and UnicodeString.
51b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
52b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>Internally, a Formattable object is a union of primitive types.
53b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * As such, it can only store one flavor of data at a time.  To
54b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * determine what flavor of data it contains, use the getType method.
55b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
56b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>As of ICU 3.0, Formattable may also wrap a UObject pointer,
57b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * which it owns.  This allows an instance of any ICU class to be
58b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * encapsulated in a Formattable.  For legacy reasons and for
59b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * efficiency, primitive numeric types are still stored directly
60b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * within a Formattable.
61b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
62b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <p>The Formattable class is not suitable for subclassing.
6359d709d503bab6e2b61931737e662dd293b40578ccornelius *
6459d709d503bab6e2b61931737e662dd293b40578ccornelius * <p>See UFormattable for a C wrapper.
65b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
66b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruclass U_I18N_API Formattable : public UObject {
67b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querupublic:
68b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
69b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * This enum is only used to let callers distinguish between
70b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the Formattable(UDate) constructor and the Formattable(double)
71b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * constructor; the compiler cannot distinguish the signatures,
72b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * since UDate is currently typedefed to be either double or long.
73b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * If UDate is changed later to be a bonafide class
74b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * or struct, then we no longer need this enum.
75b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.4
76b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
77b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    enum ISDATE { kIsDate };
78b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
79b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
80b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Default constructor
81b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.4
82b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
83b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Formattable(); // Type kLong, value 0
84b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
85b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
86b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Creates a Formattable object with a UDate instance.
87b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param d the UDate instance.
88b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param flag the flag to indicate this is a date. Always set it to kIsDate
8959d709d503bab6e2b61931737e662dd293b40578ccornelius     * @stable ICU 2.0
90b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
91b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Formattable(UDate d, ISDATE flag);
92b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
93b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
94b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Creates a Formattable object with a double number.
95b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param d the double number.
96b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
97b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
98b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Formattable(double d);
99b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Creates a Formattable object with a long number.
102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param l the long number.
103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Formattable(int32_t l);
106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Creates a Formattable object with an int64_t number
109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param ll the int64_t number.
110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.8
111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Formattable(int64_t ll);
113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_CONVERSION
115b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Creates a Formattable object with a char string pointer.
117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Assumes that the char string is null terminated.
118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param strToCopy the char string.
119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Formattable(const char* strToCopy);
122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
12550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * Creates a Formattable object of an appropriate numeric type from a
12650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * a decimal number in string form.  The Formattable will retain the
12750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * full precision of the input in decimal format, even when it exceeds
12859d709d503bab6e2b61931737e662dd293b40578ccornelius     * what can be represented by a double or int64_t.
12950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *
13050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * @param number  the unformatted (not localized) string representation
13150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *                     of the Decimal number.
13250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * @param status  the error code.  Possible errors include U_INVALID_FORMAT_ERROR
13350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *                if the format of the string does not conform to that of a
13450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *                decimal number.
13527f654740f2a26ad62a5c155af9199af9e69b889claireho     * @stable ICU 4.4
13650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     */
13750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    Formattable(const StringPiece &number, UErrorCode &status);
13850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
13950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    /**
140b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Creates a Formattable object with a UnicodeString object to copy from.
141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param strToCopy the UnicodeString string.
142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
143b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Formattable(const UnicodeString& strToCopy);
145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
146b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Creates a Formattable object with a UnicodeString object to adopt from.
148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param strToAdopt the UnicodeString string.
149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Formattable(UnicodeString* strToAdopt);
152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Creates a Formattable object with an array of Formattable objects.
155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param arrayToCopy the Formattable object array.
156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param count the array count.
157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Formattable(const Formattable* arrayToCopy, int32_t count);
160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Creates a Formattable object that adopts the given UObject.
163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param objectToAdopt the UObject to set this object to
164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.0
165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Formattable(UObject* objectToAdopt);
167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Copy constructor.
170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Formattable(const Formattable&);
173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Assignment operator.
176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param rhs   The Formattable object to copy into this object.
177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Formattable&    operator=(const Formattable &rhs);
180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Equality comparison.
183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param other    the object to be compared with.
184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return        TRUE if other are equal to this, FALSE otherwise.
185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool          operator==(const Formattable &other) const;
18859d709d503bab6e2b61931737e662dd293b40578ccornelius
18959d709d503bab6e2b61931737e662dd293b40578ccornelius    /**
190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Equality operator.
191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param other    the object to be compared with.
192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return        TRUE if other are unequal to this, FALSE otherwise.
193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
195b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool          operator!=(const Formattable& other) const
196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      { return !operator==(other); }
197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
19859d709d503bab6e2b61931737e662dd293b40578ccornelius    /**
199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Destructor.
200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual         ~Formattable();
203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Clone this object.
206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Clones can be used concurrently in multiple threads.
207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * If an error occurs, then NULL is returned.
208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * The caller must delete the clone.
209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return a clone of this object
211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @see getDynamicClassID
213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.8
214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Formattable *clone() const;
216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
21759d709d503bab6e2b61931737e662dd293b40578ccornelius    /**
218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Selector for flavor of data type contained within a
219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Formattable object.  Formattable is a union of several
220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * different types, and at any time contains exactly one type.
221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.4
222b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    enum Type {
224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /**
225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * Selector indicating a UDate value.  Use getDate to retrieve
226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * the value.
227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * @stable ICU 2.4
228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         */
229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        kDate,
230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /**
232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * Selector indicating a double value.  Use getDouble to
233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * retrieve the value.
234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * @stable ICU 2.4
235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         */
236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        kDouble,
237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
238b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /**
239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * Selector indicating a 32-bit integer value.  Use getLong to
240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * retrieve the value.
241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * @stable ICU 2.4
242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         */
243b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        kLong,
244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /**
246b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * Selector indicating a UnicodeString value.  Use getString
247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * to retrieve the value.
248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * @stable ICU 2.4
249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         */
250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        kString,
251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
252b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /**
253b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * Selector indicating an array of Formattables.  Use getArray
254b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * to retrieve the value.
255b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * @stable ICU 2.4
256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         */
257b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        kArray,
258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /**
260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * Selector indicating a 64-bit integer value.  Use getInt64
261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * to retrieve the value.
262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * @stable ICU 2.8
263b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         */
264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        kInt64,
265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /**
267b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * Selector indicating a UObject value.  Use getObject to
268b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * retrieve the value.
269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * @stable ICU 3.0
270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         */
271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        kObject
272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru   };
273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the data type of this Formattable object.
276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return    the data type of this Formattable object.
277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
278b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Type            getType(void) const;
28059d709d503bab6e2b61931737e662dd293b40578ccornelius
281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Returns TRUE if the data type of this Formattable object
28359d709d503bab6e2b61931737e662dd293b40578ccornelius     * is kDouble, kLong, or kInt64
284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return TRUE if this is a pure numeric object
285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.0
286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool           isNumeric() const;
28859d709d503bab6e2b61931737e662dd293b40578ccornelius
289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the double value of this object. If this object is not of type
291b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * kDouble then the result is undefined.
292b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return    the double value of this object.
293b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
29459d709d503bab6e2b61931737e662dd293b40578ccornelius     */
295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    double          getDouble(void) const { return fValue.fDouble; }
296b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
297b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the double value of this object. If this object is of type
29950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * long, int64 or Decimal Number then a conversion is peformed, with
300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * possible loss of precision.  If the type is kObject and the
301b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * object is a Measure, then the result of
302b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * getNumber().getDouble(status) is returned.  If this object is
303b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * neither a numeric type nor a Measure, then 0 is returned and
304b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the status is set to U_INVALID_FORMAT_ERROR.
305b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status the error code
306b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return the double value of this object.
307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.0
30859d709d503bab6e2b61931737e662dd293b40578ccornelius     */
309b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    double          getDouble(UErrorCode& status) const;
310b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
311b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
312b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the long value of this object. If this object is not of type
313b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * kLong then the result is undefined.
314b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return    the long value of this object.
315b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
31659d709d503bab6e2b61931737e662dd293b40578ccornelius     */
317b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t         getLong(void) const { return (int32_t)fValue.fInt64; }
318b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
319b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
320b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the long value of this object. If the magnitude is too
321b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * large to fit in a long, then the maximum or minimum long value,
322b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * as appropriate, is returned and the status is set to
323b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * U_INVALID_FORMAT_ERROR.  If this object is of type kInt64 and
324b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * it fits within a long, then no precision is lost.  If it is of
32559d709d503bab6e2b61931737e662dd293b40578ccornelius     * type kDouble, then a conversion is peformed, with
326b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * truncation of any fractional part.  If the type is kObject and
327b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the object is a Measure, then the result of
328b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * getNumber().getLong(status) is returned.  If this object is
329b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * neither a numeric type nor a Measure, then 0 is returned and
330b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the status is set to U_INVALID_FORMAT_ERROR.
331b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status the error code
332b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return    the long value of this object.
333b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.0
33459d709d503bab6e2b61931737e662dd293b40578ccornelius     */
335b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t         getLong(UErrorCode& status) const;
336b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
338b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the int64 value of this object. If this object is not of type
339b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * kInt64 then the result is undefined.
340b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return    the int64 value of this object.
341b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.8
34259d709d503bab6e2b61931737e662dd293b40578ccornelius     */
343b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int64_t         getInt64(void) const { return fValue.fInt64; }
344b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
345b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
34650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * Gets the int64 value of this object. If this object is of a numeric
34750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * type and the magnitude is too large to fit in an int64, then
348b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the maximum or minimum int64 value, as appropriate, is returned
349b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * and the status is set to U_INVALID_FORMAT_ERROR.  If the
350b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * magnitude fits in an int64, then a casting conversion is
351b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * peformed, with truncation of any fractional part.  If the type
352b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * is kObject and the object is a Measure, then the result of
353b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * getNumber().getDouble(status) is returned.  If this object is
354b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * neither a numeric type nor a Measure, then 0 is returned and
355b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the status is set to U_INVALID_FORMAT_ERROR.
356b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status the error code
357b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return    the int64 value of this object.
358b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.0
35959d709d503bab6e2b61931737e662dd293b40578ccornelius     */
360b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int64_t         getInt64(UErrorCode& status) const;
361b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
362b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
363b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the Date value of this object. If this object is not of type
364b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * kDate then the result is undefined.
365b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return    the Date value of this object.
366b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
36759d709d503bab6e2b61931737e662dd293b40578ccornelius     */
368b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UDate           getDate() const { return fValue.fDate; }
369b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
370b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
371b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the Date value of this object.  If the type is not a date,
372b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * status is set to U_INVALID_FORMAT_ERROR and the return value is
373b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * undefined.
374b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status the error code.
375b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return    the Date value of this object.
376b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.0
37759d709d503bab6e2b61931737e662dd293b40578ccornelius     */
378b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     UDate          getDate(UErrorCode& status) const;
379b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
380b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
381b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the string value of this object. If this object is not of type
382b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * kString then the result is undefined.
383b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param result    Output param to receive the Date value of this object.
384b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return          A reference to 'result'.
385b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
38659d709d503bab6e2b61931737e662dd293b40578ccornelius     */
387b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString&  getString(UnicodeString& result) const
388b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      { result=*fValue.fString; return result; }
389b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
390b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
391b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the string value of this object. If the type is not a
392b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * string, status is set to U_INVALID_FORMAT_ERROR and a bogus
393b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * string is returned.
394b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param result    Output param to receive the Date value of this object.
39559d709d503bab6e2b61931737e662dd293b40578ccornelius     * @param status    the error code.
396b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return          A reference to 'result'.
397b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.0
39859d709d503bab6e2b61931737e662dd293b40578ccornelius     */
399b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString&  getString(UnicodeString& result, UErrorCode& status) const;
400b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
401b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
402b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets a const reference to the string value of this object. If
403b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * this object is not of type kString then the result is
404b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * undefined.
405b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return   a const reference to the string value of this object.
406b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
407b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
408b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    inline const UnicodeString& getString(void) const;
409b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
410b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
411b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets a const reference to the string value of this object.  If
412b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the type is not a string, status is set to
413b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * U_INVALID_FORMAT_ERROR and the result is a bogus string.
414b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status    the error code.
415b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return   a const reference to the string value of this object.
416b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.0
417b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
418b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const UnicodeString& getString(UErrorCode& status) const;
419b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
420b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
421b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets a reference to the string value of this object. If this
422b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * object is not of type kString then the result is undefined.
423b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return   a reference to the string value of this object.
424b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
425b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
426b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    inline UnicodeString& getString(void);
427b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
428b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
429b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets a reference to the string value of this object. If the
430b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * type is not a string, status is set to U_INVALID_FORMAT_ERROR
431b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * and the result is a bogus string.
43259d709d503bab6e2b61931737e662dd293b40578ccornelius     * @param status    the error code.
433b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return   a reference to the string value of this object.
434b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.0
435b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
436b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString& getString(UErrorCode& status);
437b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
438b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
439b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the array value and count of this object. If this object
440b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * is not of type kArray then the result is undefined.
441b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param count    fill-in with the count of this object.
442b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return         the array value of this object.
443b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
44459d709d503bab6e2b61931737e662dd293b40578ccornelius     */
445b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const Formattable* getArray(int32_t& count) const
446b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      { count=fValue.fArrayAndCount.fCount; return fValue.fArrayAndCount.fArray; }
447b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
448b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
449b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Gets the array value and count of this object. If the type is
450b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * not an array, status is set to U_INVALID_FORMAT_ERROR, count is
451b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * set to 0, and the result is NULL.
452b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param count    fill-in with the count of this object.
45359d709d503bab6e2b61931737e662dd293b40578ccornelius     * @param status the error code.
454b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return         the array value of this object.
455b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.0
45659d709d503bab6e2b61931737e662dd293b40578ccornelius     */
457b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const Formattable* getArray(int32_t& count, UErrorCode& status) const;
458b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
459b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
460b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Accesses the specified element in the array value of this
461b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Formattable object. If this object is not of type kArray then
462b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the result is undefined.
463b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param index the specified index.
464b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return the accessed element in the array.
465b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
466b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
467b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Formattable&    operator[](int32_t index) { return fValue.fArrayAndCount.fArray[index]; }
46859d709d503bab6e2b61931737e662dd293b40578ccornelius
469b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
470b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Returns a pointer to the UObject contained within this
471b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * formattable, or NULL if this object does not contain a UObject.
472b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return a UObject pointer, or NULL
473b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.0
474b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
475b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const UObject*  getObject() const;
476b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
477b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
47850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * Returns a numeric string representation of the number contained within this
47950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * formattable, or NULL if this object does not contain numeric type.
48050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * For values obtained by parsing, the returned decimal number retains
48150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * the full precision and range of the original input, unconstrained by
48250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * the limits of a double floating point or a 64 bit int.
48359d709d503bab6e2b61931737e662dd293b40578ccornelius     *
48450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * This function is not thread safe, and therfore is not declared const,
48550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * even though it is logically const.
48650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *
48750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * Possible errors include U_MEMORY_ALLOCATION_ERROR, and
48850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * U_INVALID_STATE if the formattable object has not been set to
48950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * a numeric type.
49050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *
49150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * @param status the error code.
49250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * @return the unformatted string representation of a number.
49327f654740f2a26ad62a5c155af9199af9e69b889claireho     * @stable ICU 4.4
49450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     */
49550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    StringPiece getDecimalNumber(UErrorCode &status);
49650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
49750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     /**
498b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets the double value of this object and changes the type to
499b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * kDouble.
500b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param d    the new double value to be set.
501b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
50259d709d503bab6e2b61931737e662dd293b40578ccornelius     */
503b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void            setDouble(double d);
504b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
505b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
506b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets the long value of this object and changes the type to
507b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * kLong.
508b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param l    the new long value to be set.
509b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
51059d709d503bab6e2b61931737e662dd293b40578ccornelius     */
511b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void            setLong(int32_t l);
512b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
513b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
514b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets the int64 value of this object and changes the type to
515b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * kInt64.
516b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param ll    the new int64 value to be set.
517b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.8
51859d709d503bab6e2b61931737e662dd293b40578ccornelius     */
519b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void            setInt64(int64_t ll);
520b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
521b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
522b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets the Date value of this object and changes the type to
523b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * kDate.
524b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param d    the new Date value to be set.
525b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
52659d709d503bab6e2b61931737e662dd293b40578ccornelius     */
527b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void            setDate(UDate d);
528b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
529b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
530b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets the string value of this object and changes the type to
531b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * kString.
532b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param stringToCopy    the new string value to be set.
533b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
53459d709d503bab6e2b61931737e662dd293b40578ccornelius     */
535b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void            setString(const UnicodeString& stringToCopy);
536b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
537b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
538b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets the array value and count of this object and changes the
539b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * type to kArray.
540b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param array    the array value.
541b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param count    the number of array elements to be copied.
542b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
54359d709d503bab6e2b61931737e662dd293b40578ccornelius     */
544b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void            setArray(const Formattable* array, int32_t count);
545b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
546b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
547b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets and adopts the string value and count of this object and
548b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * changes the type to kArray.
549b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param stringToAdopt    the new string value to be adopted.
550b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
55159d709d503bab6e2b61931737e662dd293b40578ccornelius     */
552b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void            adoptString(UnicodeString* stringToAdopt);
553b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
554b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
555b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets and adopts the array value and count of this object and
556b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * changes the type to kArray.
557b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.0
55859d709d503bab6e2b61931737e662dd293b40578ccornelius     */
559b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void            adoptArray(Formattable* array, int32_t count);
56059d709d503bab6e2b61931737e662dd293b40578ccornelius
561b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
562b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Sets and adopts the UObject value of this object and changes
563b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * the type to kObject.  After this call, the caller must not
564b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * delete the given object.
565b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param objectToAdopt the UObject value to be adopted
566b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 3.0
567b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
568b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void            adoptObject(UObject* objectToAdopt);
569b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
570b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
57150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * Sets the the numeric value from a decimal number string, and changes
57259d709d503bab6e2b61931737e662dd293b40578ccornelius     * the type to to a numeric type appropriate for the number.
57350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * The syntax of the number is a "numeric string"
57450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * as defined in the Decimal Arithmetic Specification, available at
57550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * http://speleotrove.com/decimal
57650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * The full precision and range of the input number will be retained,
57750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * even when it exceeds what can be represented by a double or an int64.
57850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *
57950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * @param numberString  a string representation of the unformatted decimal number.
58050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * @param status        the error code.  Set to U_INVALID_FORMAT_ERROR if the
58150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *                      incoming string is not a valid decimal number.
58227f654740f2a26ad62a5c155af9199af9e69b889claireho     * @stable ICU 4.4
58350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     */
58450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    void             setDecimalNumber(const StringPiece &numberString,
58550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho                                      UErrorCode &status);
58650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
58750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    /**
588b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * ICU "poor man's RTTI", returns a UClassID for the actual class.
589b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
590b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.2
591b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
592b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual UClassID getDynamicClassID() const;
593b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
594b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
595b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * ICU "poor man's RTTI", returns a UClassID for this class.
596b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
597b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @stable ICU 2.2
598b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
599b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static UClassID U_EXPORT2 getStaticClassID();
600b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
60159d709d503bab6e2b61931737e662dd293b40578ccornelius#ifndef U_HIDE_DRAFT_API
60259d709d503bab6e2b61931737e662dd293b40578ccornelius    /**
60359d709d503bab6e2b61931737e662dd293b40578ccornelius     * Convert the UFormattable to a Formattable.  Internally, this is a reinterpret_cast.
60459d709d503bab6e2b61931737e662dd293b40578ccornelius     * @param fmt a valid UFormattable
60559d709d503bab6e2b61931737e662dd293b40578ccornelius     * @return the UFormattable as a Formattable object pointer.  This is an alias to the original
60659d709d503bab6e2b61931737e662dd293b40578ccornelius     * UFormattable, and so is only valid while the original argument remains in scope.
60759d709d503bab6e2b61931737e662dd293b40578ccornelius     * @draft ICU 52
60859d709d503bab6e2b61931737e662dd293b40578ccornelius     */
60959d709d503bab6e2b61931737e662dd293b40578ccornelius    static inline Formattable *fromUFormattable(UFormattable *fmt);
61059d709d503bab6e2b61931737e662dd293b40578ccornelius
61159d709d503bab6e2b61931737e662dd293b40578ccornelius    /**
61259d709d503bab6e2b61931737e662dd293b40578ccornelius     * Convert the const UFormattable to a const Formattable.  Internally, this is a reinterpret_cast.
61359d709d503bab6e2b61931737e662dd293b40578ccornelius     * @param fmt a valid UFormattable
61459d709d503bab6e2b61931737e662dd293b40578ccornelius     * @return the UFormattable as a Formattable object pointer.  This is an alias to the original
61559d709d503bab6e2b61931737e662dd293b40578ccornelius     * UFormattable, and so is only valid while the original argument remains in scope.
61659d709d503bab6e2b61931737e662dd293b40578ccornelius     * @draft ICU 52
61759d709d503bab6e2b61931737e662dd293b40578ccornelius     */
61859d709d503bab6e2b61931737e662dd293b40578ccornelius    static inline const Formattable *fromUFormattable(const UFormattable *fmt);
61959d709d503bab6e2b61931737e662dd293b40578ccornelius
62059d709d503bab6e2b61931737e662dd293b40578ccornelius    /**
62159d709d503bab6e2b61931737e662dd293b40578ccornelius     * Convert this object pointer to a UFormattable.
62259d709d503bab6e2b61931737e662dd293b40578ccornelius     * @return this object as a UFormattable pointer.   This is an alias to this object,
62359d709d503bab6e2b61931737e662dd293b40578ccornelius     * and so is only valid while this object remains in scope.
62459d709d503bab6e2b61931737e662dd293b40578ccornelius     * @draft ICU 52
62559d709d503bab6e2b61931737e662dd293b40578ccornelius     */
62659d709d503bab6e2b61931737e662dd293b40578ccornelius    inline UFormattable *toUFormattable();
62759d709d503bab6e2b61931737e662dd293b40578ccornelius
62859d709d503bab6e2b61931737e662dd293b40578ccornelius    /**
62959d709d503bab6e2b61931737e662dd293b40578ccornelius     * Convert this object pointer to a UFormattable.
63059d709d503bab6e2b61931737e662dd293b40578ccornelius     * @return this object as a UFormattable pointer.   This is an alias to this object,
63159d709d503bab6e2b61931737e662dd293b40578ccornelius     * and so is only valid while this object remains in scope.
63259d709d503bab6e2b61931737e662dd293b40578ccornelius     * @draft ICU 52
63359d709d503bab6e2b61931737e662dd293b40578ccornelius     */
63459d709d503bab6e2b61931737e662dd293b40578ccornelius    inline const UFormattable *toUFormattable() const;
63559d709d503bab6e2b61931737e662dd293b40578ccornelius#endif  /* U_HIDE_DRAFT_API */
63659d709d503bab6e2b61931737e662dd293b40578ccornelius
637103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_DEPRECATED_API
638b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
639b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Deprecated variant of getLong(UErrorCode&).
640b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @param status the error code
641b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @return the long value of this object.
642b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * @deprecated ICU 3.0 use getLong(UErrorCode&) instead
64359d709d503bab6e2b61931737e662dd293b40578ccornelius     */
644b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    inline int32_t getLong(UErrorCode* status) const;
645103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_DEPRECATED_API */
646b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
647103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API
64850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    /**
64950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * Internal function, do not use.
65050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * TODO:  figure out how to make this be non-public.
65150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *        NumberFormat::format(Formattable, ...
65250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *        needs to get at the DigitList, if it exists, for
65350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *        big decimal formatting.
65450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *  @internal
65550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     */
656b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    DigitList *getDigitList() const { return fDecimalNum;}
65750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
658103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    /**
659103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     *  @internal
660103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     */
661103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    DigitList *getInternalDigitList();
662103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius
66350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    /**
66450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *  Adopt, and set value from, a DigitList
66550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *     Internal Function, do not use.
66650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *  @param dl the Digit List to be adopted
66750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     *  @internal
66850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     */
66950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    void adoptDigitList(DigitList *dl);
67059d709d503bab6e2b61931737e662dd293b40578ccornelius
67159d709d503bab6e2b61931737e662dd293b40578ccornelius    /**
67259d709d503bab6e2b61931737e662dd293b40578ccornelius     * Internal function to return the CharString pointer.
67359d709d503bab6e2b61931737e662dd293b40578ccornelius     * @param status error code
67459d709d503bab6e2b61931737e662dd293b40578ccornelius     * @return pointer to the CharString - may become invalid if the object is modified
67559d709d503bab6e2b61931737e662dd293b40578ccornelius     * @internal
67659d709d503bab6e2b61931737e662dd293b40578ccornelius     */
67759d709d503bab6e2b61931737e662dd293b40578ccornelius    CharString *internalGetCharString(UErrorCode &status);
67859d709d503bab6e2b61931737e662dd293b40578ccornelius
679103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_INTERNAL_API */
68050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
681b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruprivate:
682b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /**
683b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Cleans up the memory for unwanted values.  For example, the adopted
684b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * string or array objects.
685b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
686b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void            dispose(void);
68727f654740f2a26ad62a5c155af9199af9e69b889claireho
68850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    /**
68950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     * Common initialization, for use by constructors.
69050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho     */
69150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    void            init();
692b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
693b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString* getBogus() const;
694b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
695b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    union {
696b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UObject*        fObject;
697b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UnicodeString*  fString;
698b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        double          fDouble;
699b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        int64_t         fInt64;
700b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UDate           fDate;
701b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        struct {
702b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          Formattable*  fArray;
703b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          int32_t       fCount;
704b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }               fArrayAndCount;
705b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    } fValue;
706b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
70727f654740f2a26ad62a5c155af9199af9e69b889claireho    CharString           *fDecimalStr;
708103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius
70950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    DigitList            *fDecimalNum;
71050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
71154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius    char                fStackData[UNUM_INTERNAL_STACKARRAY_SIZE]; // must be big enough for DigitList
712103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius
713b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Type                fType;
714b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString       fBogus; // Bogus string when it's needed.
715b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru};
716b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
717b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UDate Formattable::getDate(UErrorCode& status) const {
718b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (fType != kDate) {
719b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (U_SUCCESS(status)) {
720b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            status = U_INVALID_FORMAT_ERROR;
721b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
722b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return 0;
723b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
724b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return fValue.fDate;
725b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
726b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
727b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline const UnicodeString& Formattable::getString(void) const {
728b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return *fValue.fString;
729b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
730b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
731b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline UnicodeString& Formattable::getString(void) {
732b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return *fValue.fString;
733b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
734b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
73559d709d503bab6e2b61931737e662dd293b40578ccornelius#ifndef U_HIDE_DEPRECATED_API
736b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruinline int32_t Formattable::getLong(UErrorCode* status) const {
737b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return getLong(*status);
738b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
73959d709d503bab6e2b61931737e662dd293b40578ccornelius#endif  /* U_HIDE_DEPRECATED_API */
74059d709d503bab6e2b61931737e662dd293b40578ccornelius
74159d709d503bab6e2b61931737e662dd293b40578ccornelius#ifndef U_HIDE_DRAFT_API
74259d709d503bab6e2b61931737e662dd293b40578ccorneliusinline UFormattable* Formattable::toUFormattable() {
74359d709d503bab6e2b61931737e662dd293b40578ccornelius  return reinterpret_cast<UFormattable*>(this);
74459d709d503bab6e2b61931737e662dd293b40578ccornelius}
74559d709d503bab6e2b61931737e662dd293b40578ccornelius
74659d709d503bab6e2b61931737e662dd293b40578ccorneliusinline const UFormattable* Formattable::toUFormattable() const {
74759d709d503bab6e2b61931737e662dd293b40578ccornelius  return reinterpret_cast<const UFormattable*>(this);
74859d709d503bab6e2b61931737e662dd293b40578ccornelius}
74959d709d503bab6e2b61931737e662dd293b40578ccornelius
75059d709d503bab6e2b61931737e662dd293b40578ccorneliusinline Formattable* Formattable::fromUFormattable(UFormattable *fmt) {
75159d709d503bab6e2b61931737e662dd293b40578ccornelius  return reinterpret_cast<Formattable *>(fmt);
75259d709d503bab6e2b61931737e662dd293b40578ccornelius}
753103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius
75459d709d503bab6e2b61931737e662dd293b40578ccorneliusinline const Formattable* Formattable::fromUFormattable(const UFormattable *fmt) {
75559d709d503bab6e2b61931737e662dd293b40578ccornelius  return reinterpret_cast<const Formattable *>(fmt);
75659d709d503bab6e2b61931737e662dd293b40578ccornelius}
75759d709d503bab6e2b61931737e662dd293b40578ccornelius#endif  /* U_HIDE_DRAFT_API */
758b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
759b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_NAMESPACE_END
760b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
761b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif /* #if !UCONFIG_NO_FORMATTING */
762b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
763b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif //_FMTABLE
764b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//eof
765