// ----------------------------------------------------------------------------- // ModifyClientUid // ----------------------------------------------------------------------------- // void CHssIapHandler::ModifyClientUid( TDes& aUid ) { DEBUG("CHssIapHandler::ModifyClientUid"); TInt indx = aUid.Find( KMark1 ); if ( KErrNotFound != indx ) { aUid.Delete( indx, 1 ); indx = aUid.Find( KMark2 ); if ( KErrNotFound != indx ) { aUid.Delete( indx, 1 ); } } }
void CUtils::StripSpaces(TDes& aText) { TInt i; for (i=0; i<aText.Length(); i++) if (aText[i] != ' ') break; if (i) aText.Delete(0,i); for (i=aText.Length()-1; i>=0; i--) if (aText[i] != ' ') break; if (i != aText.Length()-1) aText.Delete(i+1,aText.Length()-1-i); }
// ----------------------------------------------------------------------------- // ModifyClientUid // ----------------------------------------------------------------------------- // void CHotSpotSession::ModifyClientUid( TDes& aUid ) { DEBUG("CHotSpotSession::ModifyClientUid"); TInt indx = aUid.Find( KMark1 ); if ( KErrNotFound != indx ) { aUid.Delete( indx, 1 ); indx = aUid.Find( KMark2 ); if ( KErrNotFound != indx ) { aUid.Delete( indx, 1 ); } } }
void CXmppChannelIdUtilities::ValidateId(TDes& aId) { aId.LowerCase(); // Remove non-ascii characters for(TInt i = aId.Length() - 1; i >= 0; i--) { if(aId[i] >= 123) { aId[i] = (aId[i] % 26) + 97; } else if(aId[i] != 32 && aId[i] != 95 && aId[i] != 45 && (aId[i] <= 47 || (aId[i] >= 57 && aId[i] <= 64) || (aId[i] >= 91 && aId[i] <= 96))) { aId.Delete(i, 1); } } // Trim whitespace aId.Trim(); // Add hyphens for(TInt i = 0; i < aId.Length(); i++) { if(aId[i] == 32 || aId[i] == 95) { aId[i] = 45; } } }
void CntFilterDetail::TMatch::stripOutNonDigitChars(TDes& text) { for (TInt chrPos = 0; chrPos < text.Length(); ++chrPos) { TChar chr = text[chrPos]; if (!chr.IsDigit()) { text.Delete(chrPos, 1); --chrPos; } } }
/** Strip out any non-digit characters before we convert the phone number to an integer. @param aText Phone number which on return will have any non-digit characters removed. */ void CPplCommAddrTable::TMatch::StripOutNonDigitChars(TDes& aText) { for(TInt chrPos = 0; chrPos < aText.Length(); ++chrPos) { TChar chr = aText[chrPos]; if (!chr.IsDigit() ) { aText.Delete(chrPos, 1); --chrPos; } } }
// --------------------------------------------------------------------------- // CPresenceXDM::GetUniqueRuleId() // --------------------------------------------------------------------------- // void CPresenceXDM::GetUniqueRuleId(TDes& aRuleId) { OPENG_DP(D_OPENG_LIT( " CPresenceXDM::GetUniqueRuleId" )); aRuleId.Copy(KPresRuleIDPrefix); TInt myNumber; // make sure that newly created rule id doesnt exist in the document while (IsRuleExist(aRuleId)) { aRuleId.Delete(KPresRuleIDPrefixLength, KPresRuleIDNumLength); myNumber = Math::Random() - KPresRuleIdCalc; aRuleId.AppendNumFixedWidth(myNumber,EDecimal,KPresRuleIDNumLength); } OPENG_DP(D_OPENG_LIT( " aRuleId = %S" ), &aRuleId); }
/** Removes no dir markers from source text. */ void CResourceLoader::RemoveNoDirMarkers(TDes& aText) { TInt nextkey(0); while (nextkey < aText.Length()) { nextkey = aText.Locate(KDirNotFound); if (nextkey != KErrNotFound) { aText.Delete(nextkey, 1); nextkey++; } else { break; } } }
// --------------------------------------------------------------------------- // 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 ); } } } }
/** 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); aDest.Insert(desCount, subsMarker); desOffset += KExtraSpaceForSubStringDirMarkers; } } } } // Adjust substring directionality markers if necessary // and if there is enough room in destination string if (checkSubstringDirectionalities) { TText mainMarker = (aDirectionality == TBidiText::ELeftToRight ? KLRMarker : KRLMarker); TInt freeSpace = aDest.MaxLength() - aDest.Length(); // If not already done, protect the directionality of the original string // and all of the KSubStringSeparator separated substrings. if (freeSpace > 0 && aDest.Length() && aDest[0] != mainMarker && aDest[0] != KSubStringSeparator && aDest[0] != KDirNotFound) { aDest.Insert(0, TPtrC(&mainMarker, 1)); freeSpace--; } // Find and protect KSubStringSeparator separated substrings. // Go through string backwards so that any changes will not affect indexes // that are not yet checked. TInt j(aDest.Length()-1); while (freeSpace > 0 && j >= 0) { if (aDest[j] == KSubStringSeparator && j < (aDest.Length() - 1) && aDest[j+1] != mainMarker && aDest[j+1] != KDirNotFound) { aDest.Insert(j+1, TPtrC(&mainMarker, 1)); freeSpace--; } j--; } } return replaceCount; }
/** Resolves directionality of the given source text. Place-holder strings are removed so that they don't affect the result. */ TBidiText::TDirectionality CResourceLoader::ResolveDirectionality(TDes& aText, TBool* aFound) { TInt i = 0; // Remove place-holders from string so they don't affect directionality // length parameters e.g. "[29]" do not contain strongly directional // characters so can ignore them. while (i < aText.Length()) { TPtrC remainder = aText.Right(aText.Length() - i); TInt nextKey = remainder.Locate(KKeyPrefix); i += nextKey; if (nextKey != KErrNotFound && i < aText.Length() - 1) { TInt lastCharInKey = i + 1; // skip possible key index TText t = aText[lastCharInKey]; if (t >= '0' && t <= '9') { lastCharInKey++; if (lastCharInKey < aText.Length()) { t = aText[lastCharInKey]; if (t >= '0' && t <= '9') { lastCharInKey++; } } } // lastCharInKey is now the index of 'N' or 'U' in the key if (lastCharInKey < aText.Length()) { TText t = aText[lastCharInKey]; if (t == 'U' || t == 'N') { // found key, delete it and continue loop to // search for the next key aText.Delete(i, lastCharInKey - i + 1); } // This was not a proper key - check the remaining string else { i = lastCharInKey + 1; } } // end of string encountered - stop else { break; } } // no key found - stop else { break; } } return TBidiText::TextDirectionality(aText, aFound); }
/* ------------------------------------------------------------------------------- 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 if(drive == 'Z') break; // the last driver else if(drive == 'A' ) drive = 'Z'; //after checking A check Z else drive = (TChar)(TInt(drive)-1) ; //after checking Y check X and so on in reverse alphabetical order } //while rfs.Close(); }