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