]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
46f4442e A |
3 | /* |
4 | ******************************************************************************* | |
729e4ab9 | 5 | * Copyright (C) 2008-2009, International Business Machines Corporation and |
46f4442e A |
6 | * others. All Rights Reserved. |
7 | ******************************************************************************* | |
8 | * | |
9 | * File DTINTRV.H | |
10 | * | |
11 | ******************************************************************************* | |
12 | */ | |
13 | ||
14 | #ifndef __DTINTRV_H__ | |
15 | #define __DTINTRV_H__ | |
16 | ||
17 | #include "unicode/utypes.h" | |
340931cb A |
18 | |
19 | #if U_SHOW_CPLUSPLUS_API | |
20 | ||
46f4442e A |
21 | #include "unicode/uobject.h" |
22 | ||
23 | /** | |
24 | * \file | |
25 | * \brief C++ API: Date Interval data type | |
26 | */ | |
27 | ||
46f4442e A |
28 | U_NAMESPACE_BEGIN |
29 | ||
30 | ||
31 | /** | |
32 | * This class represents a date interval. | |
33 | * It is a pair of UDate representing from UDate 1 to UDate 2. | |
729e4ab9 | 34 | * @stable ICU 4.0 |
46f4442e A |
35 | **/ |
36 | class U_COMMON_API DateInterval : public UObject { | |
37 | public: | |
38 | ||
39 | /** | |
40 | * Construct a DateInterval given a from date and a to date. | |
41 | * @param fromDate The from date in date interval. | |
42 | * @param toDate The to date in date interval. | |
729e4ab9 | 43 | * @stable ICU 4.0 |
46f4442e A |
44 | */ |
45 | DateInterval(UDate fromDate, UDate toDate); | |
46 | ||
47 | /** | |
48 | * destructor | |
729e4ab9 | 49 | * @stable ICU 4.0 |
46f4442e A |
50 | */ |
51 | virtual ~DateInterval(); | |
52 | ||
53 | /** | |
54 | * Get the from date. | |
55 | * @return the from date in dateInterval. | |
729e4ab9 | 56 | * @stable ICU 4.0 |
46f4442e | 57 | */ |
3d1f044b | 58 | inline UDate getFromDate() const; |
46f4442e A |
59 | |
60 | /** | |
61 | * Get the to date. | |
62 | * @return the to date in dateInterval. | |
729e4ab9 | 63 | * @stable ICU 4.0 |
46f4442e | 64 | */ |
3d1f044b | 65 | inline UDate getToDate() const; |
46f4442e A |
66 | |
67 | ||
68 | /** | |
69 | * Return the class ID for this class. This is useful only for comparing to | |
70 | * a return value from getDynamicClassID(). For example: | |
71 | * <pre> | |
72 | * . Base* polymorphic_pointer = createPolymorphicObject(); | |
73 | * . if (polymorphic_pointer->getDynamicClassID() == | |
0f5d89e8 | 74 | * . derived::getStaticClassID()) ... |
46f4442e A |
75 | * </pre> |
76 | * @return The class ID for all objects of this class. | |
729e4ab9 | 77 | * @stable ICU 4.0 |
46f4442e A |
78 | */ |
79 | static UClassID U_EXPORT2 getStaticClassID(void); | |
80 | ||
81 | /** | |
82 | * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This | |
83 | * method is to implement a simple version of RTTI, since not all C++ | |
84 | * compilers support genuine RTTI. Polymorphic operator==() and clone() | |
85 | * methods call this method. | |
86 | * | |
87 | * @return The class ID for this object. All objects of a | |
88 | * given class have the same class ID. Objects of | |
89 | * other classes have different class IDs. | |
729e4ab9 | 90 | * @stable ICU 4.0 |
46f4442e A |
91 | */ |
92 | virtual UClassID getDynamicClassID(void) const; | |
93 | ||
94 | ||
95 | /** | |
96 | * Copy constructor. | |
729e4ab9 | 97 | * @stable ICU 4.0 |
46f4442e A |
98 | */ |
99 | DateInterval(const DateInterval& other); | |
100 | ||
101 | /** | |
102 | * Default assignment operator | |
729e4ab9 | 103 | * @stable ICU 4.0 |
46f4442e A |
104 | */ |
105 | DateInterval& operator=(const DateInterval&); | |
106 | ||
107 | /** | |
108 | * Equality operator. | |
109 | * @return TRUE if the two DateIntervals are the same | |
729e4ab9 | 110 | * @stable ICU 4.0 |
46f4442e A |
111 | */ |
112 | virtual UBool operator==(const DateInterval& other) const; | |
113 | ||
114 | /** | |
115 | * Non-equality operator | |
116 | * @return TRUE if the two DateIntervals are not the same | |
729e4ab9 | 117 | * @stable ICU 4.0 |
46f4442e | 118 | */ |
3d1f044b | 119 | inline UBool operator!=(const DateInterval& other) const; |
46f4442e A |
120 | |
121 | ||
122 | /** | |
123 | * clone this object. | |
124 | * The caller owns the result and should delete it when done. | |
125 | * @return a cloned DateInterval | |
729e4ab9 | 126 | * @stable ICU 4.0 |
46f4442e A |
127 | */ |
128 | virtual DateInterval* clone() const; | |
129 | ||
130 | private: | |
131 | /** | |
132 | * Default constructor, not implemented. | |
46f4442e A |
133 | */ |
134 | DateInterval(); | |
135 | ||
136 | UDate fromDate; | |
137 | UDate toDate; | |
138 | ||
139 | } ;// end class DateInterval | |
140 | ||
141 | ||
142 | inline UDate | |
143 | DateInterval::getFromDate() const { | |
144 | return fromDate; | |
145 | } | |
146 | ||
147 | ||
148 | inline UDate | |
149 | DateInterval::getToDate() const { | |
150 | return toDate; | |
151 | } | |
152 | ||
153 | ||
154 | inline UBool | |
155 | DateInterval::operator!=(const DateInterval& other) const { | |
156 | return ( !operator==(other) ); | |
157 | } | |
158 | ||
159 | ||
160 | U_NAMESPACE_END | |
340931cb A |
161 | |
162 | #endif /* U_SHOW_CPLUSPLUS_API */ | |
46f4442e A |
163 | |
164 | #endif |