OLD | NEW |
| (Empty) |
1 /* | |
2 ********************************************************************** | |
3 * Copyright (c) 2004-2006, International Business Machines | |
4 * Corporation and others. All Rights Reserved. | |
5 ********************************************************************** | |
6 * Author: Alan Liu | |
7 * Created: April 26, 2004 | |
8 * Since: ICU 3.0 | |
9 ********************************************************************** | |
10 */ | |
11 #ifndef __MEASURE_H__ | |
12 #define __MEASURE_H__ | |
13 | |
14 #include "unicode/utypes.h" | |
15 | |
16 /** | |
17 * \file | |
18 * \brief C++ API: MeasureUnit object. | |
19 */ | |
20 | |
21 #if !UCONFIG_NO_FORMATTING | |
22 | |
23 #include "unicode/fmtable.h" | |
24 | |
25 U_NAMESPACE_BEGIN | |
26 | |
27 class MeasureUnit; | |
28 | |
29 /** | |
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 | |
32 * unit, such as feet or meters. This is an abstract class. | |
33 * Subclasses specify a concrete Unit type. | |
34 * | |
35 * <p>Measure objects are parsed and formatted by subclasses of | |
36 * MeasureFormat. | |
37 * | |
38 * <p>Measure objects are immutable. | |
39 * | |
40 * <p>This is an abstract class. | |
41 * | |
42 * @author Alan Liu | |
43 * @stable ICU 3.0 | |
44 */ | |
45 class U_I18N_API Measure: public UObject { | |
46 public: | |
47 /** | |
48 * Construct an object with the given numeric amount and the given | |
49 * unit. After this call, the caller must not delete the given | |
50 * unit object. | |
51 * @param number a numeric object; amount.isNumeric() must be TRUE | |
52 * @param adoptedUnit the unit object, which must not be NULL | |
53 * @param ec input-output error code. If the amount or the unit | |
54 * is invalid, then this will be set to a failing value. | |
55 * @stable ICU 3.0 | |
56 */ | |
57 Measure(const Formattable& number, MeasureUnit* adoptedUnit, | |
58 UErrorCode& ec); | |
59 | |
60 /** | |
61 * Copy constructor | |
62 * @stable ICU 3.0 | |
63 */ | |
64 Measure(const Measure& other); | |
65 | |
66 /** | |
67 * Assignment operator | |
68 * @stable ICU 3.0 | |
69 */ | |
70 Measure& operator=(const Measure& other); | |
71 | |
72 /** | |
73 * Return a polymorphic clone of this object. The result will | |
74 * have the same class as returned by getDynamicClassID(). | |
75 * @stable ICU 3.0 | |
76 */ | |
77 virtual UObject* clone() const = 0; | |
78 | |
79 /** | |
80 * Destructor | |
81 * @stable ICU 3.0 | |
82 */ | |
83 virtual ~Measure(); | |
84 | |
85 /** | |
86 * Equality operator. Return true if this object is equal | |
87 * to the given object. | |
88 * @stable ICU 3.0 | |
89 */ | |
90 UBool operator==(const UObject& other) const; | |
91 | |
92 /** | |
93 * Return a reference to the numeric value of this object. The | |
94 * numeric value may be of any numeric type supported by | |
95 * Formattable. | |
96 * @stable ICU 3.0 | |
97 */ | |
98 inline const Formattable& getNumber() const; | |
99 | |
100 /** | |
101 * Return a reference to the unit of this object. | |
102 * @stable ICU 3.0 | |
103 */ | |
104 inline const MeasureUnit& getUnit() const; | |
105 | |
106 protected: | |
107 /** | |
108 * Default constructor. | |
109 * @stable ICU 3.0 | |
110 */ | |
111 Measure(); | |
112 | |
113 private: | |
114 /** | |
115 * The numeric value of this object, e.g. 2.54 or 100. | |
116 */ | |
117 Formattable number; | |
118 | |
119 /** | |
120 * The unit of this object, e.g., "millimeter" or "JPY". This is | |
121 * owned by this object. | |
122 */ | |
123 MeasureUnit* unit; | |
124 }; | |
125 | |
126 inline const Formattable& Measure::getNumber() const { | |
127 return number; | |
128 } | |
129 | |
130 inline const MeasureUnit& Measure::getUnit() const { | |
131 return *unit; | |
132 } | |
133 | |
134 U_NAMESPACE_END | |
135 | |
136 #endif // !UCONFIG_NO_FORMATTING | |
137 #endif // __MEASURE_H__ | |
OLD | NEW |