本文整理汇总了C++中TDesC16::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ TDesC16::Length方法的具体用法?C++ TDesC16::Length怎么用?C++ TDesC16::Length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TDesC16
的用法示例。
在下文中一共展示了TDesC16::Length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Set
/** Sets an existing descriptor setting to a new value or creates a new setting
with a descriptor value if it doesn't exist.
@param aKey Key of setting to be written to.
@param aValue Value to be written.
@return
KErrNone if successful,
KErrArgument if aValue is longer than KMaxUnicodeStringLength or
the setting exists but is not a descriptor,
plus other system-wide error codes.
@post
Transactions fail on all error conditions.
Outside transactions: on success the new value is persistent,
on failure the repository is unmodified.
@capability Dependent Caller must satisfy the write access policy of that key in the repository.
*/
EXPORT_C TInt CRepository::Set(TUint32 aKey, const TDesC16& aValue)
{
if (aValue.Length()>KMaxUnicodeStringLength)
return KErrArgument;
TPtrC8 pVal((const TUint8*)aValue.Ptr(), aValue.Length()*2);
return Set(aKey,pVal);
}
示例2: Write
// ==========================================================================
// METHOD: Write
//
// DESIGN: Write the given buffer. Chunk the string if it is longer than
// KMaxTextPerLine.
// ==========================================================================
void CLogFileHandler::Write( const TDesC8& aClassName,
const TDesC8& aFuncName,
const TDesC16& aDes )
{
TRAP_IGNORE( AddTimestampToOutputBufferL() );
TInt prefixLength = iOutputBuffer.Length();
TRAP_IGNORE( AddClassAndFunctionToOutputBufferL( aClassName, aFuncName ) );
TInt curPos = 0;
while( curPos < aDes.Length() )
{
TInt lengthToWrite = Min( KMaxTextPerLine - iOutputBuffer.Length(), aDes.Length() - curPos );
TRAP_IGNORE( WriteLineL( aDes.Mid( curPos, lengthToWrite ) ) );
iOutputBuffer.SetLength( prefixLength );
curPos += lengthToWrite;
} // end while
} // END Write
示例3: CompleteAndReleaseL
void CCatalogsBaseMessageImpl::CompleteAndReleaseL(
const TDesC16& aOutputData,
TInt aStatus )
{
DLTRACEIN(("TDesC16, TInt, handle: %d, this: %x", Handle(), this));
if ( iSenderLost )
{
DLINFO(("Sender was lost, deleting message"));
delete this;
DLTRACEOUT((""));
return;
}
TInt clientDescLength( iMessage.GetDesMaxLengthL( 3 ) );
if ( clientDescLength < aOutputData.Length() )
{
if( iMessage.Function() == ECatalogsExternalAllocMessage )
{
TInt incompMsgHandle( iSession.WriteToLargerDesL( aOutputData,
aStatus ) );
TBuf16<KCatalogsMinimumAllocSize> internalMsg(
KCatalogsMinimumAllocLength );
internalMsg.Num( incompMsgHandle );
internalMsg.Append( KCatalogsTooSmallDescMsgElementDivider );
internalMsg.AppendNum( aOutputData.Length() );
TRAPD( error, iMessage.WriteL( KOutputSlot, internalMsg ) );
if ( error != KErrNone )
{
iSession.RemoveIncompleteMessage( incompMsgHandle );
User::Leave( error );
}
}
iMessage.Complete( KCatalogsErrorTooSmallDescriptor );
}
else
{
iMessage.WriteL( KOutputSlot, aOutputData );
iMessage.Complete( aStatus );
}
delete this;
DLTRACEOUT((""));
}
示例4:
// -----------------------------------------------------------------------------
// CSatNotifySendSs::CreateTerminalRespL
// Constructs SendSs specific part of terminal response and calls
// DOS to send the actual message.
// -----------------------------------------------------------------------------
//
TInt CSatNotifySendSs::CreateTerminalRespL
(
TUint8 aPCmdNumber,
TUint8 aGeneralResult,
const TDesC16& aAdditionalInfo
)
{
OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSS_CREATETERMINALRESPL_1, "CSAT:: CSatNotifySendSs::CreateTerminalRespL");
// Create and append response data
TTlv tlvSpecificData;
tlvSpecificData.AddTag( KTlvResultTag );
// Append general result
tlvSpecificData.AddByte( aGeneralResult );
for (TInt i = 0; i < aAdditionalInfo.Length(); i++ )
{
tlvSpecificData.AddByte( static_cast<TUint8>( aAdditionalInfo[i] ) );
}
// Prepare data
iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber;
TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag();
// Pack data
CSatDataPackage dataPackage;
dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data );
// Forward request to the DOS
return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL(
ESatTerminalRsp, &dataPackage );
}
示例5: SetPolyPointsL
// -----------------------------------------------------------------------------
// Sets poly points.
// -----------------------------------------------------------------------------
//
void CAknsAlPolyBase::SetPolyPointsL( const TDesC16& aPointString )
{
TInt coordCount = aPointString.Length();
if ((coordCount & 0x1) || coordCount < 4) // odd number or too few point coordinates
{
RDebug::Printf("%s, line %d, ERROR: Illegal coordinate count", __FILE__, __LINE__);
User::Leave(KErrArgument);
}
iPointCount = coordCount >> 1;
iPoints = new (ELeave) TPolyPoint[iPointCount];
iPoints[0].iX = aPointString[0];
iPoints[0].iY = aPointString[1];
TUint16 oldX = iPoints[0].iX;
TUint16 oldY = iPoints[0].iY;
// parse numbers from the descriptor
for (TInt i = 1; i < iPointCount; i++) // first point already set
{
iPoints[i].iX = aPointString[i*2];
iPoints[i].iY = aPointString[i*2+1];
if (oldX == iPoints[i].iX && oldY == iPoints[i].iY)
{
RDebug::Printf("%s, line %d, ERROR: subsequent coordinates cannot be equal", __FILE__, __LINE__);
User::Leave(KErrArgument);
}
oldX = iPoints[i].iX;
oldY = iPoints[i].iY;
}
}
示例6: new
// -----------------------------------------------------------------------------
// Sets poly1D points.
// -----------------------------------------------------------------------------
//
void CAknsAlPolyBase::SetPolyPoints1DL( const TDesC16& aPointString )
{
TInt coordCount = aPointString.Length();
if ((coordCount & 0x1) || coordCount < 4) // odd number or too few point coordinates
User::Leave(KErrArgument);
iPointCount = coordCount >> 1;
iPoints = new (ELeave) TPolyPoint[iPointCount];
iPoints[0].iX = aPointString[0];
iPoints[0].iY = aPointString[1];
TUint16 oldX = iPoints[0].iX;
// parse numbers from the descriptor
for (TInt i = 1; i < iPointCount; i++) // first point already set
{
iPoints[i].iX = aPointString[i*2];
iPoints[i].iY = aPointString[i*2+1];
if (iPoints[i].iX < oldX) // points must be in ascending order
User::Leave(KErrArgument);
oldX = iPoints[i].iX;
}
}
示例7: NTChallengeResponseL
inline void CPppMsChap::NTChallengeResponseL(const TDesC8& aChallenge,
const TDesC16& aPassword,
TDes8& aResponse)
/**
Computes a MS-CHAP Windows NT compatible Challenge Response.
@param aChallenge [in] A MS-CHAP Challenge (8 octets).
@param aPassword [in] The Microsoft Windows NT password (0 to 256
Unicode char).
@param aResponse [out] The MS-CHAP Windows NT compatible Challenge
Response (24 octets).
@note This function implements the NTChallengeResponse routine
specified in RFC 2433.
@internalComponent
*/
{
ASSERT(aChallenge.Length() == KPppMsChapChallengeSize);
ASSERT(aPassword.Length() <= KPppMsChapMaxNTPasswordLength);
ASSERT(aResponse.Length() == KPppMsChapNTResponseSize);
HBufC8* paddedPasswordHashBuf =
HBufC8::NewLC(KPppMsChapPaddedHashSize);
TPtr8 paddablePasswordHash(paddedPasswordHashBuf->Des());
paddablePasswordHash.SetLength(KPppMsChapHashSize);
NtPasswordHashL(aPassword, paddablePasswordHash);
ChallengeResponseL(aChallenge,
paddablePasswordHash,
aResponse);
CleanupStack::PopAndDestroy(paddedPasswordHashBuf);
ASSERT(aResponse.Length() == KPppMsChapNTResponseSize);
}
示例8:
EXPORT_C void CPTPIPInitCmdAck::SetDeviceFriendlyName(TDesC16& aName)
{
OstTraceFunctionEntry0( CPTPIPINITCMDACK_SETDEVICEFRIENDLYNAME_ENTRY );
if(KErrNone == iBuffer.Create(aName,aName.Length()+KMTPNullCharLen))
{
iBuffer.Append(KMTPNullChar);
}
}
示例9: totalConverted
// -----------------------------------------------------------------------------
// JPLangUtil::ConvertFullHiragnaToFullKatakana
// Converts Full-width Hiragana and Special Character text found in
// aUnicodeSource to their Full-width counterparts and places the
// resulting text into aUnicodeTarget.
// -----------------------------------------------------------------------------
//
EXPORT_C TInt JPLangUtil::ConvertFullHiragnaToFullKatakana
( const TDesC16& aUnicodeSource, TDes16& aUnicodeTarget )
{
TInt totalConverted( 0 );
const TInt length( aUnicodeSource.Length() );
const TInt maxLength( aUnicodeTarget.MaxLength() );
if( length > maxLength )
{
return KErrTooBig;
}
const TUint comp = KFullWidthKatakanaSmallA - KFullWidthHiraganaSmallA;
aUnicodeTarget.Zero();
for( TInt i( 0 ); i < length; ++i )
{
const TText uniChar( aUnicodeSource[i] );
TText uniChar2(0);
if (i + 1 < length)
{
uniChar2 = aUnicodeSource[i+1];
}
// First check if this is this Full Width Katakana
if (KFullWidthHiraganaSmallA <= uniChar && uniChar <= KFullWidthHiraganaVU)
{
if (uniChar == KFullWidthHiraganaU
&& uniChar2 == KFullWidthHiraganaVoicedSound)
{
aUnicodeTarget.Append(KFullWidthKatakanaSmallVU);
totalConverted++;
i++;
}
else
{
TUint katakana = uniChar + comp;
if (IsKatakana(katakana))
{
aUnicodeTarget.Append(katakana);
totalConverted++;
}
}
}
else
{
aUnicodeTarget.Append(uniChar);
totalConverted++;
}
}
// Now handle special characters
// This logic may be moved into this function to avoid another loop over
// the text
totalConverted +=
UnicodeTextUtil::ConvertSpecialCharactersInPlace( EFullToHalfWidth,
aUnicodeTarget );
return totalConverted;
}
示例10: iNbrArgs
//---------------------------------------------------------------------
//
//---------------------------------------------------------------------
CLogEntry::CLogEntry(const TDesC16& aMsg, TInt aNbrArg, TInt aArg1, TInt aArg2, TInt aArg3, TInt aArg4) : iNbrArgs(aNbrArg),
iArg1(aArg1), iArg2(aArg2), iArg3(aArg3), iArg4(aArg4)
{
iMsg = HBufC16::New(aMsg.Length());
if(iMsg)
{
(*iMsg) = aMsg;
}
}
示例11: FindNeqL
/** Finds all the settings that match the specification given by aPartialKey
and aMask, but are either not string values or do not match the given string.
@param aPartialKey
Contains a bit pattern that all the keys returned must at least partially
match.
@param aMask
Has bits set for all the bits in aPartialKey that must match the returned
keys.
@param aValue
Settings for the keys found will be settings that either contain values
that are not strings or strings with value other than aValue.
@param aFoundKeys All the keys found.
For each key k in aFoundKeys, (k & aMask) == (aPartialKey & aMask) and
the setting with key k is either not a string value or a string value not
equal to aValue.
@see FindL()
@return
KErrNone if successful,
KErrNotFound if capability check passed but no non-matching items are found,
plus other system-wide error codes.
@post Transactions fail only on those "other system-wide error codes".
@capability Dependent Caller must satisfy the read policies of all settings found in the source range.
*/
EXPORT_C TInt CRepository::FindNeqL(TUint32 aPartialKey, TUint32 aMask,
const TDesC16& aValue, RArray<TUint32>& aFoundKeys)
{
TPtrC8 pVal((const TUint8*)aValue.Ptr(), aValue.Length()*2);
TRAPD(ret,iImpl->FindSettingsComparisonL(aPartialKey,aMask,pVal,ENotEqual,aFoundKeys));
if (ret==KErrNoMemory)
User::LeaveNoMemory();
return ret;
}
示例12: ParseL
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void CNcdConfigurationParser::ParseL( const TDesC16& aData )
{
DLTRACEIN(("16-bit parse, length=%d",aData.Length()));
HBufC8* utf8 = NcdProtocolUtils::ConvertUnicodeToUtf8L( aData );
CleanupStack::PushL( utf8 );
ParseL( *utf8 );
CleanupStack::PopAndDestroy( utf8 );
}
示例13: ExternalizeDesL
void ExternalizeDesL(const TDesC16& aDes, RWriteStream& aStream)
{
TInt length = aDes.Length();
aStream.WriteInt32L(length);
if (length > 0)
{
aStream << aDes;
}
}
示例14: WriteAll
EXPORT_C void CSenLogger::WriteAll(TInt aChannel, TInt aLevel, const TDesC16& aText)
{
RFileLogger* pLogger = Logger(aChannel, aLevel);
if ( pLogger )
{
TInt i = 0;
TInt lineAmount(KColumnWidth);
TInt length = aText.Length();
while(i<aText.Length())
{
if ( length - i < KColumnWidth )
{
lineAmount = length - i;
}
pLogger->Write(aText.Mid(i, lineAmount));
i += KColumnWidth;
}
}
}
示例15: challengeHash
inline void CPppMsChap2::GenerateNTResponseL(
const TDesC8& aAuthenticatorChallenge,
const TDesC8& aPeerChallenge,
const TDesC8& aUserName,
const TDesC16& aPassword,
TDes8& aResponse)
/**
Generates a MS-CHAP-V2 NT-Response.
@param aAuthenticatorChallenge [in] The MS-CHAP-V2 authenticator
challenge (16 octets).
@param aPeerChallenge [in] The MS-CHAP-V2 peer challenge (16
octets).
@param aUserName [in] The Microsoft Windows NT username (0 to 256
char).
@param aPassword [in] The Microsoft Windows NT password (0 to 256
unicode char).
@param aResponse [out] The MS-CHAP-V2 Challenge Response,
NT-Response (24 octets).
@note This function implements the GenerateNTResponse routine
specified in RFC 2759.
@internalComponent
*/
{
ASSERT(aAuthenticatorChallenge.Length() ==
KPppMsChap2AuthenticatorChallengeSize);
ASSERT(aPeerChallenge.Length() ==
KPppMsChap2PeerChallengeSize);
ASSERT(aUserName.Length() <= KPppMsChapMaxNTUserNameLength);
ASSERT(aPassword.Length() <= KPppMsChapMaxNTPasswordLength);
ASSERT(aResponse.Length() == KPppMsChap2NTResponseSize);
HBufC8* challengeHashBuf =
HBufC8::NewMaxLC(KPppMsChap2ChallengeHashSize);
TPtr8 challengeHash(challengeHashBuf->Des());
ChallengeHashL(aPeerChallenge,
aAuthenticatorChallenge,
aUserName,
challengeHash);
HBufC8* paddedPasswordHashBuf =
HBufC8::NewLC(KPppMsChap2PaddedHashSize);
TPtr8 paddablePasswordHash(paddedPasswordHashBuf->Des());
paddablePasswordHash.SetLength(KPppMsChap2HashSize);
NtPasswordHashL(aPassword, paddablePasswordHash);
ChallengeResponseL(challengeHash,
paddablePasswordHash,
aResponse);
CleanupStack::PopAndDestroy(paddedPasswordHashBuf);
CleanupStack::PopAndDestroy(challengeHashBuf);
ASSERT(aResponse.Length()==KPppMsChap2NTResponseSize);
}