Measure objects are formatted by MeasureFormat. 39 * 40 *
Measure objects are immutable. 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 nullptr 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 Measure* clone() const; 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 bool operator==(const UObject& other) const; 91 92 #ifndef U_HIDE_DRAFT_API 93 /** 94 * Inequality operator. Returns true if this object is not equal to the other object. 95 * @param other the object to compare with 96 * @return true if the objects are not equal 97 * @draft ICU 74 98 */ 99 inline bool operator!=(const UObject& other) const { return !operator==(other); } 100 #endif // U_HIDE_DRAFT_API 101 102 /** 103 * Return a reference to the numeric value of this object. The 104 * numeric value may be of any numeric type supported by 105 * Formattable. 106 * @stable ICU 3.0 107 */ 108 inline const Formattable& getNumber() const; 109 110 /** 111 * Return a reference to the unit of this object. 112 * @stable ICU 3.0 113 */ 114 inline const MeasureUnit& getUnit() const; 115 116 /** 117 * Return the class ID for this class. This is useful only for comparing to 118 * a return value from getDynamicClassID(). For example: 119 *
120 * . Base* polymorphic_pointer = createPolymorphicObject(); 121 * . if (polymorphic_pointer->getDynamicClassID() == 122 * . erived::getStaticClassID()) ... 123 *