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