michael@0: /* michael@0: ******************************************************************************* michael@0: * Copyright (C) 2009-2011, International Business Machines Corporation and michael@0: * others. All Rights Reserved. michael@0: ******************************************************************************* michael@0: */ michael@0: #ifndef __ZTRANS_H michael@0: #define __ZTRANS_H michael@0: michael@0: /** michael@0: * \file michael@0: * \brief C API: Time zone transition classes michael@0: */ michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_FORMATTING michael@0: michael@0: #ifndef UCNV_H michael@0: michael@0: /** michael@0: * A TimeZoneTransition. Use the ztrans_* API to manipulate. Create with michael@0: * ztrans_open*, and destroy with ztrans_close. michael@0: */ michael@0: struct ZTrans; michael@0: typedef struct ZTrans ZTrans; michael@0: michael@0: #endif michael@0: michael@0: /** michael@0: * Constructs a time zone transition with the time and the rules before/after michael@0: * the transition. michael@0: * michael@0: * @param time The time of transition in milliseconds since the base time. michael@0: * @param from The time zone rule used before the transition. michael@0: * @param to The time zone rule used after the transition. michael@0: */ michael@0: U_CAPI ZTrans* U_EXPORT2 michael@0: ztrans_open(UDate time, const void* from, const void* to); michael@0: michael@0: /** michael@0: * Constructs an empty TimeZoneTransition michael@0: */ michael@0: U_CAPI ZTrans* U_EXPORT2 michael@0: ztrans_openEmpty(); michael@0: michael@0: /** michael@0: * Disposes of the storage used by a ZTrans object. This function should michael@0: * be called exactly once for objects returned by ztrans_open*. michael@0: * @param trans the object to dispose of michael@0: */ michael@0: U_CAPI void U_EXPORT2 michael@0: ztrans_close(ZTrans *trans); michael@0: michael@0: /** michael@0: * Returns a copy of this object. michael@0: * @param rule the original ZRule michael@0: * @return the newly allocated copy of the ZRule michael@0: */ michael@0: U_CAPI ZTrans* U_EXPORT2 michael@0: ztrans_clone(ZTrans *trans); michael@0: michael@0: /** michael@0: * Returns true if trans1 is identical to trans2 michael@0: * and vis versa. michael@0: * @param trans1 to be checked for containment michael@0: * @param trans2 to be checked for containment michael@0: * @return true if the test condition is met michael@0: */ michael@0: U_CAPI UBool U_EXPORT2 michael@0: ztrans_equals(const ZTrans* trans1, const ZTrans* trans2); michael@0: michael@0: /** michael@0: * Returns the time of transition in milliseconds. michael@0: * param trans, the transition to use michael@0: * @return The time of the transition in milliseconds since the 1970 Jan 1 epoch time. michael@0: */ michael@0: U_CAPI UDate U_EXPORT2 michael@0: ztrans_getTime(ZTrans* trans); michael@0: michael@0: /** michael@0: * Sets the time of transition in milliseconds. michael@0: * param trans, the transition to use michael@0: * @param time The time of the transition in milliseconds since the 1970 Jan 1 epoch time. michael@0: */ michael@0: U_CAPI void U_EXPORT2 michael@0: ztrans_setTime(ZTrans* trans, UDate time); michael@0: michael@0: /** michael@0: * Returns the rule used before the transition. michael@0: * param trans, the transition to use michael@0: * @return The time zone rule used after the transition. michael@0: */ michael@0: U_CAPI void* U_EXPORT2 michael@0: ztrans_getFrom(ZTrans* & trans); michael@0: michael@0: /** michael@0: * Sets the rule used before the transition. The caller remains michael@0: * responsible for deleting the TimeZoneRule object. michael@0: * param trans, the transition to use michael@0: * param trans, the transition to use michael@0: * @param from The time zone rule used before the transition. michael@0: */ michael@0: U_CAPI void U_EXPORT2 michael@0: ztrans_setFrom(ZTrans* trans, const void* from); michael@0: michael@0: /** michael@0: * Adopts the rule used before the transition. The caller must michael@0: * not delete the TimeZoneRule object passed in. michael@0: * param trans, the transition to use michael@0: * @param from The time zone rule used before the transition. michael@0: */ michael@0: U_CAPI void U_EXPORT2 michael@0: ztrans_adoptFrom(ZTrans* trans, void* from); michael@0: michael@0: /** michael@0: * Returns the rule used after the transition. michael@0: * param trans, the transition to use michael@0: * @return The time zone rule used after the transition. michael@0: */ michael@0: U_CAPI void* U_EXPORT2 michael@0: ztrans_getTo(ZTrans* trans); michael@0: michael@0: /** michael@0: * Sets the rule used after the transition. The caller remains michael@0: * responsible for deleting the TimeZoneRule object. michael@0: * param trans, the transition to use michael@0: * @param to The time zone rule used after the transition. michael@0: */ michael@0: U_CAPI void U_EXPORT2 michael@0: ztrans_setTo(ZTrans* trans, const void* to); michael@0: michael@0: /** michael@0: * Adopts the rule used after the transition. The caller must michael@0: * not delete the TimeZoneRule object passed in. michael@0: * param trans, the transition to use michael@0: * @param to The time zone rule used after the transition. michael@0: */ michael@0: U_CAPI void U_EXPORT2 michael@0: ztrans_adoptTo(ZTrans* trans, void* to); michael@0: michael@0: /** michael@0: * Return the class ID for this class. This is useful only for comparing to michael@0: * a return value from getDynamicClassID(). For example: michael@0: *
michael@0:  * .   Base* polymorphic_pointer = createPolymorphicObject();
michael@0:  * .   if (polymorphic_pointer->getDynamicClassID() ==
michael@0:  * .       erived::getStaticClassID()) ...
michael@0:  * 
michael@0: * param trans, the transition to use michael@0: * @return The class ID for all objects of this class. michael@0: */ michael@0: U_CAPI UClassID U_EXPORT2 michael@0: ztrans_getStaticClassID(ZTrans* trans); michael@0: michael@0: /** michael@0: * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This michael@0: * method is to implement a simple version of RTTI, since not all C++ michael@0: * compilers support genuine RTTI. Polymorphic operator==() and clone() michael@0: * methods call this method. michael@0: * michael@0: * param trans, the transition to use michael@0: * @return The class ID for this object. All objects of a michael@0: * given class have the same class ID. Objects of michael@0: * other classes have different class IDs. michael@0: */ michael@0: U_CAPI UClassID U_EXPORT2 michael@0: ztrans_getDynamicClassID(ZTrans* trans); michael@0: michael@0: #endif michael@0: michael@0: #endif