servicediscoveryandcontrol/pnp/test/upnp/upnpdescription/src/tattributeiter.cpp
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "tattributeiter.h"
       
    17 
       
    18 TAttributeIter::TAttributeIter(const CUPnPProperty* aParamPart)
       
    19 	: iParamPart(aParamPart)
       
    20 	{
       
    21 	First();
       
    22 	}
       
    23 
       
    24 TAttributeIter::~TAttributeIter()
       
    25 	{
       
    26 	}
       
    27 
       
    28 void TAttributeIter::First()
       
    29 	{
       
    30 	iPosIdx = 0;
       
    31 	CheckInvalidation();
       
    32 	}
       
    33 
       
    34 TBool TAttributeIter::AtEnd()
       
    35 	{
       
    36 	return (iPosIdx == KErrNotFound);
       
    37 	}
       
    38 
       
    39 void TAttributeIter::operator++()
       
    40 	{
       
    41 	__ASSERT_DEBUG ( iPosIdx != KErrNotFound, User::Invariant() );
       
    42 
       
    43 	++iPosIdx;
       
    44 	CheckInvalidation();
       
    45 	}
       
    46 
       
    47 const CAttribute* TAttributeIter::operator()()
       
    48 	{
       
    49 	CheckInvalidation();
       
    50 	__ASSERT_DEBUG ( iPosIdx != KErrNotFound, User::Invariant() );
       
    51 	
       
    52 	return iParamPart->iAttributeArray.operator[](iPosIdx);
       
    53 	}
       
    54 
       
    55 void TAttributeIter::CheckInvalidation()
       
    56 	{
       
    57 	if (iPosIdx >= iParamPart->iAttributeArray.Count())
       
    58 		iPosIdx = KErrNotFound; // Hit the end
       
    59 	}
       
    60