/** * Reads the value present from the test steps ini file within the mentioned section name and key name * Copies the value to the TInt reference passed in. The value can optionally be prefixed with 0x * @param aSectName - Section within the test steps ini file * @param aKeyName - Name of a key within a section * @return aResult - The integer value of the Hex input * @return TBool - ETrue for found, EFalse for not found */ TBool CDataWrapperBase::GetHexFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TInt& aResult) { TPtrC result; TBool ret=EFalse; TRAPD(err, ret=GetCommandStringParameterL(aSectName, aKeyName, result)); if ( err != KErrNone ) { ret=EFalse; } if ( ret ) { TLex lex; if( result.FindC(KPrefixHex)==KErrNone ) { lex=result.Mid(KPrefixHex().Length()); } else { lex=result; } ret=(lex.Val((TUint &)aResult, EHex)==KErrNone); } return ret; }
/** * Reads the value present from the test steps ini file within the mentioned section name and key name * Copies the value to the TPtrC reference passed in * @param aSectName - Section within the test steps ini file * @param aKeyName - Name of a key within a section * @return aResult - Reference to the string on the heap * @return TBool - ETrue for found, EFalse for not found */ TBool CDataWrapperBase::GetStringFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TPtrC& aResult) { TBool ret=EFalse; TRAPD(err, ret=GetCommandStringParameterL(aSectName, aKeyName, aResult)); if ( err != KErrNone ) { ret=EFalse; } return ret; }
/** * Reads the value present from the test steps ini file within the mentioned section name and key name * Copies the value to the TReal reference passed in * @param aSectName - Section within the test steps ini file * @param aKeyName - Name of a key within a section * @return aResult - The value of the real * @return TBool - ETrue for found, EFalse for not found */ TBool CDataWrapperBase::GetRealFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TReal& aResult) { TPtrC result; TBool ret=EFalse; TRAPD(err, ret=GetCommandStringParameterL(aSectName, aKeyName, result)); if ( err != KErrNone ) { ret = EFalse; } if ( ret ) { TLex lex(result); ret = ( lex.Val(aResult)==KErrNone ); } return ret; }
/** * Reads the value present from the test steps ini file within the mentioned section name and key name * Copies the value to the TBool reference passed in possible values TRUE, FALSE * @param aSectName - Section within the test steps ini file * @param aKeyName - Name of a key within a section * @return aResult - The value of the boolean * @return TBool - ETrue for found, EFalse for not found */ TBool CDataWrapperBase::GetBoolFromConfig(const TDesC& aSectName,const TDesC& aKeyName,TBool& aResult) { TBool ret=EFalse; TPtrC result; TRAPD(err, ret=GetCommandStringParameterL(aSectName, aKeyName, result)); if ( err != KErrNone ) { ret=EFalse; } if ( ret ) { _LIT(KTrue,"true"); aResult=(result.FindF(KTrue) != KErrNotFound); } return ret; }
/** * Reads the value present from the test steps ini file within the mentioned section name and key name * Copies the value to the TUint reference passed in. * If the value is prefixed with 0x the value is read as a hexadecimal value * If the value is suffixed with b the value is read as a binary value * If the value is prefixed with a 0 the value is read as an octal value * If it does not match the above it is read in as an integer * @param aSectName - Section within the test steps ini file * @param aKeyName - Name of a key within a section * @return aResult - The integer value of the Hex input * @return TBool - ETrue for found, EFalse for not found */ TBool CDataWrapperBase::GetUintFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TUint& aResult) { TPtrC result; TBool ret=EFalse; TRAPD(err, ret=GetCommandStringParameterL(aSectName, aKeyName, result)); if ( err != KErrNone ) { ret=EFalse; } if ( ret ) { TLex lex(result); if( result.FindC(KPrefixHex)==KErrNone ) { lex=result.Mid(KPrefixHex().Length()); ret=(lex.Val(aResult, EHex)==KErrNone); } else { TInt binarySuffixPosition=result.Length()-KSuffixBinary().Length(); if ( result.FindC(KSuffixBinary)==binarySuffixPosition ) { lex=result.Left(binarySuffixPosition); ret=(lex.Val(aResult, EBinary)==KErrNone); } else { if( result.FindC(KPrefixOctal)==KErrNone ) { ret=(lex.Val(aResult, EOctal)==KErrNone); } else { TInt intResult; ret=(lex.Val(intResult)==KErrNone); if ( ret ) { aResult=(TUint)intResult; } } } } } return ret; }
/** * Return array of string parameters i.e. key=a1,a2,a3 returns array which contains * String a1, a2 and a3. * @return ret - EFalse if can't get a String parameter from Config file. ETrue if KErrNone */ TBool CDataWrapperBase::GetArrayFromConfig(const TDesC& aSectName, const TDesC& aKeyName, RPointerArray<HBufC>& aResult) { TBool ret=EFalse; TPtrC completeArray; TRAPD(err, ret=GetCommandStringParameterL(aSectName, aKeyName, completeArray)); if ( err != KErrNone ) { ret=EFalse; } TLex16 lex(completeArray); // Here we have the array as a string i.e. "a1,a2,a3" TBuf<256> buf; TChar chr; while(!lex.Eos()) { chr = lex.Get(); // Check if there was a list separator if (chr == ',') { HBufC* param = buf.AllocLC(); buf.Zero(); aResult.Append(param); CleanupStack::Pop(param); // pointer to buf is stored in RPointerArray } // If not separator character we can store the character into array else { buf.Append(chr); } } // Remember to put last token into array (,a3) HBufC* param = buf.AllocLC(); aResult.Append(param); CleanupStack::Pop(param); return ret; }