os/ossrv/genericopenlibs/openenvcore/libc/inc/localeinfo.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/openenvcore/libc/inc/localeinfo.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,177 @@
     1.4 +/*
     1.5 +* Copyright (c) 2006-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 "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:  Contains the class declartion for locale related functions
    1.18 + *     
    1.19 + *
    1.20 +*/
    1.21 +
    1.22 + 
    1.23 +#include <e32base.h>
    1.24 +#include <e32std.h>
    1.25 +#include <e32ldr.h>
    1.26 +#include <charconv.h>
    1.27 +#include <f32file.h>
    1.28 +#include <locale.h>
    1.29 +#include <langinfo.h>
    1.30 +#include <string.h>
    1.31 +#include <stdio.h>
    1.32 +#include <ctype.h>
    1.33 +#include "lmonetary.h"
    1.34 +#include "lnumeric.h"
    1.35 +#include "timelocal.h"
    1.36 +#include "sysif.h"
    1.37 +
    1.38 +// CONSTANTS
    1.39 +const TInt KNumLocaleExports = 22;
    1.40 +
    1.41 +class CLocale:public CBase
    1.42 +{
    1.43 +private:	
    1.44 +	CLocale();
    1.45 +	static CLocale* New();
    1.46 +	TInt ConstructL();
    1.47 +	
    1.48 +public:	
    1.49 +	static CLocale* GetInstance();
    1.50 +	static void DeleteInstance();
    1.51 +	
    1.52 +	static struct lc_numeric_T* GetCurrentNumericLocale(void);
    1.53 +	static struct lc_monetary_T* GetCurrentMonetaryLocale(void);
    1.54 +	static struct lc_time_T* GetCurrentTimeLocale(void);
    1.55 +	
    1.56 +	TText*  SetLocale(TDesC& aLocale);
    1.57 +	TInt LoadLocale(TDesC& aLocale);
    1.58 +    #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
    1.59 +	TInt SyncLocale(TLocaleAspect aspect);
    1.60 +    #endif
    1.61 +	const TText* nl_langinfo(nl_item aItem);
    1.62 +	struct lconv * localeconv();
    1.63 +	
    1.64 +   
    1.65 +#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
    1.66 +#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
    1.67 +	TInt  GetSystemLocale(TDesC& aLanDllName,TDesC& aRegDllName);
    1.68 +	const TText* GetCollateLocaleName(void);
    1.69 +#endif
    1.70 +	TInt  GetSystemLocale(TDesC& aDllName);
    1.71 +    const TText* GetLocaleName(void);
    1.72 +#else
    1.73 +  TText* GetLocaleName(void);
    1.74 +#endif
    1.75 +
    1.76 +    
    1.77 +
    1.78 +	TInt MonetaryLoadLocaleL(const char* localeName);
    1.79 +	TInt NumericLoadLocale(const char* localeName);
    1.80 +	TInt TimeLoadLocaleL(const char* localeName);
    1.81 +	
    1.82 +	TInt ConvertToMultiByteL(TUint8* aNarrowCharString, const TText16* aWideCharString, TInt  aCharsetUID);
    1.83 +    #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
    1.84 +	void ConvertToMultiByteCustom(TUint8* aNarrowCharString, const TText16* aWideCharString);
    1.85 +    #endif
    1.86 +	TInt GetCharcaterSetIDL(const char* aLocaleName);
    1.87 +	/*******************************************************************
    1.88 +	Overloading new and delete operators so that they will
    1.89 +	allocate and deallocare memory from/to the private heap of backend
    1.90 +	********************************************************************/
    1.91 +	inline TAny* operator new(TUint aSize, TAny* aBase) __NO_THROW
    1.92 +		{
    1.93 +		Mem::FillZ(aBase, aSize); return aBase;
    1.94 +		}
    1.95 +		
    1.96 +	inline TAny* operator new(TUint aSize) __NO_THROW
    1.97 +		{
    1.98 +		return Backend()->Alloc(aSize);
    1.99 +		}
   1.100 +		
   1.101 +	inline TAny* operator new(TUint aSize, TLeave)
   1.102 +		{
   1.103 +		TAny* ptr = Backend()->Alloc(aSize);
   1.104 +		if (ptr == NULL)
   1.105 +			{
   1.106 +			User::Leave(KErrNoMemory);
   1.107 +			}
   1.108 +		return ptr;
   1.109 +		}
   1.110 +		
   1.111 +	inline TAny* operator new(TUint aSize, TUint aExtraSize) __NO_THROW
   1.112 +		{
   1.113 +		return Backend()->Alloc(aSize + aExtraSize);
   1.114 +		}
   1.115 +		
   1.116 +	inline TAny* operator new(TUint aSize, TLeave, TUint aExtraSize)
   1.117 +		{
   1.118 +		TAny* ptr = Backend()->Alloc(aSize + aExtraSize);
   1.119 +		if (ptr == NULL)
   1.120 +			{
   1.121 +			User::Leave(KErrNoMemory);
   1.122 +			}
   1.123 +		return ptr;
   1.124 +		}
   1.125 +	
   1.126 +	//Corresponding overloaded delete operators
   1.127 +	inline void operator delete(TAny *aPtr, TAny*) __NO_THROW
   1.128 +		{
   1.129 +		Backend()->Free( aPtr );
   1.130 +		}
   1.131 +		
   1.132 +	inline void operator delete(TAny *aPtr) __NO_THROW
   1.133 +		{
   1.134 +		Backend()->Free( aPtr );
   1.135 +		}
   1.136 +		
   1.137 +	inline void operator delete(TAny *aPtr, TLeave) 
   1.138 +		{
   1.139 +		Backend()->Free( aPtr );
   1.140 +		}
   1.141 +		
   1.142 +	inline void operator delete(TAny *aPtr, TUint) __NO_THROW
   1.143 +		{
   1.144 +		Backend()->Free( aPtr );
   1.145 +		}
   1.146 +	inline void operator delete(TAny *aPtr, TLeave, TUint) 
   1.147 +		{
   1.148 +		Backend()->Free( aPtr );
   1.149 +		}
   1.150 +
   1.151 +private:
   1.152 +	static CLocale* iNewLocale;
   1.153 +	static struct lc_monetary_T* iMonetary_locale;
   1.154 +	static struct lc_numeric_T* iNumeric_locale;
   1.155 +	static struct lc_time_T* iTime_locale;
   1.156 +	
   1.157 +	
   1.158 +	SLocaleLanguage iLanguageSettings;
   1.159 +	SLocaleLocaleSettings iLocaleSettings;
   1.160 +	SLocaleTimeDateFormat iLocaleTimeDateFormat;
   1.161 +	TLocale iLocale;
   1.162 +    TLibraryFunction iData[KNumLocaleExports];
   1.163 +	TChar iThousandsSeparator;
   1.164 +	TChar iDecimalSeparator;
   1.165 +#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
   1.166 +	TLibraryFunction iDataRegion[KNumLocaleExports];// will contain Monetary , numeric and time info
   1.167 +    TLibraryFunction iDataLanguage[KNumLocaleExports];// will contain month table and Day Table   details
   1.168 +    TBuf<30> iRegDllName;
   1.169 +    TBuf<30> iLanDllName;
   1.170 +	TBool iOldDllPresent;
   1.171 +	TInt LoadNewLocaleDll( TDesC& aLocale );
   1.172 +	TInt ParseNewLocaleFile( TDesC& aLocale );
   1.173 +	TInt TimeLoadNewLocaleL( const char* localeName );
   1.174 +	
   1.175 +#endif
   1.176 +};
   1.177 +//end of file
   1.178 +
   1.179 +
   1.180 +