dtintrv.h 3.6 KB

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