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