| 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 |  | 
|---|
| 19 | #if U_SHOW_CPLUSPLUS_API | 
|---|
| 20 |  | 
|---|
| 21 | #include "unicode/uobject.h" | 
|---|
| 22 |  | 
|---|
| 23 | /** | 
|---|
| 24 | * \file | 
|---|
| 25 | * \brief C++ API: Date Interval data type | 
|---|
| 26 | */ | 
|---|
| 27 |  | 
|---|
| 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. | 
|---|
| 34 | * @stable ICU 4.0 | 
|---|
| 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. | 
|---|
| 43 | * @stable ICU 4.0 | 
|---|
| 44 | */ | 
|---|
| 45 | DateInterval(UDate fromDate, UDate toDate); | 
|---|
| 46 |  | 
|---|
| 47 | /** | 
|---|
| 48 | * destructor | 
|---|
| 49 | * @stable ICU 4.0 | 
|---|
| 50 | */ | 
|---|
| 51 | virtual ~DateInterval(); | 
|---|
| 52 |  | 
|---|
| 53 | /** | 
|---|
| 54 | * Get the from date. | 
|---|
| 55 | * @return  the from date in dateInterval. | 
|---|
| 56 | * @stable ICU 4.0 | 
|---|
| 57 | */ | 
|---|
| 58 | inline UDate getFromDate() const; | 
|---|
| 59 |  | 
|---|
| 60 | /** | 
|---|
| 61 | * Get the to date. | 
|---|
| 62 | * @return  the to date in dateInterval. | 
|---|
| 63 | * @stable ICU 4.0 | 
|---|
| 64 | */ | 
|---|
| 65 | inline UDate getToDate() const; | 
|---|
| 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() == | 
|---|
| 74 | * .       derived::getStaticClassID()) ... | 
|---|
| 75 | * </pre> | 
|---|
| 76 | * @return          The class ID for all objects of this class. | 
|---|
| 77 | * @stable ICU 4.0 | 
|---|
| 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. | 
|---|
| 90 | * @stable ICU 4.0 | 
|---|
| 91 | */ | 
|---|
| 92 | virtual UClassID getDynamicClassID(void) const; | 
|---|
| 93 |  | 
|---|
| 94 |  | 
|---|
| 95 | /** | 
|---|
| 96 | * Copy constructor. | 
|---|
| 97 | * @stable ICU 4.0 | 
|---|
| 98 | */ | 
|---|
| 99 | DateInterval(const DateInterval& other); | 
|---|
| 100 |  | 
|---|
| 101 | /** | 
|---|
| 102 | * Default assignment operator | 
|---|
| 103 | * @stable ICU 4.0 | 
|---|
| 104 | */ | 
|---|
| 105 | DateInterval& operator=(const DateInterval&); | 
|---|
| 106 |  | 
|---|
| 107 | /** | 
|---|
| 108 | * Equality operator. | 
|---|
| 109 | * @return TRUE if the two DateIntervals are the same | 
|---|
| 110 | * @stable ICU 4.0 | 
|---|
| 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 | 
|---|
| 117 | * @stable ICU 4.0 | 
|---|
| 118 | */ | 
|---|
| 119 | inline UBool operator!=(const DateInterval& other) const; | 
|---|
| 120 |  | 
|---|
| 121 |  | 
|---|
| 122 | /** | 
|---|
| 123 | * clone this object. | 
|---|
| 124 | * The caller owns the result and should delete it when done. | 
|---|
| 125 | * @return a cloned DateInterval | 
|---|
| 126 | * @stable ICU 4.0 | 
|---|
| 127 | */ | 
|---|
| 128 | virtual DateInterval* clone() const; | 
|---|
| 129 |  | 
|---|
| 130 | private: | 
|---|
| 131 | /** | 
|---|
| 132 | * Default constructor, not implemented. | 
|---|
| 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 | 
|---|
| 161 |  | 
|---|
| 162 | #endif /* U_SHOW_CPLUSPLUS_API */ | 
|---|
| 163 |  | 
|---|
| 164 | #endif | 
|---|
| 165 |  | 
|---|