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


C++ TPtr8::MaxLength方法代码示例

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


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

示例1: InsertIntoPayload

void CLocationEngine::InsertIntoPayload(TInt aPosition, const TDesC8& aString, TPtr8& aLogStanza) {
	if(aLogStanza.Length() + aString.Length() > aLogStanza.MaxLength()) {
		iLogStanza = iLogStanza->ReAlloc(aLogStanza.MaxLength() + aString.Length() + 32);
		aLogStanza.Set(iLogStanza->Des());
	}

	aLogStanza.Insert(aPosition, aString);
}
开发者ID:Persepoliss,项目名称:symbian-client,代码行数:8,代码来源:LocationEngine.cpp

示例2:

// The caller must free the returned buffer. The buffer is guaranteed
// to have a zero terminator.
HBufC8* ConvToUtf8ZL(const TDesC& name16)
{
  // Note that there is no non-leaving variant of this function, such
  // that the result has no maximum size.
  // 
  // Do not know what happens if any 0 values appear in "name16"; this
  // is not documented.
  HBufC8* name8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(name16);

  // Ensure there is a zero terminator. Quite a lot of work to do this
  // efficiently.
  TPtr8 ptr = name8->Des();
  if (ptr.Length() < ptr.MaxLength()) {
    ptr.PtrZ(); // modifies HBufC8 content
  } else {
    HBufC8* bigger8 = name8->ReAlloc(ptr.Length() + 1);
    if (bigger8) {
      name8 = bigger8; // name8 already deleted by ReAlloc
      name8->Des().PtrZ(); // modifies HBufC8 content
    } else {
      delete name8;
      User::Leave(KErrNoMemory);
    }
  }

  return name8;
}
开发者ID:contextlogger,项目名称:contextlogger2,代码行数:29,代码来源:utils_cl2_cxx.cpp

示例3: WriteL

// -----------------------------------------------------------------------------
// CCapInfo::WriteL(const TDesC& aText)
// Writes one element to capability buffer.
// -----------------------------------------------------------------------------
//
void CCapInfo::WriteL(const TDesC& aText)
    {
    if (aText.Length() > iBuf.MaxLength())
        {
        User::Leave(KErrTooBig);
        }
        

    iBuf=aText;
    iBuf.Trim();
    FormatElement(iBuf);
    TPtr8 ptr = iHeapBuf->Des();

    if ( iBuf.Length()+2 > ptr.MaxLength() )
        {
        User::Leave(KErrTooBig);
        }
        
    //unicode conversion
    HBufC8* convBuf = HBufC8::NewLC( iBuf.Size() );
    TPtr8 convPtr = convBuf->Des();
    
    CnvUtfConverter::ConvertFromUnicodeToUtf8(convPtr, iBuf);

    ptr.Copy(convPtr);
    ptr.Append( KLineFeed );  // linefeed
    
    CleanupStack::PopAndDestroy( convBuf );
    
    TInt pos=iCapabilityBuf->Size();
    iCapabilityBuf->InsertL(pos, ptr);

    iBuf=KNullDesC;
    }
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:39,代码来源:capinfo.cpp

示例4: wcslen

EXPORT_C int WstringToTptr8(wstring& aSrc, char* cPtr, TPtr8& aDes)
{
    int retval = ESuccess;
    unsigned int wlen = 0, ilendes = 0;
    const wchar_t* wcharString = aSrc.c_str();
    int minusone = -1;
    
    if (L'\0' == wcharString[0])
    {
    	return EStringNoData;
    }
    
	wlen = wcslen(wcharString);
	ilendes = aDes.MaxLength();
	
	if (ilendes < 2*wlen)
	{
		return EInsufficientMemory;
	}
	
	if(minusone != wcstombs(cPtr, wcharString, wlen*2))
	{
		aDes.Set((unsigned char *)cPtr, wlen*2, ilendes);	
	}
	else
	{
		retval = EInvalidWCSSequence;
	}
		
	return retval;
}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:31,代码来源:wstringtodescriptor8.cpp

示例5: ptr

