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