当前位置: 首页>>代码示例>>C++>>正文


C++ TDes8::SetLength方法代码示例

本文整理汇总了C++中TDes8::SetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ TDes8::SetLength方法的具体用法?C++ TDes8::SetLength怎么用?C++ TDes8::SetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TDes8的用法示例。


在下文中一共展示了TDes8::SetLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HandleRecievedMsgL

// -----------------------------------------------------------------------------
// CExprUDPMsg::HandleReceivedDataL()
// -----------------------------------------------------------------------------
//
TBool CExprUDPMsg::HandleRecievedMsgL( TDes8& aData, TInt& aStartPos, TInt& aLength )
    {
    // Check if the prefix matches
    aStartPos = aData.Find( KUDPPrefix );

    if ( aStartPos != KErrNotFound  )
        {
        // Found a matching prefix
        // Let the observer know
        iObserver->FrameStarted();

        TPtr8 dataToParse( aData.MidTPtr( aStartPos ) );

        TInt err = TryParsingL( dataToParse, aLength );

        if ( err != KErrNone )
            {
            // corrupted data in the frame
            iObserver->ProtocolErrorL( err, aData );
            // delete the corrupted data
            aData.SetLength( 0 );
            }

        return ETrue;
        }
    else
        {
        return EFalse;
        }

    }
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:35,代码来源:CExprUDPMsg.cpp

示例2: CompleteOPL

void CSdpPDUHandler::CompleteOPL(TDes8& aPdu, const TDesC8& aWritePdu, const TInt aMaxAttrCount)
/**
	Verifies the size of the response parameters
	and writes out correct length for the attributes.
 @verbatim
		response descriptor			DesC
		written area (attributes)	DesC
		maximum byte count			TInt
 @endverbatim

	Method will leave if response is bigger than requested or allowed for.
	Returns nothing

**/
{
    TUint16 finalLength = (TUint16)aWritePdu.Length();
    if (finalLength > aMaxAttrCount) User::Leave(KErrNoMemory);
    aPdu.SetLength(KRspAttributeCountSize + finalLength + KContStateHeader);
    BigEndian::Put16(&aPdu[KRspAttrCountOffset], finalLength);
// now need to update the DES size
    if (iDesSize == 3)
    {
        BigEndian::Put16(&aPdu[KRspAttributeListOffset+1], (unsigned short)(finalLength-iDesSize));
    }
    else if (iDesSize == 2)
    {
        if (finalLength > 0xff) User::Leave(KErrNoMemory);
        aPdu[KRspAttributeListOffset+1] = (unsigned char)((finalLength&0xff)-iDesSize);
    }
    else User::Leave(KErrUnknown);   // perhaps this should be a panic
    aPdu[aPdu.Length()-1] = 0; // FIXME: Put contState here
}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:32,代码来源:pduhandler.cpp

示例3: RecvLine

