]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/unicode/measure.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 **********************************************************************
5 * Copyright (c) 2004-2015, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 **********************************************************************
9 * Created: April 26, 2004
11 **********************************************************************
16 #include "unicode/utypes.h"
18 #if U_SHOW_CPLUSPLUS_API
22 * \brief C++ API: MeasureUnit object.
25 #if !UCONFIG_NO_FORMATTING
27 #include "unicode/fmtable.h"
34 * An amount of a specified unit, consisting of a number and a Unit.
35 * For example, a length measure consists of a number and a length
36 * unit, such as feet or meters.
38 * <p>Measure objects are formatted by MeasureFormat.
40 * <p>Measure objects are immutable.
45 class U_I18N_API Measure
: public UObject
{
48 * Construct an object with the given numeric amount and the given
49 * unit. After this call, the caller must not delete the given
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.
57 Measure(const Formattable
& number
, MeasureUnit
* adoptedUnit
,
64 Measure(const Measure
& other
);
70 Measure
& operator=(const Measure
& other
);
73 * Return a polymorphic clone of this object. The result will
74 * have the same class as returned by getDynamicClassID().
77 virtual Measure
* clone() const;
86 * Equality operator. Return true if this object is equal
87 * to the given object.
90 UBool
operator==(const UObject
& other
) const;
93 * Return a reference to the numeric value of this object. The
94 * numeric value may be of any numeric type supported by
98 inline const Formattable
& getNumber() const;
101 * Return a reference to the unit of this object.
104 inline const MeasureUnit
& getUnit() const;
107 * Return the class ID for this class. This is useful only for comparing to
108 * a return value from getDynamicClassID(). For example:
110 * . Base* polymorphic_pointer = createPolymorphicObject();
111 * . if (polymorphic_pointer->getDynamicClassID() ==
112 * . erived::getStaticClassID()) ...
114 * @return The class ID for all objects of this class.
117 static UClassID U_EXPORT2
getStaticClassID(void);
120 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
121 * method is to implement a simple version of RTTI, since not all C++
122 * compilers support genuine RTTI. Polymorphic operator==() and clone()
123 * methods call this method.
125 * @return The class ID for this object. All objects of a
126 * given class have the same class ID. Objects of
127 * other classes have different class IDs.
130 virtual UClassID
getDynamicClassID(void) const;
134 * Default constructor.
141 * The numeric value of this object, e.g. 2.54 or 100.
146 * The unit of this object, e.g., "millimeter" or "JPY". This is
147 * owned by this object.
152 inline const Formattable
& Measure::getNumber() const {
156 inline const MeasureUnit
& Measure::getUnit() const {
162 #endif // !UCONFIG_NO_FORMATTING
164 #endif /* U_SHOW_CPLUSPLUS_API */
166 #endif // __MEASURE_H__