os/graphics/windowing/windowserver/test/t_integ/src/t_wservconfigdata.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
/**
sl@0
    17
 @file
sl@0
    18
 @test
sl@0
    19
 @internalComponent
sl@0
    20
*/
sl@0
    21
sl@0
    22
#include "t_wservconfigdata.h"
sl@0
    23
sl@0
    24
//
sl@0
    25
// Construction/Destruction
sl@0
    26
//
sl@0
    27
sl@0
    28
CT_WServConfigData::CT_WServConfigData()
sl@0
    29
	{
sl@0
    30
	}
sl@0
    31
sl@0
    32
CT_WServConfigData::~CT_WServConfigData()
sl@0
    33
	{
sl@0
    34
	Empty();
sl@0
    35
	}
sl@0
    36
sl@0
    37
void CT_WServConfigData::ReplaceData(const TDesC& aName, const TDesC& aData)
sl@0
    38
	{
sl@0
    39
	TInt	count=iArrayName.Count();
sl@0
    40
	TInt	index=0;
sl@0
    41
	for ( index=0; index<count; ++index )
sl@0
    42
		{
sl@0
    43
		if ( aName.Compare(iArrayName[index]) == 0 )
sl@0
    44
			{
sl@0
    45
			break;
sl@0
    46
			}
sl@0
    47
		}
sl@0
    48
	
sl@0
    49
	iArrayData.Remove(index);
sl@0
    50
	iArrayData.Insert(aData,index);
sl@0
    51
	}
sl@0
    52
	
sl@0
    53
void CT_WServConfigData::AddDataL(const TDesC& aName, const TDesC& aData)
sl@0
    54
	{
sl@0
    55
	//	Ensure name does not already exist
sl@0
    56
	TInt	count=iArrayName.Count();
sl@0
    57
	TInt	index=0;
sl@0
    58
	for ( index=0; index<count; ++index )
sl@0
    59
		{
sl@0
    60
		if ( aName.Compare(iArrayName[index]) == 0 )
sl@0
    61
			{
sl@0
    62
			User::Leave(KErrAlreadyExists);
sl@0
    63
			}
sl@0
    64
		}
sl@0
    65
sl@0
    66
	iArrayName.AppendL(aName);
sl@0
    67
	iArrayData.AppendL(aData);
sl@0
    68
	}
sl@0
    69
sl@0
    70
void CT_WServConfigData::DeleteDataL(const TDesC& aName)
sl@0
    71
	{
sl@0
    72
	//	Ensure name already exist
sl@0
    73
	TBool	found=EFalse;
sl@0
    74
	TInt	count=iArrayName.Count();
sl@0
    75
	for ( TInt index=0; (index<count) && (!found); ++index )
sl@0
    76
		{
sl@0
    77
		if ( aName.Compare(iArrayName[index]) == 0 )
sl@0
    78
			{
sl@0
    79
			found=ETrue;
sl@0
    80
			iArrayName.Remove(index);
sl@0
    81
			iArrayData.Remove(index);
sl@0
    82
			}
sl@0
    83
		}
sl@0
    84
sl@0
    85
	if ( !found )
sl@0
    86
		{
sl@0
    87
		User::Leave(KErrNotFound);
sl@0
    88
		}
sl@0
    89
	}
sl@0
    90
sl@0
    91
sl@0
    92
const TWServConfigData& CT_WServConfigData::GetData(const TInt aIndex) const
sl@0
    93
	{
sl@0
    94
	return iArrayData[aIndex];
sl@0
    95
	}
sl@0
    96
sl@0
    97
const TWServConfigData& CT_WServConfigData::GetName(const TInt aIndex) const
sl@0
    98
	{
sl@0
    99
	return iArrayName[aIndex];
sl@0
   100
	}
sl@0
   101
sl@0
   102
void CT_WServConfigData::Empty()
sl@0
   103
	{
sl@0
   104
	iArrayName.Close();
sl@0
   105
	iArrayData.Close();
sl@0
   106
	}
sl@0
   107
sl@0
   108
TInt CT_WServConfigData::NoOfEntriesL() const
sl@0
   109
	{
sl@0
   110
	TInt	dataCount=iArrayData.Count();
sl@0
   111
	TInt	nameCount=iArrayName.Count();
sl@0
   112
sl@0
   113
	if (dataCount!=nameCount)
sl@0
   114
		{
sl@0
   115
		User::Leave(KErrGeneral);
sl@0
   116
		}
sl@0
   117
sl@0
   118
	return dataCount;
sl@0
   119
	}