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