本文整理汇总了C++中RBuf8::Size方法的典型用法代码示例。如果您正苦于以下问题:C++ RBuf8::Size方法的具体用法?C++ RBuf8::Size怎么用?C++ RBuf8::Size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RBuf8
的用法示例。
在下文中一共展示了RBuf8::Size方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ServiceL
void CSandboxSession::ServiceL(const RMessage2 &aMessage)
{
if (aMessage.Function() >= EMaxArgs)
{
aMessage.Complete(KErrArgument);
return;
}
if (aMessage.Function() == EGetRecog2)
{
aMessage.WriteL(0, iBuf);
iBuf.Close();
aMessage.Complete(KErrNone);
}
else if (aMessage.Function() == EGetRecog)
{
if (iBuf.MaxLength() == 0)
{
iBuf.ReAllocL(1024); // Must be > sizeof(TDataType) otherwise the reallocating logic below is flawed
}
TUid uid = TUid::Uid(aMessage.Int0());
TUid destructorKey;
CApaDataRecognizerType* rec = static_cast<CApaDataRecognizerType*>(REComSession::CreateImplementationL(uid, destructorKey));
TInt count = rec->MimeTypesCount();
for (TInt j = 0; j < count; j++)
{
TDataType type = rec->SupportedDataTypeL(j);
TPckg<TDataType> buf(type);
if (iBuf.Length() + buf.Length() >= iBuf.MaxLength())
{
iBuf.ReAllocL(iBuf.MaxLength() * 2);
}
iBuf.Append(buf);
}
aMessage.Complete(iBuf.Size());
}
else if (aMessage.Function() == ECloseServer)
{
aMessage.Complete(KErrNone);
CActiveScheduler::Stop();
}
else if (aMessage.Function() == EGetVTablePtr)
{
TUid destructorKey;
TAny* obj = NULL;
obj = REComSession::CreateImplementationL(TUid::Uid(aMessage.Int0()), destructorKey);
TAny* vtablePtr = *((TAny**)obj);
TPckg<TAny*> res(vtablePtr);
aMessage.WriteL(1, res);
aMessage.Complete(KErrNone);
}
else
{
ASSERT(0);
}
}
示例2: SerializeToBufferL
TInt CXmlEngSerializerGZIP::SerializeToBufferL(RBuf8& aBuf,
const TXmlEngNode aNode,
const TXmlEngSerializationOptions& aOpt)
{
CXmlEngGZIPBufferOutputStream* gzbos = CXmlEngGZIPBufferOutputStream::NewLC(aBuf);
TRAPD(err,aNode.OwnerDocument().SaveL(*gzbos,aNode,aOpt));
TInt sErr = gzbos->CheckError();
if(sErr)
{
User::Leave(sErr);
}
if(err)
{
User::Leave(err);
}
CleanupStack::PopAndDestroy(gzbos);
return aBuf.Size();
}
示例3: TestConcurrentTxRx
/**
Test the driver data flow path by loopback,
i.e Transmit the data and receive same data back.
It runs the device @ default configuration
@param aLoopback
Loopback mode as internal or external
aTxData
Transmit Data buffer
aRxSize
Receive data size
*/
void TestExDriver::TestConcurrentTxRx(TInt aLoopback, const TDesC8& aTxData, TInt aRxSize)
{
TInt r;
TRequestStatus stat;
iTest.Printf(_L("Test Concurrent Synchronous Requests - Tx/Rx\n"));
// Open channel
r=iLdd.Open(KUnit1);
iTest(r==KErrNone);
// Create a buffer that has to be filled and returned by the driver
RBuf8 rxBuf;
r=rxBuf.Create(aRxSize);
iTest(r==KErrNone);
r=iLdd.SetIntLoopback(aLoopback);
iTest(r==KErrNone);
TData TData(&iLdd,&aTxData,&iSem1);
// Call ldd interface ReceiveData() API to get data to rxBuf
RThread TransferThread;
_LIT(KThreadName, "TestThread");
TInt ret = TransferThread.Create( KThreadName, // Thread name
TransferTestThread, // Function to be called
KDefaultStackSize,
KHeapSize,
KHeapSize,
(TAny *)&TData
);
iTest.Printf(_L("Receive Data\n"));
TransferThread.Logon(stat);
TransferThread.Resume();
iSem1.Signal();
r = iLdd.ReceiveData(rxBuf);
// In case of zero length request
if (aRxSize==0)
{
// Driver should return error immediately
iTest(r!=KErrNone);
TransferThread.Kill(KErrNone);
TransferThread.Close();
// Close the RBuf
rxBuf.Close();
// Close channel
iLdd.Close();
return;
}
// Print the receive data to display.
// It automatically checks the Tx and Rx data. Fails if not matched.
//
TInt i;
iTest.Printf(_L("Received Data of size (%d):"),rxBuf.Size());
for (i=0; i<rxBuf.Size(); i++)
{
iTest.Printf(_L("%c"),(rxBuf.Ptr())[i]);
if ((TUint8)(rxBuf.Ptr())[i] != aTxData[i])
{
iTest.Printf(_L("Transmit and Receive data do not match\n"));
iTest(EFalse);
}
}
iTest.Printf(_L("\n"));
User::WaitForRequest(stat);
TransferThread.Close();
// Free the receive buffer
rxBuf.Close();
// Close channel
iLdd.Close();
}
示例4: ContentLengthL
// ==========================================================================
// FUNCTION: ContentLengthL
// ==========================================================================
TUint CContainerStoreContentManager::ContentLengthL( TContainerId aId, TBool aIsEncrypted )
{
TUint returnValue = 0;
TFileName contentFilename;
ContentFilename( aId, contentFilename );
// Open the content file.
RFile file;
TInt result = file.Open( iFs, contentFilename, KFILE_MODE_READ );
if( result == KErrNone )
{
CleanupClosePushL( file );
TInt fileSize;
User::LeaveIfError( file.Size( fileSize ) );
if ( !aIsEncrypted )
{
returnValue = fileSize;
}
else
{
UpdateBlockSizeL( aIsEncrypted );
RBuf8 encryptedBuffer;
encryptedBuffer.CreateL( iBlockSize );
CleanupClosePushL( encryptedBuffer );
RBuf8 plaintextBuffer;
plaintextBuffer.CreateL( iBlockSize );
CleanupClosePushL( plaintextBuffer );
// Read the last block.
TInt seekPosition = fileSize - iBlockSize;
User::LeaveIfError( file.Seek( ESeekCurrent, seekPosition ) );
User::LeaveIfError( file.Read( encryptedBuffer, iBlockSize ) );
// Decrypt the last block.
iEncryption.DecryptL( encryptedBuffer, plaintextBuffer );
iEncryption.RemovePaddingL( plaintextBuffer );
// The content length is the file size minus the number of pad bytes in the final block.
returnValue = fileSize - iBlockSize + plaintextBuffer.Size();
CleanupStack::PopAndDestroy( &plaintextBuffer );
CleanupStack::PopAndDestroy( &encryptedBuffer );
}
CleanupStack::PopAndDestroy( &file );
}
// If no content file exists then treat it as content length 0.
else if( result != KErrNotFound )
{
User::Leave( result );
} // end if
return returnValue;
} // end ContentLengthL
示例5: SerializeL
// --------------------------------------------------------------------------------------
// Serializes TXmlEngNode to buffer
// --------------------------------------------------------------------------------------
//
TInt CXmlEngSerializerXOP::SerializeL( RBuf8& aBuffer,
const TXmlEngNode aRoot,
const TXmlEngSerializationOptions& aOptions )
{
if(aBuffer.Length())
{
aBuffer.Close();
}
LeaveIfXopIncludeL(aRoot);
iDataContainerArray.Reset();
if(aOptions.iDataSerializer)
{
return CXmlEngSerializer::SerializeL(aBuffer, aRoot, aOptions);
}
TXmlEngSerializationOptions opt = aOptions;
opt.iDataSerializer = this;
RBuf8 xopDocument;
CleanupClosePushL(xopDocument);
aRoot.OwnerDocument().SaveL(xopDocument, aRoot, opt);
if( iCleanXOPInfoset )
{
if(xopDocument.Size() > aBuffer.MaxSize())
{
aBuffer.ReAllocL( xopDocument.Size() );
}
aBuffer.Append(xopDocument);
}
else
{
// adjust buffer size
TInt bufSize = KXOPDocumentStart().Size()
+ KMimeRoot().Size()
+ xopDocument.Size()
+ KXOPDocumentEnd().Size();
for(TInt j = 0; j < iDataContainerArray.Count(); j++)
{
TPtrC8 contentTypeStr;
if(GetContentTypeValue(iDataContainerArray[j], contentTypeStr))
{
bufSize += KMimeHeaderContentType().Size()
+ contentTypeStr.Size()
+ KNewLine().Size();
}
bufSize += KMimeHeaderStart().Size()
+ KMimeHeaderContentIdStart().Size()
+ iDataContainerArray[j].Cid().Length()
+ KMimeHeaderContentIdEnd().Size()
+ KNewLine().Size()
+ iDataContainerArray[j].Size();
}
if (bufSize > aBuffer.MaxSize())
{
aBuffer.ReAllocL( bufSize );
}
// write to buffer
aBuffer.Append(KXOPDocumentStart());
aBuffer.Append(KMimeRoot());
aBuffer.Append(xopDocument);
for(TInt i = 0; i < iDataContainerArray.Count(); i++)
{
aBuffer.Append(KMimeHeaderStart);
TPtrC8 contentTypeStr;
if(GetContentTypeValue(iDataContainerArray[i], contentTypeStr))
{
aBuffer.Append(KMimeHeaderContentType);
aBuffer.Append(contentTypeStr);
aBuffer.Append(KNewLine);
}
aBuffer.Append(KMimeHeaderContentIdStart);
aBuffer.Append(iDataContainerArray[i].Cid());
aBuffer.Append(KMimeHeaderContentIdEnd);
aBuffer.Append(KNewLine);
switch(iDataContainerArray[i].NodeType())
{
case TXmlEngNode::EBinaryContainer:
{
if(opt.iOptions & TXmlEngSerializationOptions::KOptionDecodeBinaryContainers )
{
HBufC8* decodedData = CreateDecodedBufLC(iDataContainerArray[i].AsBinaryContainer().Contents());
aBuffer.Append(decodedData->Des());
CleanupStack::PopAndDestroy(); //decodedData
}
else
{
aBuffer.Append(iDataContainerArray[i].AsBinaryContainer().Contents());
}
break;
}
case TXmlEngNode::EChunkContainer:
{
TPtrC8 data = TPtrC8(
((RChunk&)iDataContainerArray[i].AsChunkContainer().Chunk()).Base()
//.........这里部分代码省略.........
示例6: GetCodeSegmentsL
void CServerCrashDataSource::GetCodeSegmentsL( const TUint64 aTid, RCodeSegPointerList &aCodeSegList, TUint & aTotalCodeSegListDescSize )
{
LOG_MSG2("->CServerCrashDataSource::GetCodeSegmentsL(aTid=%Lu)\n", aTid );
aCodeSegList.ResetAndDestroy();
aTotalCodeSegListDescSize = 0;
TUint32 size = KMaxFileName;
RBuf8 buffer;
buffer.CreateL(KMaxFileName);
CleanupClosePushL(buffer);
DoGetListL( ECodeSegs, aTid, (TUint)-1, buffer, size );
LOG_MSG2( " DoGetListL( ECodeSegs ) returned buffer.Size()=0x%X\n", buffer.Size() );
TUint8* ptr = (TUint8*)buffer.Ptr();
const TUint8* ptrEnd = ptr + size;
while(ptr < ptrEnd)
{
TCodeSegListEntry* entry = (TCodeSegListEntry*)ptr;
LOG_MSG4( " entry->CodeBase=0x%X, CodeSize=0x%X, ConstDataSize=0x%X\n",
entry->iCodeBase, entry->iCodeSize, entry->iConstDataSize );
LOG_MSG4( " InitDataBase=0x%X, InitDataSize=0x%X, UnintDataSize=0x%X\n",
entry->iInitialisedDataBase, entry->iInitialisedDataSize, entry->iUninitialisedDataSize );
LOG_MSG3( " IsXip=0x%X, CodeSegType=0x%X\n", entry->iIsXip, entry->iCodeSegType );
TCodeSegInfo *codeSeg = new(ELeave) TCodeSegInfo;
TPtr name(&(entry->iName[0]), entry->iNameLength, entry->iNameLength);
codeSeg->iName = name;
codeSeg->iType = entry->iCodeSegType;
codeSeg->iXIP = entry->iIsXip;
codeSeg->iCodeSize = entry->iCodeSize;
codeSeg->iCodeRunAddr = entry->iCodeBase;
if( codeSeg->iXIP )
{
codeSeg->iCodeLoadAddr = codeSeg->iCodeRunAddr;
}
else
{
codeSeg->iCodeLoadAddr = 0; //TODO
}
codeSeg->iRoDataSize = entry->iConstDataSize;
codeSeg->iRoDataRunAddr = entry->iCodeBase + entry->iCodeSize;
if( codeSeg->iXIP )
{
codeSeg->iRoDataLoadAddr = codeSeg->iRoDataRunAddr;
}
else
{
codeSeg->iRoDataLoadAddr = 0; //TODO
}
codeSeg->iDataSize = entry->iInitialisedDataSize + entry->iUninitialisedDataSize;
codeSeg->iDataRunAddr = entry->iInitialisedDataBase;
if( codeSeg->iXIP )
{
codeSeg->iDataLoadAddr = codeSeg->iDataRunAddr;
}
else
{
codeSeg->iDataLoadAddr = 0; //TODO
}
TInt err = aCodeSegList.Append(codeSeg);
if(err != KErrNone)
{
delete codeSeg;
User::Leave(err);
}
aTotalCodeSegListDescSize += sizeof(TCodeSegInfo);
ptr += Align4(entry->GetSize());
}
CleanupStack::PopAndDestroy(&buffer);
}
示例7: wptr
//
// LtkUtils::W32CrackL
// loads the autometric logging engine, dlogev.dll, into wserv
// enabling Autometric to monitor events from within wserv - key/pointer events, text drawn to screen etc
//
EXPORT_C void LtkUtils::W32CrackL()
{
#ifndef FSHELL_WSERV_SUPPORT
User::Leave(KErrNotSupported);
#else
// Check if P&S says it's already enabled, if so no need to do anything
if (W32CrackIsEnabled()) return;
_LIT(KWsIniFile, "z:\\system\\data\\wsini.ini");
_LIT(KCWsIniFile,"c:\\system\\data\\wsini.ini");
_LIT(KLogEv, "LOG EV\r\n");
// Open z file
RFs fs;
User::LeaveIfError(fs.Connect());
CleanupClosePushL(fs);
RFile file;
User::LeaveIfError(file.Open(fs, KWsIniFile, EFileRead));
CleanupClosePushL(file);
TInt size;
User::LeaveIfError(file.Size(size));
RBuf8 buf;
buf.CreateL(size + KLogEv().Size());
CleanupClosePushL(buf);
User::LeaveIfError(file.Read(buf));
TPtrC16 wptr((TUint16*)buf.Ptr(), buf.Size()/2);
buf.Insert(2, TPtrC8((TUint8*)KLogEv().Ptr(), KLogEv().Size())); // +2 to get past the BOM
TInt err = KErrNone;
err = fs.MkDirAll(KCWsIniFile); // mkdir c:\system\data\ in case it is not exist
if((err != KErrNone) && (err != KErrAlreadyExists))
{
User::Leave(err);
}
User::LeaveIfError(file.Replace(fs, KCWsIniFile, EFileWrite));
User::LeaveIfError(file.Write(buf));
CleanupStack::PopAndDestroy(2, &file); // file, buf
err = RMemoryAccess::LoadDriver();
if ((err != KErrNone) && (err != KErrAlreadyExists))
{
User::Leave(err);
}
RMemoryAccess memAccess;
User::LeaveIfError(memAccess.Open());
CleanupClosePushL(memAccess);
RWsSession ws;
User::LeaveIfError(ws.Connect(fs));
CleanupClosePushL(ws);
#ifdef __WINS__
// On wins the binary isn't renamed
_LIT(KWservMatch, "wserv*.exe*");
#else
_LIT(KWservMatch, "EwSrv.exe*");
#endif
TFindProcess find(KWservMatch);
TFullName name;
User::LeaveIfError(find.Next(name));
RProcess wservProc;
User::LeaveIfError(wservProc.Open(find));
if (wservProc.ExitType() != EExitPending)
{
// in case wserv kicks off the preferred implementation in a new process then kills itself
// (is one retry enough or should we be looping here?)
wservProc.Close();
User::LeaveIfError(find.Next(name));
User::LeaveIfError(wservProc.Open(find));
}
CleanupClosePushL(wservProc);
name = wservProc.FileName();
name[0] = 'c';
TPtrC8 narrowName = name.Collapse();
User::LeaveIfError(memAccess.InPlaceSetProcessFileName(wservProc, narrowName));
// Now tell wserv to reload its wsini.ini and enable logging
ws.LogCommand(RWsSession::ELoggingEnable);
ws.Flush();
// cleanup
CleanupStack::PopAndDestroy(4, &fs);
#endif // FSHELL_WSERV_SUPPORT
}
示例8: DoRunL
void CCmdBtraceout::DoRunL()
{
if (iStdin)
{
CTextBuffer* buffer = CTextBuffer::NewLC(512);
Stdin().SetReadMode(RIoReadHandle::EOneOrMore);
TBuf<256> buf;
while (Stdin().Read(buf) == KErrNone)
{
buffer->AppendL(buf);
}
RBuf8 data;
data.CreateL(buffer->Length());
data.Copy(buffer->Descriptor()); // This will collapse us back to real 8-bit data
if (iTruncate)
{
if (iOptions.IsPresent(&iFilterUid))
{
if (iArguments.IsPresent(3))
{
PrintWarning(_L("Ignoring 'arg_2' (%u) and all following arguments"), iArg2);
}
BTraceFilteredN(iCategory, iSubcategory, iFilterUid, iArg1, data.Ptr(), data.Size());
}
else
{
if (iArguments.IsPresent(3))
{
PrintWarning(_L("Ignoring 'arg_3' (%u)"), iArg3);
}
BTraceN(iCategory, iSubcategory, iArg1, iArg2, data.Ptr(), data.Size());
}
}
else
{
if (iOptions.IsPresent(&iFilterUid))
{
if (iArguments.IsPresent(2))
{
PrintWarning(_L("Ignoring 'arg_1' (%u) and all following arguments"), iArg1);
}
BTraceFilteredBig(iCategory, iSubcategory, iFilterUid, data.Ptr(), data.Size());
}
else
{
if (iArguments.IsPresent(3))
{
PrintWarning(_L("Ignoring 'arg_2' (%u) and all following arguments"), iArg2);
}
BTraceBig(iCategory, iSubcategory, iArg1, data.Ptr(), data.Size());
}
}
data.Close();
CleanupStack::PopAndDestroy(buffer);
}
else
{
if (iArguments.IsPresent(4))
{
if (iOptions.IsPresent(&iFilterUid))
{
if (iArguments.IsPresent(3))
{
PrintWarning(_L("Ignoring 'arg_3' (%u)"), iArg3);
}
BTraceFiltered12(iCategory, iSubcategory, iFilterUid, iArg1, iArg2);
}
else
{
BTrace12(iCategory, iSubcategory, iArg1, iArg2, iArg3);
}
}
else if (iArguments.IsPresent(3))
{
if (iOptions.IsPresent(&iFilterUid))
{
BTraceFiltered12(iCategory, iSubcategory, iFilterUid, iArg1, iArg2);
}
else
{
BTrace8(iCategory, iSubcategory, iArg1, iArg2);
}
}
else if (iArguments.IsPresent(2))
{
if (iOptions.IsPresent(&iFilterUid))
{
BTraceFiltered8(iCategory, iSubcategory, iFilterUid, iArg1);
}
else
{
BTrace4(iCategory, iSubcategory, iArg1);
}
}
else
{
if (iOptions.IsPresent(&iFilterUid))
{
//.........这里部分代码省略.........
示例9: TestConcurrentTxRx
/**
Test the driver data flow path by loopback,
i.e Transmit the data and receive same data back.
It runs the device @ default configuration
@param aLoopback
Loopback mode as internal or external
aTxData
Transmit Data buffer
aRxSize
Receive data size
*/
void TestExDriver::TestConcurrentTxRx(TInt aLoopback, const TDesC8& aTxData, TInt aRxSize)
{
TInt r;
// Request status object for transmit and receive. These object will be
// used to read the status of asynchronous requests after the notification
// of request completion
//
TRequestStatus txStatus;
TRequestStatus rxStatus;
// Timers and their respective status objects for Tx and Rx
RTimer timerTx;
RTimer timerRx;
TRequestStatus timeStatusTx;
TRequestStatus timeStatusRx;
iTest.Printf(_L("Test Concurrent Asynchronous Requests - Tx/Rx\n"));
// Open channel
r=iLdd.Open(KUnit1);
iTest(r==KErrNone);
// Create a buffer that has to be filled and returned by the driver
RBuf8 rxBuf;
r=rxBuf.Create(aRxSize);
iTest(r==KErrNone);
r=iLdd.SetIntLoopback(aLoopback);
iTest(r==KErrNone);
// Create the timer that is relative to the thread
r = timerTx.CreateLocal();
iTest(r==KErrNone);
r = timerRx.CreateLocal();
iTest(r==KErrNone);
// Trigger timerRx expiry after KTimeOutTxRx. The status should be pending
timerRx.After(timeStatusRx,KTimeOutTxRx);
iTest(timeStatusRx==KRequestPending);
// Call ldd interface ReceiveData() API to get data to rxBuf
r = iLdd.ReceiveData(rxStatus, rxBuf);
// In case of zero length request
if (aRxSize==0)
{
// Driver should return error immediately
iTest(r!=KErrNone);
// Close the RBuf
rxBuf.Close();
// Close channel
iLdd.Close();
return;
}
else
{
// Asynchronous request should be pending, with request message
// posted to driver successfully
//
iTest((r==KErrNone)&&(rxStatus.Int()==KRequestPending));
}
// Trigger timerTx expiry after KTimeOutTxRx. The status should be pending
timerTx.After(timeStatusTx,KTimeOutTxRx);
iTest(timeStatusTx==KRequestPending);
// Call ldd interface TransmitData() API test data descriptor as parameter
r = iLdd.TransmitData(txStatus, aTxData);
// In case of zero length request
if (aTxData.Size()==0)
{
// Driver should return error immediately
iTest(r!=KErrNone);
// Close the RBuf
rxBuf.Close();
// Close channel
iLdd.Close();
return;
}
else
{
// Asynchronous request should be pending, with request message
// posted to driver successfully
//
iTest(r==KErrNone);
}
// Wait till the request is complete on rxStatus and txStatus. User thread
//.........这里部分代码省略.........