annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/unicode/tmutamt.h @ 69:33d812a61356

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