sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description: Contains the class declartion for locale related functions
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*
|
sl@0
|
17 |
*/
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
#include <e32base.h>
|
sl@0
|
21 |
#include <e32std.h>
|
sl@0
|
22 |
#include <e32ldr.h>
|
sl@0
|
23 |
#include <charconv.h>
|
sl@0
|
24 |
#include <f32file.h>
|
sl@0
|
25 |
#include <locale.h>
|
sl@0
|
26 |
#include <langinfo.h>
|
sl@0
|
27 |
#include <string.h>
|
sl@0
|
28 |
#include <stdio.h>
|
sl@0
|
29 |
#include <ctype.h>
|
sl@0
|
30 |
#include "lmonetary.h"
|
sl@0
|
31 |
#include "lnumeric.h"
|
sl@0
|
32 |
#include "timelocal.h"
|
sl@0
|
33 |
#include "sysif.h"
|
sl@0
|
34 |
|
sl@0
|
35 |
// CONSTANTS
|
sl@0
|
36 |
const TInt KNumLocaleExports = 22;
|
sl@0
|
37 |
|
sl@0
|
38 |
class CLocale:public CBase
|
sl@0
|
39 |
{
|
sl@0
|
40 |
private:
|
sl@0
|
41 |
CLocale();
|
sl@0
|
42 |
static CLocale* New();
|
sl@0
|
43 |
TInt ConstructL();
|
sl@0
|
44 |
|
sl@0
|
45 |
public:
|
sl@0
|
46 |
static CLocale* GetInstance();
|
sl@0
|
47 |
static void DeleteInstance();
|
sl@0
|
48 |
|
sl@0
|
49 |
static struct lc_numeric_T* GetCurrentNumericLocale(void);
|
sl@0
|
50 |
static struct lc_monetary_T* GetCurrentMonetaryLocale(void);
|
sl@0
|
51 |
static struct lc_time_T* GetCurrentTimeLocale(void);
|
sl@0
|
52 |
|
sl@0
|
53 |
TText* SetLocale(TDesC& aLocale);
|
sl@0
|
54 |
TInt LoadLocale(TDesC& aLocale);
|
sl@0
|
55 |
#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
|
sl@0
|
56 |
TInt SyncLocale(TLocaleAspect aspect);
|
sl@0
|
57 |
#endif
|
sl@0
|
58 |
const TText* nl_langinfo(nl_item aItem);
|
sl@0
|
59 |
struct lconv * localeconv();
|
sl@0
|
60 |
|
sl@0
|
61 |
|
sl@0
|
62 |
#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
|
sl@0
|
63 |
#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
|
sl@0
|
64 |
TInt GetSystemLocale(TDesC& aLanDllName,TDesC& aRegDllName);
|
sl@0
|
65 |
const TText* GetCollateLocaleName(void);
|
sl@0
|
66 |
#endif
|
sl@0
|
67 |
TInt GetSystemLocale(TDesC& aDllName);
|
sl@0
|
68 |
const TText* GetLocaleName(void);
|
sl@0
|
69 |
#else
|
sl@0
|
70 |
TText* GetLocaleName(void);
|
sl@0
|
71 |
#endif
|
sl@0
|
72 |
|
sl@0
|
73 |
|
sl@0
|
74 |
|
sl@0
|
75 |
TInt MonetaryLoadLocaleL(const char* localeName);
|
sl@0
|
76 |
TInt NumericLoadLocale(const char* localeName);
|
sl@0
|
77 |
TInt TimeLoadLocaleL(const char* localeName);
|
sl@0
|
78 |
|
sl@0
|
79 |
TInt ConvertToMultiByteL(TUint8* aNarrowCharString, const TText16* aWideCharString, TInt aCharsetUID);
|
sl@0
|
80 |
#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
|
sl@0
|
81 |
void ConvertToMultiByteCustom(TUint8* aNarrowCharString, const TText16* aWideCharString);
|
sl@0
|
82 |
#endif
|
sl@0
|
83 |
TInt GetCharcaterSetIDL(const char* aLocaleName);
|
sl@0
|
84 |
/*******************************************************************
|
sl@0
|
85 |
Overloading new and delete operators so that they will
|
sl@0
|
86 |
allocate and deallocare memory from/to the private heap of backend
|
sl@0
|
87 |
********************************************************************/
|
sl@0
|
88 |
inline TAny* operator new(TUint aSize, TAny* aBase) __NO_THROW
|
sl@0
|
89 |
{
|
sl@0
|
90 |
Mem::FillZ(aBase, aSize); return aBase;
|
sl@0
|
91 |
}
|
sl@0
|
92 |
|
sl@0
|
93 |
inline TAny* operator new(TUint aSize) __NO_THROW
|
sl@0
|
94 |
{
|
sl@0
|
95 |
return Backend()->Alloc(aSize);
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
inline TAny* operator new(TUint aSize, TLeave)
|
sl@0
|
99 |
{
|
sl@0
|
100 |
TAny* ptr = Backend()->Alloc(aSize);
|
sl@0
|
101 |
if (ptr == NULL)
|
sl@0
|
102 |
{
|
sl@0
|
103 |
User::Leave(KErrNoMemory);
|
sl@0
|
104 |
}
|
sl@0
|
105 |
return ptr;
|
sl@0
|
106 |
}
|
sl@0
|
107 |
|
sl@0
|
108 |
inline TAny* operator new(TUint aSize, TUint aExtraSize) __NO_THROW
|
sl@0
|
109 |
{
|
sl@0
|
110 |
return Backend()->Alloc(aSize + aExtraSize);
|
sl@0
|
111 |
}
|
sl@0
|
112 |
|
sl@0
|
113 |
inline TAny* operator new(TUint aSize, TLeave, TUint aExtraSize)
|
sl@0
|
114 |
{
|
sl@0
|
115 |
TAny* ptr = Backend()->Alloc(aSize + aExtraSize);
|
sl@0
|
116 |
if (ptr == NULL)
|
sl@0
|
117 |
{
|
sl@0
|
118 |
User::Leave(KErrNoMemory);
|
sl@0
|
119 |
}
|
sl@0
|
120 |
return ptr;
|
sl@0
|
121 |
}
|
sl@0
|
122 |
|
sl@0
|
123 |
//Corresponding overloaded delete operators
|
sl@0
|
124 |
inline void operator delete(TAny *aPtr, TAny*) __NO_THROW
|
sl@0
|
125 |
{
|
sl@0
|
126 |
Backend()->Free( aPtr );
|
sl@0
|
127 |
}
|
sl@0
|
128 |
|
sl@0
|
129 |
inline void operator delete(TAny *aPtr) __NO_THROW
|
sl@0
|
130 |
{
|
sl@0
|
131 |
Backend()->Free( aPtr );
|
sl@0
|
132 |
}
|
sl@0
|
133 |
|
sl@0
|
134 |
inline void operator delete(TAny *aPtr, TLeave)
|
sl@0
|
135 |
{
|
sl@0
|
136 |
Backend()->Free( aPtr );
|
sl@0
|
137 |
}
|
sl@0
|
138 |
|
sl@0
|
139 |
inline void operator delete(TAny *aPtr, TUint) __NO_THROW
|
sl@0
|
140 |
{
|
sl@0
|
141 |
Backend()->Free( aPtr );
|
sl@0
|
142 |
}
|
sl@0
|
143 |
inline void operator delete(TAny *aPtr, TLeave, TUint)
|
sl@0
|
144 |
{
|
sl@0
|
145 |
Backend()->Free( aPtr );
|
sl@0
|
146 |
}
|
sl@0
|
147 |
|
sl@0
|
148 |
private:
|
sl@0
|
149 |
static CLocale* iNewLocale;
|
sl@0
|
150 |
static struct lc_monetary_T* iMonetary_locale;
|
sl@0
|
151 |
static struct lc_numeric_T* iNumeric_locale;
|
sl@0
|
152 |
static struct lc_time_T* iTime_locale;
|
sl@0
|
153 |
|
sl@0
|
154 |
|
sl@0
|
155 |
SLocaleLanguage iLanguageSettings;
|
sl@0
|
156 |
SLocaleLocaleSettings iLocaleSettings;
|
sl@0
|
157 |
SLocaleTimeDateFormat iLocaleTimeDateFormat;
|
sl@0
|
158 |
TLocale iLocale;
|
sl@0
|
159 |
TLibraryFunction iData[KNumLocaleExports];
|
sl@0
|
160 |
TChar iThousandsSeparator;
|
sl@0
|
161 |
TChar iDecimalSeparator;
|
sl@0
|
162 |
#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
|
sl@0
|
163 |
TLibraryFunction iDataRegion[KNumLocaleExports];// will contain Monetary , numeric and time info
|
sl@0
|
164 |
TLibraryFunction iDataLanguage[KNumLocaleExports];// will contain month table and Day Table details
|
sl@0
|
165 |
TBuf<30> iRegDllName;
|
sl@0
|
166 |
TBuf<30> iLanDllName;
|
sl@0
|
167 |
TBool iOldDllPresent;
|
sl@0
|
168 |
TInt LoadNewLocaleDll( TDesC& aLocale );
|
sl@0
|
169 |
TInt ParseNewLocaleFile( TDesC& aLocale );
|
sl@0
|
170 |
TInt TimeLoadNewLocaleL( const char* localeName );
|
sl@0
|
171 |
|
sl@0
|
172 |
#endif
|
sl@0
|
173 |
};
|
sl@0
|
174 |
//end of file
|
sl@0
|
175 |
|
sl@0
|
176 |
|
sl@0
|
177 |
|