contentstorage/cautils/src/caidsarray.cpp
changeset 60 f62f87b200ec
equal deleted inserted replaced
4:1a2a00e78665 60:f62f87b200ec
       
     1 /*
       
     2  * Copyright (c) 2008 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:  ?Description
       
    15  *
       
    16  */
       
    17 
       
    18 #include <s32mem.h>
       
    19 #include "caidsarray.h"
       
    20 
       
    21 // ======== MEMBER FUNCTIONS ========
       
    22 
       
    23 // ---------------------------------------------------------------------------
       
    24 //
       
    25 // ---------------------------------------------------------------------------
       
    26 //
       
    27 EXPORT_C void RCaIdsArray::ExternalizeL( RWriteStream& aStream ) const
       
    28     {
       
    29     aStream.WriteInt32L( Count() );
       
    30     for( TInt i = 0; i < Count(); i++ )
       
    31         {
       
    32         aStream.WriteInt32L( operator[]( i ) );
       
    33         }
       
    34     aStream.CommitL();
       
    35     }
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 EXPORT_C void RCaIdsArray::InternalizeL( RReadStream& aStream )
       
    42     {
       
    43     Reset();
       
    44     TInt count = aStream.ReadInt32L();
       
    45     for( TInt i = 0; i < count; i++ )
       
    46         {
       
    47         AppendL( aStream.ReadInt32L() );
       
    48         }
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 EXPORT_C HBufC8* RCaIdsArray::MarshalDataLC() const
       
    56     {
       
    57     HBufC8* desc = HBufC8::NewLC( ( Count() + 1 ) * sizeof(TInt32) );
       
    58     TPtr8 ptr( desc->Des() );
       
    59     RDesWriteStream stream( ptr );
       
    60     CleanupClosePushL( stream );
       
    61     ExternalizeL( stream );
       
    62     stream.CommitL();
       
    63     CleanupStack::PopAndDestroy( &stream );
       
    64     return desc;
       
    65     }