wvsettings20/IMPSSrc/IMPSSAPSerializer.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 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:  Serialization tools for SAP Settings Store.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include    <e32std.h>
       
    20 #include    "IMPSSAPSerializer.h"
       
    21 
       
    22 
       
    23 // -----------------------------------------------------------------------------
       
    24 // IMPSSAPSerializer::ExternalizeBufferL()
       
    25 // -----------------------------------------------------------------------------
       
    26 //
       
    27 void IMPSSAPSerializer::ExternalizeBufferL( const HBufC* aBuffer, RWriteStream& aStream )
       
    28     {
       
    29     if ( aBuffer && aBuffer->Length() != 0 )
       
    30         {
       
    31         aStream.WriteInt32L( aBuffer->Length() );
       
    32         aStream.WriteL( *aBuffer );
       
    33         }
       
    34     else
       
    35         {
       
    36         aStream.WriteInt32L( 0 );
       
    37         }
       
    38     }
       
    39 
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // IMPSSAPSerializer::InternalizeBufferL()
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 HBufC* IMPSSAPSerializer::InternalizeBufferL( RReadStream& aStream )
       
    46     {
       
    47     HBufC* buffer = NULL;
       
    48 
       
    49     TInt length = aStream.ReadInt32L();
       
    50     if ( length != 0 )
       
    51         {
       
    52         buffer = HBufC::NewLC( length );
       
    53         TPtr ptr( buffer->Des() );
       
    54         aStream.ReadL( ptr, length );
       
    55         CleanupStack::Pop(); //buffer
       
    56         }
       
    57 
       
    58     return buffer;
       
    59     }
       
    60 
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // IMPSSAPSerializer::BufferSizeInBytes()
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 TInt IMPSSAPSerializer::BufferSizeInBytes( const HBufC* aBuffer )
       
    67     {
       
    68     TInt size = 4; //Buffer length indicator: 4 bytes
       
    69 
       
    70     if ( aBuffer && aBuffer->Length() != 0 )
       
    71         {
       
    72         size = size + aBuffer->Size();
       
    73         }
       
    74 
       
    75     return size;
       
    76     }
       
    77 
       
    78 
       
    79 
       
    80 //  End of File