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


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

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


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

示例1: WriteContentLineL

/**
Writes the current content line to the stream after conversion to UTF-8.
Performs any necessary folding.
@internalTechnology
*/
void CICalContentLineWriter::WriteContentLineL()
	{
	TRACE_ENTRY_POINT;
	
	// Convert to UTF-8 for writing
	HBufC8* tmpLine = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*iCurrentLine);
	CleanupStack::PushL(tmpLine);
	
	TInt pos(0);
	TInt remaining(tmpLine->Length());
	
	// Fold the line if longer than 75 octets
	TInt lineLength(KICalMaxLineLength);
	
	while (remaining > lineLength)
		{
		iWriteStream.WriteL(tmpLine->Mid(pos), lineLength);
		iWriteStream.WriteL(KICalFoldLine);
		pos += lineLength;
		remaining -= lineLength;
		lineLength = KICalMaxFoldedLineLength;
		}
		
	// Complete the line
	iWriteStream.WriteL(tmpLine->Mid(pos));
	iWriteStream.WriteL(KICalCRLF);	

	CleanupStack::PopAndDestroy(tmpLine);
	
	iCurrentLine->Des().SetLength(0);
	
	TRACE_EXIT_POINT;
	}
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:38,代码来源:ICalContentLineWriter.cpp

示例2: ptr

