upnp/upnpstack/upnputils/src/upnplist.cpp
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 /** @file
       
     2 * Copyright (c) 2002-2004 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:  CUpnpHttpHeaderList
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include "upnplist.h"
       
    21 
       
    22 // -----------------------------------------------------------------------------
       
    23 // C++ default constructor.
       
    24 // -----------------------------------------------------------------------------
       
    25 //
       
    26 CUpnpHttpHeaderList::CUpnpHttpHeaderList() : iHeaderList( 4 )
       
    27 	{
       
    28 	}
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // C++ default destructor.
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CUpnpHttpHeaderList::~CUpnpHttpHeaderList()
       
    35 	{
       
    36 	iHeaderList.Close();
       
    37 	}
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // Method deletes all objects from the list.
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 
       
    44 void CUpnpHttpHeaderList::DeleteObjects()
       
    45     {
       
    46 	TInt size = Count();
       
    47 	for ( int i = 0; i < size; i++ )
       
    48 	    {
       
    49 		if ( iHeaderList[i] != NULL )
       
    50 	    	{
       
    51 			CUpnpHttpHeader* t = iHeaderList[i];
       
    52 			delete t;
       
    53 			t = NULL;
       
    54 		    }
       
    55 	    }
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // Returns the number of elements in list.
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 void CUpnpHttpHeaderList::AddL( const CUpnpHttpHeader* aHeader )
       
    63     {
       
    64 	iHeaderList.AppendL( aHeader );
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // Returns the number of elements in list.
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 EXPORT_C void CUpnpHttpHeaderList::Remove( const CUpnpHttpHeader* aHeader )
       
    72     {
       
    73 	TInt index = iHeaderList.Find( aHeader );
       
    74 	if (index >= 0 )
       
    75         {
       
    76 	    iHeaderList.Remove( index );
       
    77 	    iHeaderList.Compress();
       
    78         }
       
    79     }
       
    80 	 
       
    81 // -----------------------------------------------------------------------------
       
    82 // Returns the number of elements in list.
       
    83 // -----------------------------------------------------------------------------
       
    84 //	 
       
    85 EXPORT_C CUpnpHttpHeader* CUpnpHttpHeaderList::First()
       
    86     {
       
    87 	if ( Count() > 0 )
       
    88 	    {
       
    89 		return iHeaderList[0];
       
    90 	    }
       
    91 	return NULL;	
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // Returns the number of elements in list.
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 TInt CUpnpHttpHeaderList::Count() const
       
    99 	{
       
   100 	return iHeaderList.Count();	
       
   101 	}
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // Goes to the next element on the list.
       
   105 // -----------------------------------------------------------------------------
       
   106 //	
       
   107 EXPORT_C CUpnpHttpHeader* CUpnpHttpHeaderList::Next( const CUpnpHttpHeader* aHeader )
       
   108 	{
       
   109 	TInt index = iHeaderList.Find( aHeader);
       
   110 	index++;
       
   111 	if ( Count() > index )
       
   112         {
       
   113 		return iHeaderList[index];
       
   114         }
       
   115 	else
       
   116         {
       
   117 		return NULL;
       
   118 		}
       
   119 	}
       
   120 
       
   121 
       
   122 //end of file