| 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(); |
| 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() const override; |
| 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 bool 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 |
inline bool 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() = delete; |
| 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 bool |
| 154 |
DateInterval::operator!=(const DateInterval& other) const { |
| 155 |
return ( !operator==(other) ); |
| 156 |
} |
| 157 |
|
| 158 |
|
| 159 |
U_NAMESPACE_END |
| 160 |
|
| 161 |
#endif /* U_SHOW_CPLUSPLUS_API */ |
| 162 |
|
| 163 |
#endif |