syncmlfw/ds/dsutils/changefinder/src/NSmlDataItemUidSet.cpp
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2005 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:  Sources
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <s32strm.h>
       
    21 #include <nsmlchangefinder.h>
       
    22 
       
    23 
       
    24 // ============================ MEMBER FUNCTIONS ===============================
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // CNSmlDataItemUidSet::CNSmlDataItemUidSet
       
    28 // Constructor.
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 EXPORT_C CNSmlDataItemUidSet::CNSmlDataItemUidSet()
       
    32     {
       
    33     }
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CNSmlDataItemUidSet::~CNSmlDataItemUidSet
       
    37 // Destructor.
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CNSmlDataItemUidSet::~CNSmlDataItemUidSet()
       
    41     {
       
    42     Reset();
       
    43     }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CNSmlDataItemUidSet::AddItem
       
    47 // Adds item to UID set.
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 EXPORT_C TInt CNSmlDataItemUidSet::AddItem( TSmlDbItemUid aItemId )
       
    51 	{
       
    52     if ( iUidSet.Find( aItemId ) != KErrNotFound )
       
    53         {
       
    54         return KErrAlreadyExists;
       
    55         }
       
    56     return iUidSet.Append( aItemId );
       
    57 	}
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CNSmlDataItemUidSet::Reset
       
    61 // Resets UID set.
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 EXPORT_C void CNSmlDataItemUidSet::Reset()
       
    65 	{
       
    66 	iUidSet.Reset();
       
    67 	}
       
    68 	
       
    69 // -----------------------------------------------------------------------------
       
    70 // CNSmlDataItemUidSet::InternalizeL
       
    71 // This method internalizes class from stream.
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 EXPORT_C void CNSmlDataItemUidSet::InternalizeL( RReadStream& aStream )
       
    75 	{
       
    76     TInt count( aStream.ReadInt32L() );
       
    77     for ( TInt i = 0; i < count; i++ )
       
    78         {
       
    79         AddItem( aStream.ReadInt32L() );	
       
    80         }	
       
    81 	}
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CNSmlDataItemUidSet::DoItemCount
       
    85 // Returns the number of items in the set.
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 TInt CNSmlDataItemUidSet::DoItemCount() const
       
    89 	{
       
    90 	return iUidSet.Count();
       
    91 	}
       
    92 	
       
    93 // -----------------------------------------------------------------------------
       
    94 // CNSmlDataItemUidSet::DoItemIndex
       
    95 // Returns the index of UID.
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 TInt CNSmlDataItemUidSet::DoItemIndex( TSmlDbItemUid aItemId ) const
       
    99 	{
       
   100 	return iUidSet.Find( aItemId );
       
   101 	}
       
   102 	
       
   103 // -----------------------------------------------------------------------------
       
   104 // CNSmlDataItemUidSet::DoItemAt
       
   105 // Retuns the item UID.
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 TSmlDbItemUid CNSmlDataItemUidSet::DoItemAt( TInt aIndex ) const
       
   109 	{
       
   110 	return iUidSet[aIndex];
       
   111 	}
       
   112 	
       
   113 // -----------------------------------------------------------------------------
       
   114 // CNSmlDataItemUidSet::DoExternalizeL
       
   115 // This method externalizes class to stream.
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 void CNSmlDataItemUidSet::DoExternalizeL( RWriteStream& aStream ) const
       
   119 	{
       
   120 	aStream.WriteInt32L( iUidSet.Count() );
       
   121 	for ( TInt i = 0; i < iUidSet.Count(); i++ )
       
   122 		{
       
   123 		aStream.WriteInt32L( iUidSet[i] );
       
   124 		}
       
   125 	}
       
   126 
       
   127 // End of File