]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
729e4ab9 A |
3 | /* |
4 | ******************************************************************************* | |
2ca993e8 | 5 | * Copyright (C) 2009-2016, International Business Machines Corporation and |
4388f060 | 6 | * others. All Rights Reserved. |
729e4ab9 A |
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 | ||
2ca993e8 A |
21 | #include "unicode/uobject.h" |
22 | ||
729e4ab9 A |
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. | |
729e4ab9 A |
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. | |
729e4ab9 | 41 | */ |
4388f060 | 42 | U_CAPI ZTrans* U_EXPORT2 |
729e4ab9 A |
43 | ztrans_open(UDate time, const void* from, const void* to); |
44 | ||
45 | /** | |
46 | * Constructs an empty <code>TimeZoneTransition</code> | |
729e4ab9 | 47 | */ |
4388f060 | 48 | U_CAPI ZTrans* U_EXPORT2 |
729e4ab9 A |
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 | |
729e4ab9 | 55 | */ |
4388f060 | 56 | U_CAPI void U_EXPORT2 |
729e4ab9 A |
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 | |
729e4ab9 | 63 | */ |
4388f060 | 64 | U_CAPI ZTrans* U_EXPORT2 |
729e4ab9 A |
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 | |
729e4ab9 | 73 | */ |
4388f060 | 74 | U_CAPI UBool U_EXPORT2 |
729e4ab9 A |
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. | |
729e4ab9 | 81 | */ |
4388f060 | 82 | U_CAPI UDate U_EXPORT2 |
729e4ab9 A |
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. | |
729e4ab9 | 89 | */ |
4388f060 | 90 | U_CAPI void U_EXPORT2 |
729e4ab9 A |
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. | |
729e4ab9 | 97 | */ |
4388f060 | 98 | U_CAPI void* U_EXPORT2 |
729e4ab9 A |
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. | |
729e4ab9 | 107 | */ |
4388f060 | 108 | U_CAPI void U_EXPORT2 |
729e4ab9 A |
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. | |
729e4ab9 | 116 | */ |
4388f060 | 117 | U_CAPI void U_EXPORT2 |
729e4ab9 A |
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. | |
729e4ab9 | 124 | */ |
4388f060 | 125 | U_CAPI void* U_EXPORT2 |
729e4ab9 A |
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. | |
729e4ab9 | 133 | */ |
4388f060 | 134 | U_CAPI void U_EXPORT2 |
729e4ab9 A |
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. | |
729e4ab9 | 142 | */ |
4388f060 | 143 | U_CAPI void U_EXPORT2 |
729e4ab9 A |
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. | |
729e4ab9 | 156 | */ |
4388f060 | 157 | U_CAPI UClassID U_EXPORT2 |
729e4ab9 A |
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. | |
729e4ab9 | 170 | */ |
4388f060 | 171 | U_CAPI UClassID U_EXPORT2 |
729e4ab9 A |
172 | ztrans_getDynamicClassID(ZTrans* trans); |
173 | ||
174 | #endif | |
175 | ||
176 | #endif |