dtintrv.h 3.8 KB

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