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