本文整理汇总了C++中TDes8::Zero方法的典型用法代码示例。如果您正苦于以下问题:C++ TDes8::Zero方法的具体用法?C++ TDes8::Zero怎么用?C++ TDes8::Zero使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TDes8
的用法示例。
在下文中一共展示了TDes8::Zero方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ValidateAndConvertPercentEncodedTriple
/**
Validates and Converts the valid Percent encoded triplets to Uppercase for specified
sub component of URI. For eg: Converts %3a to %3A
@param aData A reference to a string to be validated and converted to upper case.
@param aCaseNormalizedData A reference to a descriptor that is converted to
uppercase that is to be returned.
@return returns a bool whether it is a valid Percent encoded triplet
*/
TBool ValidateAndConvertPercentEncodedTriple(TDesC8& aData , TDes8& aCaseNormalizedData )
{
// See if the descriptor is actually long enough and
// Check that the three characters form an escape triple - first char is '%'
if( aData.Length() < KEscapeTripleLength || aData[KEscDelimiterPos] != KEscapeIndicator )
{
return EFalse;//do nothing
}
// Check that next two characters are valid
TInt mostSignificantDigitValue = KHexDigit().LocateF(aData[KMostSignificantNibblePos] );
TInt leastSignificantDigitValue = KHexDigit().LocateF(aData[KLeastSignificantNibblePos] );
if( mostSignificantDigitValue== KErrNotFound || leastSignificantDigitValue == KErrNotFound )
{
// Either of the characters were not a valid hex character
return EFalse;
}
aCaseNormalizedData.Zero();
aCaseNormalizedData.Append(KEscapeIndicator);
//Coverts most significant hex character to uppercase
(mostSignificantDigitValue >= 0 && mostSignificantDigitValue <= 0xF) ?
aCaseNormalizedData.Append(KHexDigit().Mid(mostSignificantDigitValue,1)) :
aCaseNormalizedData.Append(KHexDigit().Mid(mostSignificantDigitValue,1));
//Coverts least significant hex character to uppercase
(leastSignificantDigitValue >= 0 && leastSignificantDigitValue <= 0xF) ?
aCaseNormalizedData.Append(KHexDigit().Mid(leastSignificantDigitValue,1)) :
aCaseNormalizedData.Append(aData[KLeastSignificantNibblePos]);
return ETrue;
}
示例2: DoBuf
EXPORT_C void CTestUtils::DoBuf(TDes8& buf, const TDesC& label, const TDesC8& data)
{
buf.Zero();
buf.Copy(label);
buf.Append(data);
buf.Append(_L("\r\n"));
}
示例3: ColumnBinary
/**
Copies the content of a binary column, identified by aColumnIndex, to the place refered by aDest parameter.
If the destination buffer is not big enough, the function will copy as much data as possible and will
return KErrOverflow.
@param aColumnIndex Column index
@param aDest Refers to the place where the column data will be copied.
@return KErrNone, if the function completes successfully,
otherwise one of the other system-wide error codes.
@panic SqlDb 5 Column index out of bounds.
@panic SqlDb 11 Statement cursor not positioned on a row
*/
TInt CSqlStatementImpl::ColumnBinary(TInt aColumnIndex, TDes8& aDest)
{
__ASSERT_ALWAYS((TUint)aColumnIndex < (TUint)iColumnCnt, __SQLPANIC(ESqlPanicBadColumnIndex));
__ASSERT_ALWAYS(iState == CSqlStatementImpl::EAtRow, __SQLPANIC(ESqlPanicInvalidRow));
iColumnValBufIt.MoveTo(aColumnIndex);
TInt err = KErrNone;
//The binary column value has not been transferred to the client side if its length is >= KSqlMaxDesLen bytes.
//In this case an additional call to the server is made to get the column value.
if(!iColumnValBufIt.IsPresent())
{
if(iColumnValBufIt.Type() != ESqlBinary)
{
aDest.Zero();
return err;
}
err = iSqlStmtSession.ReadColumnValue(aColumnIndex, aDest);
}
else
{
TPtrC8 src = iColumnValBufIt.Binary();
TInt len = src.Length();
if(len > aDest.MaxLength())
{
len = aDest.MaxLength();
err = KErrOverflow;
}
aDest.Copy(src.Ptr(), len);
}
return err;
}
示例4: GetData
/**
* Get the data from the transaction
*
* Return the minimum of client buffer size and amount left to read
*/
TInt CDummyWSPCOTrans::GetData(TDes8& aBuffer, RWSPCOTrans::TDataType aDataType, TInt* aSizeLeft) const
{
__ASSERT_DEBUG(aBuffer.MaxSize()>0, User::Panic(_L("Client buffer not allocated"),0));
//const TDesC8* requestedData=*iDataArray[aDataType];
const TDesC8* requestedData= iDataArray[aDataType];
TInt bufferSize = aBuffer.MaxSize();
TInt reqSize = requestedData->Size();
TInt* offset = iOffsetArray.At(aDataType);
TInt retSize = Min(bufferSize, (reqSize - *offset));
aBuffer.Zero();
aBuffer.Append(requestedData->Mid(*offset, retSize));
*offset += retSize;
if (*offset==reqSize)
{
*aSizeLeft = 0;
*offset = 0;
return KErrNone;
}
else
{
*aSizeLeft = reqSize-*offset;
return RWAPConn::EMoreData;
}
}
示例5: ReadNextLineL
TInt CTmsTestStep::ReadNextLineL( RFile &aFile, TDes8 &aLine )
// read a cr/lf limiited line from the file, assumes file is a valid file
// and that aLine is of sufficient length to hold the data
{
aLine.Zero();
TBuf8<1> chr;
for (;;)
{
aFile.Read(chr);
if ( chr.Length() == 0 )
{
break;
}
if (chr.CompareF(KRet) == 0)
{
// got a line, exctract newline as well
aFile.Read(chr);
break;
}
else
{
aLine.Append(chr);
}
}
return aLine.Length();
}
示例6: ReadString
TUint TInputManager::ReadString(TDes8& aStr)
{
TKeyCode key;
aStr.Zero();
while( (key = iConsole.Getch()) != EKeyEnter)
{
if (aStr.Length() == aStr.MaxLength())
return aStr.MaxLength();
if (key == EKeyBackspace)
{
if (aStr.Length() > 0)
{
aStr.Delete(aStr.Length()-1, 1);
ConsoleBackspace(1);
}
}
else
{
TUint8 keyChar(key);
aStr.Append(keyChar);
iConsole.Printf(_L("%c"), keyChar);
}
}
iConsole.Printf(_L("\n"));
return aStr.Length();
}
示例7: ReadL
/**
Implementation of pure virtual function.
@see MWTCacheInterface::ReadL()
*/
void CDynamicDirCache::ReadL(TInt64 aPos, TInt aLength, TDes8& aDes)
{
#ifdef _DEBUG
if(iCacheDisabled)
{
// cache is disabled for debug purposes
__PRINT(_L("CDynamicDirCache disabled"));
User::LeaveIfError(iDrive.ReadNonCritical(aPos, aLength, aDes));
return;
}
#endif //_DEBUG
aDes.Zero();
const TUint32 PageSz = iPageSizeInBytes;//-- cache page size
TInt64 pageStartMedPos = CalcPageStartPos(aPos);
const TUint32 bytesToPageEnd = (TUint32)(pageStartMedPos + PageSz - aPos); //-- number of bytes from aPos to the end of the page
// __PRINT5(_L("CDynamicDirCache::ReadL: aPos=%lx, aLength=%x, page:%lx, pageSz:%x, bytesToPageEnd=%x"), aPos, aLength, pageStartMedPos, PageSz, bytesToPageEnd);
// if all data needed is on a single page
if((TUint32)aLength <= bytesToPageEnd)
{
ReadDataFromSinglePageL(aPos, aLength, aDes);
}
// or data to be read cross cache page boundary or probably we have more than 1 page to read
else
{
__PRINT(_L("CDynamicDirCache::ReadL() CROSS PAGE!"));
TUint32 dataLen(aLength); //-- current data length
TInt64 currMediaPos(aPos); //-- current media position
//-- 1. read data that are already in the current page
ReadDataFromSinglePageL(currMediaPos, bytesToPageEnd, aDes);
dataLen -= bytesToPageEnd;
currMediaPos += bytesToPageEnd;
TPtr8 dataNext = aDes.MidTPtr(aDes.Length());
//-- 2. read whole pages of data
while (dataLen >= PageSz)
{
//-- find out if currMediaPos is in cache. If not, find a spare page and read data there
ReadDataFromSinglePageL(currMediaPos, PageSz, dataNext);
currMediaPos += PageSz;
dataLen -= PageSz;
dataNext = dataNext.MidTPtr(dataNext.Length());
}
//-- 3. read the rest of the data
if(dataLen > 0)
{
ReadDataFromSinglePageL(currMediaPos, dataLen, dataNext);
}
} //else((TUint32)aLength <= bytesToPageEnd)
}
示例8:
void CResourceManager::GetMsgDigestByMd5L(TDes8 &aDest, const TDesC8 &aSrc)
{
_LIT8( KDigestFormat, "%02x" );
aDest.Zero();
CMD5 *md5 = CMD5::NewL();
CleanupStack::PushL(md5);
TPtrC8 ptrHash = md5->Hash(aSrc);
for (TInt i = 0; i < ptrHash.Length(); i++) {
aDest.AppendFormat(KDigestFormat, ptrHash[i]);
}
CleanupStack::PopAndDestroy(md5);
}
示例9: BtDevAddrToString
static void BtDevAddrToString(TDes8& aString, const TBTDevAddr& addr)
{
// GetReadable() does not produce a "standard" result,
// so have to construct a string manually.
aString.Zero();
_LIT8(KColon, ":");
for (TInt i=0; i<6; i++) {
const TUint8& val = addr[i];
aString.AppendNumFixedWidthUC(val, EHex, 2);
if (i < 5)
aString.Append(KColon);
}
}
示例10: GetCaps
void DKmsExtrLddFactory::GetCaps(TDes8& aCapsDes) const
/**
Implement DLogicalDevice by populating the supplied buffer
with information about this logical device.
Currently no information is supported and this function
resets the supplied buffer.
@param aCapsDes Buffer to populate with information
about this logical device.
*/
{
aCapsDes.Zero();
}
示例11: TRAP
void Big5::ConvertFromUnicodeL(TDes8& aForeign, const TDesC16& aUnicode, const TDesC8& /*aReplacementForUnconvertibleUnicodeCharacters*/, TFatUtilityFunctions::TOverflowAction aOverflowAction)
{
TInt err = KErrNone;
aForeign.Zero();
TRAP(err, UnicodeConv::ConvertFromUnicodeL(aForeign, aUnicode));
// Ignore overflow errors if you're allowed to truncate the string
if (aOverflowAction == TFatUtilityFunctions::EOverflowActionTruncate && err == KErrOverflow)
{
err = KErrNone;
}
User::LeaveIfError(err);
}
示例12: DesEncryptL
void CPppMsChap::DesEncryptL(const TDesC8& aClear,
const TDesC8& aKey,
TDes8& aCypher)
/**
Encrypts a plaintext into a ciphertext using the DES encryption
algorithm in ECB mode.
@param aClear [in] A plaintext (8 octets).
@param aKey [in] A key (7 octets).
@param aCypher [out] The ciphertext (8 octets).
@note This function implements the DesEncrypt routine specified in
RFC 2433.
@internalComponent
*/
{
ASSERT(aClear.Length() == KPppMsChapDESClearTextSize);
ASSERT(aKey.Length() == KPppMsChapDESKeySize);
ASSERT(aCypher.Length() == KPppMsChapDESCipherTextSize);
HBufC8* desKeyBuf=HBufC8::NewMaxLC(KPppDESKeySize);
TPtr8 desKey(desKeyBuf->Des());
// RFC 2433: "Use the DES encryption algorithm [4] in ECB mode [10] to
// encrypt Clear into Cypher such that Cypher can only be decrypted
// back to Clear by providing Key. Note that the DES algorithm takes
// as input a 64-bit stream where the 8th, 16th, 24th, etc. bits are
// parity bits ignored by the encrypting algorithm. Unless you write
// your own DES to accept 56-bit input without parity, you will need
// to insert the parity bits yourself."
MakeDesKey(aKey, desKey);
CBlockTransformation* encryptor =
CDESEncryptor::NewLC(desKey, EFalse);
CPaddingNone* padding = CPaddingNone::NewLC();
CBufferedEncryptor* bufEncryptor =
CBufferedEncryptor::NewL(encryptor, padding);
CleanupStack::Pop(padding);
CleanupStack::Pop(encryptor);
CleanupStack::PushL(bufEncryptor);
aCypher.Zero();
bufEncryptor->ProcessFinalL(aClear, aCypher);
CleanupStack::PopAndDestroy(bufEncryptor);
CleanupStack::PopAndDestroy(desKeyBuf);
ASSERT(aCypher.Length() == KPppMsChapDESCipherTextSize);
}
示例13: DesHashL
// NB The use of the LAN Manager compatible challenge response has
// been deprecated according to RFC 2433.
inline void CPppMsChap::DesHashL(const TDesC8& aClear, TDes8& aCypher)
/**
Makes aCypher an irreversibly encrypted form of aClear by
encrypting known text using aClear as the secret key. The known
text consists of the string "[email protected]#$%".
@param aClear [in] A plaintext used as the secret key for
encryption (7 octets).
@param aCypher [out] The ciphertext (8 octets).
@note This function implements the DesHash routine specified in RFC
2433.
@note The use of the LAN Manager compatible challenge response has
been deprecated according to RFC 2433.
@internalComponent
*/
{
ASSERT(aClear.Length() == KPppMsChapDESKeySize);
ASSERT(aCypher.Length() == KPppMsChapDESCipherTextSize);
HBufC8* desKeyBuf = HBufC8::NewMaxLC(KPppDESKeySize);
TPtr8 desKey(desKeyBuf->Des());
MakeDesKey(aClear, desKey);
// A magic string literal specified in RFC 2433 used as clear text for
// making aCypher an irreversibly encrypted form of aClear by
// encrypting this clear text using aClear as the secret key.
_LIT8(KStdText, "[email protected]#$%");
CBlockTransformation* encryptor =
CDESEncryptor::NewLC(desKey, EFalse);
CPaddingNone* padding = CPaddingNone::NewLC();
CBufferedEncryptor* bufEncryptor =
CBufferedEncryptor::NewL(encryptor, padding);
CleanupStack::Pop(padding);
CleanupStack::Pop(encryptor);
CleanupStack::PushL(bufEncryptor);
aCypher.Zero();
bufEncryptor->ProcessFinalL(KStdText, aCypher);
CleanupStack::PopAndDestroy(bufEncryptor);
CleanupStack::PopAndDestroy(desKeyBuf);
ASSERT(aCypher.Length() == KPppMsChapDESCipherTextSize);
}
示例14: GetDataL
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
void CImeiSettings::GetDataL(TDes8& aType,TDes8& aData,TDes& aExtension,TInt& aId)
{
aId = iId;
aData.Zero();
if(iListBox)
{
iListBox->StoreSettingsL();
TFileName Hjelpper;
Hjelpper.Copy(iListBox->iType);
Hjelpper.Append(_L("/"));
Hjelpper.Append(iListBox->iTypeId);
aType.Copy(Hjelpper);
aExtension.Copy(iListBox->iExtension);
}
}
示例15: DoSegmentNextL
TBool CSmsBufferSegmenter::DoSegmentNextL(TDes8& aSegmentBuffer,TInt aSegmentSize,
TInt& aUnconvertedChars, TInt& aDowngradedChars,
TSmsEncoding aEncoding)
//
// Extracts a "native" segment from the SMS buffer, converts to the required
// character set and breaks off the next segment of required size.
// Returns true if this was the last segment
//
{
OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSBUFFERSEGMENTER_DOSEGMENTNEXTL_1, "CSmsBufferSegmenter::DoSegmentNextL(): aSegmentSize=%d", aSegmentSize);
__ASSERT_ALWAYS(aSegmentSize>0,Panic(KGsmuPanicIllegalSegmentSize));
__ASSERT_ALWAYS(aSegmentBuffer.MaxLength()>=aSegmentSize,Panic(KGsmuPanicSegmentBufferTooSmall));
// Extract from buffer until we have enough chars for a segment or we're at the end
aSegmentBuffer.Zero();
TBuf<CSmsBufferBase::EMaxBufLength> nativeChars;
while ((iConvertedBufferPtr.Length()<aSegmentSize)&&(iElementsExtracted<iSmsBuffer.Length()))
{
TInt elementsToExtract=Min(static_cast<TInt>(CSmsBufferBase::EMaxBufLength),iSmsBuffer.Length()-iElementsExtracted);
iSmsBuffer.Extract(nativeChars,iElementsExtracted,elementsToExtract);
TInt numberOfUnconvertibleCharacters;
TInt numberOfDowngradedCharacters;
TPtrC8 smsCharsPtr=iAlphabetConverter.ConvertFromNativeL(nativeChars,
aEncoding,
numberOfUnconvertibleCharacters,
numberOfDowngradedCharacters);
aUnconvertedChars += numberOfUnconvertibleCharacters;
aDowngradedChars += numberOfDowngradedCharacters;
CheckConvertedBufferAllocL(iConvertedBufferPtr.Length()+smsCharsPtr.Length());
iConvertedBufferPtr.Append(smsCharsPtr);
iElementsExtracted+=elementsToExtract;
}
// Determine number of converted elements to put in this segment
TInt elementsInSegment=ElementsToReturnFromConvertedBufferL(aSegmentSize);
// And copy...
aSegmentBuffer.Copy(iConvertedBufferPtr.Ptr(),elementsInSegment);
iConvertedBufferPtr.Delete(0,elementsInSegment);
// If this is the last segment then ensure no unconverted characters remain
return !MoreL();
} // CSmsBufferSegmenter::DoSegmentNextL