OLD | NEW |
1 /* | 1 /* |
2 ********************************************************************** | 2 ********************************************************************** |
3 * Copyright (c) 2004-2006, International Business Machines | 3 * Copyright (c) 2004-2014, International Business Machines |
4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
5 ********************************************************************** | 5 ********************************************************************** |
6 * Author: Alan Liu | 6 * Author: Alan Liu |
7 * Created: April 26, 2004 | 7 * Created: April 26, 2004 |
8 * Since: ICU 3.0 | 8 * Since: ICU 3.0 |
9 ********************************************************************** | 9 ********************************************************************** |
10 */ | 10 */ |
11 #ifndef __MEASURE_H__ | 11 #ifndef __MEASURE_H__ |
12 #define __MEASURE_H__ | 12 #define __MEASURE_H__ |
13 | 13 |
14 #include "unicode/utypes.h" | 14 #include "unicode/utypes.h" |
15 | 15 |
16 /** | 16 /** |
17 * \file | 17 * \file |
18 * \brief C++ API: MeasureUnit object. | 18 * \brief C++ API: MeasureUnit object. |
19 */ | 19 */ |
20 | 20 |
21 #if !UCONFIG_NO_FORMATTING | 21 #if !UCONFIG_NO_FORMATTING |
22 | 22 |
23 #include "unicode/fmtable.h" | 23 #include "unicode/fmtable.h" |
24 | 24 |
25 U_NAMESPACE_BEGIN | 25 U_NAMESPACE_BEGIN |
26 | 26 |
27 class MeasureUnit; | 27 class MeasureUnit; |
28 | 28 |
29 /** | 29 /** |
30 * An amount of a specified unit, consisting of a number and a Unit. | 30 * An amount of a specified unit, consisting of a number and a Unit. |
31 * For example, a length measure consists of a number and a length | 31 * For example, a length measure consists of a number and a length |
32 * unit, such as feet or meters. This is an abstract class. | 32 * unit, such as feet or meters. |
33 * Subclasses specify a concrete Unit type. | |
34 * | 33 * |
35 * <p>Measure objects are parsed and formatted by subclasses of | 34 * <p>Measure objects are formatted by MeasureFormat. |
36 * MeasureFormat. | |
37 * | 35 * |
38 * <p>Measure objects are immutable. | 36 * <p>Measure objects are immutable. |
39 * | 37 * |
40 * <p>This is an abstract class. | |
41 * | |
42 * @author Alan Liu | 38 * @author Alan Liu |
43 * @stable ICU 3.0 | 39 * @stable ICU 3.0 |
44 */ | 40 */ |
45 class U_I18N_API Measure: public UObject { | 41 class U_I18N_API Measure: public UObject { |
46 public: | 42 public: |
47 /** | 43 /** |
48 * Construct an object with the given numeric amount and the given | 44 * Construct an object with the given numeric amount and the given |
49 * unit. After this call, the caller must not delete the given | 45 * unit. After this call, the caller must not delete the given |
50 * unit object. | 46 * unit object. |
51 * @param number a numeric object; amount.isNumeric() must be TRUE | 47 * @param number a numeric object; amount.isNumeric() must be TRUE |
(...skipping 15 matching lines...) Expand all Loading... |
67 * Assignment operator | 63 * Assignment operator |
68 * @stable ICU 3.0 | 64 * @stable ICU 3.0 |
69 */ | 65 */ |
70 Measure& operator=(const Measure& other); | 66 Measure& operator=(const Measure& other); |
71 | 67 |
72 /** | 68 /** |
73 * Return a polymorphic clone of this object. The result will | 69 * Return a polymorphic clone of this object. The result will |
74 * have the same class as returned by getDynamicClassID(). | 70 * have the same class as returned by getDynamicClassID(). |
75 * @stable ICU 3.0 | 71 * @stable ICU 3.0 |
76 */ | 72 */ |
77 virtual UObject* clone() const = 0; | 73 virtual UObject* clone() const; |
78 | 74 |
79 /** | 75 /** |
80 * Destructor | 76 * Destructor |
81 * @stable ICU 3.0 | 77 * @stable ICU 3.0 |
82 */ | 78 */ |
83 virtual ~Measure(); | 79 virtual ~Measure(); |
84 | 80 |
85 /** | 81 /** |
86 * Equality operator. Return true if this object is equal | 82 * Equality operator. Return true if this object is equal |
87 * to the given object. | 83 * to the given object. |
88 * @stable ICU 3.0 | 84 * @stable ICU 3.0 |
89 */ | 85 */ |
90 UBool operator==(const UObject& other) const; | 86 UBool operator==(const UObject& other) const; |
91 | 87 |
92 /** | 88 /** |
93 * Return a reference to the numeric value of this object. The | 89 * Return a reference to the numeric value of this object. The |
94 * numeric value may be of any numeric type supported by | 90 * numeric value may be of any numeric type supported by |
95 * Formattable. | 91 * Formattable. |
96 * @stable ICU 3.0 | 92 * @stable ICU 3.0 |
97 */ | 93 */ |
98 inline const Formattable& getNumber() const; | 94 inline const Formattable& getNumber() const; |
99 | 95 |
100 /** | 96 /** |
101 * Return a reference to the unit of this object. | 97 * Return a reference to the unit of this object. |
102 * @stable ICU 3.0 | 98 * @stable ICU 3.0 |
103 */ | 99 */ |
104 inline const MeasureUnit& getUnit() const; | 100 inline const MeasureUnit& getUnit() const; |
105 | 101 |
| 102 /** |
| 103 * Return the class ID for this class. This is useful only for comparing to |
| 104 * a return value from getDynamicClassID(). For example: |
| 105 * <pre> |
| 106 * . Base* polymorphic_pointer = createPolymorphicObject(); |
| 107 * . if (polymorphic_pointer->getDynamicClassID() == |
| 108 * . erived::getStaticClassID()) ... |
| 109 * </pre> |
| 110 * @return The class ID for all objects of this class. |
| 111 * @draft ICU 53 |
| 112 */ |
| 113 static UClassID U_EXPORT2 getStaticClassID(void); |
| 114 |
| 115 /** |
| 116 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This |
| 117 * method is to implement a simple version of RTTI, since not all C++ |
| 118 * compilers support genuine RTTI. Polymorphic operator==() and clone() |
| 119 * methods call this method. |
| 120 * |
| 121 * @return The class ID for this object. All objects of a |
| 122 * given class have the same class ID. Objects of |
| 123 * other classes have different class IDs. |
| 124 * @draft ICU 53 |
| 125 */ |
| 126 virtual UClassID getDynamicClassID(void) const; |
| 127 |
106 protected: | 128 protected: |
107 /** | 129 /** |
108 * Default constructor. | 130 * Default constructor. |
109 * @stable ICU 3.0 | 131 * @stable ICU 3.0 |
110 */ | 132 */ |
111 Measure(); | 133 Measure(); |
112 | 134 |
113 private: | 135 private: |
114 /** | 136 /** |
115 * The numeric value of this object, e.g. 2.54 or 100. | 137 * The numeric value of this object, e.g. 2.54 or 100. |
(...skipping 12 matching lines...) Expand all Loading... |
128 } | 150 } |
129 | 151 |
130 inline const MeasureUnit& Measure::getUnit() const { | 152 inline const MeasureUnit& Measure::getUnit() const { |
131 return *unit; | 153 return *unit; |
132 } | 154 } |
133 | 155 |
134 U_NAMESPACE_END | 156 U_NAMESPACE_END |
135 | 157 |
136 #endif // !UCONFIG_NO_FORMATTING | 158 #endif // !UCONFIG_NO_FORMATTING |
137 #endif // __MEASURE_H__ | 159 #endif // __MEASURE_H__ |
OLD | NEW |