1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/mw/tzlocalizationdatatypes.h Wed Mar 31 12:27:01 2010 +0100
1.3 @@ -0,0 +1,295 @@
1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __TZLOCAL_DATATYPES_H__
1.20 +#define __TZLOCAL_DATATYPES_H__
1.21 +
1.22 +#include <e32base.h> //CBase
1.23 +
1.24 +/**
1.25 +Encapsulates the correspondence between a time zone ID and a resource ID and
1.26 +facilitates fast finding of resources in the resource file. For internal use only.
1.27 +
1.28 +@internalTechnology
1.29 +*/
1.30 +class TTzLocalizedId
1.31 + {
1.32 + public:
1.33 + // Represents an invalid UTC offset of 25 hours and 1 minutes, in minutes
1.34 + enum TTzUTCOffset
1.35 + {
1.36 + ETzInvalidUTCOffset = 1501
1.37 + };
1.38 +
1.39 + public:
1.40 + TTzLocalizedId(const TUint16 aTzId, const TUint aResourceId =0);
1.41 +
1.42 + //Accessor methods
1.43 + inline TUint16 TimeZoneId() const;
1.44 + inline TUint ResourceId() const;
1.45 + inline TInt UTCOffset() const;
1.46 + inline void SetUTCOffset(TInt aOffsetInMinutes);
1.47 +
1.48 + private:
1.49 + TUint16 iTzId;
1.50 + TUint iResourceId;
1.51 + TInt iUTCOffset; //UTC offset stored in minutes
1.52 + };
1.53 +
1.54 +/**
1.55 +Encapsulates a localized (exemplar) city.
1.56 +
1.57 +@publishedAll
1.58 +@released
1.59 +*/
1.60 +class CTzLocalizedCity : public CBase
1.61 + {
1.62 + public:
1.63 + static CTzLocalizedCity* NewL(
1.64 + const TDesC& aName,
1.65 + const TTzLocalizedId& aTzLocalizedId,
1.66 + const TUint8 aGroupId =0);
1.67 + static CTzLocalizedCity* NewLC(
1.68 + const TDesC& aName,
1.69 + const TTzLocalizedId& aTzLocalizedId,
1.70 + const TUint8 aGroupId =0);
1.71 + ~CTzLocalizedCity();
1.72 +
1.73 + //Accessor methods
1.74 + IMPORT_C TPtrC Name() const;
1.75 + IMPORT_C TUint16 TimeZoneId() const;
1.76 + IMPORT_C TUint8 GroupId() const;
1.77 + TTzLocalizedId TzLocalizedId() const;
1.78 + TInt UTCOffset() const;
1.79 + void SetUTCOffset(TInt aUTCoffset);
1.80 + void SetCityIndex(TInt aIndex);
1.81 + TInt CityIndex() const;
1.82 +
1.83 + private:
1.84 + void ConstructL(const TDesC& aName);
1.85 + CTzLocalizedCity(const TUint8 aGroupId, const TTzLocalizedId& aTzLocalizedId);
1.86 +
1.87 + private:
1.88 + //Member data
1.89 + HBufC* iName;
1.90 + TUint8 iGroupId;
1.91 + TTzLocalizedId iTzLocalizedId;
1.92 + TInt iCityIndex;
1.93 + };
1.94 +
1.95 +/**
1.96 +Encapsulates a localized group of (exemplar) cities.
1.97 +
1.98 +@publishedAll
1.99 +@released
1.100 +*/
1.101 +class CTzLocalizedCityGroup : public CBase
1.102 + {
1.103 + public:
1.104 + static CTzLocalizedCityGroup* NewL(const TDesC& aName, const TUint8 aGroupId);
1.105 + static CTzLocalizedCityGroup* NewLC(const TDesC& aName, const TUint8 aGroupId);
1.106 + ~CTzLocalizedCityGroup();
1.107 +
1.108 + //Accessor methods
1.109 + IMPORT_C TPtrC Name() const;
1.110 + IMPORT_C TUint8 Id() const;
1.111 +
1.112 + private:
1.113 + void ConstructL(const TDesC& aName);
1.114 + CTzLocalizedCityGroup(const TUint8 aGroupId);
1.115 +
1.116 + private:
1.117 + //Member data
1.118 + HBufC* iName;
1.119 + TUint8 iGroupId;
1.120 + };
1.121 +
1.122 +/**
1.123 +Encapsulates a group of LDML localized timezone names.
1.124 +LDML stands for Locale Data Markup Language. For details, see
1.125 +http://www.openi18n.org/specs/ldml/1.0/ldml-spec.htm.
1.126 +
1.127 +@publishedAll
1.128 +@released
1.129 +*/
1.130 +class CTzLocalizedTimeZone : public CBase
1.131 + {
1.132 + public: //enums
1.133 + /**
1.134 + Flags to identify a cached zone.
1.135 + @publishedAll
1.136 + @released
1.137 + */
1.138 + enum TTzFrequentlyUsedZone
1.139 + {
1.140 + /** The current zone. */
1.141 + ECurrentZone,
1.142 + /** The home zone. */
1.143 + EHomeZone,
1.144 + /** The zone of interest. */
1.145 + EInterestZone,
1.146 + /** The first recently-used zone. */
1.147 + ERecentZone1,
1.148 + /** The second recently-used zone. */
1.149 + ERecentZone2,
1.150 + /** Specifies the number of cached zones. Not to be used as an API argument. */
1.151 + ECachedTimeZones // If new items are added to this enum, this must
1.152 + // left as last item, because it is used to keep
1.153 + // count of the number of cached zones
1.154 + };
1.155 +
1.156 + public:
1.157 + static CTzLocalizedTimeZone* NewL(
1.158 + const TTzLocalizedId& aTzLocalizedId,
1.159 + const TDesC& aStandardName,
1.160 + const TDesC& aDaylightName,
1.161 + const TDesC& aShortStandardName,
1.162 + const TDesC& aShortDaylightName);
1.163 +
1.164 + static CTzLocalizedTimeZone* NewLC(
1.165 + const TTzLocalizedId& aTzLocalizedId,
1.166 + const TDesC& aStandardName,
1.167 + const TDesC& aDaylightName,
1.168 + const TDesC& aShortStandardName,
1.169 + const TDesC& aShortDaylightName);
1.170 +
1.171 + ~CTzLocalizedTimeZone();
1.172 +
1.173 + //Accessor methods
1.174 + IMPORT_C TUint16 TimeZoneId() const;
1.175 + IMPORT_C TPtrC StandardName() const;
1.176 + IMPORT_C TPtrC DaylightName() const;
1.177 + IMPORT_C TPtrC ShortStandardName() const;
1.178 + IMPORT_C TPtrC ShortDaylightName() const;
1.179 + TTzLocalizedId TzLocalizedId() const;
1.180 + TInt UTCOffset() const;
1.181 + void SetUTCOffset(TInt aUTCoffset);
1.182 +
1.183 + private:
1.184 + void ConstructL(
1.185 + const TDesC& aStandardName,
1.186 + const TDesC& aDaylightName,
1.187 + const TDesC& aShortStandardName,
1.188 + const TDesC& aShortDaylightName);
1.189 + CTzLocalizedTimeZone(const TTzLocalizedId& aTzLocalizedId);
1.190 +
1.191 + private:
1.192 + //Member data
1.193 + TTzLocalizedId iTzLocalizedId;
1.194 + HBufC* iStandardName;
1.195 + HBufC* iDaylightName;
1.196 + HBufC* iShortStandardName;
1.197 + HBufC* iShortDaylightName;
1.198 + };
1.199 +
1.200 +/**
1.201 +Template for arrays of localized objects. Implemented using a thin template.
1.202 +All functions are inline.
1.203 +
1.204 +@publishedAll
1.205 +@released
1.206 +*/
1.207 +template <class T>
1.208 +class CTzLocalizedArray : public CBase
1.209 + {
1.210 + protected:
1.211 + inline ~CTzLocalizedArray();
1.212 +
1.213 + inline T& At(TInt aIndex) const;
1.214 + inline TInt Count() const;
1.215 + inline void AppendL(T* aElement);
1.216 + inline void Remove(TInt aIndex);
1.217 + inline void Sort(TLinearOrder<T> aOrder);
1.218 + inline TInt Find(T* aEntry,TIdentityRelation<T> aIdentityRelation);
1.219 +
1.220 + inline CTzLocalizedArray();
1.221 +
1.222 + private:
1.223 + //Member data
1.224 + RPointerArray<T> iArray;
1.225 + };
1.226 +
1.227 +// Assign concrete classes for each of the arrays that will be used
1.228 +// This guards against future BC problems
1.229 +
1.230 +/**
1.231 +An array of cities. This just passes function calls on to its templated base
1.232 +class, CTzLocalizedArray.
1.233 +
1.234 +@publishedAll
1.235 +@released
1.236 +*/
1.237 +class CTzLocalizedCityArray : public CTzLocalizedArray<CTzLocalizedCity>
1.238 + {
1.239 + public:
1.240 + IMPORT_C static CTzLocalizedCityArray* NewL();
1.241 + IMPORT_C static CTzLocalizedCityArray* NewLC();
1.242 +
1.243 + IMPORT_C CTzLocalizedCity& At(TInt aIndex) const;
1.244 + IMPORT_C TInt Count() const;
1.245 + IMPORT_C void AppendL(CTzLocalizedCity* aCity);
1.246 + IMPORT_C void Remove(TInt aIndex);
1.247 + IMPORT_C void Sort(TLinearOrder<CTzLocalizedCity> anOrder);
1.248 + IMPORT_C TInt Find(CTzLocalizedCity* anEntry,TIdentityRelation<CTzLocalizedCity> aIdentityRelation);
1.249 + };
1.250 +
1.251 +/**
1.252 +An array of city groups. This just passes function calls on to its templated base
1.253 +class, CTzLocalizedArray.
1.254 +
1.255 +@publishedAll
1.256 +@released
1.257 +*/
1.258 +class CTzLocalizedCityGroupArray : public CTzLocalizedArray<CTzLocalizedCityGroup>
1.259 + {
1.260 + public:
1.261 + IMPORT_C static CTzLocalizedCityGroupArray* NewL();
1.262 + IMPORT_C static CTzLocalizedCityGroupArray* NewLC();
1.263 +
1.264 + IMPORT_C CTzLocalizedCityGroup& At(TInt aIndex) const;
1.265 + IMPORT_C TInt Count() const;
1.266 + IMPORT_C void AppendL(CTzLocalizedCityGroup* aGroup);
1.267 + IMPORT_C void Remove(TInt aIndex);
1.268 + IMPORT_C void Sort(TLinearOrder<CTzLocalizedCityGroup> anOrder);
1.269 + IMPORT_C TInt Find(CTzLocalizedCityGroup* anEntry,TIdentityRelation<CTzLocalizedCityGroup> aIdentityRelation);
1.270 + };
1.271 +
1.272 +/**
1.273 +An array of time zones. This just passes function calls on to its templated base
1.274 +class, CTzLocalizedArray.
1.275 +
1.276 +@publishedAll
1.277 +@released
1.278 +*/
1.279 +class CTzLocalizedTimeZoneArray : public CTzLocalizedArray<CTzLocalizedTimeZone>
1.280 + {
1.281 + public:
1.282 + IMPORT_C static CTzLocalizedTimeZoneArray* NewL();
1.283 + IMPORT_C static CTzLocalizedTimeZoneArray* NewLC();
1.284 +
1.285 + IMPORT_C CTzLocalizedTimeZone& At(TInt aIndex) const;
1.286 + IMPORT_C TInt Count() const;
1.287 + IMPORT_C void AppendL(CTzLocalizedTimeZone* aElement);
1.288 + IMPORT_C void Remove(TInt aIndex);
1.289 + IMPORT_C void Sort(TLinearOrder<CTzLocalizedTimeZone> anOrder);
1.290 + IMPORT_C TInt Find(CTzLocalizedTimeZone* anEntry,TIdentityRelation<CTzLocalizedTimeZone> aIdentityRelation);
1.291 + };
1.292 +
1.293 +#include <tzlocalizationdatatypes.inl>
1.294 +
1.295 +#endif //__TZLOCAL_DATATYPES_H__
1.296 +//==================================================================
1.297 +// End of file
1.298 +//==================================================================