PECengine/CoreUtilsLib2/SrvInc/PEngMessagePacker.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     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:  Collection of tools used to pack and unpack
       
    15 *                data transferred over IPC.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef __PENGMESSAGEPACKER_H__
       
    20 #define __PENGMESSAGEPACKER_H__
       
    21 
       
    22 //  INCLUDES
       
    23 #include <E32Base.h>
       
    24 #include <Badesca.h>
       
    25 
       
    26 
       
    27 // CLASS DECLARATION
       
    28 
       
    29 /**
       
    30  * Collection of tools used to pack and unpack
       
    31  * data transferred over IPC.
       
    32  *
       
    33  * @since 3.0
       
    34  */
       
    35 class PEngMessagePacker
       
    36     {
       
    37     public:  //Packing and adding to descriptor array
       
    38 
       
    39         /**
       
    40          * Calculating descriptor array package size.
       
    41          * Overloads for array of buffer.
       
    42          */
       
    43         IMPORT_C static TInt DesArrayPackageSize( const MDesCArray& aDesArray );
       
    44         IMPORT_C static TInt DesArrayPackageSize( const TDesC& aDesAsArray );
       
    45 
       
    46 
       
    47         /**
       
    48          * Packing descriptor array to new or existing buffer.
       
    49          *
       
    50          * New buffer variant returns buffer ownership to caller.
       
    51          */
       
    52         IMPORT_C static HBufC16* PackDesArrayL( const MDesCArray& aDesArray );
       
    53         IMPORT_C static TInt PackDesArray( TDes& aBuffer,
       
    54                                            const MDesCArray& aDesArray );
       
    55 
       
    56 
       
    57         /**
       
    58          * Packing one descriptor as descriptor array
       
    59          * to new or existing buffer.
       
    60          *
       
    61          * New buffer variant returns buffer ownership to caller.
       
    62          */
       
    63         IMPORT_C static HBufC16* PackOneDesAsArrayL( const TDesC& aDes );
       
    64         IMPORT_C static TInt PackOneDesAsArray( TDes& aBuffer,
       
    65                                                 const TDesC& aDes );
       
    66 
       
    67 
       
    68         /**
       
    69          * Adding a descriptor to existing descriptor array package.
       
    70          */
       
    71         IMPORT_C static TInt AppendToDesArray( TDes& aBuffer,
       
    72                                                const TDesC& aDes );
       
    73 
       
    74 
       
    75     public:  //UnPacking the descriptor array
       
    76 
       
    77         /**
       
    78          * Gets element count from descriptor array package.
       
    79          */
       
    80         IMPORT_C static TInt DesArrayCount( const TDesC& aBuffer );
       
    81 
       
    82 
       
    83         /**
       
    84          * Extracts descriptor array package to existing array.
       
    85          */
       
    86         IMPORT_C static TInt UnpackDesArrayL( const TDesC& aBuffer,
       
    87                                               CDesCArray& aArray );
       
    88 
       
    89         /**
       
    90          * Extracts descriptor array package to existing pointer array.
       
    91          */
       
    92         IMPORT_C static TInt UnpackDesArrayL( const TDesC& aBuffer,
       
    93                                               CPtrCArray& aArray );
       
    94 
       
    95         /**
       
    96          * Extracts descriptor array package to new array.
       
    97          *
       
    98          * Returns array ownership to caller.
       
    99          */
       
   100         IMPORT_C static CDesCArray* UnpackDesArrayLC( const TDesC& aBuffer );
       
   101 
       
   102 
       
   103         /**
       
   104          * Extracts first descriptor from descriptor
       
   105          * array package.
       
   106          * Returns buffer ownership to caller.
       
   107          */
       
   108         IMPORT_C static HBufC*  UnpackFirstDesFromArrayL( const TDesC& aBuffer );
       
   109 
       
   110 
       
   111 
       
   112     public:  //Integer arrays
       
   113 
       
   114         /**
       
   115          * Calculates TInt array package size.
       
   116          */
       
   117         IMPORT_C static TInt TIntArrayPackageSize( TInt aElementCount );
       
   118 
       
   119 
       
   120         /**
       
   121          * Packs TInt array to new or existing buffer.
       
   122          * New buffer variant returns buffer ownership to caller.
       
   123          */
       
   124         IMPORT_C static HBufC16* PackTIntArrayL( const RArray<TInt>& aTIntArray );
       
   125 
       
   126         /**
       
   127          * Resets the TInt array package to empty.
       
   128          */
       
   129         IMPORT_C static void ResetTIntArray( TDes& aBuffer );
       
   130 
       
   131         /**
       
   132          * Gets element count from TInt array package.
       
   133          */
       
   134         IMPORT_C static TInt TIntArrayCount( const TDesC& aBuffer );
       
   135 
       
   136         /**
       
   137          * Gets certain element from TInt array package.
       
   138          */
       
   139         IMPORT_C static TInt TIntFromArray( const TDesC& aBuffer,
       
   140                                             TInt aIndex );
       
   141 
       
   142     private: // private functions
       
   143 
       
   144         /**
       
   145          * Unpack des array
       
   146          */
       
   147         template<class T>
       
   148         static TInt UnpackDesTempArrayL( const TDesC& aBuffer,
       
   149                                          T& aArray );
       
   150 
       
   151     private: //Prohibited constructor / destructor
       
   152         PEngMessagePacker();
       
   153         ~PEngMessagePacker();
       
   154 
       
   155     };
       
   156 
       
   157 
       
   158 #endif // __PENGMESSAGEPACKER_H__
       
   159 
       
   160 
       
   161 //  End of File
       
   162 
       
   163