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


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

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


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

示例1:

void CRFC3984Encode::PayloadizeFrameSingleNALModeL(
    TDes8& aBuffer, 
    TUint32 /*aTimeStamp*/, 
    TUint32& /*aMarkerBit*/, 
    TInt& aNalCount )
    {
	// This implementation assumes the NAL units for one frame are seperated
	// by 0x001 or 0x0001 start codes 
    
    // Resetting iBufferIndex for this new frame, always do this for new frame
    // because this is used to find start codes within one frame
    iBufferIndex = 0; 	
    
    TInt startIndex = 0;	// holds first byte-index of NALU
    TInt endIndex = 0;		// hold byte-index of next to last byte of NALU
    TInt size = 0;
    HBufC8 * pBuffer = 0;
    
    // loop to find and packetize all NAL Units in the frame
	while ( ETrue )
	    {
		startIndex = TMccCodecInfo::FindAvcNaluStart( iBufferIndex, aBuffer );
		if ( KErrNotFound == startIndex )
		    {
			break;
		    }
		
		endIndex = TMccCodecInfo::FindAvcNaluEnd( iBufferIndex, aBuffer );
		if ( KErrNotFound == endIndex )
		    {
			break;
		    }
		
		if ( startIndex == endIndex )
		    {
			break;
		    }
				
		// finding size of the NAL unit
		size = endIndex - startIndex;
		
		__ASSERT_ALWAYS( size > 0, User::Leave( KErrGeneral ) ); // some flaw in logic
		
		pBuffer = HBufC8::NewLC( size );
		
		TPtr8 aPtr = pBuffer->Des();
		// Now the size and start Index is known, copying the data
		
		aPtr.Copy( aBuffer.Mid( startIndex, size ) );
		
		// Now inserting pointer
		iPayloadizedBuffers.InsertL( pBuffer, iNalCount );
		CleanupStack::Pop( pBuffer );
		pBuffer = NULL;	// ownership transferred
		iNalCount++;
	    }
    
    aNalCount = iNalCount;
    }
开发者ID:kuailexs,项目名称:symbiandump-mw1,代码行数:59,代码来源:rfc3984encode.cpp

示例2: ChangeToDecimal

// ---------------------------------------------------------
// CCookieTimer::ChangeToDecimal
// ---------------------------------------------------------
//
TInt CCookieManagerServer::ChangeToDecimal( TDes8& aBuf,TUint32& aUid )
    {
    CLOG( ( EServer, 0, _L( "-> CCookieManagerServer::ChangeToDecimal" ) ) );
     TBuf8<100> tempBuf;
     TPtrC8 tempPtr = aBuf.Mid( KHexDel().Length());
     tempBuf.Copy(tempPtr);
     TLex8 lex(tempBuf);
     TInt ret = lex.Val(aUid,EHex);
     CLOG( ( EServer, 0, _L( "<- CCookieManagerServer::ChangeToDecimal" ) ) );
     return ret;
    }
开发者ID:kuailexs,项目名称:symbiandump-mw2,代码行数:15,代码来源:CookieManagerServer.cpp

示例3: ReplaceUrl

//////////////////////////////////////////////////////////////////////
// util
//////////////////////////////////////////////////////////////////////
void ReplaceUrl(TDes8& aUrl,const TDesC8& aIsRepeatedKStr,const TDesC8& aStr){
  HBufC8* tmp=HBufC8::NewL(aUrl.Length()+aStr.Length()+128);
  int iPos=aUrl.FindF(aIsRepeatedKStr);
  if(iPos>=0){
    tmp->Des().Copy(aUrl.Left(iPos)); //加上前面有用的字符
    tmp->Des().Append(aStr);
    int iStart=iPos+aIsRepeatedKStr.Length(); //要被替换的字符,加上要被替换的字符长度
    int iLen2=aUrl.Length()-iStart;
    tmp->Des().Append(aUrl.Mid(iStart,iLen2)); //加上后面有用的字符
    aUrl.Copy(tmp->Des());
  }
  delete tmp;
}
开发者ID:rusteer,项目名称:symbian,代码行数:16,代码来源:SocketEngine.cpp

示例4: GenerateKey

void MainWindow::GenerateKey(TDes8& aKey, TInt aLen)
        {
        aKey.Zero();

        TTime currentTime;
        currentTime.HomeTime();

        // ??000Ä꿪ʼ¼Æ??
        TInt startYear = 2000;

        // µ±Ç°Äê·Ý
        TInt currentYear = currentTime.DateTime().Year();
        TTime time(TDateTime(currentYear, EJanuary, 0, 0, 0, 0, 0));

        TTimeIntervalSeconds s;
        currentTime.SecondsFrom(time, s);

        // µÃµ½ÃëÊý
        TInt i = s.Int();

        aKey.AppendFormat(_L8("%X"), i);
        aKey.AppendFormat(_L8("%X"), currentYear - startYear);

        TInt len = aKey.Length();
        if (len > aLen)
                {
                aKey.Mid(0, aLen);
                }
        else
                {
                for (TInt i = 0; i < aLen - len; i++)
                        {
                        TTime theTime;
                        theTime.UniversalTime();
                        TInt64 randSeed(theTime.Int64());
                        TInt number(Math::Rand(randSeed) + i);

                        number = number % 10 + 48;
                        aKey.Append(number);
                        }
                }
        }
