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