// ----------------------------------------------------------------------------- // 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; } } }
// 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); }
// 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 }
//------------------------------------------------------------------------------------------------------------ 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); }