os/ossrv/genericopenlibs/openenvcore/libc/inc/localeinfo.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:  Contains the class declartion for locale related functions
    15  *     
    16  *
    17 */
    18 
    19  
    20 #include <e32base.h>
    21 #include <e32std.h>
    22 #include <e32ldr.h>
    23 #include <charconv.h>
    24 #include <f32file.h>
    25 #include <locale.h>
    26 #include <langinfo.h>
    27 #include <string.h>
    28 #include <stdio.h>
    29 #include <ctype.h>
    30 #include "lmonetary.h"
    31 #include "lnumeric.h"
    32 #include "timelocal.h"
    33 #include "sysif.h"
    34 
    35 // CONSTANTS
    36 const TInt KNumLocaleExports = 22;
    37 
    38 class CLocale:public CBase
    39 {
    40 private:	
    41 	CLocale();
    42 	static CLocale* New();
    43 	TInt ConstructL();
    44 	
    45 public:	
    46 	static CLocale* GetInstance();
    47 	static void DeleteInstance();
    48 	
    49 	static struct lc_numeric_T* GetCurrentNumericLocale(void);
    50 	static struct lc_monetary_T* GetCurrentMonetaryLocale(void);
    51 	static struct lc_time_T* GetCurrentTimeLocale(void);
    52 	
    53 	TText*  SetLocale(TDesC& aLocale);
    54 	TInt LoadLocale(TDesC& aLocale);
    55     #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
    56 	TInt SyncLocale(TLocaleAspect aspect);
    57     #endif
    58 	const TText* nl_langinfo(nl_item aItem);
    59 	struct lconv * localeconv();
    60 	
    61    
    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);
    66 #endif
    67 	TInt  GetSystemLocale(TDesC& aDllName);
    68     const TText* GetLocaleName(void);
    69 #else
    70   TText* GetLocaleName(void);
    71 #endif
    72 
    73     
    74 
    75 	TInt MonetaryLoadLocaleL(const char* localeName);
    76 	TInt NumericLoadLocale(const char* localeName);
    77 	TInt TimeLoadLocaleL(const char* localeName);
    78 	
    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);
    82     #endif
    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
    89 		{
    90 		Mem::FillZ(aBase, aSize); return aBase;
    91 		}
    92 		
    93 	inline TAny* operator new(TUint aSize) __NO_THROW
    94 		{
    95 		return Backend()->Alloc(aSize);
    96 		}
    97 		
    98 	inline TAny* operator new(TUint aSize, TLeave)
    99 		{
   100 		TAny* ptr = Backend()->Alloc(aSize);
   101 		if (ptr == NULL)
   102 			{
   103 			User::Leave(KErrNoMemory);
   104 			}
   105 		return ptr;
   106 		}
   107 		
   108 	inline TAny* operator new(TUint aSize, TUint aExtraSize) __NO_THROW
   109 		{
   110 		return Backend()->Alloc(aSize + aExtraSize);
   111 		}
   112 		
   113 	inline TAny* operator new(TUint aSize, TLeave, TUint aExtraSize)
   114 		{
   115 		TAny* ptr = Backend()->Alloc(aSize + aExtraSize);
   116 		if (ptr == NULL)
   117 			{
   118 			User::Leave(KErrNoMemory);
   119 			}
   120 		return ptr;
   121 		}
   122 	
   123 	//Corresponding overloaded delete operators
   124 	inline void operator delete(TAny *aPtr, TAny*) __NO_THROW
   125 		{
   126 		Backend()->Free( aPtr );
   127 		}
   128 		
   129 	inline void operator delete(TAny *aPtr) __NO_THROW
   130 		{
   131 		Backend()->Free( aPtr );
   132 		}
   133 		
   134 	inline void operator delete(TAny *aPtr, TLeave) 
   135 		{
   136 		Backend()->Free( aPtr );
   137 		}
   138 		
   139 	inline void operator delete(TAny *aPtr, TUint) __NO_THROW
   140 		{
   141 		Backend()->Free( aPtr );
   142 		}
   143 	inline void operator delete(TAny *aPtr, TLeave, TUint) 
   144 		{
   145 		Backend()->Free( aPtr );
   146 		}
   147 
   148 private:
   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;
   153 	
   154 	
   155 	SLocaleLanguage iLanguageSettings;
   156 	SLocaleLocaleSettings iLocaleSettings;
   157 	SLocaleTimeDateFormat iLocaleTimeDateFormat;
   158 	TLocale iLocale;
   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 );
   171 	
   172 #endif
   173 };
   174 //end of file
   175 
   176 
   177