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