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