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