|
||||
File indexing completed on 2025-01-18 10:13:08
0001 // © 2016 and later: Unicode, Inc. and others. 0002 // License & terms of use: http://www.unicode.org/copyright.html 0003 /* 0004 ******************************************************************************* 0005 * Copyright (C) 2009-2010, Google, International Business Machines Corporation and * 0006 * others. All Rights Reserved. * 0007 ******************************************************************************* 0008 */ 0009 0010 #ifndef __TMUTAMT_H__ 0011 #define __TMUTAMT_H__ 0012 0013 0014 /** 0015 * \file 0016 * \brief C++ API: time unit amount object. 0017 */ 0018 0019 #include "unicode/utypes.h" 0020 0021 #if U_SHOW_CPLUSPLUS_API 0022 0023 #if !UCONFIG_NO_FORMATTING 0024 0025 #include "unicode/measure.h" 0026 #include "unicode/tmunit.h" 0027 0028 U_NAMESPACE_BEGIN 0029 0030 0031 /** 0032 * Express a duration as a time unit and number. Patterned after Currency. 0033 * @see TimeUnitAmount 0034 * @see TimeUnitFormat 0035 * @stable ICU 4.2 0036 */ 0037 class U_I18N_API TimeUnitAmount: public Measure { 0038 public: 0039 /** 0040 * Construct TimeUnitAmount object with the given number and the 0041 * given time unit. 0042 * @param number a numeric object; number.isNumeric() must be true 0043 * @param timeUnitField the time unit field of a time unit 0044 * @param status the input-output error code. 0045 * If the number is not numeric or the timeUnitField 0046 * is not valid, 0047 * then this will be set to a failing value: 0048 * U_ILLEGAL_ARGUMENT_ERROR. 0049 * @stable ICU 4.2 0050 */ 0051 TimeUnitAmount(const Formattable& number, 0052 TimeUnit::UTimeUnitFields timeUnitField, 0053 UErrorCode& status); 0054 0055 /** 0056 * Construct TimeUnitAmount object with the given numeric amount and the 0057 * given time unit. 0058 * @param amount a numeric amount. 0059 * @param timeUnitField the time unit field on which a time unit amount 0060 * object will be created. 0061 * @param status the input-output error code. 0062 * If the timeUnitField is not valid, 0063 * then this will be set to a failing value: 0064 * U_ILLEGAL_ARGUMENT_ERROR. 0065 * @stable ICU 4.2 0066 */ 0067 TimeUnitAmount(double amount, TimeUnit::UTimeUnitFields timeUnitField, 0068 UErrorCode& status); 0069 0070 0071 /** 0072 * Copy constructor 0073 * @stable ICU 4.2 0074 */ 0075 TimeUnitAmount(const TimeUnitAmount& other); 0076 0077 0078 /** 0079 * Assignment operator 0080 * @stable ICU 4.2 0081 */ 0082 TimeUnitAmount& operator=(const TimeUnitAmount& other); 0083 0084 0085 /** 0086 * Clone. 0087 * @return a polymorphic clone of this object. The result will have the same class as returned by getDynamicClassID(). 0088 * @stable ICU 4.2 0089 */ 0090 virtual TimeUnitAmount* clone() const override; 0091 0092 0093 /** 0094 * Destructor 0095 * @stable ICU 4.2 0096 */ 0097 virtual ~TimeUnitAmount(); 0098 0099 0100 /** 0101 * Equality operator. 0102 * @param other the object to compare to. 0103 * @return true if this object is equal to the given object. 0104 * @stable ICU 4.2 0105 */ 0106 virtual bool operator==(const UObject& other) const; 0107 0108 0109 /** 0110 * Not-equality operator. 0111 * @param other the object to compare to. 0112 * @return true if this object is not equal to the given object. 0113 * @stable ICU 4.2 0114 */ 0115 bool operator!=(const UObject& other) const; 0116 0117 0118 /** 0119 * Return the class ID for this class. This is useful only for comparing to 0120 * a return value from getDynamicClassID(). For example: 0121 * <pre> 0122 * . Base* polymorphic_pointer = createPolymorphicObject(); 0123 * . if (polymorphic_pointer->getDynamicClassID() == 0124 * . erived::getStaticClassID()) ... 0125 * </pre> 0126 * @return The class ID for all objects of this class. 0127 * @stable ICU 4.2 0128 */ 0129 static UClassID U_EXPORT2 getStaticClassID(void); 0130 0131 0132 /** 0133 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This 0134 * method is to implement a simple version of RTTI, since not all C++ 0135 * compilers support genuine RTTI. Polymorphic operator==() and clone() 0136 * methods call this method. 0137 * 0138 * @return The class ID for this object. All objects of a 0139 * given class have the same class ID. Objects of 0140 * other classes have different class IDs. 0141 * @stable ICU 4.2 0142 */ 0143 virtual UClassID getDynamicClassID(void) const override; 0144 0145 0146 /** 0147 * Get the time unit. 0148 * @return time unit object. 0149 * @stable ICU 4.2 0150 */ 0151 const TimeUnit& getTimeUnit() const; 0152 0153 /** 0154 * Get the time unit field value. 0155 * @return time unit field value. 0156 * @stable ICU 4.2 0157 */ 0158 TimeUnit::UTimeUnitFields getTimeUnitField() const; 0159 }; 0160 0161 0162 0163 inline bool 0164 TimeUnitAmount::operator!=(const UObject& other) const { 0165 return !operator==(other); 0166 } 0167 0168 U_NAMESPACE_END 0169 0170 #endif /* #if !UCONFIG_NO_FORMATTING */ 0171 0172 #endif /* U_SHOW_CPLUSPLUS_API */ 0173 0174 #endif // __TMUTAMT_H__ 0175 //eof 0176 //
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |