本文整理汇总了C++中TDes::Insert方法的典型用法代码示例。如果您正苦于以下问题:C++ TDes::Insert方法的具体用法?C++ TDes::Insert怎么用?C++ TDes::Insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TDes
的用法示例。
在下文中一共展示了TDes::Insert方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetIniFileNameL
void CIniFileManager::GetIniFileNameL(TDes& aFileName, TBool aIncPrivatePath)
{
if (aIncPrivatePath)
{
User::LeaveIfError(iFs.PrivatePath(aFileName));
}
// Drive name goes before the path.
aFileName.Insert(0,TDriveUnit(EDriveC).Name());
// Filename goes after the path.
aFileName.Append(KContactsIniFileName);
}
示例2: GetResourcePath
void GetResourcePath(TDes& aAppPath)
{
#if defined ( EKA2 )
TParsePtrC parse((CEikonEnv::Static()->EikAppUi()->Application())->ResourceFileName());
aAppPath.Insert(0, parse.Drive());
#else
CompleteWithAppPath(aAppPath);
#endif
#ifdef __WINS__
aAppPath[0] = 'c';
#endif
}
示例3: GetAppPath
void GetAppPath(TDes& aAppPath)
{
#if defined ( EKA2 )
User::LeaveIfError(CEikonEnv::Static()->FsSession().PrivatePath(aAppPath));
// insert the drive to the private path
TParsePtrC parse((CEikonEnv::Static()->EikAppUi()->Application())->AppFullName());
aAppPath.Insert(0, parse.Drive());
#else
CompleteWithAppPath(aAppPath);
#endif
#ifdef __WINS__
aAppPath[0] = 'c';
#endif
}
示例4: GetiniPath
EXPORT_C TInt TEFparser::GetiniPath( TDesC& aBuf,
const TDesC& aScriptPath,
TDes& aIniFilePath)
{
TInt err = KErrNone;
TInt endPos = aScriptPath.LocateReverse('\\');
if (endPos == KErrNotFound)
{
err = KErrNotFound;
}
else
{
aIniFilePath.Copy(aBuf);
aIniFilePath.Insert(0, aScriptPath.Left(endPos+1));
}
return err;
}
示例5: MakeElementL
// -----------------------------------------------------------------------------
// CapParser::MakeElementL(TDes& aText, TInt aId, const TDesC& aValue)
// Constructs element with value (eg. "<Free>23456</Free>").
// -----------------------------------------------------------------------------
//
void CapParser::MakeElementL(TDes& aText, TInt aId, const TDesC& aValue)
{
aText=KNullDesC;
ReplaceSpecialCharsL( aText, aValue );
TBuf<KTagSize> buf;
MakeElementL( buf, aId, TXmlParser::EElementBegin );
TInt len = aText.Length() + buf.Length() + buf.Length() + 1;
if ( len > aText.MaxLength())
{
User::Leave(KErrTooBig);
}
aText.Insert( 0, buf );
MakeElementL( buf, aId, TXmlParser::EElementEnd );
aText.Append( buf );
}
示例6: AddFormatText
// -----------------------------------------------------------------------------
// CCapInfo::AddFormatText( TDes& aText, TInt aNum ) const
// Adds format text
// -----------------------------------------------------------------------------
//
void CCapInfo::AddFormatText( TDes& aText, TInt aNum ) const
{
TBuf<KBufSize> buf;
buf = KNullDesC;
if ( aNum > KNestingLimit )
{
aNum = KNestingLimit;
}
for ( TInt i=0; i<aNum; i++ )
{
buf.Append( KFormatText );
}
if ( aText.MaxLength()-aText.Length()>buf.Length() )
{
aText.Insert( 0, buf );
}
}
示例7: CompleteWithAppPathM
void CompleteWithAppPathM(TDes &aPath)
{
TFileName fullAppName = RProcess().FileName();
TParse parse;
TParse parse1;
parse.Set(fullAppName, NULL, NULL);
parse1.Set(aPath, NULL, NULL);
if(parse1.DrivePresent())
{
aPath[0] = parse.Drive()[0];
}
else
{
aPath.Insert(0, parse.Drive());
}
#ifdef __WINS__
aPath[0] = 'c';
#endif
}
示例8: Formater
/**
Finds the keystring from the source string and replaces it with the
replacement string. The formated string is stored in the destination
descriptor.
*/
TInt CResourceLoader::Formater(TDes& aDest, const TDesC& aSource, const TDesC& aKey, const TDesC& aSubs, TBidiText::TDirectionality aDirectionality)
{
// substitute string must not contain KSubStringSeparator,
// or results will be unpredictable
__ASSERT_DEBUG(aSubs.Locate(KSubStringSeparator) == KErrNotFound,
User::Panic(KPanicCategory, EInvalidSubstitute));
TInt keylength(aKey.Length());
//aDest must be empty.
aDest.Zero();
// offset indicates end of last handled key in source
TInt offset(0);
// offset in destination string
TInt desOffset(0);
// Substring directionalities are adjusted after all changes are done.
TBool checkSubstringDirectionalities(EFalse);
// count is the position in the source from which the substring starts
TInt count(0);
// Replaced parameters count
TInt replaceCount(0);
while (count != KErrNotFound)
{
// desCount is the position of the substring starts in destination.
TInt desCount(0);
TPtrC remainder = aSource.Right(aSource.Length() - offset);
count = remainder.Find(aKey);
TInt maxSubLength = -1;
if (count != KErrNotFound)
{
replaceCount++;
desOffset += count;
offset += count;
count = offset;
desCount = desOffset;
// copy source to destination if first time
if (aDest.Length() == 0)
aDest.Append(aSource);
// delete found key from destination
aDest.Delete(desCount, keylength);
offset += keylength; // increase offset by key length
if (count + keylength < (aSource.Length()-1)) // aKey is not at the end of string
{
if (aSource[count+keylength] == '[') // Key includes max datalength
{
maxSubLength = 10*(aSource[count+keylength+1]-'0')
+ (aSource[count+keylength+2]-'0');
aDest.Delete(desCount,4); // Length information stored->delete from descriptor
offset += 4; // increase offset by max sub length indicator
}
}
aDest.Insert(desCount, aSubs);
desOffset = desCount + aSubs.Length();
if (maxSubLength > 0 && aSubs.Length() > maxSubLength)
{
aDest.Delete(desCount+maxSubLength-1, aSubs.Length()+1-maxSubLength);
TText ellipsis(KEllipsis);
aDest.Insert(desCount+maxSubLength-1, TPtrC(&ellipsis,1));
desOffset = desCount + maxSubLength;
}
TBidiText::TDirectionality subsDir =
TBidiText::TextDirectionality(aDest.Mid(desCount, desOffset - desCount));
// If inserted string has different directionality,
// insert directionality markers so that bidi algorithm works in a desired way.
if (aDirectionality != subsDir)
{
checkSubstringDirectionalities = ETrue;
TInt freeSpace = aDest.MaxLength() - aDest.Length();
// Protect the directionality of the inserted string.
if (freeSpace >= KExtraSpaceForSubStringDirMarkers)
{
TBuf<1> subsMarker;
subsMarker.Append(subsDir == TBidiText::ELeftToRight ?
KLRMarker : KRLMarker);
aDest.Insert(desOffset, subsMarker);
//.........这里部分代码省略.........
示例9: CorrectFilePathL
/*
-------------------------------------------------------------------------------
Class: TStifUtil
Method: CorrectFilePath
Description: Checks if file path contains drive letter. If not file is serched
on all drives and first hit is added to file name.
Parameters: TDes& aFilePath: in/out: file path to correct
Return Values: None
Errors/Exceptions: Leaves if some of called leaving methods leaves
-------------------------------------------------------------------------------
*/
EXPORT_C void TStifUtil::CorrectFilePathL( TDes& aFilePath )
{
_LIT( KDriveSelector, ":\\" );
_LIT( KDriveSelectorFormat_1, "%c:" );
_LIT( KDriveSelectorFormat_2, "%c:\\" );
TChar KDriveZ = EDriveZ;//'Z';
_LIT( KBackslash, "\\" );
TInt length = aFilePath.Length();
if (length == 0 )
{
return;
}
if (length > 2 )
{
// Check if file path contains drive selector
if ( aFilePath.Mid( 1, 2 ) == KDriveSelector )
{
// File path contains selector letter so we have nothing to do here
return;
}
}
// Check if file path contains backslash at the begining and
// select proper drive selector format according to this information
TInt driveSelectorFormat = 2;
if ( aFilePath.Mid( 0, 1 ) == KBackslash )
{
driveSelectorFormat = 1;
}
RFs rfs;
if ( rfs.Connect() != KErrNone )
{
return;
}
// Get available drives list, revers it order and move z drive at
// the end of the list.
TDriveList drivesList;
rfs.DriveList(drivesList);
// Set drive variable to last drive (except for Z, which will be checked at the end)
char drive = 'Y' ;
// Loop through all the drives in following order: YX..CBAZ
while(drive >= 'A' && drive <= 'Z')
{
// Do further action only if drive exists
TInt driveint;
rfs.CharToDrive(drive, driveint);
if(drivesList[driveint])
{
//further checking (drive selector and file existence)
// Prepare drive selector
TBuf<3> driveSelector;
if ( driveSelectorFormat == 1 )
{
driveSelector.Format( KDriveSelectorFormat_1, drive );
}
else if ( driveSelectorFormat == 2 )
{
driveSelector.Format( KDriveSelectorFormat_2, drive );
}
aFilePath.Insert( 0, driveSelector );
TEntry entry;
if ( rfs.Entry(aFilePath, entry) == KErrNone )
{
rfs.Close();
return;
}
// File does not exists on selected drive. Restoring orginal file path
aFilePath.Delete( 0, driveSelector.Length() );
}//if(drivesList[driveint])
// Select next drive
//.........这里部分代码省略.........