1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __TZLOCAL_DATATYPES_H__
17 #define __TZLOCAL_DATATYPES_H__
22 The resource structure LOCALIZED_TIMEZONE (defined in TimeZoneLocalization.rh) is used
23 to represent a time zone item in a resource file. One of the members of this structure is
24 WORD time_zone_id which stores the id of the time zone.
26 This class stores a time zone id (iTzId) and its associated resource id (iResourceId). This
27 facilitates fast finding of resources in the resource file. For internal use only.
29 For instance for a time zone defined as follow in the resource file, iTzId would be 2728 and
30 iResourceId would be r_tz_europe_tirane (more precisely the resource id assigned to r_tz_europe_tirane
31 by the resource compiler).
33 RESOURCE LOCALIZED_TIMEZONE r_tz_europe_tirane
36 standard_name = 2728_standard_name;
37 daylight_name = 2728_daylight_name;
38 short_standard_name = 2728_short_standard_name;
39 short_daylight_name = 2728_short_daylight_name;
45 city_name = 2728_tirane_name;
55 explicit TTzLocalizedId(const TUint16 aTzId, const TUint aResourceId);
58 inline TUint16 TimeZoneId() const;
59 inline TUint ResourceId() const;
67 Encapsulates a localized (exemplar) city.
72 class CTzLocalizedCity : public CBase
75 static CTzLocalizedCity* NewL(
77 const TTzLocalizedId& aTzLocalizedId,
78 const TUint8 aGroupId =0);
79 static CTzLocalizedCity* NewLC(
81 const TTzLocalizedId& aTzLocalizedId,
82 const TUint8 aGroupId =0);
86 IMPORT_C TPtrC Name() const;
87 IMPORT_C TUint16 TimeZoneId() const;
88 IMPORT_C TUint8 GroupId() const;
89 TTzLocalizedId TzLocalizedId() const;
90 TInt UTCOffset() const;
91 void SetUTCOffset(TInt aUTCoffset);
92 void SetCityIndex(TInt aIndex);
93 TInt CityIndex() const;
96 void ConstructL(const TDesC& aName);
97 CTzLocalizedCity(const TUint8 aGroupId, const TTzLocalizedId& aTzLocalizedId);
102 TTzLocalizedId iTzLocalizedId;
105 When sorting arrays in UTC order the UTC offset is stored here. It is expressed in minutes.
106 This value should only be used for this purpose.
112 Encapsulates a localized group of (exemplar) cities.
117 class CTzLocalizedCityGroup : public CBase
120 static CTzLocalizedCityGroup* NewL(const TDesC& aName, const TUint8 aGroupId);
121 static CTzLocalizedCityGroup* NewLC(const TDesC& aName, const TUint8 aGroupId);
122 ~CTzLocalizedCityGroup();
125 IMPORT_C TPtrC Name() const;
126 IMPORT_C TUint8 Id() const;
129 void ConstructL(const TDesC& aName);
130 CTzLocalizedCityGroup(const TUint8 aGroupId);
138 Encapsulates a group of LDML localized timezone names.
139 LDML stands for Locale Data Markup Language. For details, see
140 http://www.openi18n.org/specs/ldml/1.0/ldml-spec.htm
145 class CTzLocalizedTimeZone : public CBase
149 Flags to identify a cached zone.
153 enum TTzFrequentlyUsedZone
155 /** The current zone. */
157 /** The home zone. */
159 /** The zone of interest. */
161 /** The first recently-used zone. */
163 /** The second recently-used zone. */
165 /** Specifies the number of cached zones. Not to be used as an API argument. */
166 ECachedTimeZones // If new items are added to this enum, this must
167 // left as last item, because it is used to keep
168 // count of the number of cached zones
172 static CTzLocalizedTimeZone* NewL(
173 const TTzLocalizedId& aTzLocalizedId,
174 const TDesC& aStandardName,
175 const TDesC& aDaylightName,
176 const TDesC& aShortStandardName,
177 const TDesC& aShortDaylightName);
179 static CTzLocalizedTimeZone* NewLC(
180 const TTzLocalizedId& aTzLocalizedId,
181 const TDesC& aStandardName,
182 const TDesC& aDaylightName,
183 const TDesC& aShortStandardName,
184 const TDesC& aShortDaylightName);
186 ~CTzLocalizedTimeZone();
189 IMPORT_C TUint16 TimeZoneId() const;
190 IMPORT_C TPtrC StandardName() const;
191 IMPORT_C TPtrC DaylightName() const;
192 IMPORT_C TPtrC ShortStandardName() const;
193 IMPORT_C TPtrC ShortDaylightName() const;
194 TTzLocalizedId TzLocalizedId() const;
195 TInt UTCOffset() const;
196 void SetUTCOffset(TInt aUTCoffset);
200 const TDesC& aStandardName,
201 const TDesC& aDaylightName,
202 const TDesC& aShortStandardName,
203 const TDesC& aShortDaylightName);
204 CTzLocalizedTimeZone(const TTzLocalizedId& aTzLocalizedId);
207 TTzLocalizedId iTzLocalizedId;
208 HBufC* iStandardName;
209 HBufC* iDaylightName;
210 HBufC* iShortStandardName;
211 HBufC* iShortDaylightName;
213 When sorting arrays in UTC order the UTC offset is stored here. It is expressed in minutes.
214 This value should only be used for this purpose.
220 Template for arrays of localized objects. Implemented using a thin template.
221 All functions are inline.
227 class CTzLocalizedArray : public CBase
230 inline ~CTzLocalizedArray();
232 inline T& At(TInt aIndex) const;
233 inline TInt Count() const;
234 inline void AppendL(T* aElement);
235 inline void Remove(TInt aIndex);
236 inline void Sort(TLinearOrder<T> aOrder);
237 inline TInt Find(T* aEntry,TIdentityRelation<T> aIdentityRelation);
238 inline void ReserveL(TInt aCount);
240 inline CTzLocalizedArray();
243 RPointerArray<T> iArray;
246 // Assign concrete classes for each of the arrays that will be used
247 // This guards against future BC problems
250 An array of cities. This just passes function calls on to its templated base
251 class, CTzLocalizedArray.
256 class CTzLocalizedCityArray : public CTzLocalizedArray<CTzLocalizedCity>
259 IMPORT_C static CTzLocalizedCityArray* NewL();
260 IMPORT_C static CTzLocalizedCityArray* NewLC();
262 IMPORT_C CTzLocalizedCity& At(TInt aIndex) const;
263 IMPORT_C TInt Count() const;
264 IMPORT_C void AppendL(CTzLocalizedCity* aCity);
265 IMPORT_C void Remove(TInt aIndex);
266 IMPORT_C void Sort(TLinearOrder<CTzLocalizedCity> anOrder);
267 IMPORT_C TInt Find(CTzLocalizedCity* anEntry,TIdentityRelation<CTzLocalizedCity> aIdentityRelation);
268 void ReserveL(TInt aCount);
272 An array of city groups. This just passes function calls on to its templated base
273 class, CTzLocalizedArray.
278 class CTzLocalizedCityGroupArray : public CTzLocalizedArray<CTzLocalizedCityGroup>
281 IMPORT_C static CTzLocalizedCityGroupArray* NewL();
282 IMPORT_C static CTzLocalizedCityGroupArray* NewLC();
284 IMPORT_C CTzLocalizedCityGroup& At(TInt aIndex) const;
285 IMPORT_C TInt Count() const;
286 IMPORT_C void AppendL(CTzLocalizedCityGroup* aGroup);
287 IMPORT_C void Remove(TInt aIndex);
288 IMPORT_C void Sort(TLinearOrder<CTzLocalizedCityGroup> anOrder);
289 IMPORT_C TInt Find(CTzLocalizedCityGroup* anEntry,TIdentityRelation<CTzLocalizedCityGroup> aIdentityRelation);
290 void ReserveL(TInt aCount);
294 An array of time zones. This just passes function calls on to its templated base
295 class, CTzLocalizedArray.
300 class CTzLocalizedTimeZoneArray : public CTzLocalizedArray<CTzLocalizedTimeZone>
303 IMPORT_C static CTzLocalizedTimeZoneArray* NewL();
304 IMPORT_C static CTzLocalizedTimeZoneArray* NewLC();
306 IMPORT_C CTzLocalizedTimeZone& At(TInt aIndex) const;
307 IMPORT_C TInt Count() const;
308 IMPORT_C void AppendL(CTzLocalizedTimeZone* aElement);
309 IMPORT_C void Remove(TInt aIndex);
310 IMPORT_C void Sort(TLinearOrder<CTzLocalizedTimeZone> anOrder);
311 IMPORT_C TInt Find(CTzLocalizedTimeZone* anEntry,TIdentityRelation<CTzLocalizedTimeZone> aIdentityRelation);
312 void ReserveL(TInt aCount);
315 #include <tzlocalizationdatatypes.inl>
317 #endif //__TZLOCAL_DATATYPES_H__