ztrans.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. *******************************************************************************
  5. * Copyright (C) 2009-2016, International Business Machines Corporation and
  6. * others. All Rights Reserved.
  7. *******************************************************************************
  8. */
  9. #ifndef __ZTRANS_H
  10. #define __ZTRANS_H
  11. /**
  12. * \file
  13. * \brief C API: Time zone transition classes
  14. */
  15. #include "unicode/utypes.h"
  16. #if !UCONFIG_NO_FORMATTING
  17. #include "unicode/uobject.h"
  18. /**
  19. * A TimeZoneTransition. Use the ztrans_* API to manipulate. Create with
  20. * ztrans_open*, and destroy with ztrans_close.
  21. */
  22. struct ZTrans;
  23. typedef struct ZTrans ZTrans;
  24. /**
  25. * Constructs a time zone transition with the time and the rules before/after
  26. * the transition.
  27. *
  28. * @param time The time of transition in milliseconds since the base time.
  29. * @param from The time zone rule used before the transition.
  30. * @param to The time zone rule used after the transition.
  31. */
  32. U_CAPI ZTrans* U_EXPORT2
  33. ztrans_open(UDate time, const void* from, const void* to);
  34. /**
  35. * Constructs an empty <code>TimeZoneTransition</code>
  36. */
  37. U_CAPI ZTrans* U_EXPORT2
  38. ztrans_openEmpty();
  39. /**
  40. * Disposes of the storage used by a ZTrans object. This function should
  41. * be called exactly once for objects returned by ztrans_open*.
  42. * @param trans the object to dispose of
  43. */
  44. U_CAPI void U_EXPORT2
  45. ztrans_close(ZTrans *trans);
  46. /**
  47. * Returns a copy of this object.
  48. * @param rule the original ZRule
  49. * @return the newly allocated copy of the ZRule
  50. */
  51. U_CAPI ZTrans* U_EXPORT2
  52. ztrans_clone(ZTrans *trans);
  53. /**
  54. * Returns true if trans1 is identical to trans2
  55. * and vis versa.
  56. * @param trans1 to be checked for containment
  57. * @param trans2 to be checked for containment
  58. * @return true if the test condition is met
  59. */
  60. U_CAPI UBool U_EXPORT2
  61. ztrans_equals(const ZTrans* trans1, const ZTrans* trans2);
  62. /**
  63. * Returns the time of transition in milliseconds.
  64. * param trans, the transition to use
  65. * @return The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
  66. */
  67. U_CAPI UDate U_EXPORT2
  68. ztrans_getTime(ZTrans* trans);
  69. /**
  70. * Sets the time of transition in milliseconds.
  71. * param trans, the transition to use
  72. * @param time The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
  73. */
  74. U_CAPI void U_EXPORT2
  75. ztrans_setTime(ZTrans* trans, UDate time);
  76. /**
  77. * Returns the rule used before the transition.
  78. * param trans, the transition to use
  79. * @return The time zone rule used after the transition.
  80. */
  81. U_CAPI void* U_EXPORT2
  82. ztrans_getFrom(ZTrans* & trans);
  83. /**
  84. * Sets the rule used before the transition. The caller remains
  85. * responsible for deleting the TimeZoneRule object.
  86. * param trans, the transition to use
  87. * param trans, the transition to use
  88. * @param from The time zone rule used before the transition.
  89. */
  90. U_CAPI void U_EXPORT2
  91. ztrans_setFrom(ZTrans* trans, const void* from);
  92. /**
  93. * Adopts the rule used before the transition. The caller must
  94. * not delete the TimeZoneRule object passed in.
  95. * param trans, the transition to use
  96. * @param from The time zone rule used before the transition.
  97. */
  98. U_CAPI void U_EXPORT2
  99. ztrans_adoptFrom(ZTrans* trans, void* from);
  100. /**
  101. * Returns the rule used after the transition.
  102. * param trans, the transition to use
  103. * @return The time zone rule used after the transition.
  104. */
  105. U_CAPI void* U_EXPORT2
  106. ztrans_getTo(ZTrans* trans);
  107. /**
  108. * Sets the rule used after the transition. The caller remains
  109. * responsible for deleting the TimeZoneRule object.
  110. * param trans, the transition to use
  111. * @param to The time zone rule used after the transition.
  112. */
  113. U_CAPI void U_EXPORT2
  114. ztrans_setTo(ZTrans* trans, const void* to);
  115. /**
  116. * Adopts the rule used after the transition. The caller must
  117. * not delete the TimeZoneRule object passed in.
  118. * param trans, the transition to use
  119. * @param to The time zone rule used after the transition.
  120. */
  121. U_CAPI void U_EXPORT2
  122. ztrans_adoptTo(ZTrans* trans, void* to);
  123. /**
  124. * Return the class ID for this class. This is useful only for comparing to
  125. * a return value from getDynamicClassID(). For example:
  126. * <pre>
  127. * . Base* polymorphic_pointer = createPolymorphicObject();
  128. * . if (polymorphic_pointer->getDynamicClassID() ==
  129. * . erived::getStaticClassID()) ...
  130. * </pre>
  131. * param trans, the transition to use
  132. * @return The class ID for all objects of this class.
  133. */
  134. U_CAPI UClassID U_EXPORT2
  135. ztrans_getStaticClassID(ZTrans* trans);
  136. /**
  137. * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
  138. * method is to implement a simple version of RTTI, since not all C++
  139. * compilers support genuine RTTI. Polymorphic operator==() and clone()
  140. * methods call this method.
  141. *
  142. * param trans, the transition to use
  143. * @return The class ID for this object. All objects of a
  144. * given class have the same class ID. Objects of
  145. * other classes have different class IDs.
  146. */
  147. U_CAPI UClassID U_EXPORT2
  148. ztrans_getDynamicClassID(ZTrans* trans);
  149. #endif
  150. #endif