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