TInt RecvLine(RTest &aTest, TDes8 &aBuf, RSocket &aSock)
	{
	TInt offset=0;
	TText ch=0;

	do
		{
		TPtr8 ptr(NULL, 0);
		TSockXfrLength len;
		TRequestStatus stat;

		ptr.Set((TUint8 *)aBuf.Ptr()+offset, aBuf.Length()-offset, aBuf.Length()-offset);
		aSock.RecvOneOrMore(ptr,0,stat,len);
		User::WaitForRequest(stat);
		aTest(stat==KErrNone);
		TInt length=len();
		TInt n=0;
		while (length--)
			{
			ch = *(ptr.Ptr()+n);
			if (ch=='\r' || ch=='\n')
				break;
			++offset;
			++n;
			}
		}
	while (ch!='\r' && ch!='\n' );

	aBuf.SetLength(offset);
	return offset;
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:31,代码来源:FINGER.CPP

示例4: ConvertTextToBinary

/**
Converts a buffer containing string of the hexadecimal characters,
representing the binary data, into this binary data!

@param aSrc The buffer containing text representation.
@param aDst Binary data will be written to this buffer.
*/
void ConvertTextToBinary(const TDesC& aSrc, TDes8& aDst)
	{
	// Check that the ASCII PDU length is even
	__ASSERT_ALWAYS((aSrc.Length()&0x1)==0x0, SimPanic(EInvalidParameterFormatInConfigFile));

	aDst.SetLength(aSrc.Length() / 2);

	for (TInt ii = 0; ii < aSrc.Length(); ii += 2)
		{
		TInt val = 0;
		if ((aSrc[ii] >= '0') && (aSrc[ii] <= '9'))
			{
			val = ((aSrc[ii] - '0') << 4);
			}
		else if ((aSrc[ii] >= 'A') && (aSrc[ii] <= 'F'))
			{
			val = ((aSrc[ii] - 'A' + 10) << 4);
			}

		if ((aSrc[ii+1] >= '0') && (aSrc[ii+1] <= '9'))
			{
			val += (aSrc[ii+1] - '0');
			}
		else if ((aSrc[ii+1] >= 'A') && (aSrc[ii+1] <= 'F'))
			{
			val += (aSrc[ii+1] - 'A' + 10);
			}

		aDst[ii/2] = (TUint8) val;
		}
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:38,代码来源:utils.cpp

示例5: DoReadL

/** Reads data from the stream buffer into the specified descriptor.

This function is called by ReadL(TDes8&,TInt,TRequestStatus&).

This implementation deals with the request synchronously, and completes the 
request with KErrNone. Other implementations may choose to deal with this 
in a true asynchronous manner.

In addition, the read operation itself uses the DoReadL(TAny*,TInt) variant.

@param aDes The target descriptor for the data read from the stream buffer. 
On return, the length of the descriptor is set to the number of bytes read 
from the stream buffer.
@param aMaxLength The maximum number of bytes to be read. This value must not 
be greater than the maximum length of the descriptor, otherwise the function 
raises a STORE-Stream 2 panic.
@param aStatus The request status that indicates the completion status of this 
asynchronous request.
@return The maximum number of bytes to be read, as used in this request. This 
implementation uses, and returns, the value supplied in aMaxLength. Other 
implementations may choose to use a different value.
@see MStreamBuf::ReadL() */
EXPORT_C TInt MStreamBuf::DoReadL(TDes8& aDes,TInt aMaxLength,TRequestStatus& aStatus)
	{
	__ASSERT_DEBUG(aMaxLength<=aDes.MaxLength(),Panic(EStreamReadBeyondEnd));
	aDes.SetLength(DoReadL((TUint8*)aDes.Ptr(),aMaxLength));
	TRequestStatus* stat=&aStatus;
	User::RequestComplete(stat,KErrNone);
	return aMaxLength;
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:30,代码来源:US_BUF.CPP

示例6: DecryptMasterKeyL

void CPBEncryptSet::DecryptMasterKeyL(TDes8& aMasterKey) const
	{
	CPBDecryptorElement* decryptor = CPBDecryptorElement::NewLC(
		iData->EncryptParms().Cipher(), *iEncryptKey, iData->EncryptParms().IV());
	aMasterKey.SetLength(0);
	decryptor->Process(*iEncryptedMasterKey, aMasterKey);
	CleanupStack::PopAndDestroy(decryptor);
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:8,代码来源:pbeset.cpp

示例7: SendDataRxCmdL

TInt CBulkOnlyTransport::SendDataRxCmdL(const MClientCommandServiceReq* aCommand,
                                        TDes8& aCopyBuf,
                                        TInt& aLen)
{
    __MSFNLOG

    TInt r = KErrNone;
    SendCbwL(aCommand, TBotCbw::EDataIn, aLen);

    // store initial length as data is appended to the buffer
    TInt startPos = aCopyBuf.Length();

    TInt len = aLen;

    while (len)
    {
        if(len > KResponsePacketSize)
            iBulkDataTd.SaveData(KResponsePacketSize);
        else
            iBulkDataTd.SaveData(len);
        iBulkPipeIn.Transfer(iBulkDataTd, iStatus);
        User::WaitForRequest(iStatus);

        r = iStatus.Int();
        if (r != KErrNone)
        {
            if (r == KErrUsbStalled)
            {
                __BOTPRINT(_L("SendDataRxCmdL ClearRemoteStall"));
                iBulkPipeIn.ClearRemoteStall();
#ifdef MASSSTORAGE_PUBLISHER
                TMsPublisher publisher(TMsPublisher::KStallProperty);
#endif
                break;
            }
            DoResetRecovery();
            __BOTPRINT1(_L("Usb transfer error %d"),r);
            User::Leave(KErrGeneral);
        }

        TPtrC8 data = iBulkDataTd.Buffer();
        aCopyBuf.Append(data.Ptr(), data.Length());
        if(len > KResponsePacketSize)
            len -= KResponsePacketSize;
        else
            len = 0;
    }

    ReceiveCswL();
    TUint32 lenReceived = 0;

    r = ProcessInTransferL(lenReceived);
    aLen = lenReceived;
    aCopyBuf.SetLength(startPos + lenReceived);

    return r;
}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:57,代码来源:cbulkonlytransport.cpp

示例8: Read

// -----------------------------------------------------------------------------
// CDirectoryDesc::Read : Reading from a Directory
// -----------------------------------------------------------------------------
void CDirectoryDesc::Read(TDes8& aDesc, TRequestStatus& aStatus)
{
    TInt errorNum = KErrNone;
    const TInt16 KDirentSize = 8;
    TInt readLen = aDesc.MaxLength();
    TUint8* bufPtr = const_cast<TUint8*>(aDesc.Ptr());
    TInt copiedInfo = 0;
    TEntryArray entries;
    errorNum = iDir.Read( entries );
    TDirent direntEntry;

    if (errorNum == KErrNone || errorNum == KErrEof)
    {
        errorNum = KErrNone;
        TEntry entry;
        TInt len = 0;
        TInt count = entries.Count();
        TBuf8<KMaxFileName> fileName;
        TInt index = 0;
        TInt copyLen = 0;
        //Loop through each entry and get all the informations
        for (; index<count && copiedInfo<readLen; index++, copiedInfo += copyLen)
        {
            entry = entries[index];
            //Copy File's UID
            TUid fileUID = entry.iType.MostDerived();
            direntEntry.iEntryNum = fileUID.iUid;
            HBufC8 *name;
            if(ConvertUnicodeToUtf8(entry.iName,name,errorNum) == -1)
            {
                break;
            }
            //Copy entry type and record Length
            fileName.Copy( name->Des() );
            delete name;
            len = fileName.Length();
            direntEntry.iRecLen = KDirentSize + len + 1;
            //Maintaing a four byte boundary.
            direntEntry.iRecLen = Align4(direntEntry.iRecLen);
            direntEntry.iEntryType = 0;
            direntEntry.iNameLen = len;
            //Copy entry name
            Mem::Copy( direntEntry.iEntryName, fileName.PtrZ(), len+1);

            //Copy structure on to the buffer
            copyLen = Min(direntEntry.iRecLen, (readLen - copiedInfo));
            Mem::Copy( bufPtr, &direntEntry, copyLen );
            bufPtr += copyLen;
        }
    }

    //Set the Length
    aDesc.SetLength( copiedInfo );
    TRequestStatus* status = &aStatus;
    User::RequestComplete(status, errorNum);
}
开发者ID:kuailexs,项目名称:symbiandump-os2,代码行数:59,代码来源:udirectorydesc.cpp

示例9:

void CPaddingSSLv3::DoPadL(const TDesC8& aInput,TDes8& aOutput)
	{
	TInt paddingBytes=BlockSize()-(aInput.Length()%BlockSize());
	aOutput.Append(aInput);
	aOutput.SetLength(aOutput.Length()+paddingBytes);
	for (TInt i=1;i<=paddingBytes;i++)
		{
		aOutput[aOutput.Length()-i]=(TUint8)(paddingBytes-1);
		}
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:10,代码来源:padding.cpp

示例10: TrimRightSpaceAndNull

// ---------------------------------------------------------
// CNSmlCmdsBase::TrimRightSpaceAndNull
// Trims right spaces and zero terminator (NULL) 
// ---------------------------------------------------------
EXPORT_C void CNSmlCmdsBase::TrimRightSpaceAndNull( TDes8& aDes ) const
	{
	aDes.TrimRight();
	if ( aDes.Length() > 0 )
		{
		if ( aDes[aDes.Length() - 1] == NULL )
			{
			aDes.SetLength( aDes.Length() - 1 );
			}	
		}
	}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:15,代码来源:nsmlcmdsbase.cpp

示例11: FormatSqlStmt

static void FormatSqlStmt(TDes8& aSqlBuf, const char aSql[], TInt aRecIds[], TInt aRecCnt)
	{
	aSqlBuf.Copy(TPtrC8((const TUint8*)aSql));
	aSqlBuf.Append(_L8("("));
	for(TInt i=0;i<aRecCnt;++i)
		{
		aSqlBuf.AppendNum((TInt64)aRecIds[i]);
		aSqlBuf.Append(_L8(","));
		}
	aSqlBuf.SetLength(aSqlBuf.Length() - 1);
	aSqlBuf.Append(_L8(")"));
	}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:12,代码来源:tsqlitesecure_perf.cpp

示例12: KUDesGet

/**
Copies the content of the source descriptor to the destination descriptor.

If the current thread is a user thread, i.e. the mode in spsr_svc is 'User',
then data is read using user mode privileges .

@param aDest The destination descriptor.
@param aSrc  The source descriptor.

@panic KERN-COMMON 19, if aDest is not a valid descriptor type.
@panic KERN-COMMON 23, if aSrc is longer that the maximum length of aDest.
@panic KERN-EXEC   33, if aSrc is not a valid descriptor type.

@pre Do not call from User thread if in a critical section.
@pre Interrupts must be enabled.
@pre Kernel must be unlocked.
@pre No fast mutex can be held.
@pre Call in a thread context.
@pre Can be used in a device driver.

@post The length of the destination descriptor is equal to the length of the source descriptor.
*/
EXPORT_C void Kern::KUDesGet(TDes8& aDest, const TDesC8& aSrc)
	{
	CHECK_PRECONDITIONS(MASK_NO_CRITICAL_IF_USER|MASK_THREAD_STANDARD,"Kern::KUDesGet");	
//ETDes8BadDescriptorType = 19
//ETDes8Overflow = 23
//EKUDesInfoInvalidType= 33
	TInt ulen, umax;
	TUint8* kptr=(TUint8*)aDest.Ptr();
	const TUint8* uptr=Kern::KUDesInfo(aSrc, ulen, umax);
	aDest.SetLength(ulen);
	kumemget(kptr,uptr,ulen);
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:34,代码来源:kdes8.cpp

示例13: ReadSettingName

TBool CSTPreferences::ReadSettingName(RFile& aFile, TDes8& aSettingName, TInt& aSettingLength)
{
	aSettingName.SetLength(0);
	
	TBuf8<KMaxSettingNameLength + 10> buffer;
	
	if (aFile.Read(buffer) != KErrNone)
		return EFalse;
	
	TInt filePos = 0;
	if (aFile.Seek(ESeekCurrent, filePos) != KErrNone)
		return EFalse;
	
	TLex8 lex(buffer);
	lex.SkipSpaceAndMark();
	
	while (lex.Peek())
	{
		if (lex.Peek() == ':')
		{
			aSettingName = lex.MarkedToken();
			LWRITELN(iLog, aSettingName);
			lex.Inc();
			break;
		}
		
		lex.Inc();
	}
	
	if (lex.Val(aSettingLength) != KErrNone)
		return EFalse;
	
	//iLog->WriteLineL(aSettingLength);

	while (lex.Peek())
	{
		if (lex.Peek() == '=')
			break;
		
		lex.Inc();
	}
	
	if (lex.Peek() != '=')
		return EFalse;
	
	lex.Inc();
	
	TInt offset = filePos - (buffer.Length() - lex.Offset());
	if (aFile.Seek(ESeekStart, offset) != KErrNone)
		return EFalse;
	
	return ETrue;
}
开发者ID:Nokia700,项目名称:SymTorrent,代码行数:53,代码来源:STPreferences.cpp

示例14: GetUniqueKey

void CEnumerator::GetUniqueKey( TDes8& aKey )
    {
    LOGFN( "CEnumerator::GetUniqueKey" );
    aKey.SetLength( 0 );
    if ( iUniqueKey.CompareC( KZeroID ) == 0 )
        {
        aKey.Fill( '\0', KWmDrmIdSize );
        }
    else
        {
        aKey.Copy( iUniqueKey );
        }
    }
开发者ID:kuailexs,项目名称:symbiandump-mw1,代码行数:13,代码来源:enumerator.cpp

示例15: ReadPacket

TInt YModem::ReadPacket(TDes8& aDest)
	{
	TUint8* pD = (TUint8*)aDest.Ptr();
	TInt r;
	TPtr8 d(pD, 0, 1);
	r = ReadBlock(d);
	if (r != KErrNone)
		return r;
	if (d.Length()==0)
		return KErrZeroLengthPacket;
	TUint8 b0 = *pD;
	if (b0==CAN)
		return KErrAbort;
	if (b0==EOT)
		return KErrEof;
	if (b0==SOH)
		iBlockSize=128;
	else if (b0==STX)
		iBlockSize=1024;
	else
		return KErrBadPacketType;
	iTimeout=5000000;
	iPacketSize = iBlockSize+5;
	d.Set(pD+1, 0, iPacketSize-1);
	r = ReadBlock(d);
	if (r!=KErrNone && r!=KErrTimedOut)
		return r;
	if (d.Length() < iPacketSize-1)
		return KErrPacketTooShort;
	TUint8 seq = pD[1];
	TUint8 seqbar = pD[2];
	seqbar^=seq;
	if (seqbar != 0xff)
		return KErrCorruptSequenceNumber;
	if (seq==iSeqNum)
		return KErrAlreadyExists;
	else
		{
		TUint8 nextseq=(TUint8)(iSeqNum+1);
		if (seq!=nextseq)
			return KErrWrongSequenceNumber;
		}
	iCrc=0;
	UpdateCrc(pD+3, iBlockSize);
	aDest.SetLength(iPacketSize);
	TUint16 rx_crc = (TUint16)((pD[iPacketSize-2]<<8) | pD[iPacketSize-1]);
	if (rx_crc != iCrc)
		return KErrBadCrc;
	++iSeqNum;
	return KErrNone;
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:51,代码来源:ymodem.cpp


注:本文中的TDes8::SetLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。