1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/i18n/unicode/tmunit.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,149 @@ 1.4 +/* 1.5 + ******************************************************************************* 1.6 + * Copyright (C) 2009-2010, Google, International Business Machines Corporation and * 1.7 + * others. All Rights Reserved. * 1.8 + ******************************************************************************* 1.9 + */ 1.10 + 1.11 +#ifndef __TMUNIT_H__ 1.12 +#define __TMUNIT_H__ 1.13 + 1.14 + 1.15 +/** 1.16 + * \file 1.17 + * \brief C++ API: time unit object 1.18 + */ 1.19 + 1.20 + 1.21 +#include "unicode/measunit.h" 1.22 + 1.23 +#if !UCONFIG_NO_FORMATTING 1.24 + 1.25 +U_NAMESPACE_BEGIN 1.26 + 1.27 +/** 1.28 + * Measurement unit for time units. 1.29 + * @see TimeUnitAmount 1.30 + * @see TimeUnit 1.31 + * @stable ICU 4.2 1.32 + */ 1.33 +class U_I18N_API TimeUnit: public MeasureUnit { 1.34 +public: 1.35 + /** 1.36 + * Constants for all the time units we supported. 1.37 + * @stable ICU 4.2 1.38 + */ 1.39 + enum UTimeUnitFields { 1.40 + UTIMEUNIT_YEAR, 1.41 + UTIMEUNIT_MONTH, 1.42 + UTIMEUNIT_DAY, 1.43 + UTIMEUNIT_WEEK, 1.44 + UTIMEUNIT_HOUR, 1.45 + UTIMEUNIT_MINUTE, 1.46 + UTIMEUNIT_SECOND, 1.47 + UTIMEUNIT_FIELD_COUNT 1.48 + }; 1.49 + 1.50 + /** 1.51 + * Create Instance. 1.52 + * @param timeUnitField time unit field based on which the instance 1.53 + * is created. 1.54 + * @param status input-output error code. 1.55 + * If the timeUnitField is invalid, 1.56 + * then this will be set to U_ILLEGAL_ARGUMENT_ERROR. 1.57 + * @return a TimeUnit instance 1.58 + * @stable ICU 4.2 1.59 + */ 1.60 + static TimeUnit* U_EXPORT2 createInstance(UTimeUnitFields timeUnitField, 1.61 + UErrorCode& status); 1.62 + 1.63 + 1.64 + /** 1.65 + * Override clone. 1.66 + * @stable ICU 4.2 1.67 + */ 1.68 + virtual UObject* clone() const; 1.69 + 1.70 + /** 1.71 + * Copy operator. 1.72 + * @stable ICU 4.2 1.73 + */ 1.74 + TimeUnit(const TimeUnit& other); 1.75 + 1.76 + /** 1.77 + * Assignment operator. 1.78 + * @stable ICU 4.2 1.79 + */ 1.80 + TimeUnit& operator=(const TimeUnit& other); 1.81 + 1.82 + /** 1.83 + * Equality operator. 1.84 + * @return true if 2 objects are the same. 1.85 + * @stable ICU 4.2 1.86 + */ 1.87 + virtual UBool operator==(const UObject& other) const; 1.88 + 1.89 + /** 1.90 + * Non-Equality operator. 1.91 + * @return true if 2 objects are not the same. 1.92 + * @stable ICU 4.2 1.93 + */ 1.94 + UBool operator!=(const UObject& other) const; 1.95 + 1.96 + /** 1.97 + * Returns a unique class ID for this object POLYMORPHICALLY. 1.98 + * This method implements a simple form of RTTI used by ICU. 1.99 + * @return The class ID for this object. All objects of a given 1.100 + * class have the same class ID. Objects of other classes have 1.101 + * different class IDs. 1.102 + * @stable ICU 4.2 1.103 + */ 1.104 + virtual UClassID getDynamicClassID() const; 1.105 + 1.106 + /** 1.107 + * Returns the class ID for this class. This is used to compare to 1.108 + * the return value of getDynamicClassID(). 1.109 + * @return The class ID for all objects of this class. 1.110 + * @stable ICU 4.2 1.111 + */ 1.112 + static UClassID U_EXPORT2 getStaticClassID(); 1.113 + 1.114 + 1.115 + /** 1.116 + * Get time unit field. 1.117 + * @return time unit field. 1.118 + * @stable ICU 4.2 1.119 + */ 1.120 + UTimeUnitFields getTimeUnitField() const; 1.121 + 1.122 + /** 1.123 + * Destructor. 1.124 + * @stable ICU 4.2 1.125 + */ 1.126 + virtual ~TimeUnit(); 1.127 + 1.128 +private: 1.129 + UTimeUnitFields fTimeUnitField; 1.130 + 1.131 + /** 1.132 + * Constructor 1.133 + * @internal ICU 4.2 1.134 + */ 1.135 + TimeUnit(UTimeUnitFields timeUnitField); 1.136 + 1.137 +}; 1.138 + 1.139 + 1.140 +inline UBool 1.141 +TimeUnit::operator!=(const UObject& other) const { 1.142 + return !operator==(other); 1.143 +} 1.144 + 1.145 + 1.146 +U_NAMESPACE_END 1.147 + 1.148 +#endif /* #if !UCONFIG_NO_FORMATTING */ 1.149 + 1.150 +#endif // __TMUNIT_H__ 1.151 +//eof 1.152 +//