epoc32/include/mw/tzlocalizationdatatypes.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/tzlocalizationdatatypes.h@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
     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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef __TZLOCAL_DATATYPES_H__
    17 #define __TZLOCAL_DATATYPES_H__
    18 
    19 #include <e32base.h>	//CBase
    20 
    21 /**
    22 Encapsulates the correspondence between a time zone ID and a resource ID and
    23 facilitates fast finding of resources in the resource file.  For internal use only.
    24 
    25 @internalTechnology
    26 */
    27 class TTzLocalizedId
    28 	{
    29 	public:
    30 		// Represents an invalid UTC offset of 25 hours and 1 minutes, in minutes
    31 		enum TTzUTCOffset
    32 			{
    33 			ETzInvalidUTCOffset = 1501
    34 			};
    35 
    36 	public:
    37 		TTzLocalizedId(const TUint16 aTzId, const TUint aResourceId =0);
    38 
    39 		//Accessor methods
    40 		inline TUint16 TimeZoneId() const;
    41 		inline TUint ResourceId() const;
    42 		inline TInt UTCOffset() const;
    43 		inline void SetUTCOffset(TInt aOffsetInMinutes);
    44 
    45 	private:
    46 		TUint16 iTzId;
    47 		TUint iResourceId;
    48 		TInt iUTCOffset;	//UTC offset stored in minutes
    49 	};
    50 
    51 /**
    52 Encapsulates a localized (exemplar) city.
    53 
    54 @publishedAll
    55 @released
    56 */
    57 class CTzLocalizedCity : public CBase
    58 	{
    59 	public:
    60 		static CTzLocalizedCity* NewL(
    61 			const TDesC& aName,
    62 			const TTzLocalizedId& aTzLocalizedId,
    63 			const TUint8 aGroupId =0);
    64 		static CTzLocalizedCity* NewLC(
    65 			const TDesC& aName,
    66 			const TTzLocalizedId& aTzLocalizedId,
    67 			const TUint8 aGroupId =0);
    68 		~CTzLocalizedCity();
    69 
    70 		//Accessor methods
    71 		IMPORT_C TPtrC Name() const;
    72 		IMPORT_C TUint16 TimeZoneId() const;
    73 		IMPORT_C TUint8 GroupId() const;
    74 		TTzLocalizedId TzLocalizedId() const;
    75 		TInt UTCOffset() const;
    76 		void SetUTCOffset(TInt aUTCoffset);
    77         void SetCityIndex(TInt aIndex);
    78        	TInt CityIndex() const;
    79 
    80 	private:
    81 		void ConstructL(const TDesC& aName);
    82 		CTzLocalizedCity(const TUint8 aGroupId, const TTzLocalizedId& aTzLocalizedId);
    83 
    84 	private:
    85 		//Member data
    86 		HBufC* iName;
    87 		TUint8 iGroupId;
    88 		TTzLocalizedId iTzLocalizedId;
    89         TInt iCityIndex;
    90 	};
    91 
    92 /**
    93 Encapsulates a localized group of (exemplar) cities.
    94 
    95 @publishedAll
    96 @released
    97 */
    98 class CTzLocalizedCityGroup : public CBase
    99 	{
   100 	public:
   101 		static CTzLocalizedCityGroup* NewL(const TDesC& aName, const TUint8 aGroupId);
   102 		static CTzLocalizedCityGroup* NewLC(const TDesC& aName, const TUint8 aGroupId);
   103 		~CTzLocalizedCityGroup();
   104 
   105 		//Accessor methods
   106 		IMPORT_C TPtrC Name() const;
   107 		IMPORT_C TUint8 Id() const;
   108 
   109 	private:
   110 		void ConstructL(const TDesC& aName);
   111 		CTzLocalizedCityGroup(const TUint8 aGroupId);
   112 
   113 	private:
   114 		//Member data
   115 		HBufC* iName;
   116 		TUint8 iGroupId;
   117 	};
   118 
   119 /**
   120 Encapsulates a group of LDML localized timezone names.
   121 LDML stands for Locale Data Markup Language. For details, see 
   122 http://www.openi18n.org/specs/ldml/1.0/ldml-spec.htm.
   123 
   124 @publishedAll
   125 @released
   126 */
   127 class CTzLocalizedTimeZone : public CBase
   128 	{
   129 	public: //enums
   130 		/**
   131 		Flags to identify a cached zone.
   132 		@publishedAll
   133 		@released
   134 		*/
   135 		enum TTzFrequentlyUsedZone
   136 			{
   137 			/** The current zone. */
   138 			ECurrentZone,
   139 			/** The home zone. */
   140 			EHomeZone,
   141 			/** The zone of interest. */
   142 			EInterestZone,
   143 			/** The first recently-used zone. */
   144 			ERecentZone1,
   145 			/** The second recently-used zone. */
   146 			ERecentZone2,
   147 			/** Specifies the number of cached zones. Not to be used as an API argument. */
   148 			ECachedTimeZones	// If new items are added to this enum, this must 
   149 								// left as last item, because it is used to keep 
   150 								// count of the number of cached zones
   151 			};
   152 
   153 	public:
   154 		static CTzLocalizedTimeZone* NewL(
   155 			const TTzLocalizedId& aTzLocalizedId,
   156 			const TDesC& aStandardName,
   157 			const TDesC& aDaylightName,
   158 			const TDesC& aShortStandardName,
   159 			const TDesC& aShortDaylightName);
   160 
   161 		static CTzLocalizedTimeZone* NewLC(
   162 			const TTzLocalizedId& aTzLocalizedId,
   163 			const TDesC& aStandardName,
   164 			const TDesC& aDaylightName,
   165 			const TDesC& aShortStandardName,
   166 			const TDesC& aShortDaylightName);
   167 
   168 		~CTzLocalizedTimeZone();
   169 
   170 		//Accessor methods
   171 		IMPORT_C TUint16 TimeZoneId() const;
   172 		IMPORT_C TPtrC StandardName() const;
   173 		IMPORT_C TPtrC DaylightName() const;
   174 		IMPORT_C TPtrC ShortStandardName() const;
   175 		IMPORT_C TPtrC ShortDaylightName() const;
   176 		TTzLocalizedId TzLocalizedId() const;
   177 		TInt UTCOffset() const;
   178 		void SetUTCOffset(TInt aUTCoffset);
   179 
   180 	private:
   181 		void ConstructL(
   182 			const TDesC& aStandardName,
   183 			const TDesC& aDaylightName,
   184 			const TDesC& aShortStandardName,
   185 			const TDesC& aShortDaylightName);
   186 		CTzLocalizedTimeZone(const TTzLocalizedId& aTzLocalizedId);
   187 
   188 	private:
   189 		//Member data
   190 		TTzLocalizedId iTzLocalizedId;
   191 		HBufC* iStandardName;
   192 		HBufC* iDaylightName;
   193 		HBufC* iShortStandardName;
   194 		HBufC* iShortDaylightName;
   195 	};
   196 
   197 /**
   198 Template for arrays of localized objects. Implemented using a thin template. 
   199 All functions are inline.
   200 
   201 @publishedAll
   202 @released
   203 */
   204 template <class T>
   205 class CTzLocalizedArray : public CBase
   206 	{
   207 	protected:
   208 		inline ~CTzLocalizedArray();
   209 
   210 		inline T& At(TInt aIndex) const;
   211 		inline TInt Count() const;
   212 		inline void AppendL(T* aElement);
   213 		inline void Remove(TInt aIndex);
   214 		inline void Sort(TLinearOrder<T> aOrder);
   215 		inline TInt Find(T* aEntry,TIdentityRelation<T> aIdentityRelation);
   216 
   217 		inline CTzLocalizedArray();
   218 
   219 	private:
   220 		//Member data
   221 		RPointerArray<T> iArray;
   222 	};
   223 
   224 // Assign concrete classes for each of the arrays that will be used
   225 // This guards against future BC problems
   226 
   227 /**
   228 An array of cities. This just passes function calls on to its templated base
   229 class, CTzLocalizedArray.
   230 
   231 @publishedAll
   232 @released
   233 */
   234 class CTzLocalizedCityArray : public CTzLocalizedArray<CTzLocalizedCity>
   235 	{
   236 	public:
   237 		IMPORT_C static CTzLocalizedCityArray* NewL();
   238 		IMPORT_C static CTzLocalizedCityArray* NewLC();
   239 
   240 		IMPORT_C CTzLocalizedCity& At(TInt aIndex) const;
   241 		IMPORT_C TInt Count() const;
   242 		IMPORT_C void AppendL(CTzLocalizedCity* aCity);
   243 		IMPORT_C void Remove(TInt aIndex);
   244 		IMPORT_C void Sort(TLinearOrder<CTzLocalizedCity> anOrder);
   245 		IMPORT_C TInt Find(CTzLocalizedCity* anEntry,TIdentityRelation<CTzLocalizedCity> aIdentityRelation);
   246 	};
   247 	
   248 /**
   249 An array of city groups. This just passes function calls on to its templated base
   250 class, CTzLocalizedArray.
   251 
   252 @publishedAll
   253 @released
   254 */
   255 class CTzLocalizedCityGroupArray : public CTzLocalizedArray<CTzLocalizedCityGroup>
   256 	{
   257 	public:
   258 		IMPORT_C static CTzLocalizedCityGroupArray* NewL();
   259 		IMPORT_C static CTzLocalizedCityGroupArray* NewLC();
   260 
   261 		IMPORT_C CTzLocalizedCityGroup& At(TInt aIndex) const;
   262 		IMPORT_C TInt Count() const;
   263 		IMPORT_C void AppendL(CTzLocalizedCityGroup* aGroup);
   264 		IMPORT_C void Remove(TInt aIndex);
   265 		IMPORT_C void Sort(TLinearOrder<CTzLocalizedCityGroup> anOrder);
   266 		IMPORT_C TInt Find(CTzLocalizedCityGroup* anEntry,TIdentityRelation<CTzLocalizedCityGroup> aIdentityRelation);
   267 	};
   268 
   269 /**
   270 An array of time zones. This just passes function calls on to its templated base
   271 class, CTzLocalizedArray.
   272 
   273 @publishedAll
   274 @released
   275 */
   276 class CTzLocalizedTimeZoneArray : public CTzLocalizedArray<CTzLocalizedTimeZone>
   277 	{
   278 	public:
   279 		IMPORT_C static CTzLocalizedTimeZoneArray* NewL();
   280 		IMPORT_C static CTzLocalizedTimeZoneArray* NewLC();
   281 
   282 		IMPORT_C CTzLocalizedTimeZone& At(TInt aIndex) const;
   283 		IMPORT_C TInt Count() const;
   284 		IMPORT_C void AppendL(CTzLocalizedTimeZone* aElement);
   285 		IMPORT_C void Remove(TInt aIndex);
   286 		IMPORT_C void Sort(TLinearOrder<CTzLocalizedTimeZone> anOrder);
   287 		IMPORT_C TInt Find(CTzLocalizedTimeZone* anEntry,TIdentityRelation<CTzLocalizedTimeZone> aIdentityRelation);
   288 	};
   289 
   290 #include <tzlocalizationdatatypes.inl>
   291 
   292 #endif //__TZLOCAL_DATATYPES_H__
   293 //==================================================================
   294 // End of file
   295 //==================================================================