dtintrv.h 3.8 KB

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