开发者ID:is00hcw,项目名称:mobile-sdk,代码行数:42,代码来源:mainwindow.cpp

示例5: ChallengeResponseL

inline void CPppMsChap::ChallengeResponseL(const TDesC8& aChallenge,
					TDes8& aPaddablePasswordHash,
					TDes8& aResponse)
/**
   Computes the Challenge Response.
   @param aChallenge [in] A MS-CHAP Challenge (8 octets).
   @param aPaddablePasswordHash [in/out] The hash of the password in a
   paddable buffer (16 octets in a buffer with at least 21 octets
   maximum length).
   @param aResponse [out] The Challenge Response (24 octets).
   @note This function implements the ChallengeResponse routine
   specified in RFC 2433.
   @internalComponent
*/
	{
	ASSERT(aChallenge.Length()==KPppMsChapChallengeSize);
	ASSERT(aPaddablePasswordHash.Length()==KPppMsChapHashSize &&
		aPaddablePasswordHash.MaxLength() >=
			KPppMsChapPaddedHashSize);
	ASSERT(aResponse.Length() == KPppMsChapNTResponseSize);

// aPaddablePasswordHash contains the hash of the password (16 octets)
// zero-padded to 21 octets

// RFC 2433 - ChallengeResponse(): "Set ZPasswordHash to
// PasswordHash zero-padded to 21 octets", i.e. 5 octets
	aPaddablePasswordHash.AppendFill(0, 
					KPppMsChapPaddedHashSize -
						KPppMsChapHashSize);

// The first 8 octets of aResponse
	TPtr8 responseChunk(const_cast<TUint8*>(aResponse.Ptr()),
				KPppDESKeySize, 
				KPppDESKeySize);
	DesEncryptL(aChallenge,
		aPaddablePasswordHash.Left(KPppMsChapDESKeySize),
		responseChunk);

// The second 8 octets of aResponse
	responseChunk.Set(const_cast<TUint8*>(aResponse.Ptr()) +
					KPppDESKeySize, 
			KPppDESKeySize,
			KPppDESKeySize);
  	DesEncryptL(aChallenge,
		aPaddablePasswordHash.Mid(KPppMsChapDESKeySize,
			KPppMsChapDESKeySize), 
		responseChunk);

// The third 8 octets of aResponse
	responseChunk.Set(const_cast<TUint8*>(aResponse.Ptr()) +
		2*KPppDESKeySize, KPppDESKeySize, KPppDESKeySize);
 	DesEncryptL(aChallenge,
		aPaddablePasswordHash.Mid(2*KPppMsChapDESKeySize,
			KPppMsChapDESKeySize),
		responseChunk);


// Restore the original length of the password hash
	aPaddablePasswordHash.SetLength(KPppMsChapHashSize);

	ASSERT(aResponse.Length() == KPppMsChapNTResponseSize);
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:62,代码来源:MSCHAP.CPP

示例6: TryParsingL

// -----------------------------------------------------------------------------
// CExprUDPMsg::TryParsingL
// -----------------------------------------------------------------------------
//
TInt CExprUDPMsg::TryParsingL( TDes8& aData, TInt& aLength )
    {
    __ASSERT_ALWAYS( aData.Left( KUDPPrefix().Length() ) == KUDPPrefix,
        User::Panic( _L("Protocol"), 1 ) );

    // UDP:0123,000e,[Some test data]
    TInt frameOverhead =
        KUDPPrefix().Length() +
        KHexDecimalLength +
        KPortSuffix().Length() +
        KHexDecimalLength +
        KLengthSuffix().Length() +
        KDataSuffix().Length() +
        KMessageSuffix().Length();

    if ( aData.Length() >= frameOverhead )
        {
        TPtrC8 portPtr(
            aData.Mid( KUDPPrefix().Length(), KHexDecimalLength ) );

        TLex8 portLexer( portPtr );
        TUint port;
        if ( portLexer.Val( port, EHex ) != KErrNone )
            {
            return KErrCorrupt;
            }
        DEBUG_PRINT( DEBUG_STRING( "CExprUDPMsg::TryParsingL, port = %d" ), port );

        //Check port suffix
        if ( aData.Mid( KUDPPrefix().Length() +
            KHexDecimalLength, KPortSuffix().Length() ) != KPortSuffix )
            {
            return KErrCorrupt;
            }

        TPtrC8 lengthPtr( aData.Mid( KUDPPrefix().Length() +
            KHexDecimalLength + KPortSuffix().Length(), KHexDecimalLength ) );
        TLex8 lengthLexer( lengthPtr );
        TUint length;
        if ( lengthLexer.Val( length, EHex ) != KErrNone )
            {
            return KErrCorrupt;
            }
        DEBUG_PRINT( DEBUG_STRING( "CExprUDPMsg::TryParsingL, length = %d" ), length );

        //Check length suffix
        if ( aData.Mid(
            KUDPPrefix().Length() +
            KHexDecimalLength +
            KPortSuffix().Length() +
            KHexDecimalLength, KLengthSuffix().Length() ) != KLengthSuffix )
            {
            return KErrCorrupt;
            }

        DEBUG_PRINT( DEBUG_STRING( "CExprUDPMsg::TryParsingL, parsing data" ), length );

        if ( aData.Length() >= TInt( frameOverhead + length ) )
            {
            TInt messagePos = KUDPPrefix().Length() +
                KHexDecimalLength +
                KPortSuffix().Length() +
                KHexDecimalLength +
                KLengthSuffix().Length();

            TPtrC8 message( aData.Mid( messagePos, length ) );
            if ( aData.Mid( messagePos + length,
                KDataSuffix().Length() ) != KDataSuffix )
                {
                return KErrCorrupt;
                }
            DEBUG_PRINT( DEBUG_STRING( "CExprUDPMsg::TryParsingL, message OK" ) );

            if ( aData.Mid( messagePos + length + KDataSuffix().Length(),
                KMessageSuffix().Length() ) != KMessageSuffix )
                {
                return KErrCorrupt;
                }

            // send parsed results
            iObserver->FrameParsedL( port, message );
            // set the length of the handled message
            aLength = frameOverhead + length;

            return KErrNone;
            }

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

示例7: shiftBytePtr

TInt CISO2022KRImplementation::ConvertFromUnicode(
    CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, 
    const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, 
    TDes8& aForeign, 
    const TDesC16& aUnicode, 
    CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters)
	{
    TInt ret;
    TInt currPos = 3;
    TUint outputConversionFlags = 0;
    TUint inputConversionFlags = CCnvCharacterSetConverter::EInputConversionFlagAppend;
    TISO2022FromUniState currState = EISO2022Initialize;
    TUint8 shiftByte = 0;
    TPtr8 shiftBytePtr(NULL, 0);

    aForeign.SetLength(0);

    /* Start with escape sequence */
    aForeign.Append( KLit8EscapeSequence );

    ret = CCnvCharacterSetConverter::DoConvertFromUnicode( CnvCp949Table::ConversionData(),
                                                           aDefaultEndiannessOfForeignCharacters,
                                                           aReplacementForUnconvertibleUnicodeCharacters,
                                                           aForeign,
                                                           aUnicode,
                                                           aIndicesOfUnconvertibleCharacters,
                                                           outputConversionFlags, 
                                                           inputConversionFlags );
    /* Append shift in and out bytes as needed */
    while( currPos < aForeign.Length() )
        {
        TUint8 *currChar = (TUint8 *)aForeign.Mid(currPos).Ptr();
        if( *currChar > KMaxAscii )
            { /* KSC character */
            if( currState != EISO2022KSC )
                { /* Insert shift out byte */
                shiftByte = SHIFT_OUT_BYTE;
                currState = EISO2022KSC;
                }

            /* Clear the 8th bit */
            *currChar = (*currChar & ~(0x80));
            }
        else
            { /* ASCII character */
            if( currState != EISO2022Ascii )
                { /* Insert shift in byte */
                shiftByte = SHIFT_IN_BYTE;
                currState = EISO2022Ascii;
                }
            }

        if( shiftByte )
            {
            if( (aForeign.Length() + 1) > aForeign.MaxLength() )
                { /* Make room for shift byte */
                if( aForeign[ (aForeign.Length() - 1) ] > KMaxAscii )
                    { /* Drop a dual byte KSC character */
                    aForeign.SetLength( aForeign.Length() - 2 );
                    }
                else
                    { /* Drop a single byte ASCII character */
                    aForeign.SetLength( aForeign.Length() - 1 );
                    }
                    /* Increase unconverted amount */
                    ret++;
                /* TBD, propably should try to fix aIndicesOfUnconvertibleCharacters
                        if possible */
                }
                shiftBytePtr.Set( &shiftByte, 1, 1 );
                aForeign.Insert( currPos, shiftBytePtr );
                currPos++;
                shiftByte = 0;
            }

        /* Skip current character */
        currPos++;
        }

    return ret;
    }
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:81,代码来源:iso2022kr.cpp


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