telephonyserverplugins/simtsy/testconfigfileparser/src/testconfigsection.cpp
author hgs
Wed, 25 Aug 2010 14:35:42 +0100
changeset 64 b34bb05ac869
permissions -rw-r--r--
201031_04
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
64
b34bb05ac869 201031_04
hgs
parents:
diff changeset
     1
/*
b34bb05ac869 201031_04
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
b34bb05ac869 201031_04
hgs
parents:
diff changeset
     3
* All rights reserved.
b34bb05ac869 201031_04
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
b34bb05ac869 201031_04
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
b34bb05ac869 201031_04
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
b34bb05ac869 201031_04
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
b34bb05ac869 201031_04
hgs
parents:
diff changeset
     8
*
b34bb05ac869 201031_04
hgs
parents:
diff changeset
     9
* Initial Contributors:
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    11
*
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    12
* Contributors:
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    13
*
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    14
* Description: 
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    15
*
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    16
*/
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    17
#include "testconfigfileparser.h"
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    18
#include <f32file.h>
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    19
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    20
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    21
//
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    22
// CTestConfigSection
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    23
//
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    24
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    25
CTestConfigSection::CTestConfigSection()
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    26
	: CBase()
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    27
	{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    28
	}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    29
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    30
EXPORT_C CTestConfigSection* CTestConfigSection::NewLC(const TDesC8& aSectionName, CTestConfigSection& aDefaults)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    31
	{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    32
	CTestConfigSection* self = new (ELeave) CTestConfigSection();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    33
	CleanupStack::PushL(self);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    34
	self->iDefaults = aDefaults.CopyLC();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    35
	CleanupStack::Pop(self->iDefaults);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    36
	self->ConstructL(aSectionName);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    37
	return self;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    38
	}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    39
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    40
EXPORT_C CTestConfigSection* CTestConfigSection::NewLC(const TDesC8& aSectionName)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    41
	{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    42
	CTestConfigSection* self = new (ELeave) CTestConfigSection();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    43
	CleanupStack::PushL(self);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    44
	self->ConstructL(aSectionName);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    45
	return self;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    46
	}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    47
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    48
void CTestConfigSection::ConstructL(const TDesC8& aSectionName)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    49
	{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    50
	iSectionName = aSectionName.AllocL();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    51
	}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    52
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    53
EXPORT_C const TDesC8& CTestConfigSection::ItemValue(const TDesC8& aItem, const TDesC8& aDefault) const
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    54
	{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    55
	const CTestConfigItem* sectionItem = Item(aItem);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    56
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    57
	if (sectionItem != NULL)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    58
		{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    59
		const TPtrC8 value(sectionItem->Value());
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    60
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    61
		if (iDefaults != NULL && (value.CompareF(KScriptDefault1) == 0 || value.CompareF(KScriptDefault2) == 0))
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    62
			{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    63
			return iDefaults->ItemValue(aItem, aDefault);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    64
			}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    65
		else
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    66
			{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    67
			return sectionItem->Value();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    68
			}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    69
		}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    70
	else if (iDefaults != NULL)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    71
		{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    72
		return iDefaults->ItemValue(aItem, aDefault);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    73
		}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    74
	else
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    75
		{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    76
		return aDefault;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    77
		}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    78
	}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    79
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    80
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    81
EXPORT_C TInt CTestConfigSection::ItemValue(const TDesC8& aItem, const TInt aDefault) const
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    82
	{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    83
	const TDesC8& value = ItemValue(aItem, KNullDesC8);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    84
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    85
	if (value.Length() == 0)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    86
		{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    87
		if (iDefaults != NULL)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    88
			return iDefaults->ItemValue(aItem, aDefault);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    89
		else
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    90
			return aDefault;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    91
		}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    92
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    93
	TLex8 input(value);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    94
	TInt ret = aDefault;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    95
	TInt err = input.Val(ret);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    96
	
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    97
	if (err)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    98
		{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
    99
		if (iDefaults != NULL)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   100
			return iDefaults->ItemValue(aItem, aDefault);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   101
		else
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   102
			return aDefault;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   103
		}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   104
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   105
	return ret;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   106
	}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   107
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   108
EXPORT_C CTestConfigItem& CTestConfigSection::AddItemL(const TDesC8& aItem, const TDesC8& aValue)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   109
	{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   110
	CTestConfigItem* sectionItem = CTestConfigItem::NewLC(*this, aItem, aValue);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   111
	User::LeaveIfError(iItems.Append(sectionItem));
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   112
	CleanupStack::Pop(sectionItem);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   113
	return *sectionItem;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   114
	}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   115
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   116
EXPORT_C void CTestConfigSection::DeleteItemsL(const TDesC8& aItem)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   117
	{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   118
	TInt count = iItems.Count();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   119
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   120
	//Remove existing CTestConfigItems that have the same item name
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   121
	while (count--)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   122
		{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   123
		CTestConfigItem* sectionItem = iItems[count];
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   124
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   125
		if (sectionItem->Item().CompareF(aItem) == 0)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   126
			{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   127
			delete sectionItem;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   128
			iItems.Remove(count);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   129
			}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   130
		}	
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   131
	}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   132
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   133
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   134
EXPORT_C CTestConfigSection::~CTestConfigSection()
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   135
	{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   136
	iItems.ResetAndDestroy();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   137
	iItems.Close();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   138
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   139
	delete iSectionName;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   140
	delete iDefaults;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   141
	}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   142
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   143
EXPORT_C CTestConfigSection* CTestConfigSection::CopyLC() const
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   144
	{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   145
	TInt count = iItems.Count();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   146
	CTestConfigSection* copy = NULL;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   147
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   148
	if (iDefaults != NULL)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   149
		copy = CTestConfigSection::NewLC(SectionName(), *iDefaults);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   150
	else
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   151
		copy = CTestConfigSection::NewLC(SectionName());
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   152
		
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   153
	while (count--)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   154
		{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   155
		CTestConfigItem* item = iItems[count]->CopyLC();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   156
		User::LeaveIfError(copy->iItems.Append(item));
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   157
		CleanupStack::Pop(item);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   158
		}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   159
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   160
	return copy;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   161
	}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   162
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   163
void CTestConfigSection::WriteL(RFile& aFile) const
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   164
	{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   165
	//Write the section name
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   166
	HBufC8* buf = HBufC8::NewLC(iSectionName->Length());
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   167
	buf->Des().Copy(*iSectionName);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   168
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   169
	User::LeaveIfError(aFile.Write(KScriptSectionStart));
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   170
	User::LeaveIfError(aFile.Write(*buf));
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   171
	User::LeaveIfError(aFile.Write(KScriptSectionEnd));
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   172
	User::LeaveIfError(aFile.Write(KScriptCRLF8));
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   173
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   174
	CleanupStack::PopAndDestroy(buf);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   175
	const TInt count = iItems.Count();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   176
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   177
	//Write the items
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   178
	for (TInt i = 0; i < count; i++)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   179
		iItems[i]->WriteL(aFile);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   180
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   181
	User::LeaveIfError(aFile.Write(KScriptCRLF8));
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   182
	}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   183
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   184
TBool CTestConfigSection::operator==(const CTestConfigSection& aSection) const
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   185
	{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   186
	TInt count = iItems.Count();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   187
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   188
	if (count != aSection.Items().Count())
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   189
		return EFalse;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   190
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   191
	TBool retVal = (*iSectionName == aSection.SectionName());
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   192
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   193
	while (count-- && retVal)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   194
		{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   195
		retVal = retVal && (*iItems[count] == aSection[count]);
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   196
		}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   197
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   198
	return retVal;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   199
	}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   200
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   201
EXPORT_C const CTestConfigItem* CTestConfigSection::Item(const TDesC8& aItem) const
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   202
	{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   203
	const CTestConfigItem* sectionItem = NULL;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   204
	const TInt count = iItems.Count();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   205
	for (TInt i = 0; i < count; i++)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   206
		{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   207
		if (iItems[i]->Item().CompareF(aItem) == 0)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   208
			{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   209
			sectionItem = iItems[i];
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   210
			break;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   211
			}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   212
		}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   213
	return sectionItem;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   214
	}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   215
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   216
EXPORT_C CTestConfigItem* CTestConfigSection::Item(const TDesC8& aItem)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   217
	{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   218
	CTestConfigItem* sectionItem = NULL;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   219
	const TInt count = iItems.Count();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   220
	for (TInt i = 0; i < count; i++)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   221
		{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   222
		if (iItems[i]->Item().CompareF(aItem) == 0)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   223
			{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   224
			sectionItem = iItems[i];
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   225
			break;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   226
			}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   227
		}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   228
	return sectionItem;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   229
	}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   230
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   231
EXPORT_C const CTestConfigItem* CTestConfigSection::Item(const TDesC8& aItem,TInt aIndex) const
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   232
	{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   233
	const CTestConfigItem* sectionItem = NULL;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   234
	const TInt count = iItems.Count();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   235
	TInt foundItemCnt=0;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   236
	for (TInt i = 0; i < count; i++)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   237
		{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   238
		if (iItems[i]->Item().CompareF(aItem) == 0)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   239
			{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   240
			if(foundItemCnt++==aIndex)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   241
				{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   242
				sectionItem = iItems[i];
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   243
				break;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   244
				}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   245
			}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   246
		}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   247
	return sectionItem;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   248
	}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   249
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   250
EXPORT_C CTestConfigItem* CTestConfigSection::Item(const TDesC8& aItem,TInt aIndex)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   251
	{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   252
	CTestConfigItem* sectionItem = NULL;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   253
	const TInt count = iItems.Count();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   254
	TInt foundItemCnt=0;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   255
	for (TInt i = 0; i < count; i++)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   256
		{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   257
		if (iItems[i]->Item().CompareF(aItem) == 0)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   258
			{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   259
			if(foundItemCnt++==aIndex)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   260
				{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   261
				sectionItem = iItems[i];
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   262
				break;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   263
				}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   264
			}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   265
		}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   266
	return sectionItem;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   267
	}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   268
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   269
EXPORT_C void CTestConfigSection::ItemsL(RPointerArray<CTestConfigItem>& aArray, const TDesC8& aItemTag)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   270
	{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   271
	aArray.Reset();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   272
	const TInt count = iItems.Count();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   273
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   274
	for (TInt i = 0; i < count; i++) //< Order important
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   275
		{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   276
		CTestConfigItem& item = *iItems[i];
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   277
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   278
		if (item.Item().CompareF(aItemTag) == 0)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   279
			{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   280
			User::LeaveIfError(aArray.Append(&item));
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   281
			}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   282
		}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   283
	}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   284
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   285
EXPORT_C void CTestConfigSection::ItemsL(RPointerArray<const CTestConfigItem>& aArray, const TDesC8& aItemTag) const
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   286
	{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   287
	aArray.Reset();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   288
	const TInt count = iItems.Count();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   289
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   290
	for (TInt i = 0; i < count; i++) //< Order important
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   291
		{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   292
		const CTestConfigItem& item = *iItems[i];
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   293
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   294
		if (item.Item().CompareF(aItemTag) == 0)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   295
			{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   296
			User::LeaveIfError(aArray.Append(&item));
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   297
			}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   298
		}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   299
	}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   300
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   301
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   302
EXPORT_C TInt CTestConfigSection::ItemCount(const TDesC8& aItem) const
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   303
	{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   304
	const TInt count = iItems.Count();
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   305
	TInt foundItemCnt=0;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   306
	for (TInt i = 0; i < count; i++)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   307
		{
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   308
		if (iItems[i]->Item().CompareF(aItem) == 0)
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   309
			foundItemCnt++;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   310
		}
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   311
	return foundItemCnt;
b34bb05ac869 201031_04
hgs
parents:
diff changeset
   312
	}