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