ICU 74.2 74.2
Public Member Functions | Static Public Member Functions
icu::TimeUnitAmount Class Reference

Express a duration as a time unit and number. More...

#include <tmutamt.h>

Inheritance diagram for icu::TimeUnitAmount:
icu::Measure icu::UObject icu::UMemory

Public Member Functions

 TimeUnitAmount (const Formattable &number, TimeUnit::UTimeUnitFields timeUnitField, UErrorCode &status)
 Construct TimeUnitAmount object with the given number and the given time unit.
 
 TimeUnitAmount (double amount, TimeUnit::UTimeUnitFields timeUnitField, UErrorCode &status)
 Construct TimeUnitAmount object with the given numeric amount and the given time unit.
 
 TimeUnitAmount (const TimeUnitAmount &other)
 Copy constructor.
 
TimeUnitAmountoperator= (const TimeUnitAmount &other)
 Assignment operator.
 
virtual TimeUnitAmountclone () const override
 Clone.
 
virtual ~TimeUnitAmount ()
 Destructor.
 
virtual bool operator== (const UObject &other) const
 Equality operator.
 
bool operator!= (const UObject &other) const
 Not-equality operator.
 
virtual UClassID getDynamicClassID (void) const override
 Returns a unique class ID POLYMORPHICALLY.
 
const TimeUnitgetTimeUnit () const
 Get the time unit.
 
TimeUnit::UTimeUnitFields getTimeUnitField () const
 Get the time unit field value.
 
- Public Member Functions inherited from icu::Measure
 Measure (const Formattable &number, MeasureUnit *adoptedUnit, UErrorCode &ec)
 Construct an object with the given numeric amount and the given unit.
 
 Measure (const Measure &other)
 Copy constructor.
 
Measureoperator= (const Measure &other)
 Assignment operator.
 
virtual ~Measure ()
 Destructor.
 
bool operator== (const UObject &other) const
 Equality operator.
 
bool operator!= (const UObject &other) const
 Inequality operator.
 
const FormattablegetNumber () const
 Return a reference to the numeric value of this object.
 
const MeasureUnitgetUnit () const
 Return a reference to the unit of this object.
 
- Public Member Functions inherited from icu::UObject
virtual ~UObject ()
 Destructor.
 

Static Public Member Functions

static UClassID getStaticClassID (void)
 Return the class ID for this class.
 
- Static Public Member Functions inherited from icu::Measure
static UClassID getStaticClassID (void)
 Return the class ID for this class.
 

Additional Inherited Members

- Protected Member Functions inherited from icu::Measure
 Measure ()
 Default constructor.
 

Detailed Description

Express a duration as a time unit and number.

Patterned after Currency.

See also
TimeUnitAmount
TimeUnitFormat
Stable
ICU 4.2

Definition at line 37 of file tmutamt.h.

Constructor & Destructor Documentation

◆ TimeUnitAmount() [1/3]

icu::TimeUnitAmount::TimeUnitAmount ( const Formattable & number,
TimeUnit::UTimeUnitFields timeUnitField,
UErrorCode & status )

Construct TimeUnitAmount object with the given number and the given time unit.

Parameters
numbera numeric object; number.isNumeric() must be true
timeUnitFieldthe time unit field of a time unit
statusthe input-output error code. If the number is not numeric or the timeUnitField is not valid, then this will be set to a failing value: U_ILLEGAL_ARGUMENT_ERROR.
Stable
ICU 4.2

◆ TimeUnitAmount() [2/3]

icu::TimeUnitAmount::TimeUnitAmount ( double amount,
TimeUnit::UTimeUnitFields timeUnitField,
UErrorCode & status )

Construct TimeUnitAmount object with the given numeric amount and the given time unit.

Parameters
amounta numeric amount.
timeUnitFieldthe time unit field on which a time unit amount object will be created.
statusthe input-output error code. If the timeUnitField is not valid, then this will be set to a failing value: U_ILLEGAL_ARGUMENT_ERROR.
Stable
ICU 4.2

◆ TimeUnitAmount() [3/3]

icu::TimeUnitAmount::TimeUnitAmount ( const TimeUnitAmount & other)

Copy constructor.

Stable
ICU 4.2

◆ ~TimeUnitAmount()

virtual icu::TimeUnitAmount::~TimeUnitAmount ( )
virtual

Destructor.

Stable
ICU 4.2

Member Function Documentation

◆ clone()

virtual TimeUnitAmount * icu::TimeUnitAmount::clone ( ) const
overridevirtual

Clone.

Returns
a polymorphic clone of this object. The result will have the same class as returned by getDynamicClassID().
Stable
ICU 4.2

Reimplemented from icu::Measure.

◆ getDynamicClassID()

virtual UClassID icu::TimeUnitAmount::getDynamicClassID ( void ) const
overridevirtual

Returns a unique class ID POLYMORPHICALLY.

Pure virtual override. This method is to implement a simple version of RTTI, since not all C++ compilers support genuine RTTI. Polymorphic operator==() and clone() methods call this method.

Returns
The class ID for this object. All objects of a given class have the same class ID. Objects of other classes have different class IDs.
Stable
ICU 4.2

Reimplemented from icu::Measure.

◆ getStaticClassID()

static UClassID icu::TimeUnitAmount::getStaticClassID ( void )
static

Return the class ID for this class.

This is useful only for comparing to a return value from getDynamicClassID(). For example:

.   Base* polymorphic_pointer = createPolymorphicObject();
.   if (polymorphic_pointer->getDynamicClassID() ==
.       erived::getStaticClassID()) ...
Returns
The class ID for all objects of this class.
Stable
ICU 4.2

◆ getTimeUnit()

const TimeUnit & icu::TimeUnitAmount::getTimeUnit ( ) const

Get the time unit.

Returns
time unit object.
Stable
ICU 4.2

◆ getTimeUnitField()

TimeUnit::UTimeUnitFields icu::TimeUnitAmount::getTimeUnitField ( ) const

Get the time unit field value.

Returns
time unit field value.
Stable
ICU 4.2

◆ operator!=()

bool icu::TimeUnitAmount::operator!= ( const UObject & other) const
inline

Not-equality operator.


Parameters
otherthe object to compare to.
Returns
true if this object is not equal to the given object.
Stable
ICU 4.2

Definition at line 164 of file tmutamt.h.

References icu::operator==().

◆ operator=()

TimeUnitAmount & icu::TimeUnitAmount::operator= ( const TimeUnitAmount & other)

Assignment operator.

Stable
ICU 4.2

◆ operator==()

virtual bool icu::TimeUnitAmount::operator== ( const UObject & other) const
virtual

Equality operator.


Parameters
otherthe object to compare to.
Returns
true if this object is equal to the given object.
Stable
ICU 4.2

The documentation for this class was generated from the following file: