epoc32/include/mw/tzlocalizationdatatypes.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     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".
     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>
    20 
    21 /**
    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.
    25 
    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.
    28 
    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).
    32 
    33 RESOURCE LOCALIZED_TIMEZONE r_tz_europe_tirane
    34 	{
    35 	time_zone_id = 2728;
    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;
    40 	cities = 
    41 		{
    42 		TIMEZONE_CITY
    43 			{
    44 			city_group_id = 5;
    45 			city_name = 2728_tirane_name;
    46 			}
    47 		};
    48 	}
    49 
    50 @internalTechnology
    51 */
    52 class TTzLocalizedId
    53 	{
    54 	public:
    55 		explicit TTzLocalizedId(const TUint16 aTzId, const TUint aResourceId);
    56 
    57 		//Accessor methods
    58 		inline TUint16 TimeZoneId() const;
    59 		inline TUint ResourceId() const;
    60 		
    61 	private:
    62 		TUint16 iTzId;
    63 		TUint iResourceId;
    64 	};
    65 
    66 /**
    67 Encapsulates a localized (exemplar) city.
    68 
    69 @publishedAll
    70 @released
    71 */
    72 class CTzLocalizedCity : public CBase
    73 	{
    74 	public:
    75 		static CTzLocalizedCity* NewL(
    76 			const TDesC& aName,
    77 			const TTzLocalizedId& aTzLocalizedId,
    78 			const TUint8 aGroupId =0);
    79 		static CTzLocalizedCity* NewLC(
    80 			const TDesC& aName,
    81 			const TTzLocalizedId& aTzLocalizedId,
    82 			const TUint8 aGroupId =0);
    83 		~CTzLocalizedCity();
    84 
    85 		//Accessor methods
    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;
    94 
    95 	private:
    96 		void ConstructL(const TDesC& aName);
    97 		CTzLocalizedCity(const TUint8 aGroupId, const TTzLocalizedId& aTzLocalizedId);
    98 
    99 	private:
   100 		HBufC* iName;
   101 		TUint8 iGroupId;
   102 		TTzLocalizedId iTzLocalizedId;
   103         TInt iCityIndex;
   104         /**
   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.
   107         */
   108         TInt iUTCOffset;
   109 	};
   110 
   111 /**
   112 Encapsulates a localized group of (exemplar) cities.
   113 
   114 @publishedAll
   115 @released
   116 */
   117 class CTzLocalizedCityGroup : public CBase
   118 	{
   119 	public:
   120 		static CTzLocalizedCityGroup* NewL(const TDesC& aName, const TUint8 aGroupId);
   121 		static CTzLocalizedCityGroup* NewLC(const TDesC& aName, const TUint8 aGroupId);
   122 		~CTzLocalizedCityGroup();
   123 
   124 		//Accessor methods
   125 		IMPORT_C TPtrC Name() const;
   126 		IMPORT_C TUint8 Id() const;
   127 
   128 	private:
   129 		void ConstructL(const TDesC& aName);
   130 		CTzLocalizedCityGroup(const TUint8 aGroupId);
   131 
   132 	private:
   133 		HBufC* iName;
   134 		TUint8 iGroupId;
   135 	};
   136 
   137 /**
   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
   141 
   142 @publishedAll
   143 @released
   144 */
   145 class CTzLocalizedTimeZone : public CBase
   146 	{
   147 	public: //enums
   148 		/**
   149 		Flags to identify a cached zone.
   150 		@publishedAll
   151 		@released
   152 		*/
   153 		enum TTzFrequentlyUsedZone
   154 			{
   155 			/** The current zone. */
   156 			ECurrentZone,
   157 			/** The home zone. */
   158 			EHomeZone,
   159 			/** The zone of interest. */
   160 			EInterestZone,
   161 			/** The first recently-used zone. */
   162 			ERecentZone1,
   163 			/** The second recently-used zone. */
   164 			ERecentZone2,
   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
   169 			};
   170 
   171 	public:
   172 		static CTzLocalizedTimeZone* NewL(
   173 			const TTzLocalizedId& aTzLocalizedId,
   174 			const TDesC& aStandardName,
   175 			const TDesC& aDaylightName,
   176 			const TDesC& aShortStandardName,
   177 			const TDesC& aShortDaylightName);
   178 
   179 		static CTzLocalizedTimeZone* NewLC(
   180 			const TTzLocalizedId& aTzLocalizedId,
   181 			const TDesC& aStandardName,
   182 			const TDesC& aDaylightName,
   183 			const TDesC& aShortStandardName,
   184 			const TDesC& aShortDaylightName);
   185 
   186 		~CTzLocalizedTimeZone();
   187 
   188 		//Accessor methods
   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);
   197 
   198 	private:
   199 		void ConstructL(
   200 			const TDesC& aStandardName,
   201 			const TDesC& aDaylightName,
   202 			const TDesC& aShortStandardName,
   203 			const TDesC& aShortDaylightName);
   204 		CTzLocalizedTimeZone(const TTzLocalizedId& aTzLocalizedId);
   205 
   206 	private:
   207 		TTzLocalizedId iTzLocalizedId;
   208 		HBufC* iStandardName;
   209 		HBufC* iDaylightName;
   210 		HBufC* iShortStandardName;
   211 		HBufC* iShortDaylightName;
   212 		/**
   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.
   215         */
   216 		TInt iUTCOffset;
   217 	};
   218 
   219 /**
   220 Template for arrays of localized objects. Implemented using a thin template. 
   221 All functions are inline.
   222 
   223 @publishedAll
   224 @released
   225 */
   226 template <class T>
   227 class CTzLocalizedArray : public CBase
   228 	{
   229 	protected:
   230 		inline ~CTzLocalizedArray();
   231 
   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);
   239 
   240 		inline CTzLocalizedArray();
   241 
   242 	private:
   243 		RPointerArray<T> iArray;
   244 	};
   245 
   246 // Assign concrete classes for each of the arrays that will be used
   247 // This guards against future BC problems
   248 
   249 /**
   250 An array of cities. This just passes function calls on to its templated base
   251 class, CTzLocalizedArray.
   252 
   253 @publishedAll
   254 @released
   255 */
   256 class CTzLocalizedCityArray : public CTzLocalizedArray<CTzLocalizedCity>
   257 	{
   258 	public:
   259 		IMPORT_C static CTzLocalizedCityArray* NewL();
   260 		IMPORT_C static CTzLocalizedCityArray* NewLC();
   261 
   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);
   269 	};
   270 	
   271 /**
   272 An array of city groups. This just passes function calls on to its templated base
   273 class, CTzLocalizedArray.
   274 
   275 @publishedAll
   276 @released
   277 */
   278 class CTzLocalizedCityGroupArray : public CTzLocalizedArray<CTzLocalizedCityGroup>
   279 	{
   280 	public:
   281 		IMPORT_C static CTzLocalizedCityGroupArray* NewL();
   282 		IMPORT_C static CTzLocalizedCityGroupArray* NewLC();
   283 
   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);
   291 	};
   292 
   293 /**
   294 An array of time zones. This just passes function calls on to its templated base
   295 class, CTzLocalizedArray.
   296 
   297 @publishedAll
   298 @released
   299 */
   300 class CTzLocalizedTimeZoneArray : public CTzLocalizedArray<CTzLocalizedTimeZone>
   301 	{
   302 	public:
   303 		IMPORT_C static CTzLocalizedTimeZoneArray* NewL();
   304 		IMPORT_C static CTzLocalizedTimeZoneArray* NewLC();
   305 
   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);
   313 	};
   314 
   315 #include <tzlocalizationdatatypes.inl>
   316 
   317 #endif //__TZLOCAL_DATATYPES_H__