epoc32/include/comms-infras/metabuffer.h
branchSymbian2
changeset 2 2fe1408b6811
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // MetaBuffer.h
       
    15 // 
       
    16 //
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  @file MetaBuffer.h
       
    22  @internalTechnology
       
    23 */
       
    24 
       
    25 #if (!defined METABUFFER_H)
       
    26 #define METABUFFER_H
       
    27 
       
    28 #include <comms-infras/metatypevariablelen.h>
       
    29 
       
    30 namespace Meta
       
    31 {
       
    32 
       
    33 class TMetaBuf8 : public TMetaVarLen8<RBuf8>
       
    34 /**
       
    35 
       
    36 Implementation of MMetaType for dynamicaly allocated RBuf8
       
    37 
       
    38 @internalComponent
       
    39 @released since v9.0
       
    40 */
       
    41 	{
       
    42 public:
       
    43 	inline static MMetaType* NewL(const TAny* aMem, const TAny* aData);
       
    44 
       
    45 	IMPORT_C virtual TInt Load(TPtrC8& aBuffer);
       
    46 	IMPORT_C virtual TInt Store(TDes8& aBuffer) const;
       
    47 	IMPORT_C virtual void Copy(const TAny* aData);
       
    48 	IMPORT_C virtual TInt Length() const;
       
    49 
       
    50 protected:
       
    51 	TMetaBuf8(const TAny* aData) :
       
    52 		TMetaVarLen8<RBuf8>( aData )
       
    53 		{
       
    54 		}
       
    55 	};
       
    56 
       
    57 class TMetaBuf16 : public TMetaVarLen16<RBuf16>
       
    58 /**
       
    59 
       
    60 Implementation of MMetaType for dynamicaly allocated RBuf16
       
    61 
       
    62 @internalComponent
       
    63 @released since v9.0
       
    64 */
       
    65 	{
       
    66 public:
       
    67 	inline static MMetaType* NewL(const TAny* aMem, const TAny* aData);
       
    68 
       
    69 	IMPORT_C virtual TInt Load(TPtrC8& aBuffer);
       
    70 	IMPORT_C virtual TInt Store(TDes8& aBuffer) const;
       
    71 	IMPORT_C virtual void Copy(const TAny* aData);
       
    72 	IMPORT_C virtual TInt Length() const;
       
    73 
       
    74 protected:
       
    75 	TMetaBuf16(const TAny* aData) :
       
    76 		TMetaVarLen16<RBuf16>( aData )
       
    77 		{
       
    78 		}
       
    79 
       
    80 	};
       
    81 
       
    82 MMetaType* TMetaBuf8::NewL(const TAny* aMem, const TAny* aData)
       
    83 /**
       
    84  * Instantiates a meta type for RBuf8.
       
    85  * Used for attribure registration (in the data v-table).
       
    86  */
       
    87     {
       
    88     return ::new ((TUint8*)aMem) TMetaBuf8(aData);
       
    89     }
       
    90 
       
    91 MMetaType* TMetaBuf16::NewL(const TAny* aMem, const TAny* aData)
       
    92 /**
       
    93  * Instantiates a meta type for RBuf8.
       
    94  * Used for attribure registration (in the data v-table).
       
    95  */
       
    96     {
       
    97     return ::new ((TUint8*)aMem) TMetaBuf16(aData);
       
    98     }
       
    99 
       
   100 
       
   101 #if defined(_UNICODE)
       
   102 typedef TMetaBuf16 TMetaBuf;
       
   103 #else
       
   104 typedef TMetaBuf8 TMetaBuf;
       
   105 #endif
       
   106 } //namespace Meta
       
   107 
       
   108 
       
   109 #endif //METABUFFER_H