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