本文整理汇总了C++中TDes::Replace方法的典型用法代码示例。如果您正苦于以下问题:C++ TDes::Replace方法的具体用法?C++ TDes::Replace怎么用?C++ TDes::Replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TDes
的用法示例。
在下文中一共展示了TDes::Replace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReplaceSpecialCharsL
// -----------------------------------------------------------------------------
// CapParser::ReplaceSpecialCharsL( TDes& aText, const TDesC& aValue )
// Replaces special characters to xml compliant.
// -----------------------------------------------------------------------------
//
void CapParser::ReplaceSpecialCharsL( TDes& aText, const TDesC& aValue )
{
if ( aValue.Length() > aText.MaxLength() )
{
User::Leave(KErrTooBig);
}
aText.Copy( aValue );
//Replace special characters
for( TInt i = 0; i < aText.Length(); i++ )
{
switch( aText[i] )
{
case KFind1:
if ( aText.Length()+KReplace1().Length()-1 > aText.MaxLength() )
{
User::Leave(KErrTooBig);
}
aText.Replace( i, 1, KReplace1 );
i+=KReplace1().Length()-1;
break;
case KFind2:
if ( aText.Length()+KReplace2().Length()-1 > aText.MaxLength() )
{
User::Leave(KErrTooBig);
}
aText.Replace( i, 1, KReplace2 );
i+=KReplace2().Length()-1;
break;
case KFind3:
if ( aText.Length()+KReplace3().Length()-1 > aText.MaxLength() )
{
User::Leave(KErrTooBig);
}
aText.Replace( i, 1, KReplace3 );
i+=KReplace3().Length()-1;
break;
case KFind4:
if ( aText.Length()+KReplace4().Length()-1 > aText.MaxLength() )
{
User::Leave(KErrTooBig);
}
aText.Replace( i, 1, KReplace4 );
i+=KReplace4().Length()-1;
break;
case KFind5:
if ( aText.Length()+KReplace5().Length()-1 > aText.MaxLength() )
{
User::Leave(KErrTooBig);
}
aText.Replace( i, 1, KReplace5 );
i+=KReplace5().Length()-1;
break;
default:
break;
}
}
}
示例2: UpdateToActualMonthAndDay
// This function is used to update month and day in aBufLocalTime
// to actual month and day to be passed to TTime() constructor.
// Remember using TTime::FormatL() in thelpers.cpp
// has added extra month and a day to aBufLocalTime.
// aBufLocalTime is in format YYMMDD:HHMMSS.MMMMMM
// see TTime::Set() for aBufLocalTime expected format details.
TInt UpdateToActualMonthAndDay(TDes& aBufUTCTime)
{
TInt mVal = 0;
TInt dVal = 0;
TBuf <4> tempBuf;
_LIT(KFormat, "%02d");
//Get the position of colon separator
TInt colon = aBufUTCTime.Locate(':');
// Get Month & Day if Present
switch(colon)
{
case 0: break;
case 8:
{
TLex month = aBufUTCTime.Mid(4,2);
TLex day = aBufUTCTime.Mid(6,2);
month.Val(mVal);
day.Val(dVal);
}
break;
default:
{
// If the colon is at the wrong position
return (KErrArgument);
}
}
// Deduct extra month and a day and update aBufLocalTime
if(mVal > 0 && dVal > 0)
{
mVal-=1;
dVal-=1;
tempBuf.Format(KFormat, mVal);
aBufUTCTime.Replace(4,2, tempBuf);
tempBuf.Format(KFormat, dVal);
aBufUTCTime.Replace(6,2, tempBuf);
}
return(KErrNone);
}
示例3: FigureOutRealPathL
// class CIconFileHandle : public CBase, public MContextBase,
void FigureOutRealPathL(const TDesC& aFullPath, TDes& aRealPath, RFs& aFs)
{
CALLSTACKITEMSTATIC_N(_CL("JuikIcons"), _CL("FigureOutRealPathL"));
if ( aFullPath == AknIconUtils::AvkonIconFileName() )
{
aRealPath.Copy( aFullPath );
return;
}
#ifdef __S60V3__
// Change path to c:\\resource
TParse p; p.Set( aFullPath, 0, 0);
aRealPath=_L("c:\\resource\\");
aRealPath.Append(p.NameAndExt());
#else
// Just use given path
aRealPath=aFullPath;
#endif
#ifdef __WINS__
// in WINS, read always from Z
aRealPath.Replace(0, 1, _L("z"));
#else
// In device, if file doesn't exist, read from E
TBool try_mif=EFalse;
if (p.Ext().CompareF(_L(".mbm"))==0) try_mif=ETrue;
again:
if (! BaflUtils::FileExists(aFs, aRealPath)) {
aRealPath.Replace(0, 1, _L("e"));
if (! BaflUtils::FileExists(aFs, aRealPath)) {
if (try_mif) {
aRealPath=_L("c:\\resource\\");
aRealPath.Append(p.Name());
aRealPath.Append(_L(".mif"));
try_mif=EFalse;
goto again;
}
User::Leave(KErrNotFound);
}
}
#endif
}
示例4: SetRandomAlphaNumericString
//------------------------------------------------------------------------------------------------------------
void CPerfDbCreator::SetRandomAlphaNumericString(TDes& aBuf,TInt aLength, TBool aWithSeed)
{
aBuf.SetLength(aLength);
for (TInt ii=0;ii<aLength;++ii)
{
aBuf[ii]=RandomAlphaNumbericCharCode();
}
if (aWithSeed)
aBuf.Replace(0,8, iTextSeed);
}