本文整理汇总了C++中TDesC::Size方法的典型用法代码示例。如果您正苦于以下问题:C++ TDesC::Size方法的具体用法?C++ TDesC::Size怎么用?C++ TDesC::Size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TDesC
的用法示例。
在下文中一共展示了TDesC::Size方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetFieldL
/*sets a specific contact field to a value as determined by its type.
field at aPos in aFields is set to aText*/
void CPerformanceFunctionalityBase::SetFieldL(const TInt aPos, const TDesC& aText)
{
CContactItemField &field = (*iFields)[aPos];
if( field.IsTemplateLabelField() )
{
return;
}
if( 0 == aText.Size() )
{
return;
}
switch(field.StorageType())
{
case KStorageTypeText:
field.TextStorage()->SetTextL(aText);
break;
case KStorageTypeStore:
{
HBufC8 *buf = HBufC8::NewLC(aText.Size());
TPtr8 tptr8 = buf->Des();
tptr8.Copy(aText);
field.StoreStorage()->SetThingL(*buf);
CleanupStack::PopAndDestroy(buf);
}
break;
case KStorageTypeContactItemId:
{
TInt id = 0;
if( aText.Size() > 0 )
{
GetIntFromConfig( KOtherFields, KAgentId, id );
}
field.AgentStorage()->SetAgentId(id);
}
break;
case KStorageTypeDateTime:
{
if( aText.Size() > 0 )
{
TPtrC time;
GetStringFromConfig( KOtherFields, KFieldTime, time );
field.DateTimeStorage()->SetTime( TTime(time) );
}
else
{
field.DateTimeStorage()->SetTime( TTime(0) );
}
}
break;
default:
User::Panic(aText,EInvariantFalse);
break;
}
}
示例2: CompareFieldL
/*checks the value of a specific field as determined by it type
returns true if field at aPos in aFields equals aText*/
TBool CPerformanceFunctionalityBase::CompareFieldL(const TInt aPos, const TDesC& aText)
{
TBool ret = EFalse;
const CContactItemField &field = (*iFields)[aPos];
if( field.IsTemplateLabelField() )
{
return ret;
}
if( 0 == aText.Size() && !field.Storage()->IsFull() )
{
return ETrue;
}
else if( !field.Storage()->IsFull() )
{
return EFalse;
}
switch( field.StorageType() )
{
case KStorageTypeText:
ret = field.TextStorage()->Text() == aText;
break;
case KStorageTypeStore:
{
HBufC8 *buf = HBufC8::NewLC(aText.Size());
TPtr8 tptr8 = buf->Des();
tptr8.Copy(aText);
ret = field.StoreStorage()->Thing()->Compare(*buf) == 0;
CleanupStack::PopAndDestroy(buf);
}
break;
case KStorageTypeContactItemId:
{
TInt id = 0;
GetIntFromConfig( KOtherFields, KAgentId, id );
ret = field.AgentStorage()->Value() == id;
}
break;
case KStorageTypeDateTime:
{
TPtrC time;
GetStringFromConfig( KOtherFields, KFieldTime, time );
ret = field.DateTimeStorage()->Time() == TTime(time);
}
break;
default:
User::Panic(aText,EInvariantFalse);
break;
}
return ret;
}
示例3: SetFieldL
/*sets a specific contact field to a value as determined by its type.
field at aPos in aFields is set to aText*/
void CContactsRamTest::SetFieldL(const CContactItemField &aField, const TDesC& aText)
{
if( aField.IsTemplateLabelField() )
{
return;
}
if( 0 == aText.Size() )
{
return;
}
switch(aField.StorageType())
{
case KStorageTypeText:
aField.TextStorage()->SetTextL(aText);
break;
case KStorageTypeStore:
{
HBufC8 *buf = HBufC8::NewLC(aText.Size());
TPtr8 tptr8 = buf->Des();
tptr8.Copy(aText);
aField.StoreStorage()->SetThingL(*buf);
CleanupStack::PopAndDestroy(buf);
}
break;
case KStorageTypeContactItemId:
{
aField.AgentStorage()->SetAgentId( KAgentId );
}
break;
case KStorageTypeDateTime:
{
if( aText.Size() > 0 )
{
aField.DateTimeStorage()->SetTime( TTime(KTime) );
}
else
{
aField.DateTimeStorage()->SetTime( TTime(0) );
}
}
break;
default:
User::Panic(aText,EInvariantFalse);
break;
}
}
示例4: WriteL
void TDesWrite::WriteL(const TDesC& aDes)
{
WriteL(aDes.Length());
if (iDes.Size() & 1) iDes.AppendL('.'); // Pad so the desc is 2-byte aligned
TPtrC8 ptr((TUint8*)aDes.Ptr(), aDes.Size());
iDes.AppendL(ptr);
}
示例5: UserAuthenticationText
// -----------------------------------------------------------------------------
// CPKIDialog::?member_function
// ?implementation_description
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CPKIDialog::UserAuthenticationText(
const TDesC& aTextToSign,
const RArray<TCTTokenObjectHandle>& aCertHandleList,
TCTTokenObjectHandle& aCertHandle,
TRequestStatus& aStatus )
{
iCurrentOperation = EUserAuthenticationText;
InitClientStatus( aStatus );
TInt textSize = aTextToSign.Size();
TSignInput signInput;
signInput.iOperation = EUserAuthenticationText;
signInput.iVariableDataSize = textSize;
signInput.iCertHandleArrayTotal = aCertHandleList.Count();
TPckgC<TSignInput> signInputBufPtr( signInput );
// iSignInputBuf is persistent because further input processing occurs in the AO before
// calling the notifier.
iSignInputBuf.Copy( signInputBufPtr );
const TUint8* textToSignPtr = reinterpret_cast<const TUint8*>( aTextToSign.Ptr() );
iVariableDataPtr.Set( textToSignPtr, textSize );
iClientCertInfoHandlePtr = &aCertHandle;
iRequester->RequestVariableBufferDialog( iSignInputBuf, iVariableDataPtr,
aCertHandleList, iCertInfoHandleBuf );
}
示例6: ParseL
// ---------------------------------------------------------
// TCodParser::ParseL()
// ---------------------------------------------------------
//
void TCodParser::ParseL( const TDesC& aBuf, CCodData& aData )
{
CLOG(( EParse, 2, _L("-> TCodParser::ParseL") ));
CDUMP(( EParse, 2, _S("Buf:"), _S(" "), \
(const TUint8*)aBuf.Ptr(), aBuf.Size() ));
iError = KErrNone;
iData = &aData;
iBuf = &aBuf;
iCurP = iBuf->Ptr();
iEndP = iCurP + iBuf->Length();
CMediaObjectData *mediaObject = CMediaObjectData::NewL();
// Processing lines (attribute and value) until there is more lines to read.
while ( AttrLineL(mediaObject) )
{
// Some compilers require empty controlled statement block instead of
// just a semicolon.
}
iData->AppendMediaObjectL( mediaObject );
#ifdef __TEST_COD_LOG
TPtrC ptr16;
TPtrC8 ptr8;
CLOG(( EParse, 3, _L("TCodParser::ParseL data:") ));
ptr16.Set( aData.Name() );
CLOG(( EParse, 3, _L(" Name<%S>"), &ptr16 ));
ptr16.Set( aData.Vendor() );
CLOG(( EParse, 3, _L(" Vendor<%S>"), &ptr16 ));
ptr16.Set( aData.Description() );
CLOG(( EParse, 3, _L(" Desc<%S>"), &ptr16 ));
CLOG(( EParse, 3, _L(" Size(%d)"), aData.Size() ));
ptr8.Set( aData.InstallNotify() );
CLOG(( EParse, 3, _L8(" InstNotif<%S>"), &ptr8 ));
ptr8.Set( aData.NextUrl() );
CLOG(( EParse, 3, _L8(" NextUrl<%S>"), &ptr8 ));
ptr8.Set( aData.NextUrlAtError() );
CLOG(( EParse, 3, _L8(" NextUrlAtErr<%S>"), &ptr8 ));
ptr8.Set( aData.InfoUrl() );
CLOG(( EParse, 3, _L8(" InfoUrl<%S>"), &ptr8 ));
ptr16.Set( aData.Price() );
CLOG(( EParse, 3, _L(" Price<%S>"), &ptr16 ));
ptr8.Set( aData.Icon() );
CLOG(( EParse, 3, _L8(" Icon<%S>"), &ptr8 ));
#endif /* def __TEST_COD_LOG */
// NULL data for clarity. These are never used later, but don't keep
// pointers to objects which are out of reach.
iBuf = NULL;
iData = NULL;
iCurP = NULL;
iEndP = NULL;
User::LeaveIfError( iError );
CLOG(( EParse, 2, _L("<- TCodParser::ParseL") ));
}
示例7: Load
EXPORT_C TInt RSoundPlugIn::Load(const TDesC& aFileName)
/** Loads a new plug-in, replacing the existing one, if any.
This function always causes a flush of the window server buffer.
@param aFileName The filename of the plug-in DLL to load.
@return KErrNone if the function was successful. KErrNotSupported if the currently
loaded plug-in could not be unloaded or aFileName does not refer to a loadable plug-in.
@capability WriteDeviceData */
{
TInt length=aFileName.Length();
return WriteReply(&length,sizeof(length),aFileName.Ptr(),aFileName.Size(),EWsClickOpLoad);
}
示例8: HandleWidgetCommandL
// ----------------------------------------------------------------------------
// Sends the command to Widget launcher
// ----------------------------------------------------------------------------
//
static void HandleWidgetCommandL(
RApaLsSession& aSession,
const TDesC& aWidget,
const TUid& aUid,
TUint32 aOperation )
{
const TInt size( 2* aWidget.Length() + 3*sizeof( TUint32 ) );
// Message format is <filenameLength><unicode_filename><someintegervalue>
CApaCommandLine* cmd( CApaCommandLine::NewLC() );
HBufC8* opaque( HBufC8::NewLC( size ) );
RDesWriteStream stream;
TPtr8 des( opaque->Des() );
stream.Open( des );
CleanupClosePushL( stream );
// Generate the command.
stream.WriteUint32L( aUid.iUid );
stream.WriteUint32L( aWidget.Length() );
stream.WriteL( reinterpret_cast< const TUint8* >( aWidget.Ptr() ),
aWidget.Size() );
stream.WriteInt32L( aOperation );
CleanupStack::PopAndDestroy( &stream );
// Generate command.
cmd->SetCommandL( EApaCommandBackgroundAndWithoutViews );
cmd->SetOpaqueDataL( *opaque );
CleanupStack::PopAndDestroy( opaque );
cmd->SetExecutableNameL( KLauncherApp );
User::LeaveIfError( aSession.StartApp( *cmd ) );
CleanupStack::PopAndDestroy( cmd );
}
示例9: ParseL
// ---------------------------------------------------------
// TDdParser::ParseL()
// ---------------------------------------------------------
//
void TDdParser::ParseL( const TDesC& aBuf, CCodData& aData, const TBool aIsDd2, TBool& aIsLicenseTag )
{
CLOG(( EParse, 2, _L("-> TDdParser::ParseL") ));
CDUMP(( EParse, 2, _S("Buf:"), _S(" "), \
(const TUint8*)aBuf.Ptr(), aBuf.Size() ));
iError = KErrNone;
iData = &aData;
// XML Parser expects the buffer contain a BOM and be in
// network byte order (this is hard-coded into cXmlParser).
// We already have the buffer converted to UCS-2, native byte order, BOM
// removed, and this cannot be changed without changing API.
// So we have to re-add BOM and convert the buffer back to network byte
// order. This is an annoying a waste, luckily a DD file is small
// enough not to be significant.
HBufC* buf = HBufC::NewLC( aBuf.Length() + 1 );
buf->Des().Append( 0xFFFE ); // Add BOM, little endian as aBuf.
buf->Des().Append( aBuf ); // Append buffer.
// Now turn the whole buffer big-endian.
TUint8* ptr = (TUint8*)buf->Ptr();
for ( TInt i = 0; i < buf->Size(); i += 2 )
{
TUint8 tmp = ptr[i];
ptr[i] = ptr[i + 1];
ptr[i + 1] = tmp;
}
NW_WBXML_Dictionary_t* dictArray[ 1 ] =
{ (NW_WBXML_Dictionary_t*)&NW_DdDummy_WBXMLDictionary };
RNwWbxmlDictionary wbxmlDict;
User::LeaveIfError( wbxmlDict.Initialize( 1, dictArray ) );
CleanupClosePushL<RNwWbxmlDictionary>( wbxmlDict );
NW_TinyDom_Handle_t domHandle;
NW_Status_t stat;
CNwDomDocumentNode* docNode = new (ELeave) CNwDomDocumentNode();
CleanupStack::PushL( docNode );
docNode->iDocNode = CXML_DOM_DocumentNode_BuildTree
(
&domHandle,
(NW_Byte*)buf->Ptr(),
(NW_Int32)buf->Size(),
/*encoded=*/NW_FALSE,
/*publicID=*/NW_DdDummy_PublicId,
/*extTNotStringTable=*/NW_FALSE,
&stat
);
LeaveIfNwErrorL( stat );
User::LeaveIfNull( docNode->iDocNode ); // Safety code.
if (!aIsDd2)
{
DocNodeL( docNode->iDocNode );
}
else
{
iIsLicenseTag = EFalse;
ParseDd2DocNodeL( docNode->iDocNode );
}
CleanupStack::PopAndDestroy( 3, buf ); // docNode, close wbxmlDict, buf
#ifdef __TEST_COD_LOG
TPtrC ptr16;
TPtrC8 ptr8;
CLOG(( EParse, 3, _L("TCodParser::ParseL data:") ));
ptr16.Set( aData.Name() );
CLOG(( EParse, 3, _L(" Name<%S>"), &ptr16 ));
ptr16.Set( aData.Vendor() );
CLOG(( EParse, 3, _L(" Vendor<%S>"), &ptr16 ));
ptr16.Set( aData.Description() );
CLOG(( EParse, 3, _L(" Desc<%S>"), &ptr16 ));
CLOG(( EParse, 3, _L(" Size(%d)"), aData.Size() ));
ptr8.Set( aData.InstallNotify() );
CLOG(( EParse, 3, _L8(" InstNotif<%S>"), &ptr8 ));
ptr8.Set( aData.NextUrl() );
CLOG(( EParse, 3, _L8(" NextUrl<%S>"), &ptr8 ));
ptr8.Set( aData.NextUrlAtError() );
CLOG(( EParse, 3, _L8(" NextUrlAtErr<%S>"), &ptr8 ));
ptr8.Set( aData.InfoUrl() );
CLOG(( EParse, 3, _L8(" InfoUrl<%S>"), &ptr8 ));
ptr16.Set( aData.Price() );
CLOG(( EParse, 3, _L(" Price<%S>"), &ptr16 ));
ptr8.Set( aData.Icon() );
CLOG(( EParse, 3, _L8(" Icon<%S>"), &ptr8 ));
//TODO add logs for OMA 2
#endif /* def __TEST_COD_LOG */
//If there are no media objects present to download,
if( !iData->Count() )
{
User::Leave( KErrCodInvalidDescriptor );
}
// NULL data for clarity. These are never used later, but don't keep
// pointers to objects which are out of reach.
iData = NULL;
User::LeaveIfError( iError );
aIsLicenseTag = iIsLicenseTag;
//.........这里部分代码省略.........
示例10: WriteToFileL
// -----------------------------------------------------------------------------
// Write unicode text to file
// -----------------------------------------------------------------------------
//
void CBCTestLogger::WriteToFileL( RFile& aFile, const TDesC& aText )
{
TPtrC8 buf( (TUint8*)aText.Ptr(), aText.Size() );
aFile.Write( buf );
}
示例11: StoreAttributesL
// ---------------------------------------------------------
// CNSmlDsProvisioningAdapter::StoreAttributesL
// ---------------------------------------------------------
void CNSmlDsProvisioningAdapter::StoreAttributesL( const TDesC& aType )
{
_DBG_FILE("CNSmlDsProvisioningAdapter::StoreAttributesL(): begin");
TInt iDataProvElementCount = iProfiles[iProfiles.Count()-1]->iDataProvElement.Count()-1;
// Leave if aType cannot be assigned
if( ( aType.Length() > 0 ) &&
( iProfiles[iProfiles.Count()-1]->iDataProvElement[iDataProvElementCount]->iRemoteDBUri ) )
{
TBool dataProvIdFoundInZ = FALSE;
TSmlDataProviderId firstDataProvIdFound = 0;
TSmlDataProviderId uidFound = 0;
TBool doSearch = ETrue;
if ( aType.FindF( KXVcardMimeType ) != KErrNotFound )
{
if ( IsOperatorProfile( *iProfiles[iProfiles.Count()-1] ) )
{
const CNSmlDsProfileElement& profile = *iProfiles[iProfiles.Count()-1];
StoreOperatorUrlL( *profile.iHostAddress );
// Do not make a search through adapter implementations
doSearch = EFalse;
uidFound = OperatorAdapterUid();
if ( !uidFound )
{
// If OperatorAdapterUid returns 0, do a search
doSearch = ETrue;
}
}
}
// look through every implementation adapter until one found
// which supports MIME type in question
// The first one located in ROM is chosen. If none found in ROM then
// the first adapter found is chosen.
HBufC8 *type = HBufC8::NewLC(aType.Size());
TPtr8 typePtr = type->Des();
CnvUtfConverter::ConvertFromUnicodeToUtf8( typePtr, aType);
// get list of dataproviderIds
RImplInfoPtrArray implArray;
CleanupStack::PushL( PtrArrCleanupItemRArr( CImplementationInformation, &implArray ) );
TUid ifUid = { KNSmlDSInterfaceUid };
REComSession::ListImplementationsL( ifUid, implArray );
if ( doSearch )
{
TInt countProviders = implArray.Count();
for( TInt i = 0; i < countProviders; i++ )
{
CImplementationInformation* implInfo = implArray[i];
RSyncMLDataProvider dataProvider;
dataProvider.OpenL( iSession, implInfo->ImplementationUid().iUid );
CleanupClosePushL( dataProvider );
TInt mimeTypeCount = dataProvider.MimeTypeCount();
for( TInt j = 0; j < mimeTypeCount; j++ )
{
HBufC* mimeType = dataProvider.MimeType( j ).AllocLC();
TPtrC8 convMimeType = ConvertTo8LC( *mimeType );
if( typePtr.Find( convMimeType ) == 0)
{
// MIME type in question was found
uidFound = implInfo->ImplementationUid().iUid;
if( firstDataProvIdFound == 0 )
{
// save the first in case of none found from ROM
firstDataProvIdFound = uidFound;
}
// check whether the provider is located in ROM (drive Z)
if( implInfo->Drive() == EDriveZ )
{
dataProvIdFoundInZ = TRUE;
}
}
CleanupStack::PopAndDestroy(2); // mimetype, ConvertTo8LC
if( uidFound )
{
break;
}
}
CleanupStack::PopAndDestroy(); // dataProvider
if ( dataProvIdFoundInZ )
{
break;
}
else
{
//.........这里部分代码省略.........