Update contrib.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include "T_ParseBaseData.h"
23 _LIT( KCmdDrive, "Drive" );
24 _LIT( KCmdDriveAndPath, "DriveAndPath" );
25 _LIT( KCmdDrivePresent, "DrivePresent" );
26 _LIT( KCmdExt, "Ext" );
27 _LIT( KCmdExtPresent, "ExtPresent" );
28 _LIT( KCmdFullName, "FullName" );
29 _LIT( KCmdIsExtWild, "IsExtWild" );
30 _LIT( KCmdIsKMatchAny, "IsKMatchAny" );
31 _LIT( KCmdIsKMatchOne, "IsKMatchOne" );
32 _LIT( KCmdIsNameWild, "IsNameWild" );
33 _LIT( KCmdIsRoot, "IsRoot" );
34 _LIT( KCmdIsWild, "IsWild" );
35 _LIT( KCmdName, "Name" );
36 _LIT( KCmdNameAndExt, "NameAndExt" );
37 _LIT( KCmdNameOrExtPresent, "NameOrExtPresent" );
38 _LIT( KCmdNamePresent, "NamePresent" );
39 _LIT( KCmdPath, "Path" );
40 _LIT( KCmdPathPresent, "PathPresent" );
43 _LIT( KParamExpected, "expected" );
46 CT_ParseBaseData::~CT_ParseBaseData()
54 TAny* CT_ParseBaseData::GetObject()
56 * Return a pointer to the object that the data wraps
58 * @return pointer to the object that the data wraps
64 TBool CT_ParseBaseData::DoCommandL( const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/ )
66 * Process a command read from the ini file
68 * @param aCommand the command to process
69 * @param aSection the entry in the ini file requiring the command to be processed
71 * @return ETrue if the command is processed
77 if ( aCommand == KCmdDrive )
79 DoCmdDrive( aSection );
81 else if ( aCommand == KCmdDriveAndPath )
83 DoCmdDriveAndPath( aSection );
85 else if ( aCommand == KCmdDrivePresent )
87 DoCmdDrivePresent( aSection );
89 else if ( aCommand == KCmdExt )
93 else if ( aCommand == KCmdExtPresent )
95 DoCmdExtPresent( aSection );
97 else if ( aCommand == KCmdFullName )
99 DoCmdFullName( aSection );
101 else if ( aCommand == KCmdIsKMatchAny )
103 DoCmdIsKMatchAny( aSection );
105 else if ( aCommand == KCmdIsKMatchOne )
107 DoCmdIsKMatchOne( aSection );
109 else if ( aCommand == KCmdIsExtWild )
111 DoCmdIsExtWild( aSection );
113 else if ( aCommand == KCmdIsNameWild )
115 DoCmdIsNameWild( aSection );
117 else if ( aCommand == KCmdIsRoot)
119 DoCmdIsRoot( aSection );
121 else if ( aCommand == KCmdIsWild )
123 DoCmdIsWild( aSection );
125 else if ( aCommand == KCmdName )
127 DoCmdName( aSection );
129 else if ( aCommand == KCmdNameAndExt )
131 DoCmdNameAndExt( aSection );
133 else if ( aCommand == KCmdNameOrExtPresent )
135 DoCmdNameOrExtPresent( aSection );
137 else if ( aCommand == KCmdNamePresent )
139 DoCmdNamePresent( aSection );
141 else if ( aCommand == KCmdPath )
143 DoCmdPath( aSection );
145 else if ( aCommand == KCmdPathPresent )
147 DoCmdPathPresent( aSection );
158 void CT_ParseBaseData::DoCmdDrive( const TDesC& aSection )
159 /** Gets the drive letter using Drive(). */
161 INFO_PRINTF1( _L( "Drive()" ) );
163 TPtrC result = GetParse()->Drive();
164 INFO_PRINTF2(_L("Drive() return: %S"), &result);
167 if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
169 if ( result != expected )
171 ERR_PRINTF3(_L("Drive() returns %S but expected %S"), &result, &expected);
172 SetBlockResult( EFail);
177 void CT_ParseBaseData::DoCmdDriveAndPath( const TDesC& aSection )
178 /** Gets the path and drive letter using DriveAndPath(). */
180 INFO_PRINTF1( _L( "DriveAndPath()" ) );
182 TPtrC result = GetParse()->DriveAndPath();
183 INFO_PRINTF2(_L("DriveAndPath() return: %S"), &result);
186 if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
188 if ( result != expected )
190 ERR_PRINTF3(_L("DriveAndPath() returns %S but expected %S"), &result, &expected);
191 SetBlockResult( EFail);
198 void CT_ParseBaseData::DoCmdDrivePresent( const TDesC& aSection )
199 /** Tests whether a drive is present using DrivePresent(). */
201 INFO_PRINTF1( _L( "DrivePresent()" ) );
203 TBool result = GetParse()->DrivePresent();
205 TPtrC strIsTrue = result ? _L("TRUE") : _L("FALSE");
206 INFO_PRINTF2(_L("DrivePresent() return: %S"), &strIsTrue);
209 if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
211 if ( (result>0) != (expected>0) )
213 ERR_PRINTF3(_L("DrivePresent() returns %d but expected %d"), result, expected);
214 SetBlockResult( EFail);
219 void CT_ParseBaseData::DoCmdExt( const TDesC& aSection )
220 /** Gets the file extension using Ext(). */
222 INFO_PRINTF1( _L( "Ext()" ) );
224 TPtrC result = GetParse()->Ext();
225 INFO_PRINTF2(_L("Ext() returns: %S"), &result);
228 if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
230 if ( result != expected )
232 ERR_PRINTF3(_L("Ext() returns %S but expected %S"), &result, &expected);
233 SetBlockResult( EFail);
238 void CT_ParseBaseData::DoCmdExtPresent( const TDesC& aSection )
239 /** Tests whether an extension is present using ExtPresent(). */
241 INFO_PRINTF1( _L( "ExtPresent()" ) );
243 TBool result = GetParse()->ExtPresent();
245 TPtrC strIsTrue = result ? _L("TRUE") : _L("FALSE");
246 INFO_PRINTF2(_L("ExtPresent() return: %S"), &strIsTrue);
249 if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
251 if ( (result>0) != (expected>0) )
253 ERR_PRINTF3(_L("ExtPresent() returns %d but expected %d"), result, expected);
254 SetBlockResult( EFail);
259 void CT_ParseBaseData::DoCmdFullName( const TDesC& aSection )
260 /** Gets the complete file specification using FullName(). */
262 INFO_PRINTF1( _L( "FullName()" ) );
264 TPtrC result = GetParse()->FullName();
265 INFO_PRINTF2(_L("FullName() return: %S"), &result);
268 if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
270 if ( result != expected )
272 ERR_PRINTF3(_L("FullName() returns %S but expected %S"), &result, &expected);
273 SetBlockResult( EFail);
278 void CT_ParseBaseData::DoCmdIsExtWild( const TDesC& aSection )
279 /** Tests whether the extension in the fully parsed specification contains one or
280 * more wildcard characters using IsExtWild()
283 INFO_PRINTF1( _L( "IsExtWild()" ) );
285 TBool result = GetParse()->IsExtWild();
286 TPtrC temp = result ? _L("TRUE") : _L("FALSE");
287 INFO_PRINTF2(_L("IsExtWild() return: %S"), &temp);
290 if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
292 //NB! IsExtWild can return values >1
293 if ( (result>0) != (expected>0) )
295 ERR_PRINTF3(_L("IsExtWild() returns %S but expected %S"), &result, &expected);
296 SetBlockResult( EFail);
301 void CT_ParseBaseData::DoCmdIsKMatchAny( const TDesC& aSection )
302 /** Tests whether the name or the extension contains asterisk wildcards usinbg IsKMatchAny(). */
304 INFO_PRINTF1( _L( "IsKMatchAny()" ) );
306 TBool result = GetParse()->IsKMatchAny();
307 TPtrC temp = result ? _L("TRUE") : _L("FALSE");
308 INFO_PRINTF2(_L("IsKMatchAny() return: %S"), &temp);
311 if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
313 if ( (result>0) != (expected>0) )
315 ERR_PRINTF3(_L("IsKMatchAny() returns %d but expected %d"), result, expected);
316 SetBlockResult( EFail);
321 void CT_ParseBaseData::DoCmdIsKMatchOne( const TDesC& aSection )
322 /** Tests whether the name or the extension contains a question mark wildcard using IsKMatchOne() */
324 INFO_PRINTF1( _L( "IsKMatchOne()" ) );
326 TBool result = GetParse()->IsKMatchOne();
327 TPtrC temp = result ? _L("TRUE") : _L("FALSE");
328 INFO_PRINTF2(_L("IsKMatchOne() return: %S"), &temp);
331 if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
333 if ( (result>0) != (expected>0) )
335 ERR_PRINTF3(_L("IsKMatchOne() returns %d but expected %d"), result, expected);
336 SetBlockResult( EFail);
341 void CT_ParseBaseData::DoCmdIsNameWild( const TDesC& aSection )
342 /** Tests whether the filename in the fully parsed specification contains one or more wildcard
343 * characters using IsNameWild()
346 INFO_PRINTF1( _L( "IsNameWild()" ) );
348 TBool result = GetParse()->IsNameWild();
349 TPtrC temp = result ? _L("TRUE") : _L("FALSE");
350 INFO_PRINTF2(_L("IsNameWild() return: %S"), &temp);
353 if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
355 if ( (result>0) != (expected>0) )
357 ERR_PRINTF3(_L("IsNameWild() returns %d but expected %d"), result, expected);
358 SetBlockResult( EFail);
363 void CT_ParseBaseData::DoCmdIsRoot( const TDesC& aSection )
364 /** Tests whether the path in the fully parsed specification is the root directory using IsRoot(). */
366 INFO_PRINTF1( _L( "IsRoot()" ) );
368 TBool result = GetParse()->IsRoot();
369 TPtrC temp = result ? _L("TRUE") : _L("FALSE");
370 INFO_PRINTF2(_L("IsRoot() return: %S"), &temp);
373 if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
375 if ( (result>0) != (expected>0) )
377 ERR_PRINTF3(_L("IsRoot() returns %d but expected %d"), result, expected);
378 SetBlockResult( EFail);
383 void CT_ParseBaseData::DoCmdIsWild( const TDesC& aSection )
384 /** Tests whether the filename or the extension in the fully parsed specification contains one or
385 * more wildcard characters using IsWild()
388 INFO_PRINTF1( _L( "IsWild()" ) );
390 TBool result = GetParse()->IsWild();
391 TPtrC temp = result ? _L("TRUE") : _L("FALSE");
392 INFO_PRINTF2(_L("IsWild() return: %S"), &temp);
395 if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
397 if ( (result>0) != (expected>0) )
399 ERR_PRINTF3(_L("IsWild() returns %d but expected %d"), result, expected);
400 SetBlockResult( EFail);
406 void CT_ParseBaseData::DoCmdName( const TDesC& aSection )
407 /** Gets the file name using Name(). */
409 INFO_PRINTF1( _L( "Name()" ) );
411 TPtrC result = GetParse()->Name();
412 INFO_PRINTF2(_L( "Name() return: %S" ), &result);
415 if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
417 if ( result != expected )
419 ERR_PRINTF3(_L("Name() returns %S but expected %S"), &result, &expected);
420 SetBlockResult( EFail);
425 void CT_ParseBaseData::DoCmdNameOrExtPresent( const TDesC& aSection )
426 /** Tests whether a name or an extension are present using NameOrExtPresent(). */
428 INFO_PRINTF1( _L( "NameOrExtPresent()" ) );
430 TBool result = GetParse()->NameOrExtPresent();
431 TPtrC temp = result ? _L("TRUE") : _L("FALSE");
432 INFO_PRINTF2(_L("NameOrExtPresent() return: %S"), &temp);
435 if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
437 if ( (result>0) != (expected>0) )
439 ERR_PRINTF3(_L("NameOrExtPresent() returns %d but expected %d"), result, expected);
440 SetBlockResult( EFail);
445 void CT_ParseBaseData::DoCmdNameAndExt( const TDesC& aSection )
446 /** Gets the file name and extension using NameAndExt(). */
448 INFO_PRINTF1( _L( "NameAndExt()" ) );
450 TPtrC result = GetParse()->NameAndExt();
451 INFO_PRINTF2( _L( "NameAndExt() return: %S" ), &result );
454 if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
456 if ( result != expected )
458 ERR_PRINTF3(_L("NameAndExt() returns %S but expected %S"), &result, &expected);
459 SetBlockResult( EFail);
464 void CT_ParseBaseData::DoCmdNamePresent( const TDesC& aSection )
465 /** Tests whether a file name is present using NamePresent(). */
467 INFO_PRINTF1( _L( "NamePresent()" ) );
469 TBool result = GetParse()->NamePresent();
470 TPtrC temp = result ? _L("TRUE") : _L("FALSE");
471 INFO_PRINTF2(_L("NamePresent() return: %S"), &temp);
474 if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
476 if ( (result>0) != (expected>0) )
478 ERR_PRINTF3(_L("NamePresent() returns %d but expected %d"), result, expected);
479 SetBlockResult( EFail);
484 void CT_ParseBaseData::DoCmdPath( const TDesC& aSection )
485 /** Gets the path using Path(). */
487 INFO_PRINTF1( _L( "Path()" ) );
489 TPtrC result = GetParse()->Path();
490 INFO_PRINTF2( _L( "Path() return: %S" ), &result );
493 if ( GET_OPTIONAL_STRING_PARAMETER( KParamExpected, aSection, expected ) )
495 if ( result != expected )
497 ERR_PRINTF3(_L("Path() returns %S but expected %S"), &result, &expected);
498 SetBlockResult( EFail);
503 void CT_ParseBaseData::DoCmdPathPresent( const TDesC& aSection )
504 /** Tests whether a path is present using PathPresent(). */
506 INFO_PRINTF1( _L( "PathPresent()" ) );
508 TBool result = GetParse()->PathPresent();
509 TPtrC temp = result ? _L("TRUE") : _L("FALSE");
510 INFO_PRINTF2(_L("PathPresent() return: %S"), &temp);
513 if ( GET_OPTIONAL_BOOL_PARAMETER( KParamExpected, aSection, expected ) )
515 if ( (result>0) != (expected>0) )
517 ERR_PRINTF3(_L("PathPresent() returns %d but expected %d"), result, expected);
518 SetBlockResult( EFail);