First public contribution.
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Contains the class declartion for locale related functions
30 #include "lmonetary.h"
32 #include "timelocal.h"
36 const TInt KNumLocaleExports = 22;
38 class CLocale:public CBase
42 static CLocale* New();
46 static CLocale* GetInstance();
47 static void DeleteInstance();
49 static struct lc_numeric_T* GetCurrentNumericLocale(void);
50 static struct lc_monetary_T* GetCurrentMonetaryLocale(void);
51 static struct lc_time_T* GetCurrentTimeLocale(void);
53 TText* SetLocale(TDesC& aLocale);
54 TInt LoadLocale(TDesC& aLocale);
55 #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
56 TInt SyncLocale(TLocaleAspect aspect);
58 const TText* nl_langinfo(nl_item aItem);
59 struct lconv * localeconv();
62 #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
63 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
64 TInt GetSystemLocale(TDesC& aLanDllName,TDesC& aRegDllName);
65 const TText* GetCollateLocaleName(void);
67 TInt GetSystemLocale(TDesC& aDllName);
68 const TText* GetLocaleName(void);
70 TText* GetLocaleName(void);
75 TInt MonetaryLoadLocaleL(const char* localeName);
76 TInt NumericLoadLocale(const char* localeName);
77 TInt TimeLoadLocaleL(const char* localeName);
79 TInt ConvertToMultiByteL(TUint8* aNarrowCharString, const TText16* aWideCharString, TInt aCharsetUID);
80 #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
81 void ConvertToMultiByteCustom(TUint8* aNarrowCharString, const TText16* aWideCharString);
83 TInt GetCharcaterSetIDL(const char* aLocaleName);
84 /*******************************************************************
85 Overloading new and delete operators so that they will
86 allocate and deallocare memory from/to the private heap of backend
87 ********************************************************************/
88 inline TAny* operator new(TUint aSize, TAny* aBase) __NO_THROW
90 Mem::FillZ(aBase, aSize); return aBase;
93 inline TAny* operator new(TUint aSize) __NO_THROW
95 return Backend()->Alloc(aSize);
98 inline TAny* operator new(TUint aSize, TLeave)
100 TAny* ptr = Backend()->Alloc(aSize);
103 User::Leave(KErrNoMemory);
108 inline TAny* operator new(TUint aSize, TUint aExtraSize) __NO_THROW
110 return Backend()->Alloc(aSize + aExtraSize);
113 inline TAny* operator new(TUint aSize, TLeave, TUint aExtraSize)
115 TAny* ptr = Backend()->Alloc(aSize + aExtraSize);
118 User::Leave(KErrNoMemory);
123 //Corresponding overloaded delete operators
124 inline void operator delete(TAny *aPtr, TAny*) __NO_THROW
126 Backend()->Free( aPtr );
129 inline void operator delete(TAny *aPtr) __NO_THROW
131 Backend()->Free( aPtr );
134 inline void operator delete(TAny *aPtr, TLeave)
136 Backend()->Free( aPtr );
139 inline void operator delete(TAny *aPtr, TUint) __NO_THROW
141 Backend()->Free( aPtr );
143 inline void operator delete(TAny *aPtr, TLeave, TUint)
145 Backend()->Free( aPtr );
149 static CLocale* iNewLocale;
150 static struct lc_monetary_T* iMonetary_locale;
151 static struct lc_numeric_T* iNumeric_locale;
152 static struct lc_time_T* iTime_locale;
155 SLocaleLanguage iLanguageSettings;
156 SLocaleLocaleSettings iLocaleSettings;
157 SLocaleTimeDateFormat iLocaleTimeDateFormat;
159 TLibraryFunction iData[KNumLocaleExports];
160 TChar iThousandsSeparator;
161 TChar iDecimalSeparator;
162 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
163 TLibraryFunction iDataRegion[KNumLocaleExports];// will contain Monetary , numeric and time info
164 TLibraryFunction iDataLanguage[KNumLocaleExports];// will contain month table and Day Table details
165 TBuf<30> iRegDllName;
166 TBuf<30> iLanDllName;
167 TBool iOldDllPresent;
168 TInt LoadNewLocaleDll( TDesC& aLocale );
169 TInt ParseNewLocaleFile( TDesC& aLocale );
170 TInt TimeLoadNewLocaleL( const char* localeName );