os/kernelhwsrv/baseapitest/basesvs/validation/f32/sfsrv/src/T_ParsePtrData.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/baseapitest/basesvs/validation/f32/sfsrv/src/T_ParsePtrData.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,180 @@
     1.4 +/*
     1.5 +* Copyright (c) 2005-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: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#include "T_ParsePtrData.h"
    1.23 +
    1.24 +
    1.25 +// Commands
    1.26 +_LIT( KCmdDelete,					"~" );
    1.27 +_LIT( KCmdNew,						"new" );
    1.28 +_LIT( KCmdAddDir,					"AddDir");
    1.29 +_LIT( KCmdPopDir,					"PopDir");
    1.30 +
    1.31 +// Parameters
    1.32 +_LIT( KParamFileName,				"FileName" );
    1.33 +_LIT( KParamDirName,				"DirName" );
    1.34 +
    1.35 +CT_ParsePtrData* CT_ParsePtrData::NewL()
    1.36 +/**
    1.37 +* Two phase constructor
    1.38 +*/
    1.39 +	{
    1.40 +	CT_ParsePtrData* ret = new (ELeave) CT_ParsePtrData();
    1.41 +	CleanupStack::PushL( ret );
    1.42 +	ret->ConstructL();
    1.43 +	CleanupStack::Pop( ret );
    1.44 +	return ret;
    1.45 +	}
    1.46 +
    1.47 +CT_ParsePtrData::CT_ParsePtrData( )
    1.48 +:	iParsePtr(NULL)
    1.49 +/**
    1.50 +* Protected constructor. First phase construction
    1.51 +*/
    1.52 +	{
    1.53 +	}
    1.54 +
    1.55 +TParseBase* CT_ParsePtrData::GetParse()
    1.56 +	{
    1.57 +	return iParsePtr;
    1.58 +	}
    1.59 +
    1.60 +void CT_ParsePtrData::ConstructL()
    1.61 +/**
    1.62 +* Protected constructor. Second phase construction
    1.63 +*/
    1.64 +	{
    1.65 +	}
    1.66 +	
    1.67 +CT_ParsePtrData::~CT_ParsePtrData()
    1.68 +/**
    1.69 +* Destructor.
    1.70 +*/
    1.71 +	{
    1.72 +	DoCleanup();
    1.73 +	}
    1.74 +	
    1.75 +
    1.76 +TAny* CT_ParsePtrData::GetObject()
    1.77 +/**
    1.78 +* Return a pointer to the object that the data wraps
    1.79 +*
    1.80 +* @return pointer to the object that the data wraps
    1.81 +*/
    1.82 +	{
    1.83 +	return iParsePtr;
    1.84 +	}
    1.85 +
    1.86 +TBool CT_ParsePtrData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex )
    1.87 +/**
    1.88 +* Process a command read from the ini file
    1.89 +*
    1.90 +* @param aCommand	the command to process
    1.91 +* @param aEntry		the entry in the ini file requiring the command to be processed
    1.92 +*
    1.93 +* @return ETrue if the command is processed
    1.94 +*/
    1.95 +	{
    1.96 +	TBool retVal = ETrue;
    1.97 +	
    1.98 +	if ( aCommand == KCmdDelete )
    1.99 +		{
   1.100 +		DoCleanup();
   1.101 +		}
   1.102 +	else if ( aCommand == KCmdNew )
   1.103 +		{
   1.104 +		DoCmdNew( aSection );
   1.105 +		}
   1.106 +	else if ( aCommand == KCmdAddDir )
   1.107 +		{
   1.108 +		DoCmdAddDir( aSection );
   1.109 +		}
   1.110 +	else if ( aCommand == KCmdPopDir )
   1.111 +		{
   1.112 +		DoCmdPopDir();
   1.113 +		}
   1.114 +	else
   1.115 +	    {
   1.116 +	    retVal = CT_ParseBaseData::DoCommandL(aCommand, aSection, aAsyncErrorIndex);    
   1.117 +	    }
   1.118 +	
   1.119 +	return retVal;
   1.120 +	}
   1.121 +	
   1.122 +void CT_ParsePtrData::DoCleanup()
   1.123 +/** Deletes TParsePtr class instance */
   1.124 +    {
   1.125 +    INFO_PRINTF1( _L( "Delete TParsePtr class instance." ) );
   1.126 +    
   1.127 +	delete iParsePtr;
   1.128 +	iParsePtr = NULL;
   1.129 +    }
   1.130 +
   1.131 +void CT_ParsePtrData::DoCmdNew( const TDesC& aSection )
   1.132 +/** Creates new TParsePtr class instance */
   1.133 +	{
   1.134 +	DoCleanup();
   1.135 +
   1.136 +	TPtrC fileName;
   1.137 +	if ( GET_MANDATORY_STRING_PARAMETER( KParamFileName, aSection, fileName ) )
   1.138 +		{
   1.139 +		INFO_PRINTF2( _L( "Create new TParsePtr(\"%S\") class instance." ), &fileName );
   1.140 +		
   1.141 +		iFileName = fileName;
   1.142 +		TRAPD( err, iParsePtr = new (ELeave) TParsePtr( iFileName ) );
   1.143 +		if ( err != KErrNone )
   1.144 +			{
   1.145 +			ERR_PRINTF3( _L( "new TParsePtr(\"%S\") error=%d" ), &fileName, err );
   1.146 +			SetError( err );
   1.147 +			}
   1.148 +		}
   1.149 +	}
   1.150 +
   1.151 + 
   1.152 +void CT_ParsePtrData::DoCmdPopDir()
   1.153 +/** Removes the last directory from the path using PopDir(). */
   1.154 +	{
   1.155 +	INFO_PRINTF1( _L( "PopDir()" ) );
   1.156 +		
   1.157 +	TInt err = iParsePtr->PopDir();
   1.158 +	
   1.159 +	if( err != KErrNone)
   1.160 +			{
   1.161 +			ERR_PRINTF2( _L( "PopDir() returned %d error"), err);
   1.162 +			SetError(err);
   1.163 +			}
   1.164 +	}
   1.165 +
   1.166 +
   1.167 +    
   1.168 +void CT_ParsePtrData::DoCmdAddDir( const TDesC& aSection )
   1.169 +/** Adds a single directory onto the end of the path using AddDir. */
   1.170 +	{
   1.171 +	TPtrC dirName;
   1.172 +	if ( GET_MANDATORY_STRING_PARAMETER( KParamDirName, aSection, dirName ) )
   1.173 +		{
   1.174 +		INFO_PRINTF2( _L( "AddDir(\"%S\")" ), &dirName );
   1.175 +		
   1.176 +		TInt err = iParsePtr->AddDir( dirName );
   1.177 +		if(	err != KErrNone)
   1.178 +			{
   1.179 +			ERR_PRINTF2( _L( "AddDir() returned %d error"), err);
   1.180 +			SetError(err);
   1.181 +			}
   1.182 +		}
   1.183 +	}