os/kernelhwsrv/baseapitest/basesvs/validation/f32/sfsrv/src/T_ParsePtrCData.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 #include "T_ParsePtrCData.h"
    20 
    21 
    22 // Commands
    23 _LIT( KCmdDelete,					"~" );
    24 _LIT( KCmdNew,						"new" );
    25 _LIT( KCmdAddDir,					"AddDir");
    26 _LIT( KCmdPopDir,					"PopDir");
    27 
    28 // Parameters
    29 _LIT( KParamFileName,				"FileName" );
    30 _LIT( KParamDirName,				"DirName" );
    31 
    32 
    33 CT_ParsePtrCData* CT_ParsePtrCData::NewL()
    34 /**
    35 * Two phase constructor
    36 */
    37 	{
    38 	CT_ParsePtrCData* ret = new (ELeave) CT_ParsePtrCData();
    39 	CleanupStack::PushL( ret );
    40 	ret->ConstructL();
    41 	CleanupStack::Pop( ret );
    42 	return ret;
    43 	}
    44 
    45 CT_ParsePtrCData::CT_ParsePtrCData()
    46 :	iParsePtrC(NULL)
    47 /**
    48 * Protected constructor. First phase construction
    49 */
    50 	{
    51 	}
    52 	
    53 void CT_ParsePtrCData::ConstructL()
    54 /**
    55 * Protected constructor. Second phase construction
    56 */
    57 	{
    58 	}
    59 	
    60 CT_ParsePtrCData::~CT_ParsePtrCData()
    61 /**
    62 * Destructor.
    63 */
    64 	{
    65 	DoCleanup();
    66 	}
    67 	
    68 
    69 
    70 TParseBase* CT_ParsePtrCData::GetParse()
    71 	{
    72 	return iParsePtrC;
    73 	}
    74 	
    75 TBool CT_ParsePtrCData::DoCommandL( const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
    76 /**
    77 * Process a command read from the ini file
    78 *
    79 * @param aCommand	the command to process
    80 * @param aSection		the entry in the ini file requiring the command to be processed
    81 *
    82 * @return ETrue if the command is processed
    83 */
    84 	{
    85 	TBool retVal = ETrue;
    86 	
    87 	if ( aCommand == KCmdDelete )
    88 		{
    89 		DoCleanup();
    90 		}
    91 	else if ( aCommand == KCmdNew )
    92 		{
    93 		DoCmdNew( aSection );
    94 		}
    95 	else if ( aCommand == KCmdAddDir )
    96 		{
    97 		DoCmdAddDir( aSection );
    98 		}
    99 	else if ( aCommand == KCmdPopDir )
   100 		{
   101 		DoCmdPopDir();
   102 		}
   103 	else
   104 	    {
   105 	    retVal = CT_ParseBaseData::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
   106 	    }
   107 	
   108 	return retVal;
   109 	}
   110 	
   111 void CT_ParsePtrCData::DoCleanup()
   112 /** Deletes TParsePtr class instance */
   113     {
   114     INFO_PRINTF1( _L( "Delete TParsePtrC class instance." ) );
   115 
   116 	delete iParsePtrC;
   117 	iParsePtrC = NULL;
   118     }
   119 
   120 void CT_ParsePtrCData::DoCmdNew( const TDesC& aSection )
   121 /** Creates new TParsePtr class instance */
   122 	{
   123 	DoCleanup();
   124 	
   125 	TPtrC fileName;
   126 	if ( GET_MANDATORY_STRING_PARAMETER( KParamFileName, aSection, fileName ) )
   127 		{
   128 		INFO_PRINTF2( _L( "Create new TParsePtrC(\"%S\") class instance." ), &fileName );
   129 		
   130 		iFileName = fileName;
   131 		TRAPD( err, iParsePtrC = new (ELeave) TParsePtrC( iFileName ) );
   132 		if ( err != KErrNone )
   133 			{
   134 			ERR_PRINTF3( _L( "new TParsePtrC(\"%S\") error=%d" ), &fileName, err );
   135 			SetError( err );
   136 			}
   137 		}
   138 	}
   139 
   140 	
   141 void CT_ParsePtrCData::DoCmdPopDir()
   142 /** Removes the last directory from the path using PopDir(). */
   143 	{
   144 	INFO_PRINTF1( _L( "PopDir()" ) );
   145 		
   146 	TInt err = iParsePtrC->PopDir();
   147 	
   148 	if( err != KErrNone)
   149 			{
   150 			ERR_PRINTF2( _L( "PopDir() returned %d error"), err);
   151 			SetError(err);
   152 			}
   153 	}
   154 
   155     
   156 void CT_ParsePtrCData::DoCmdAddDir( const TDesC& aSection )
   157 /** Adds a single directory onto the end of the path using AddDir. */
   158 	{
   159 	TPtrC dirName;
   160 	if ( GET_MANDATORY_STRING_PARAMETER( KParamDirName, aSection, dirName ) )
   161 		{
   162 		INFO_PRINTF2( _L( "AddDir(\"%S\")" ), &dirName );
   163 		
   164 		TInt err = iParsePtrC->AddDir( dirName );
   165 		if(	err != KErrNone)
   166 			{
   167 			ERR_PRINTF2( _L( "AddDir() returned %d error"), err);
   168 			SetError(err);
   169 			}
   170 		}
   171 	}
   172