intl/icu/source/i18n/unicode/tmutamt.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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) 2009-2010, Google, International Business Machines Corporation and *
michael@0 4 * others. All Rights Reserved. *
michael@0 5 *******************************************************************************
michael@0 6 */
michael@0 7
michael@0 8 #ifndef __TMUTAMT_H__
michael@0 9 #define __TMUTAMT_H__
michael@0 10
michael@0 11
michael@0 12 /**
michael@0 13 * \file
michael@0 14 * \brief C++ API: time unit amount object.
michael@0 15 */
michael@0 16
michael@0 17 #include "unicode/measure.h"
michael@0 18 #include "unicode/tmunit.h"
michael@0 19
michael@0 20 #if !UCONFIG_NO_FORMATTING
michael@0 21
michael@0 22 U_NAMESPACE_BEGIN
michael@0 23
michael@0 24
michael@0 25 /**
michael@0 26 * Express a duration as a time unit and number. Patterned after Currency.
michael@0 27 * @see TimeUnitAmount
michael@0 28 * @see TimeUnitFormat
michael@0 29 * @stable ICU 4.2
michael@0 30 */
michael@0 31 class U_I18N_API TimeUnitAmount: public Measure {
michael@0 32 public:
michael@0 33 /**
michael@0 34 * Construct TimeUnitAmount object with the given number and the
michael@0 35 * given time unit.
michael@0 36 * @param number a numeric object; number.isNumeric() must be TRUE
michael@0 37 * @param timeUnitField the time unit field of a time unit
michael@0 38 * @param status the input-output error code.
michael@0 39 * If the number is not numeric or the timeUnitField
michael@0 40 * is not valid,
michael@0 41 * then this will be set to a failing value:
michael@0 42 * U_ILLEGAL_ARGUMENT_ERROR.
michael@0 43 * @stable ICU 4.2
michael@0 44 */
michael@0 45 TimeUnitAmount(const Formattable& number,
michael@0 46 TimeUnit::UTimeUnitFields timeUnitField,
michael@0 47 UErrorCode& status);
michael@0 48
michael@0 49 /**
michael@0 50 * Construct TimeUnitAmount object with the given numeric amount and the
michael@0 51 * given time unit.
michael@0 52 * @param amount a numeric amount.
michael@0 53 * @param timeUnitField the time unit field on which a time unit amount
michael@0 54 * object will be created.
michael@0 55 * @param status the input-output error code.
michael@0 56 * If the timeUnitField is not valid,
michael@0 57 * then this will be set to a failing value:
michael@0 58 * U_ILLEGAL_ARGUMENT_ERROR.
michael@0 59 * @stable ICU 4.2
michael@0 60 */
michael@0 61 TimeUnitAmount(double amount, TimeUnit::UTimeUnitFields timeUnitField,
michael@0 62 UErrorCode& status);
michael@0 63
michael@0 64
michael@0 65 /**
michael@0 66 * Copy constructor
michael@0 67 * @stable ICU 4.2
michael@0 68 */
michael@0 69 TimeUnitAmount(const TimeUnitAmount& other);
michael@0 70
michael@0 71
michael@0 72 /**
michael@0 73 * Assignment operator
michael@0 74 * @stable ICU 4.2
michael@0 75 */
michael@0 76 TimeUnitAmount& operator=(const TimeUnitAmount& other);
michael@0 77
michael@0 78
michael@0 79 /**
michael@0 80 * Clone.
michael@0 81 * @return a polymorphic clone of this object. The result will have the same class as returned by getDynamicClassID().
michael@0 82 * @stable ICU 4.2
michael@0 83 */
michael@0 84 virtual UObject* clone() const;
michael@0 85
michael@0 86
michael@0 87 /**
michael@0 88 * Destructor
michael@0 89 * @stable ICU 4.2
michael@0 90 */
michael@0 91 virtual ~TimeUnitAmount();
michael@0 92
michael@0 93
michael@0 94 /**
michael@0 95 * Equality operator.
michael@0 96 * @param other the object to compare to.
michael@0 97 * @return true if this object is equal to the given object.
michael@0 98 * @stable ICU 4.2
michael@0 99 */
michael@0 100 virtual UBool operator==(const UObject& other) const;
michael@0 101
michael@0 102
michael@0 103 /**
michael@0 104 * Not-equality operator.
michael@0 105 * @param other the object to compare to.
michael@0 106 * @return true if this object is not equal to the given object.
michael@0 107 * @stable ICU 4.2
michael@0 108 */
michael@0 109 UBool operator!=(const UObject& other) const;
michael@0 110
michael@0 111
michael@0 112 /**
michael@0 113 * Return the class ID for this class. This is useful only for comparing to
michael@0 114 * a return value from getDynamicClassID(). For example:
michael@0 115 * <pre>
michael@0 116 * . Base* polymorphic_pointer = createPolymorphicObject();
michael@0 117 * . if (polymorphic_pointer->getDynamicClassID() ==
michael@0 118 * . erived::getStaticClassID()) ...
michael@0 119 * </pre>
michael@0 120 * @return The class ID for all objects of this class.
michael@0 121 * @stable ICU 4.2
michael@0 122 */
michael@0 123 static UClassID U_EXPORT2 getStaticClassID(void);
michael@0 124
michael@0 125
michael@0 126 /**
michael@0 127 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
michael@0 128 * method is to implement a simple version of RTTI, since not all C++
michael@0 129 * compilers support genuine RTTI. Polymorphic operator==() and clone()
michael@0 130 * methods call this method.
michael@0 131 *
michael@0 132 * @return The class ID for this object. All objects of a
michael@0 133 * given class have the same class ID. Objects of
michael@0 134 * other classes have different class IDs.
michael@0 135 * @stable ICU 4.2
michael@0 136 */
michael@0 137 virtual UClassID getDynamicClassID(void) const;
michael@0 138
michael@0 139
michael@0 140 /**
michael@0 141 * Get the time unit.
michael@0 142 * @return time unit object.
michael@0 143 * @stable ICU 4.2
michael@0 144 */
michael@0 145 const TimeUnit& getTimeUnit() const;
michael@0 146
michael@0 147 /**
michael@0 148 * Get the time unit field value.
michael@0 149 * @return time unit field value.
michael@0 150 * @stable ICU 4.2
michael@0 151 */
michael@0 152 TimeUnit::UTimeUnitFields getTimeUnitField() const;
michael@0 153 };
michael@0 154
michael@0 155
michael@0 156
michael@0 157 inline UBool
michael@0 158 TimeUnitAmount::operator!=(const UObject& other) const {
michael@0 159 return !operator==(other);
michael@0 160 }
michael@0 161
michael@0 162 U_NAMESPACE_END
michael@0 163
michael@0 164 #endif /* #if !UCONFIG_NO_FORMATTING */
michael@0 165
michael@0 166 #endif // __TMUTAMT_H__
michael@0 167 //eof
michael@0 168 //

mercurial