ztrans.h 5.0 KB

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