]> git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/unicode/tmunit.h
ICU-461.12.tar.gz
[apple/icu.git] / icuSources / i18n / unicode / tmunit.h
1 /*
2 *******************************************************************************
3 * Copyright (C) 2009-2010, Google, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 *******************************************************************************
6 */
7
8 #ifndef __TMUNIT_H__
9 #define __TMUNIT_H__
10
11
12 /**
13 * \file
14 * \brief C++ API: time unit object
15 */
16
17
18 #include "unicode/measunit.h"
19
20 #if !UCONFIG_NO_FORMATTING
21
22 U_NAMESPACE_BEGIN
23
24 /**
25 * Measurement unit for time units.
26 * @see TimeUnitAmount
27 * @see TimeUnit
28 * @stable ICU 4.2
29 */
30 class U_I18N_API TimeUnit: public MeasureUnit {
31 public:
32 /**
33 * Constants for all the time units we supported.
34 * @stable ICU 4.2
35 */
36 enum UTimeUnitFields {
37 UTIMEUNIT_YEAR,
38 UTIMEUNIT_MONTH,
39 UTIMEUNIT_DAY,
40 UTIMEUNIT_WEEK,
41 UTIMEUNIT_HOUR,
42 UTIMEUNIT_MINUTE,
43 UTIMEUNIT_SECOND,
44 UTIMEUNIT_FIELD_COUNT
45 };
46
47 /**
48 * Create Instance.
49 * @param timeUnitField time unit field based on which the instance
50 * is created.
51 * @param status input-output error code.
52 * If the timeUnitField is invalid,
53 * then this will be set to U_ILLEGAL_ARGUMENT_ERROR.
54 * @return a TimeUnit instance
55 * @stable ICU 4.2
56 */
57 static TimeUnit* U_EXPORT2 createInstance(UTimeUnitFields timeUnitField,
58 UErrorCode& status);
59
60
61 /**
62 * Override clone.
63 * @stable ICU 4.2
64 */
65 virtual UObject* clone() const;
66
67 /**
68 * Copy operator.
69 * @stable ICU 4.2
70 */
71 TimeUnit(const TimeUnit& other);
72
73 /**
74 * Assignment operator.
75 * @stable ICU 4.2
76 */
77 TimeUnit& operator=(const TimeUnit& other);
78
79 /**
80 * Equality operator.
81 * @return true if 2 objects are the same.
82 * @stable ICU 4.2
83 */
84 virtual UBool operator==(const UObject& other) const;
85
86 /**
87 * Non-Equality operator.
88 * @return true if 2 objects are not the same.
89 * @stable ICU 4.2
90 */
91 UBool operator!=(const UObject& other) const;
92
93 /**
94 * Returns a unique class ID for this object POLYMORPHICALLY.
95 * This method implements a simple form of RTTI used by ICU.
96 * @return The class ID for this object. All objects of a given
97 * class have the same class ID. Objects of other classes have
98 * different class IDs.
99 * @stable ICU 4.2
100 */
101 virtual UClassID getDynamicClassID() const;
102
103 /**
104 * Returns the class ID for this class. This is used to compare to
105 * the return value of getDynamicClassID().
106 * @return The class ID for all objects of this class.
107 * @stable ICU 4.2
108 */
109 static UClassID U_EXPORT2 getStaticClassID();
110
111
112 /**
113 * Get time unit field.
114 * @return time unit field.
115 * @stable ICU 4.2
116 */
117 UTimeUnitFields getTimeUnitField() const;
118
119 /**
120 * Destructor.
121 * @stable ICU 4.2
122 */
123 virtual ~TimeUnit();
124
125 private:
126 UTimeUnitFields fTimeUnitField;
127
128 /**
129 * Constructor
130 * @internal ICU 4.2
131 */
132 TimeUnit(UTimeUnitFields timeUnitField);
133
134 };
135
136
137 inline UBool
138 TimeUnit::operator!=(const UObject& other) const {
139 return !operator==(other);
140 }
141
142
143 U_NAMESPACE_END
144
145 #endif /* #if !UCONFIG_NO_FORMATTING */
146
147 #endif // __TMUNIT_H__
148 //eof
149 //