void CDHCPIP6Control::GetRawOptionDataL(TUint aOpCode, TPtr8& aPtr )
	{
	HBufC8* buf = NULL;
	DHCPv6::CDHCPMessageHeaderIP6 msg(buf);
	CleanupClosePushL(msg);
	TPtr8 ptr( const_cast<TUint8*>(iValidMsg.Ptr()), iValidMsg.Length(), iValidMsg.Length() );
	msg.iRecord.ParseL(ptr); //no check necessary
    DHCPv6::COptionNode* pOption = msg.GetOptions().FindOption(aOpCode);
    if (!pOption)
      {
#ifdef SYMBIAN_TCPIPDHCP_UPDATE
      // The option is not found try to get the option through DHCP INFORM message 
      //by calling RequestInformOrCompleteCallL
      CleanupStack::PopAndDestroy();
	  TUint opcode = aOpCode;
	  TPtr8 optPtr(reinterpret_cast<TUint8*>(&opcode),1,1);
	  return(RequestInformOrCompleteCallL(optPtr));
#else	  
	  User::Leave(KErrNotFound);  
#endif //SYMBIAN_TCPIPDHCP_UPDATE	  
      }
    ptr.Set(pOption->GetBodyDes());
    if (ptr.Length() > aPtr.MaxLength())
      {
      User::Leave(KErrOverflow);
      }
    aPtr.Copy(ptr);
    CleanupStack::PopAndDestroy();
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:29,代码来源:DHCPIP6Control.cpp

示例6: DecompressNextMemberL

void CZipFileDecompressor::DecompressNextMemberL(CZipFileMember& aMember)
    {
    __ASSERT_ALWAYS(!iUncompressedFile.SubSessionHandle(), 
                    User::Invariant());
    __ASSERT_ALWAYS(!iUncompressedData, User::Invariant());
    
    
    //Ignore entries that has zero uncompressed size.
    //(This includes e.g. directories) 
    if (aMember.UncompressedSize() > 0)
        {
        const TChar KDirectorySeparator('\\');
        
        TUint32 uncompressedSize = aMember.UncompressedSize();
        HBufC8* uncompressedData = HBufC8::NewLC(uncompressedSize);
        
        RZipFileMemberReaderStream* readerStream;
        User::LeaveIfError(iZipFile->GetInputStreamL(&aMember, readerStream));
        CleanupStack::PushL(readerStream);
        
        TPtr8 uncompressedDataPtr = uncompressedData->Des();
        User::LeaveIfError(readerStream->Read(uncompressedDataPtr, 
                                              uncompressedDataPtr.MaxLength()));
        
        CleanupStack::PopAndDestroy(readerStream);
        
        HBufC* fileName = aMember.Name()->AllocLC();
        TPtr fileNamePtr= fileName->Des();
        TInt lastDirectorySeparator = fileName->LocateReverse(KDirectorySeparator);
        if (lastDirectorySeparator >= 0)
            {
            fileNamePtr = fileName->Mid(lastDirectorySeparator+1);
            }
        
        TParsePtr fileNameParser(fileNamePtr);
        
        User::LeaveIfError(iUncompressedFile.Replace(iFileServer, 
                                                     fileNameParser.NameAndExt(), 
                                                     EFileWrite));            
        CleanupStack::PopAndDestroy(fileName);
        
        CleanupStack::Pop(uncompressedData);
        iUncompressedData = uncompressedData;
        
        iUncompressedFile.Write(*iUncompressedData, iStatus);
        SetActive();
        }
    else
        {
        iStatus = KRequestPending;
        SetActive();
        TRequestStatus* ownStatus = &iStatus;
        User::RequestComplete(ownStatus, KErrNone);
        }
    }
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:55,代码来源:zipfiledecompressor.cpp

示例7: AppendBufL

// -----------------------------------------------------------------------------
// AppendBufL
// -----------------------------------------------------------------------------
//
void AppendBufL( TPtr8& aDest, HBufC8* aSrc )
    {
    TInt length = aSrc ? aSrc->Length() : KNullBuffer;

    APPEND_BUF_INT( aDest, length );

    if( length > 0 )
        {
        __ASSERT_DEBUG( (aDest.MaxLength() - aDest.Length()) > length, User::Panic( KNullDesC, KErrTooBig ) );
        aDest.Append( *aSrc );
        }
    }
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:16,代码来源:FileExt.cpp

示例8: IssueRead

void CSecureSocketReader::IssueRead()
	{
	SUPLLOG(ELogP1, "CSecureSocketReader::IssueRead() Begin\n");
	if (!IsActive())
		{
		TPtr8 ptr = iBuffer.MidTPtr(iReadSoFar);
		iPtr.Set(const_cast<TUint8*>(ptr.Ptr()), 0, ptr.MaxLength());
		iSocket.RecvOneOrMore(iPtr, iStatus, iBufferRead);
		SetActive();
		}
	SUPLLOG(ELogP1, "CSecureSocketReader::IssueRead() End\n");
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:12,代码来源:socketreader.cpp

示例9: doRandomizeL

// Call Symbian random generator
void doRandomizeL(unsigned char* buffer, size_t length)
{
    HBufC8* hbuf = HBufC8::NewLC(length);
    TPtr8 ptr = hbuf->Des();
    ptr.FillZ(ptr.MaxLength());

    CSystemRandom* rand=CSystemRandom::NewLC();
    rand->GenerateBytesL(ptr);
    memcpy(buffer, hbuf->Ptr(), length);
    CleanupStack::PopAndDestroy(rand);
    CleanupStack::PopAndDestroy(hbuf);
}
开发者ID:kuailexs,项目名称:symbiandump-os2,代码行数:13,代码来源:xmlsecc_cryptowrapper.cpp

示例10: GetReportL

void CBTHidConnection::GetReportL(TUint8 aReportType, TUint8 aReportID,
        TUint16 aLength)
    {
    LeaveIfCommandNotReadyL();

    iCommandBuffer.Zero();

    // Add the Transaction header byte
    // Report Type 0 = Reserved
    // Report Type 1 = Input
    // Report Type 2 = Output
    // Report Type 3 = Feature
    iCommandBuffer.Append(EGetReportFullBufReserved + aReportType);

    // If Report ID's are declared in the report descriptor then we
    // add this field
    if (aReportID != 0)
        {
        iCommandBuffer.Append(aReportID);
        }

    // We need to check we have a buffer large enough to hold the control
    // data we get back from the device
    if (!iControlDataBuffer)
        {
        // Allocate the buffer if it didn't exist
        iControlDataBuffer = HBufC8::NewL(aLength);
        }
    else
        {
        // Get a modifiable pointer to the buffer.
        TPtr8 dataPtr = iControlDataBuffer->Des();

        if (dataPtr.MaxLength() < aLength)
            {
            // Reallocate the buffer if its too small.
            delete iControlDataBuffer;
            iControlDataBuffer = 0;
            iControlDataBuffer = HBufC8::NewL(aLength);
            }
        else
            {
            // Existing buffer is large enough, just zero it.
            dataPtr.Zero();
            }
        }

    iControlSocketWriter->IssueWriteL(iCommandBuffer);
    iCommandIssued = ETrue;
    }
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:50,代码来源:bthidconnection.cpp

示例11: DoPacket

void CProtocolExadump::DoPacket(const RMBufPacketBase &aPacket, const RMBufPktInfo &aInfo)
	/**
	* Dump the packet.
	*
	* This is called for both incoming and outgoing packets, from the
	* respective ApplyL methods.
	*
	* @param aPacket	The packet data
	* @param aInfo		The packet inforrmation
	*/
	{
/** @code */
	// Open the dump file, if not already opened (or attempted).
	if (iOpen == 0)
		DoOpen(1500);
	if (iOpen < 0)
		return;	// cannot open output file.

	//
	// Build PCAP frame into iBuffer (pcap_pkthdr + snapped portion of the packet)
	//
	TPtr8 buf = iBuffer->Des();
	struct pcap_pkthdr *const hdr = (struct pcap_pkthdr *)buf.Ptr();
	TPtr8 ptr((TUint8 *)buf.Ptr() + sizeof(*hdr), buf.MaxLength() - sizeof(*hdr));

	const TInt snap = aInfo.iLength > ptr.MaxLength() ? ptr.MaxLength() : aInfo.iLength;
	ptr.SetLength(snap);
	aPacket.CopyOut(ptr);

	hdr->caplen = snap;
	hdr->len = aInfo.iLength;

	TTime stamp;
	stamp.UniversalTime();
	const TTimeIntervalMicroSeconds elapsed = stamp.MicroSecondsFrom(iBase);
#ifdef I64INT
	hdr->ts.tv_usec = I64INT(elapsed.Int64() % 1000000);
	hdr->ts.tv_sec = I64INT(elapsed.Int64() / 1000000);
#else
	hdr->ts.tv_usec = (elapsed.Int64() % 1000000).GetTInt();
	hdr->ts.tv_sec = (elapsed.Int64() / 1000000).GetTInt();
#endif
	//
	// Write frame out.
	//
	iDumpFile.Write(buf, snap+sizeof(*hdr));
/** @endcode */
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:48,代码来源:exadump.cpp

示例12: EncodeToL

/** 
EncodeToL()

Encode a populated outgoing message to the specified buffer.

@param  aBuf buffer pointer 
@return error indication, KErrNone otherwise
*/
EXPORT_C TInt CSuplMessageBase::EncodeToL(TPtr8& aBuf)
	{
	SUPLLOG(ELogP1, "CSuplMessageBase::EncodeToL() Begin\n");
	__ASSERT_DEBUG(iIsOutgoingMessage, User::Invariant());

	TInt retval = KErrNone;
	
	// buffer pointer, fixed max length
	TUint8* msgBuf = (TUint8*)aBuf.Ptr();
	TInt maxLength = aBuf.MaxLength();
	
	// Log the un-encoded SUPL values
	SUPLLOG(ELogP9, "-> ENCODING SUPL MESSAGE FOR SENDING\n");
	//LogMessageContent();
	
	// if the message is a SUPL POS, encode the payload
	if (iData->message.t == T_UlpMessage_msSUPLPOS)
		{
		CSuplPos* suplPos = reinterpret_cast <CSuplPos*>(this);
		retval = suplPos->EncodePosPayloadL();
		if (retval != KErrNone)
			{
			SUPLLOG(ELogP1, "CSuplMessageBase::EncodeToL() Error encoding Positioning Payload\n");
			return retval;
			}
		}
		
	// construct the encode buffer control object
	iEncodeBuffer = new (ELeave) ASN1PEREncodeBuffer (msgBuf, (unsigned int)maxLength, FALSE, (OSRTContext*)iControl->getContext());
	
	// Encode the message to the buffer
	TInt stat = iControl->EncodeTo(*iEncodeBuffer);

	if (stat == 0)
		{
		// Set the length according to reported buffer length
		TInt len = iEncodeBuffer->getMsgLen ();
		iData->length = len;
		aBuf.SetLength(len);
		
		// clear the encoded length field
		msgBuf[0] = 0;
		msgBuf[1] = 0;

		// set the encoded length field
      	msgBuf[0] |= (TUint8)( len >> 8 );
		msgBuf[1] |= (TUint8)( len );
		}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:56,代码来源:suplmessagebase.cpp

示例13: CreateHashL

// -----------------------------------------------------------------------------
// TSnapshotItem::CreateHashL
// Create hash value from group content
// -----------------------------------------------------------------------------
void TSnapshotItem::CreateHashL( CContactGroup& aGroup )
    {
    CMessageDigest* hash = CMessageDigestFactory::NewDigestLC( CMessageDigest::EMD5 );
    
    if ( aGroup.HasItemLabelField() )
        {
        TPtrC label = aGroup.GetGroupLabelL();
        HBufC8* tempBuf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( label );
        CleanupStack::PushL( tempBuf );
        hash->Update( tempBuf->Des() );
        CleanupStack::PopAndDestroy( tempBuf );
        }
    
    // Create text field from items on group
    CContactIdArray* contactsIdArray = aGroup.ItemsContainedLC();
    const TInt idBufferMaxSize( 400 );
    HBufC8* tempIdBuf = HBufC8::NewLC( idBufferMaxSize );
    TPtr8 tempId = tempIdBuf->Des();
    const TInt KMaxNumLength(5);
    if ( contactsIdArray ) // this is NULL if there are no objects
        {
        tempId.AppendNum( contactsIdArray->Count(), EHex );
        for (TInt i=0; i< contactsIdArray->Count(); i++ )
            {
            if ( tempId.Length()+KMaxNumLength > tempId.MaxLength() )
                {
                // buffer is almost full, don't add any new items
                LOGGER_WRITE("buffer full");
                break;
                }
            // add item id
            tempId.AppendNum( (*contactsIdArray)[i] , EHex );
            }
        }
    else
        {
        tempId.AppendNum( 0 );
        }
    // update hash
    hash->Update( tempId );
    
    iHash.Copy( hash->Final() );
    
    CleanupStack::PopAndDestroy( tempIdBuf );
    CleanupStack::PopAndDestroy( contactsIdArray );
    CleanupStack::PopAndDestroy( hash );
    }
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:51,代码来源:snapshotitem.cpp

示例14: GetBufferL

TVideoInputBuffer* CMMFTestVideoDecodeHwDevice::GetBufferL(TUint aBufferSize)
	{
	if (!iBufferDataArea)
		{
		TPtrC8 testBufferString(KTestBufferString);
		iBufferDataArea = testBufferString.AllocL();
		}

	TPtr8 dataAreaPtr = iBufferDataArea->Des();
	TInt reqBufferSize = aBufferSize;
	if (reqBufferSize > dataAreaPtr.MaxLength())
		User::Leave(KErrTooBig);

	// initialize iInputBuffer with test data
	iInputBuffer.iOptions = KTestBufferOptions;
	iInputBuffer.iDecodingTimestamp = aBufferSize;
	iInputBuffer.iData.Set(dataAreaPtr);

	// call new buffer callback
	iProxy->MdvppNewBuffers();

	return &iInputBuffer;
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:23,代码来源:decoder.cpp

示例15: TblCallTestL


//.........这里部分代码省略.........
	TEST(res);
		
	TheTest.Next(_L("ColLength()"));	
	TInt len = TheTbl1.ColLength(1);
	TEST(len > 0);

	TheTbl1.InsertL();
	TheTbl1.SetColL(2, 3);
	TheTbl1.SetColL(3, 4);
	TheTbl1.PutL();

	TheTest.Next(_L("GotoL(TPosition)"));	
	res = TheTbl1.GotoL(RDbRowSet::EFirst);
	TEST(res);
	
	TheTest.Next(_L("Bookmark()/GotoL(TDbBookmark)"));	
	TDbBookmark bkmk = TheTbl1.Bookmark();
	res = TheTbl1.NextL();
	TEST(res);
	TheTbl1.GotoL(bkmk);
	TheTbl1.GetL();
	val1 = TheTbl1.ColInt32(1);
	TEST(val1 == 0);
	
	TheTest.Next(_L("CountL()/IsEmptyL()"));	
	cnt = TheTbl1.CountL();
	TEST(cnt == 2);
	res = TheTbl1.IsEmptyL();
	TEST(!res);
	
	TheTest.Next(_L("MatchL()"));	
	RDbRowConstraint match;
	CleanupClosePushL(match);
	err = match.Open(TheTbl1, TDbQuery(_L("ID > 0")));
	TEST2(err, KErrNone);
	res = EFalse;
	TheTbl1.BeginningL();
	while(TheTbl1.NextL())
		{
		if(TheTbl1.MatchL(match))
			{
			res = ETrue;
			}
		}
	CleanupStack::PopAndDestroy(&match);
	TEST(res);

	TheTest.Next(_L("FindL()"));	
	res = TheTbl1.FirstL();
	TEST(res);
	err = TheTbl1.FindL(RDbRowSet::EForwards, TDbQuery(_L("ID <> 0")));
	TEST(err >= 0);
	TheTbl1.GetL();
	val1 = TheTbl1.ColInt32(1);
	TEST(val1 > 0);

	_LIT8(KTestData2, "0123456789");
	HBufC8* buf = HBufC8::NewLC(10000);
	TPtr8 ptr = buf->Des(); 
	for(i=0;i<1000;++i)
		{
		ptr += KTestData2();
		}
	
	TheTest.Next(_L("RDbColReadStream"));	
	err = TheTbl2.Open(TheDb1, KTempTblName);
	TEST2(err, KErrNone);

	TheTbl2.InsertL();
	TheTbl2.SetColL(2, *buf);
	TheTbl2.PutL();
	
	TheTbl2.InsertL();
	TheTbl2.SetColL(2, KTestData2);
	TheTbl2.PutL();
	
	res = TheTbl2.PreviousL();
	TEST(res);
	TheTbl2.GetL();
	RDbColReadStream rstream;
	rstream.OpenLC(TheTbl2, 2);
	ptr.Zero();
	rstream.ReadL(ptr, ptr.MaxLength());
	CleanupStack::PopAndDestroy(&rstream);
	TEST(ptr.Length() == ptr.MaxLength());

	TheTest.Next(_L("RDbColWriteStream"));	
	TheTbl2.InsertL();
	RDbColWriteStream wstream;
	wstream.OpenLC(TheTbl2, 2);
	wstream.WriteL(ptr, ptr.Length());
	wstream.CommitL();
	CleanupStack::PopAndDestroy(&wstream);
	TheTbl2.PutL();
	
	TheTbl2.Close();
	CleanupStack::PopAndDestroy(buf);
			
	TheTbl1.Close();
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:101,代码来源:t_dbplatsectbl.cpp


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