EXPORT_C HBufC8* CTestConfig::ReplaceLC(const TDesC8& aOld, const TDesC8& aNew, const TDesC8& aOldString)
	{
	HBufC8* rString = aOldString.AllocLC();
	TInt oldLen = aOld.Length();
	TInt newLen = aNew.Length();

	if (!oldLen)
		return rString;

	for (TInt pos = 0; pos < rString->Length(); pos += newLen)
		{
		TPtrC8 ptrC = rString->Mid(pos);
		TInt find = ptrC.Find(aOld);

		if (find == KErrNotFound)
			return rString;
	
		pos += find;

		if (newLen > oldLen)
			{
			rString = rString->ReAllocL(rString->Length() + newLen - oldLen);
			CleanupStack::Pop();
			CleanupStack::PushL(rString);
			}

		TPtr8 ptr(rString->Des());
		ptr.Replace(pos, oldLen, aNew);
		}

	return rString;
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:32,代码来源:testconfigfile.cpp

示例3: doTestStepL

TVerdict CUpdateEntryStep::doTestStepL()
	{
	TPtrC sisFile;	
	if(!GetStringFromConfig(ConfigSection(), KSisFile, sisFile))
		return PrintErrorAndReturnFailL(_L("SIS file couldn't be found in the configuration!"));

	HBufC8 *controllerData = GetControllerFromSisLC(sisFile);
	const TInt controllerOffset = 4;
	// The registry does not store the first 4 bytes of the controller - see CInstallationProcessor
	TPtrC8 controllerDataPtr = controllerData->Mid(controllerOffset);
		
	RSisRegistryAccessSession sras;
	User::LeaveIfError(sras.Connect());
	CleanupClosePushL(sras);
	sras.UpdateEntryL(controllerDataPtr, iTimeMeasuredExternally);
	CleanupStack::PopAndDestroy(2, controllerData); // controllerData, sras
	return TestStepResult();
	}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:18,代码来源:writablesessionstep.cpp

示例4: ParseFmtpAttrL

// -----------------------------------------------------------------------------
// CMccCodecInformation::ParseFmtpAttr
// Parses the fmtp attribute
// -----------------------------------------------------------------------------
//
TBool CMccCodecRed::ParseFmtpAttrL( const TDesC8& aFmtp )
    {
    // Parse codecs used for primary and secondary etc. codecs from the 
    // fmtp attribute
    // example fmtp attribute:
    // a=fmtp:99 0/103 
    // 99 is the redundancy format payload type
    // 0 is the primary codecs payload type
    // 103 is the secondary codecs payload type
    
    // NOTE: currently redundancy is allowed only for single payload type
    
    TBool updated( EFalse );
    
    TInt nextIndex = 0;
    TInt prevIndex = 0;
    TUint8 prevPayloadFormat = KMccPayloadTypeMax;
    HBufC8* modifyBuf = HBufC8::NewLC( aFmtp.Length() );
    TPtr8 pFmtpValue( modifyBuf->Des() );
    pFmtpValue = aFmtp;
    
    if( aFmtp.Length() > 0 )
        {   
        // Search for all the slashes and convert number strings between them
        // to integers    
        TBool found = ETrue;
        while( EFalse != found )
            {     
            pFmtpValue = modifyBuf->Mid( nextIndex );
            nextIndex = pFmtpValue.Locate( KCharSlash );          
            if( ( KErrNotFound == nextIndex ) ) 
                {
                found = EFalse;
                if( 0 != pFmtpValue.Length() )
                    {
                    nextIndex = pFmtpValue.Length(); // Handle last payload value      
                    }
                }
            if( 0 != pFmtpValue.Length() )
                {
                TLex8 lex = pFmtpValue.Mid( prevIndex, (nextIndex - prevIndex) );
                TUint8 payloadFormat;
                TInt err = lex.Val( payloadFormat, EDecimal );
                if( KErrNone == err )
                    {
                    if ( prevPayloadFormat != KMccPayloadTypeMax &&
                         prevPayloadFormat != payloadFormat )
                         {
                         iRedPayloads.Reset();
                         User::Leave( KErrNotSupported );
                         }
                                     
                    iRedPayloads.AppendL( static_cast<TUint>( payloadFormat ) );  
                    updated = ETrue;  
                    prevPayloadFormat = payloadFormat;  
                    }
                    
                nextIndex++;         
                prevIndex = 0;
                }
            }
        }
    
    CleanupStack::PopAndDestroy( modifyBuf );
    
    return updated;
    }
开发者ID:kuailexs,项目名称:symbiandump-mw1,代码行数:72,代码来源:MmccCodecRed.cpp

示例5: ProcessResultsL

void CPolicyTest::ProcessResultsL(TRequestStatus& aStatus)
	{
	_LIT8(KSummaryLine, " tests failed out of ");
	_LIT8(KNewLine, "\r\n");

	TInt failCount = KErrNotFound, runCount;
	
	// Read entire log file into memory to process
	RFile file;
	TDriveUnit sysDrive (RFs::GetSystemDrive());
	TBuf<128> logTmpFile (sysDrive.Name());
	logTmpFile.Append(KLogTmpPath);
	User::LeaveIfError(file.Open(iFs, logTmpFile, EFileShareReadersOnly | EFileRead));
	CleanupClosePushL(file);

	TInt size;
	User::LeaveIfError(file.Size(size));
	HBufC8* buffer = HBufC8::NewLC(size);
	TPtr8 ptr = buffer->Des();

	User::LeaveIfError(file.Read(ptr));

	iOut.writeString(_L("Child test output:\n"));

	TInt pos = 0;
	while (pos < size)
		{
		TInt nextNewline = buffer->Mid(pos).Find(KNewLine);

		// Split buffer into lines
		TPtrC8 line;
		if (nextNewline == KErrNotFound)
			{
			line.Set(buffer->Mid(pos));
			}
		else
			{
			line.Set(buffer->Mid(pos, nextNewline + KNewLine().Length()));
			}
		pos += line.Length();

		// Search for summary line
		TInt pos2 = line.Find(KSummaryLine);
		if (pos2 != KErrNotFound)
			{
			// Parse the summary line to work out if the test passed
			TLex8 lex1(line.Left(pos2));
			TInt err1 = lex1.Val(failCount);
			TLex8 lex2(line.Mid(pos2 + KSummaryLine().Length()));
			TInt err2 = lex2.Val(runCount);

			if (err1 != KErrNone || err2 != KErrNone)
				{
				iOut.writeString(_L("Failed to parse summary line\n"));
				User::LeaveIfError(err1);
				User::LeaveIfError(err2);
				}
			}
		else
			{
			// Don't print the summary line as this will confuse whatever parsed
			// the main log
			iOut.writeString(_L("> "));
			iOut.writeString(line);
			}		
		}
	
	if (failCount == KErrNotFound)
		{
		iOut.writeString(_L("Couldn't find summary line in test output\n"));
		User::Leave(KErrNotFound);
		}
	iFailCount += failCount;

	// Print results in different format
	iOut.write(_L("Tests run: %d\n"), runCount);
	iOut.write(_L("Tests failed: %d\n"), failCount);
	iOut.writeNewLine();
	
	CleanupStack::PopAndDestroy(2, &file);

	TRequestStatus* status = &aStatus;
	User::RequestComplete(status, KErrNone);
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:84,代码来源:t_policy.cpp

示例6: rc

static TInt
cipher_decrypt_doProcessL (sc_cipher_hd_t c, byte *outbuf, const byte *inbuf,
                           unsigned int nbytes, int* outputLen, int last)
{
    TInt rc(KErrNone);

    switch( c->mode ) {
    case SC_CIPHER_MODE_ECB:
    case SC_CIPHER_MODE_CBC:
    {
        TUint blockSize = c->iDecryptor->BlockSize();

        if ((c->mode == SC_CIPHER_MODE_CBC)
                && nbytes%blockSize
                && !(nbytes > blockSize
                     && (c->flags & SC_CIPHER_CBC_CTS)))
        {
            rc = KErrArgument;
        }
        else if ((c->mode == SC_CIPHER_MODE_ECB)
                 && nbytes%blockSize)
        {
            rc = KErrArgument;
        }
        else
        {
            TInt outlen;
            if (last)
                outlen = c->iDecryptor->MaxFinalOutputLength(nbytes);
            else
                outlen = c->iDecryptor->MaxOutputLength(nbytes);
            HBufC8 *result = HBufC8::NewLC(outlen);
            TPtr8 resultActual= result->Des();
            resultActual.FillZ(resultActual.MaxLength());
            resultActual.SetLength(0);

            //  could improve memory usage later by allocating a smaller buffer
            HBufC8* input = HBufC8::NewLC(nbytes);
            TPtrC8 inbufPtr(inbuf, nbytes);
            *input = inbufPtr;

            TInt j=0;

            for(; j+blockSize<nbytes; j+=blockSize)
            {   //	decryption in blocks of size blocksize
                c->iDecryptor->Process(input->Mid(j,blockSize), resultActual);
            }

            if (last)
            {
                c->iDecryptor->ProcessFinalL(input->Mid(j), resultActual);
                *outputLen = result->Size();

                // we delete iDecryptor once the decryption finishes
                // so that the next decryption can use a different key or iv
                delete c->iDecryptor;
                c->iDecryptor = NULL;
            }
            else
                c->iDecryptor->Process(input->Mid(j,blockSize), resultActual);

            memcpy(outbuf, result->Ptr(), result->Size());

            CleanupStack::PopAndDestroy(input);
            CleanupStack::PopAndDestroy(result);

        }
    }
    break;
    /*
      case SC_CIPHER_MODE_CFB:
    do_cfb_decrypt(c, outbuf, inbuf, nbytes );
    break;
      case SC_CIPHER_MODE_CTR:
    do_ctr_decrypt(c, outbuf, inbuf, nbytes );
    break;
      case SC_CIPHER_MODE_STREAM:
        c->cipher->stdecrypt ( &c->context.c,
                               outbuf, (byte*) inbuf, nbytes );
        break;
      case SC_CIPHER_MODE_NONE:
    if( inbuf != outbuf )
        memmove( outbuf, inbuf, nbytes );
    break;
        */
    default:
        rc = KErrNotSupported;
        break;

    }

    return rc;
}
开发者ID:kuailexs,项目名称:symbiandump-os2,代码行数:93,代码来源:xmlsecc_cryptowrapper.cpp

示例7: RunL

/**
Called when the INIT property is changed and once on the construction of the object. Extracts 
the message from the INIT property, notifies both the observer by calling the 
MLbsSuplPushRecObserver::OnSuplInit function and the sender by setting the ACK property.
Then it resubscribes for the INIT property to listen for next messages.

@see CSuplPushImpl
@see MLbsSuplPushRecObserver::OnSuplInit
@see CActive::RunL
*/
void CLbsSuplPushRecChannel::RunL()
	{
	LBSLOG(ELogP1, "CLbsSuplPushRecChannel::RunL() Begin\n");
	if(iStatus==KErrNone)
		{
		iInitProperty.Subscribe(iStatus);
		SetActive();
		
		TPckgBuf<TInt> length;
		TInt err = RProperty::Get(iPropOwnerSecureId, iInitPropKey, length);
		
		//The INIT propery has been defined but not set yet.
		if(err==KErrNone && length.Length()==0)
			{
			LBSLOG(ELogP1, "CLbsSuplPushRecChannel::RunL() - err==KErrNone && length.Length()==0 End\n");
			return;
			}
		
		//Can't do anything here, just resubscribe
		if(err!=KErrOverflow || length()<=0)
			{
			//The property must be set in the correct value.
			__ASSERT_DEBUG(0, User::Invariant());
			LBSLOG(ELogP1, "CLbsSuplPushRecChannel::RunL() - err!=KErrOverflow || length()<=0 End\n");
			return;
			}

		TInt len = length() + 2*sizeof(TInt);
		
		HBufC8* msg = HBufC8::New(len);
		
		//Not enough memory to handle the message, just resubscribe 
		if(msg==0)
			{
			LBSLOG(ELogP1, "CLbsSuplPushRecChannel::RunL() - msg==0 End\n");
			return;
			}
		
		TPtr8 ptr = msg->Des();
		err = RProperty::Get(iPropOwnerSecureId, iInitPropKey, ptr);
		if(err!=KErrNone || ptr.Length()!=len)
			{
			delete msg;
			//Unexpected environment error or the length of the message is not equal the length declared in
			//the header.
			__ASSERT_DEBUG(0, User::Invariant());
			LBSLOG(ELogP1, 
				"CLbsSuplPushRecChannel::RunL() RProperty::Get(iPropOwnerSecureId, iInitPropKey, ptr)|| ptr.Length()!=len End\n");
			return;
			}
		
		TPckgBuf<TInt> reqId;
		reqId.Copy(msg->Mid(sizeof(TInt), sizeof(TInt))); 
		
		if(reqId()<=0)
			{
			delete msg;
			//Message is corrupted, the reqId must be > 0. 
			__ASSERT_DEBUG(0, User::Invariant());
			LBSLOG(ELogP1, "CLbsSuplPushRecChannel::RunL() - reqId()<=0 End\n");
			return;
			}

			
		TInt ackId = 0;
		err = RProperty::Get(iPropOwnerSecureId, iAckPropKey, ackId);

		if(err!=KErrNone || ackId<0)
			{
			delete msg;
			if(ackId<0)
				{
				RProperty::Set(iPropOwnerSecureId, iAckPropKey, 0);
				}
			//Unexpected environment error or wrong ackId, it must be > 0.
			__ASSERT_DEBUG(0, User::Invariant());
			LBSLOG(ELogP1, 
					"CLbsSuplPushRecChannel::RunL() - RProperty::Get(iPropOwnerSecureId, iAckPropKey, ackId)!=KErrNone || ackId<0 End\n");
			return;
			}
		

		//We notify the observer only if message was not delivered before
		if(ackId!=reqId())
			{
			TLbsSuplPushRequestId reqIdUnsgn = reqId(); 
			TPtrC8 msgPtr = msg->Right(length());
			err = RProperty::Set(iPropOwnerSecureId, iAckPropKey, reqId());
			//Unexpected environment error.
			__ASSERT_DEBUG(err==KErrNone, User::Invariant());
//.........这里部分代码省略.........
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:101,代码来源:lbssuplpushreceiverchannel.cpp


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