diff -r e1b950c65cb4 -r 837f303aceeb epoc32/include/comms-infras/metatypevariablelen.h --- a/epoc32/include/comms-infras/metatypevariablelen.h Wed Mar 31 12:27:01 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,238 +0,0 @@ -// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// 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 -// which accompanies this distribution, and is available -// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// MetaTypeVariableLen.h -// -// - - - -/** - @file MetaTypeVariableLen.h - @internalTechnology -*/ - -#if (!defined METATYPEVARIABLELEN_H) -#define METATYPEVARIABLELEN_H - -#include - -namespace Meta -{ - -template class TMetaVarLen8; -template class TMetaVarLen16; -typedef TMetaVarLen8 TMetaDes8; -typedef TMetaVarLen16 TMetaDes16; - -#if defined(_UNICODE) -typedef TMetaDes16 TMetaDes; -#else -typedef TMetaDes8 TMetaDes; -#endif - -class TMetaVarLenBase : public MMetaType - { - public: - IMPORT_C virtual TInt Load(TPtrC8& aBuffer); - IMPORT_C virtual TInt Store(TDes8& aBuffer) const; - - protected: - TInt CheckBuf( TPtrC8& aBuffer ); - virtual void CopyBuf(TPtrC8& aBuffer,TInt aLen) = 0; - virtual void AppendToBuf( TDes8& aBuffer ) const = 0; - }; - -template -class TMetaVarLen : public TMetaVarLenBase -/** - -Implementation of MMetaType for anything that provides Length(), SetLength(), MaxLength(), -Copy() and Left() functions with arbitrarry element size - -@internalComponent -@released since v9.0 */ - { -public: - virtual void Copy(const TAny* aData); - -protected: - TMetaVarLen(const TAny* aData); - -protected: - TYPE* iData; - }; - -template -inline TMetaVarLen::TMetaVarLen(const TAny* aData) -: iData((TYPE*)aData) -/** - * Constructor - */ - { - __ASSERT_DEBUG(iData!=NULL,User::Panic(_L("TMetaVarLen"),KErrArgument)); - } - -template -void TMetaVarLen::Copy(const TAny* aData) -/** - * Copies content of the member - */ - { - const TYPE& var = *((TYPE*)aData); - iData->Copy(var.Left( iData->MaxLength() )); - } - -template -class TMetaVarLen8 : public TMetaVarLen -/** - -Implementation of MMetaType for anything that provides Length(), SetLength(), MaxLength(), -Copy() and Left() functions with element size 1 byte -Like for example TDes8, TBuf8, TPtr8. - -@internalComponent -@released since v9.0 */ - { -public: - inline static MMetaType* NewL(const TAny* aMem, const TAny* aData); - - virtual TInt Length() const; - -protected: - TMetaVarLen8(const TAny* aData); - virtual void AppendToBuf( TDes8& aBuffer ) const; - virtual void CopyBuf(TPtrC8& aBuffer,TInt aLen); - - }; - -template -class TMetaVarLen16 : public TMetaVarLen -/** - -Implementation of MMetaType for anything that provides Length(), SetLength(), MaxLength(), -Copy() and Left() functions with element size 2 bytes -Like for example TDes16, TBuf16, TPtr16 (ELEMENT is short). - -@internalComponent -@released since v9.0 */ - { -public: - inline static MMetaType* NewL(const TAny* aMem, const TAny* aData); - - virtual TInt Length() const; - -protected: - TMetaVarLen16(const TAny* aData); - virtual void AppendToBuf( TDes8& aBuffer ) const; - virtual void CopyBuf(TPtrC8& aBuffer,TInt aLen); - - }; - - -template -inline TMetaVarLen16::TMetaVarLen16(const TAny* aData) -: TMetaVarLen(aData) -/** - * Constructor - */ - { - } - -template -MMetaType* TMetaVarLen16::NewL(const TAny* aMem, const TAny* aData) -/** - * Instantiates a meta type of a particular type. - * Used for attribure registration (in the data v-table). - */ - { - return ::new ((TUint8*)aMem) TMetaVarLen16(aData); - } - -template -void TMetaVarLen16::AppendToBuf( TDes8& aBuffer ) const - { - //copy whatever fits in (no loosing high byte as the ::Copy normally would) - //a litle bit dirty solution assuming a flat memory model and byte addressing mode - aBuffer.Append(reinterpret_cast(this->iData->Ptr()), this->iData->Length() * 2); - } - -template -void TMetaVarLen16::CopyBuf(TPtrC8& aBuffer,TInt aLen) - { - //copy whatever fits in - //a litle bit dirty solution assuming a flat memory model and byte addressing mode - this->iData->Copy( reinterpret_cast(aBuffer.Ptr()), Min( this->iData->MaxLength(), aLen / 2 )); - } - -template -TInt TMetaVarLen16::Length() const -/** - * Returns the length of the data member - */ - { - return this->iData->Length() * 2 + sizeof(TUint32); - } - -template -inline TMetaVarLen8::TMetaVarLen8(const TAny* aData) -: TMetaVarLen(aData) -/** - * Constructor - */ - { - } - -template -MMetaType* TMetaVarLen8::NewL(const TAny* aMem, const TAny* aData) -/** - * Instantiates a meta type of a particular type. - * Used for attribure registration (in the data v-table). - */ - { - return ::new ((TUint8*)aMem) TMetaVarLen8(aData); - } - -template -#ifdef SYMBIAN_NETWORKING_CFTRANSPORT -void TMetaVarLen8::CopyBuf(TPtrC8& aBuffer,TInt aLen) - { - //copy whatever fits in - this->iData->Copy( aBuffer.Left( Min(this->iData->MaxLength(), aLen) ) ); - } -#else -void TMetaVarLen8::CopyBuf(TPtrC8& aBuffer,TInt /*aLen*/) - { - this->iData->Copy( aBuffer.Left( this->iData->MaxLength() ) ); - } -#endif - -template -void TMetaVarLen8::AppendToBuf( TDes8& aBuffer ) const - { - aBuffer.Append(*this->iData); - } - -template -TInt TMetaVarLen8::Length() const -/** - * Returns the length of the data member - */ - { - return this->iData->Length() + sizeof(TUint32); - } - -} //namespace Meta - - -#endif //METATYPE_H