michael@0: /* michael@0: ******************************************************************************* michael@0: * Copyright (C) 2009-2010, Google, International Business Machines Corporation and * michael@0: * others. All Rights Reserved. * michael@0: ******************************************************************************* michael@0: */ michael@0: michael@0: #ifndef __TMUNIT_H__ michael@0: #define __TMUNIT_H__ michael@0: michael@0: michael@0: /** michael@0: * \file michael@0: * \brief C++ API: time unit object michael@0: */ michael@0: michael@0: michael@0: #include "unicode/measunit.h" michael@0: michael@0: #if !UCONFIG_NO_FORMATTING michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: /** michael@0: * Measurement unit for time units. michael@0: * @see TimeUnitAmount michael@0: * @see TimeUnit michael@0: * @stable ICU 4.2 michael@0: */ michael@0: class U_I18N_API TimeUnit: public MeasureUnit { michael@0: public: michael@0: /** michael@0: * Constants for all the time units we supported. michael@0: * @stable ICU 4.2 michael@0: */ michael@0: enum UTimeUnitFields { michael@0: UTIMEUNIT_YEAR, michael@0: UTIMEUNIT_MONTH, michael@0: UTIMEUNIT_DAY, michael@0: UTIMEUNIT_WEEK, michael@0: UTIMEUNIT_HOUR, michael@0: UTIMEUNIT_MINUTE, michael@0: UTIMEUNIT_SECOND, michael@0: UTIMEUNIT_FIELD_COUNT michael@0: }; michael@0: michael@0: /** michael@0: * Create Instance. michael@0: * @param timeUnitField time unit field based on which the instance michael@0: * is created. michael@0: * @param status input-output error code. michael@0: * If the timeUnitField is invalid, michael@0: * then this will be set to U_ILLEGAL_ARGUMENT_ERROR. michael@0: * @return a TimeUnit instance michael@0: * @stable ICU 4.2 michael@0: */ michael@0: static TimeUnit* U_EXPORT2 createInstance(UTimeUnitFields timeUnitField, michael@0: UErrorCode& status); michael@0: michael@0: michael@0: /** michael@0: * Override clone. michael@0: * @stable ICU 4.2 michael@0: */ michael@0: virtual UObject* clone() const; michael@0: michael@0: /** michael@0: * Copy operator. michael@0: * @stable ICU 4.2 michael@0: */ michael@0: TimeUnit(const TimeUnit& other); michael@0: michael@0: /** michael@0: * Assignment operator. michael@0: * @stable ICU 4.2 michael@0: */ michael@0: TimeUnit& operator=(const TimeUnit& other); michael@0: michael@0: /** michael@0: * Equality operator. michael@0: * @return true if 2 objects are the same. michael@0: * @stable ICU 4.2 michael@0: */ michael@0: virtual UBool operator==(const UObject& other) const; michael@0: michael@0: /** michael@0: * Non-Equality operator. michael@0: * @return true if 2 objects are not the same. michael@0: * @stable ICU 4.2 michael@0: */ michael@0: UBool operator!=(const UObject& other) const; michael@0: michael@0: /** michael@0: * Returns a unique class ID for this object POLYMORPHICALLY. michael@0: * This method implements a simple form of RTTI used by ICU. michael@0: * @return The class ID for this object. All objects of a given michael@0: * class have the same class ID. Objects of other classes have michael@0: * different class IDs. michael@0: * @stable ICU 4.2 michael@0: */ michael@0: virtual UClassID getDynamicClassID() const; michael@0: michael@0: /** michael@0: * Returns the class ID for this class. This is used to compare to michael@0: * the return value of getDynamicClassID(). michael@0: * @return The class ID for all objects of this class. michael@0: * @stable ICU 4.2 michael@0: */ michael@0: static UClassID U_EXPORT2 getStaticClassID(); michael@0: michael@0: michael@0: /** michael@0: * Get time unit field. michael@0: * @return time unit field. michael@0: * @stable ICU 4.2 michael@0: */ michael@0: UTimeUnitFields getTimeUnitField() const; michael@0: michael@0: /** michael@0: * Destructor. michael@0: * @stable ICU 4.2 michael@0: */ michael@0: virtual ~TimeUnit(); michael@0: michael@0: private: michael@0: UTimeUnitFields fTimeUnitField; michael@0: michael@0: /** michael@0: * Constructor michael@0: * @internal ICU 4.2 michael@0: */ michael@0: TimeUnit(UTimeUnitFields timeUnitField); michael@0: michael@0: }; michael@0: michael@0: michael@0: inline UBool michael@0: TimeUnit::operator!=(const UObject& other) const { michael@0: return !operator==(other); michael@0: } michael@0: michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif /* #if !UCONFIG_NO_FORMATTING */ michael@0: michael@0: #endif // __TMUNIT_H__ michael@0: //eof michael@0: //