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