void CIntRangeTestParameter::Construct(TDes& aValue) { if(aValue.Find(_L("..")) != KErrNotFound) { TInt pos = aValue.Find(_L("..")); TLex startLex(aValue.Left(pos)); TLex endLex(aValue.Mid(pos+2)); if(startLex.Val(iStart)!=KErrNone) return; // checks if startLex is at end of string, if not there was garbage in the string so throw it out else if(!startLex.Eos()) return; if(endLex.Val(iFinish)!=KErrNone) return; // checks if startLex is at end of string, if not there was garbage in the string so throw it out else if(!endLex.Eos()) return; // checks if range is doable if(iStart > iFinish) return; } else return; iValid = ETrue; }
void CIntTestParameter::Construct(TDes& aValue) { TLex lexValue(aValue); if(aValue.Left(2) == _L("0x")) { // its a hex number TUint hexValue; TLex hexLex(aValue.Mid(2)); if(hexLex.Val(hexValue, EHex)!=KErrNone) return; // checks if hexLex is at end of string, if not there was garbage in the string // so throw it out else if(!hexLex.Eos()) return; iValue = STATIC_CAST(TInt,hexValue); } else if(lexValue.Val(iValue)!=KErrNone) return; // checks if lexValue is at end of string, if not there was garbage in the string // so throw it out else if(!lexValue.Eos()) return; iValid = ETrue; }
// Make profile name unique. Must already be a legal filename void CProfileListDialog::MakeNameUniqueL(TDes &aName) { HBufC *fileNameBuf = HBufC::NewLC(KMaxFileName); TPtr fileName = fileNameBuf->Des(); HBufC *newNameBuf = HBufC::NewLC(KMaxFileName); TPtr newName = newNameBuf->Des(); newName = aName; TBool done = EFalse; TInt num = 2; while ( !done ) { fileName = iProfileDirectory; fileName.Append(newName); TEntry dummy; TInt err = CEikonEnv::Static()->FsSession().Entry(fileName, dummy); if ( err == KErrNotFound ) { // Have a unique name aName = newName; break; } User::LeaveIfError(err); // Start adding numbers to the end of the name if ( aName.Length() > (KMaxFileName + 14) ) { aName = aName.Left(KMaxFileName + 14); } newName.Format(KUniqueProfileFormat, &aName, num); num++; } CleanupStack::PopAndDestroy(2); //fileNameBuf, newNameBuf; }
TBool CLog::ReadLogLineL(TDes& aLine) { TBuf8<2> character=_L8(" "); TBuf8<4> lineEndTestBuf=_L8(" "); aLine.SetLength(0); while (lineEndTestBuf!=KUnicodeLineEnd) { User::LeaveIfError(iLogFile.Read(character,2)); if (character.Length()>0) { lineEndTestBuf[0]=lineEndTestBuf[2]; lineEndTestBuf[1]=lineEndTestBuf[3]; lineEndTestBuf[2]=character[0]; lineEndTestBuf[3]=character[1]; const TPtrC16 widePtr((TUint16*)character.Ptr(),1); aLine.Append(widePtr); } else { return EFalse; } } aLine=aLine.Left(aLine.Length()-2); // Strip off \n\r. return ETrue; }
LOCAL_C TInt readConsoleLineBuf(const TDesC& aPrompt, TDes& aBuf) { test.Printf(_L("\n ")); TBool quit = EFalse; _LIT(KDeleteChar, "\b \b"); test.Printf(aPrompt); while (!quit) { TKeyCode k = test.Getch(); TChar key = k; switch (key) { case EKeyBackspace: if (aBuf.Length() > 0) { test.Printf(KDeleteChar); aBuf = aBuf.Left(aBuf.Length() - 1); } break; case EKeyEnter: if (aBuf.Length()) quit = ETrue; else test.Printf(_L("\nLogin, password and server address cannot be zero length ")); break; default: test.Printf(_L("%c"), key); aBuf.Append(key); break; } } return(KErrNone); }
// --------------------------------------------------------------------------- // CAknMemorySelectionModelMultiDrive::GetItem // --------------------------------------------------------------------------- // void CAknMemorySelectionModelMultiDrive::GetItem( TInt aIndex, TDes& aItem ) { aItem = iListBoxArray[ aIndex ]->Des(); if( iLayout == ELayoutPopupMenu || iLayout == ELayoutDoublePopup ) { // On layout with graphic, delete image index. _LIT( KTab, "\t" ); TInt tabIndex( aItem.Find( KTab ) ); if( tabIndex >= 0 ) { aItem.Delete( 0, tabIndex + 1 ); } if( iLayout == ELayoutDoublePopup ) { tabIndex = aItem.Find( KTab ); if( tabIndex >= 0 ) { aItem = aItem.Left( tabIndex ); } } } }