64
|
1 |
/*
|
|
2 |
* Copyright (c) 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 |
#include "testconfigfileparser.h"
|
|
18 |
#include <f32file.h>
|
|
19 |
|
|
20 |
CTestConfigItem::CTestConfigItem(CTestConfigSection& aParent)
|
|
21 |
: iParent(aParent)
|
|
22 |
{
|
|
23 |
}
|
|
24 |
|
|
25 |
void CTestConfigItem::ConstructL(const TDesC8& aItem, const TDesC8& aValue)
|
|
26 |
{
|
|
27 |
iItem = aItem.AllocL();
|
|
28 |
iValue = aValue.AllocL();
|
|
29 |
}
|
|
30 |
|
|
31 |
EXPORT_C CTestConfigItem::~CTestConfigItem()
|
|
32 |
{
|
|
33 |
delete iItem;
|
|
34 |
delete iValue;
|
|
35 |
}
|
|
36 |
|
|
37 |
EXPORT_C CTestConfigItem* CTestConfigItem::NewLC(CTestConfigSection& aParent, const TDesC8& aItem, const TDesC8& aValue)
|
|
38 |
{
|
|
39 |
CTestConfigItem* self = new (ELeave) CTestConfigItem(aParent);
|
|
40 |
CleanupStack::PushL(self);
|
|
41 |
self->ConstructL(aItem, aValue);
|
|
42 |
return self;
|
|
43 |
}
|
|
44 |
|
|
45 |
void CTestConfigItem::WriteL(RFile& aFile) const
|
|
46 |
{
|
|
47 |
//Write the section name
|
|
48 |
HBufC8* buf = HBufC8::NewLC(iItem->Length());
|
|
49 |
TPtr8 ptr(buf->Des());
|
|
50 |
|
|
51 |
ptr.Copy(*iItem);
|
|
52 |
User::LeaveIfError(aFile.Write(*buf));
|
|
53 |
User::LeaveIfError(aFile.Write(KScriptItemEnd8));
|
|
54 |
User::LeaveIfError(aFile.Write(KScriptSpace8));
|
|
55 |
CleanupStack::PopAndDestroy(buf);
|
|
56 |
|
|
57 |
HBufC8* val = CTestConfig::ReplaceLC(KScriptLF, KScriptCRLF, *iValue);
|
|
58 |
|
|
59 |
buf = HBufC8::NewLC(val->Length());
|
|
60 |
ptr.Set(buf->Des());
|
|
61 |
ptr.Copy(*val);
|
|
62 |
|
|
63 |
User::LeaveIfError(aFile.Write(*buf));
|
|
64 |
User::LeaveIfError(aFile.Write(KScriptCRLF8));
|
|
65 |
|
|
66 |
CleanupStack::PopAndDestroy(buf);
|
|
67 |
CleanupStack::PopAndDestroy(val);
|
|
68 |
}
|