本文整理汇总了C++中TPtr8::FillZ方法的典型用法代码示例。如果您正苦于以下问题:C++ TPtr8::FillZ方法的具体用法?C++ TPtr8::FillZ怎么用?C++ TPtr8::FillZ使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPtr8
的用法示例。
在下文中一共展示了TPtr8::FillZ方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EncodeValueL
// -----------------------------------------------------------------------------
// CNATFWUNSAFErrorCodeAttribute::EncodeValueL
// -----------------------------------------------------------------------------
//
HBufC8* CNATFWUNSAFErrorCodeAttribute::EncodeValueL() const
{
__TEST_INVARIANT;
TInt encodedReasonPhraseLength = EncodedReasonPhraseLength();
HBufC8* encodedValue =
HBufC8::NewLC(EReasonPhraseOffset + encodedReasonPhraseLength);
TPtr8 ptr = encodedValue->Des();
ptr.FillZ(EReasonPhraseOffset);
ptr[EClassOffset] = (iResponseCode / E100) & EClassMask;
ptr[ENumberOffset] = iResponseCode % E100;
ptr.Append(*iReasonPhrase);
TInt spacesToAppend = encodedReasonPhraseLength - iReasonPhrase->Length();
const TChar KSpace(' ');
for (TInt i = 0; i < spacesToAppend; ++i)
{
ptr.Append(KSpace);
}
CleanupStack::Pop(encodedValue);
return encodedValue;
}
示例2: DecryptFromStreamL
HBufC8* DecryptFromStreamL( RReadStream& aInStream, TPtrC8& aKey )
{
CPBEncryptionData* data = CPBEncryptionData::NewL(aInStream);
CleanupStack::PushL(data);
TInt32 encKeyLength = aInStream.ReadInt32L();
HBufC8* encKey = HBufC8::NewMaxLC(encKeyLength);
TPtr8 encKeyPtr(encKey->Des());
encKeyPtr.FillZ();
aInStream.ReadL(encKeyPtr,encKeyLength);
CPBEncryptElement* encryption = CPBEncryptElement::NewLC(*data,aKey);
CPBDecryptor* decryptor = encryption->NewDecryptLC();
HBufC8* plaintext = HBufC8::NewLC(decryptor->MaxOutputLength(encKeyPtr.Length()));
TPtr8 plaintextPtr = plaintext->Des();
plaintextPtr.FillZ();
decryptor->ProcessFinalL(encKeyPtr, plaintextPtr);
CleanupStack::Pop(plaintext);
CleanupStack::PopAndDestroy(4,data); // encKey, encryption, decryptor
return plaintext;
}
示例3: ReadDataL
void CTestUTCParse::ReadDataL(CImRecvConvert* aRecvConvert, TFileName aFileName)
{
// open the file
RFile file;
TInt error = file.Open(iTestUtils->FileSession(), aFileName, EFileShareAny);
if(error != KErrNone)
{
ERR_PRINTF2(TRefByValue<const TDesC>_L("\r\nFile open error %d"), error);
User::Leave(KErrNotFound);
}
INFO_PRINTF2(TRefByValue<const TDesC>_L("Data from %s...\r\n"), aFileName.PtrZ());
// read the file into the conversion object
HBufC8* lineBuffer = HBufC8::NewLC(1024);
TPtr8 line = lineBuffer->Des();
TBuf8<1> theChar;
TBool finished = EFalse;
aRecvConvert->ResetL();
// supply a new attachment path since previous one is discarded by call to Reset()
do {
line.FillZ();
line.SetLength(0);
// compile a line one char at a time
do {
file.Read(theChar, 1);
if(theChar.Length())
line.Append(theChar);
else
finished = ETrue;
// stop at the end of line or no more data
} while(theChar.Length() && theChar[0] != 0x0A);
if(!line.Length())
break;
aRecvConvert->ParseNextField(line); // This function doesnt actually leave, any leaves are relayed to the MessageCompleteL() function
} while(!finished);
TRAPD(err, aRecvConvert->MessageCompleteL());
if(err!=KErrNone)
{
// At this point the message should be deleted and CImRecvConvert should be Reset()
ERR_PRINTF3(TRefByValue<const TDesC>_L("\r\nError %d occured during the conversion of Message %d"), err, aRecvConvert->EntryId());
}
CleanupStack::PopAndDestroy(lineBuffer);
file.Close();
}
示例4: 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);
}
示例5: EncodeValueL
// -----------------------------------------------------------------------------
// CNATFWUNSAFTimerValAttribute::EncodeValueL
// -----------------------------------------------------------------------------
//
HBufC8* CNATFWUNSAFTimerValAttribute::EncodeValueL() const
{
HBufC8* encodedValue = HBufC8::NewLC(EAttributeValueSize);
TPtr8 ptr = encodedValue->Des();
ptr.FillZ(EAttributeValueSize);
TUint32 value(iTimerVal);
NATFWUNSAFUtils::WriteNetworkOrder32L(ptr, 0, value);
CleanupStack::Pop(encodedValue);
return encodedValue;
}
示例6: EncodeValueL
// -----------------------------------------------------------------------------
// CNATFWUNSAFIceControllingAttribute::EncodeValueL
// -----------------------------------------------------------------------------
//
HBufC8* CNATFWUNSAFIceControllingAttribute::EncodeValueL() const
{
HBufC8* encodedValue = HBufC8::NewLC(EAttributeValueSize);
TPtr8 ptr = encodedValue->Des();
ptr.FillZ(EAttributeValueSize);
TUint64 value(iIceControlling);
NATFWUNSAFUtils::WriteNetworkOrder64L(ptr, 0, value);
CleanupStack::Pop(encodedValue);
return encodedValue;
}
示例7: EncodeL
// -----------------------------------------------------------------------------
// CNATFWUNSAFAttribute::EncodeL
// -----------------------------------------------------------------------------
//
HBufC8* CNATFWUNSAFAttribute::EncodeL() const
{
HBufC8* value = EncodeValueL();
CleanupStack::PushL(value);
TInt attrValLength = value->Length();
//Pad non-DWORD-boundary aligned attributes with spaces if needed. Spaces
//used instead of \0 in order to not mess up buggy C implementations.
const TInt KGranularity = 4;
TInt bytesInLastBlock = attrValLength % KGranularity;
TInt bytesToAppend = KGranularity - bytesInLastBlock;
if (0 < bytesInLastBlock && !IsWordBoundaryAligned(Type()))
{
CBufBase* valueBuf = CBufFlat::NewL(attrValLength + bytesToAppend);
CleanupStack::PushL(valueBuf);
valueBuf->InsertL(0, *value, attrValLength);
const TChar KSpace(' ');
for (TInt i = 0; i < bytesToAppend; ++i)
{
valueBuf->InsertL(valueBuf->Size(), &KSpace, 1);
}
// Store value pointer for proper cleanupstack handling
HBufC8* oldValue = value;
value = valueBuf->Ptr(0).AllocL();
CleanupStack::PopAndDestroy(valueBuf);
CleanupStack::PopAndDestroy( oldValue );
CleanupStack::PushL( value );
}
HBufC8* attribute = HBufC8::NewLC(value->Length() + EValueOffset);
TPtr8 ptr = attribute->Des();
ptr.FillZ(EValueOffset);
NATFWUNSAFUtils::WriteNetworkOrder16L(ptr, ETypeOffset, Type());
NATFWUNSAFUtils::WriteNetworkOrder16L(ptr,
ELengthOffset,
static_cast<TUint16>(attrValLength));
ptr.Append(*value);
CleanupStack::Pop(attribute);
CleanupStack::PopAndDestroy(value);
return attribute;
}
示例8: EncodeL
/**
Encode CBW into the supplied buffer. The command is also encoded using the
supplied encoding method of MClientCommandServiceReq.
@param aBuffer The buffer to copy the encoded stream in to
@param aCommand The command to be encoded into the Command Block field
*/
void TBotCbw::EncodeL(TPtr8 &aBuffer, const MClientCommandServiceReq* aCommand) const
{
__MSFNSLOG
aBuffer.SetLength(KCbwLength);
TPtr8 commandBlock = aBuffer.MidTPtr(TBotCbw::KCbwCbOffset);
aBuffer.FillZ();
TInt cbLength = aCommand->EncodeRequestL(commandBlock);
TUint8* ptr = (TUint8 *) aBuffer.Ptr();
LittleEndian::Put32(&ptr[KCbwSignatureOffset], 0x43425355);
LittleEndian::Put32(&ptr[KCbwTagOffset], iTag);
LittleEndian::Put32(&ptr[KCbwDataTransferLengthOffset], iDataTransferLength);
aBuffer[KCbwFlagOffset] = (iDirection == EDataOut) ? 0x00 : 0x80;
aBuffer[KCbwLunOffset] = iLun;
aBuffer[KCbwCbLengthOffset] = cbLength;
__BOTPRINT1(_L("BOT TBotCbw::Encode Lun=%d"), iLun);
}
示例9: EncodeValueL
// -----------------------------------------------------------------------------
// CNATFWUNSAFChangeRequestAttribute::EncodeValueL
// -----------------------------------------------------------------------------
//
HBufC8* CNATFWUNSAFChangeRequestAttribute::EncodeValueL() const
{
HBufC8* encodedValue = HBufC8::NewLC(EAttributeValueSize);
TPtr8 ptr = encodedValue->Des();
ptr.FillZ(EAttributeValueSize);
TUint32 value(0);
if (ChangeIP())
{
value = value | EChangeIPMask;
}
if (ChangePort())
{
value = value | EChangePortMask;
}
NATFWUNSAFUtils::WriteNetworkOrder32L(ptr, 0, value);
CleanupStack::Pop(encodedValue);
return encodedValue;
}
示例10: GetBackupDataSectionL
//.........这里部分代码省略.........
// enough, if not send as much as we can
TBool enoughRoom = bytesRemaining < available;
aBuffer.Append(
headerPtr8.Ptr() + iHeaderSent,
enoughRoom ? bytesRemaining : available );
if( enoughRoom )
{
iHeaderSent = 0; // ready for next header
iBackupState = EBackupOpenAllHeaderSent;
}
else
{
iHeaderSent += available; // ready to do round again
// state remains as EBackupOpenPartHeaderSent
}
// if the buffer's full we need to return control to the backup engine
// Because the finishedFlag is not set, the BUE will process this
// chunk and then ask for another
if( aBuffer.Size() == aBuffer.MaxSize() )
{
return;
}
break;
}
// need to send some data
case EBackupOpenAllHeaderSent:
{
AKNS_TRACE_DEBUG1("CAknsSrvActiveBackupDataClient::GetBackupDataSectionL state %d", iBackupState );
// how many bytes can we send
TInt available = aBuffer.MaxSize() - aBuffer.Size();
// create a buffer for this data (plus one for PtrZ)
HBufC8* transferBuffer = HBufC8::NewLC( available + 1 );
TPtr8 bufferToSend = transferBuffer->Des();
// get the data
User::LeaveIfError( iFile.Read( bufferToSend, available ) );
// Check how much did we actually read.
TInt bytesRead = bufferToSend.Size();
// EOF
if( bytesRead == 0 )
{
CleanupStack::PopAndDestroy( transferBuffer );
iBackupState = EBackupEndOfFile;
break;
}
// add it to the aBuffer
aBuffer.Append( bufferToSend.PtrZ(), bytesRead );
// tidy up
CleanupStack::PopAndDestroy( transferBuffer );
// if the buffer's full we need to return control to the backup engine
if( aBuffer.Size() == aBuffer.MaxSize() )
{
return;
}
break;
}
// At the end of the current file.
case EBackupEndOfFile:
{
AKNS_TRACE_DEBUG1("CAknsSrvActiveBackupDataClient::GetBackupDataSectionL state %d", iBackupState );
// how many bytes can we send
if ( aBuffer.Size() != 0 )
{
TInt available = aBuffer.MaxSize() - aBuffer.Size();
// pad the end of the buffer with NULL.
HBufC8* transferBuffer = HBufC8::NewLC( available + 1 );
TPtr8 bufferToSend = transferBuffer->Des();
bufferToSend.FillZ();
aBuffer.Append( bufferToSend.PtrZ(), available );
CleanupStack::PopAndDestroy( transferBuffer );
if( aBuffer.Size() != aBuffer.MaxSize() )
{
// Sanity check
User::Leave( KErrGeneral );
}
}
// Close file and move on to next file.
iFile.Close();
++iFileIndex;
// Start all over again.
iBackupState = EBackupNoFileOpen;
break;
}
default:
{
// not reachable
return;
}
}
}
}