os/boardsupport/haitest/bspsvs/suite/common/inc/DataWrapperBase.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2005-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:
    15 *
    16 */
    17 
    18 
    19 #if (!defined __DATA_WRAPPER_BASE__)
    20 #define __DATA_WRAPPER_BASE__
    21 
    22 //	EPOC includes
    23 #include <datawrapper.h>
    24 #define SECS_TO_MS(x)  (x*1000000)
    25 
    26 typedef TBuf<KTEFMaxNameLength>	TIniDataName;
    27 
    28 _LIT(KConsname,				"Test Console");
    29 
    30 #define	GETFROMCONFIGOPTIONAL(aType, aSectName, aKeyName, aResult, aLogMessage)	\
    31 		if ( !Get##aType##FromConfig(aSectName, aKeyName, aResult) )	\
    32 			{															\
    33 			WARN_PRINTF3(aLogMessage, &aKeyName, aResult);				\
    34 			}
    35 
    36 #define	GETFROMCONFIGMANDATORY(aType, aSectName, aKeyName, aResult, aLogMessage, aDataOk)	\
    37 		if ( !Get##aType##FromConfig(aSectName, aKeyName, aResult) )	\
    38 			{															\
    39 			ERR_PRINTF2(aLogMessage, &aKeyName);						\
    40 			SetBlockResult(EFail);										\
    41 			aDataOk=EFalse;												\
    42 			}
    43 
    44 #define	GETSTRINGFROMCONFIGOPTIONAL(aSectName, aKeyName, aResult, aLogMessage)	\
    45 		if ( !GetStringFromConfig(aSectName, aKeyName, aResult) )		\
    46 			{															\
    47 			WARN_PRINTF3(aLogMessage, &aKeyName, &aResult);				\
    48 			}
    49 
    50 #define	GETSTRINGFROMCONFIGMANDATORY(aSectName, aKeyName, aResult, aLogMessage, aDataOk)	\
    51 		if ( !GetStringFromConfig(aSectName, aKeyName, aResult) )		\
    52 			{															\
    53 			ERR_PRINTF2(aLogMessage, &aKeyName);						\
    54 			SetBlockResult(EFail);										\
    55 			aDataOk=EFalse;												\
    56 			}
    57 
    58 class CDataWrapperBase : public CDataWrapper
    59 	{
    60 public:
    61 	class TEnumEntryTable
    62 		{
    63 	public:
    64 		const TDesC&	iString;
    65 		TInt			iValue;
    66 		};
    67 
    68 public:
    69 	TBool					GetBoolFromConfig(const TDesC& aSectName,const TDesC& aKeyName,TBool& aResult);
    70 	TBool					GetIntFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TInt& aResult);
    71 	TBool					GetStringFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TPtrC& aResult);
    72 	TBool					GetHexFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TInt& aResult);
    73 	TBool					GetUintFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TUint& aResult);
    74 	TBool					GetPointFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TPoint& aResult);
    75 	TBool					GetRectFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TRect& aResult);
    76 	TBool					GetSizeFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TSize& aResult);
    77 	TBool					GetEnumFromConfig(const TDesC& aSectName, const TDesC& aKeyName, const TEnumEntryTable* aTable, TInt& aResult);
    78 	TBool					GetOrFromConfig(const TDesC& aSectName, const TDesC& aKeyName, const TEnumEntryTable* aTable, TUint& aResult);
    79 	TBool 					GetUint8FromConfig(const TDesC& aSectName, const TDesC& aKeyName, TUint8& aResult);
    80 	void 					Timedelay(TInt aTimeoutInSecs);
    81 	virtual void			InitialiseL();
    82 	inline RFs&				FileServer();
    83 	inline CConsoleBase*	GetConsoleL();
    84 	TBool					TranslateEnumToString(CDataWrapper& aDataWrapper, const TDesC& aEnum, const TInt aValue, TDesC& aTrasnaltion);
    85 	TBool					TranslateNumberToEnumStringL(CDataWrapper& aDataWrapper, const TDesC& aSection, const TInt aValue, TDes& aTranslation);
    86 	void 					PromptMessageL(const TDesC& aMsg,const TInt aDelayMiliSec,TKeyCode& aKeyCode);
    87 	virtual TBool			DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex);
    88 
    89 protected:
    90 	CDataWrapperBase();
    91 	virtual ~CDataWrapperBase();
    92 
    93 	TBool	GetCommandStringParameter(const TDesC& aParameterName, const TDesC& aSection, TPtrC& aResult, TText8 *aFileName, TInt aLine, TBool aMandatory);
    94 	TBool	GetCommandIntParameter(const TDesC& aParameterName, const TDesC& aSection, TInt& aResult, TText8 *aFileName, TInt aLine, TBool aMandatory);
    95 	TBool	GetCommandBoolParameter(const TDesC& aParameterName, const TDesC& aSection, TBool& aResult, TText8 *aFileName, TInt aLine, TBool aMandatory);
    96 
    97 private:
    98 	TBool	ProcessString(const TDesC& aStr, TUint& aResult, const TEnumEntryTable* aTable);
    99 	TBool	ProcessEntry(const TDesC& aStr, TUint& aResult, const TEnumEntryTable* aTable);
   100 	TBool 	ProcessEnumList(CDataWrapper& aDataWrapper,	const TDesC& aStr, const TDesC& aEnum, const TUint& aValue, TDes& aTranslation);
   101 	TBool	GetCommandStringParameterL(const TDesC& aSectName, const TDesC& aKeyName, TPtrC& aResult);
   102 	TBool 	KeyCheck();
   103 	void 	DoCmdUtilityPromptMessageL(const TDesC& aSection);
   104 
   105 private:
   106 	// Included ini files
   107 	RPointerArray<CIniData>	iInclude;
   108 	RPointerArray<HBufC>	iBuffer;
   109 	RFs                     iFs;
   110 	RTimer					iTimer;
   111 	};
   112 
   113 #include "DataWrapperBase.inl"
   114 
   115 #endif /* __DATA_WRAPPER_BASE__ */