Exemplo n.º 1
0
    Parser::Parser(const vector<Production>& productions, const string& parserTablePath) : BasicParser(productions), parserTablePath(parserTablePath)
    {
#ifdef _DEBUG
        stream.open("ParserResult.txt", fstream::out | fstream::binary);
#endif
        // String Begin
        Rule quotationMarks = Rule('\"', &context);
        Rule ruleString = quotationMarks + *!quotationMarks + quotationMarks;
        ruleString.buildDFA();
        ruleString.setShowName("\"{String}\"");
        Production::Item itemString(ruleString);
        // String End

        // Digit Start
        Rule _0('0', &context);
        Rule _9('9', &context);
        Rule _0_9  = _0 - _9;
        Rule ruleDigit = +_0_9;
        ruleDigit.buildDFA();
        ruleDigit.setShowName("\"{Digit}\"");
        Production::Item itemDigit(ruleDigit);
        // Digit End

        // Real Start
        Rule _point('.', &context);
        Rule ruleReal = *_0_9 + _point + +_0_9;
        ruleReal.buildDFA();
        ruleReal.setShowName("\"{Real}\"");
        Production::Item itemReal(ruleReal);
        // Real End

        // Letter Start
        Rule _('_', &context);
        Rule _a('a', &context);
        Rule _z('z', &context);
        Rule _A('A', &context);
        Rule _Z('Z', &context);
        Rule _a_z = _a - _z;
        Rule _A_Z = _A - _Z;
        Rule ruleLetter = ((+_ + ruleDigit) |
            (+(_ | _a_z | _A_Z))) +
            *(_ | ruleDigit | _a_z | _A_Z);
        ruleLetter.buildDFA();
        ruleLetter.setShowName("\"{Letter}\"");
        Production::Item itemLetter(ruleLetter);
        // Letter End

        vts.push_back(pair<string, Production::Item>("{String}", itemString));
        vts.push_back(pair<string, Production::Item>("{Digit}",  itemDigit));
        vts.push_back(pair<string, Production::Item>("{Real}",   itemReal));
        vts.push_back(pair<string, Production::Item>("{Letter}", itemLetter));
    }
// ---------------------------------------------------------------------------
// CAknMemorySelectionModelMultiDrive::AddDefaultItemToLbxL
//
// If drive has volume label, use it.
// Otherwise use drive letter for drive name.
// ---------------------------------------------------------------------------
//
void CAknMemorySelectionModelMultiDrive::AddDefaultItemToLbxL(
    const TCFDDriveInfo& aDriveInfo )
    {
    HBufC* lbxItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
    TPtr itemString( lbxItemBuf->Des() );
    TDriveUnit driveUnit( aDriveInfo.iDriveNumber );

    // Item text is affected by layout
    switch( iLayout )
        {
        case ELayoutSettingPage:
            {
            if( aDriveInfo.iVolumeLabel.Length() > 0 )
                {
                itemString.Append( driveUnit.Name() );
                itemString.Append( KSpaceChar );
                itemString.Append( aDriveInfo.iVolumeLabel );
                }
            else
                {
                itemString.Append( driveUnit.Name() );
                }
            break;
            }
        case ELayoutPopupMenu:
        case ELayoutDoublePopup:
            {
            itemString.Format( KImageHeader, EIconDeviceMemory );
            itemString.Append( KTabChar );

            if( aDriveInfo.iVolumeLabel.Length() > 0 )
                {
                itemString.Append( driveUnit.Name() );
                itemString.Append( KSpaceChar );
                itemString.Append( aDriveInfo.iVolumeLabel );
                }
            else
                {
                itemString.Append( driveUnit.Name() );
                }
            break;
            }
        }

    // Finally!: append the formatted string to listbox
    User::LeaveIfError( iListBoxArray.Append( lbxItemBuf ) );
    CleanupStack::Pop( lbxItemBuf );
    _LOG1( "[CAknMemorySelectionModelMultiDrive] Item string added to lbx array: %S", &itemString );
    _LOG1( "itemString length=%d", itemString.Length() );
    }
Exemplo n.º 3
0
// -----------------------------------------------------------------------------
// CFindUtilWestern::MatchAdaptiveRefineL
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//  
TBool CFindUtilWestern::MatchAdaptiveRefineL( const TDesC& aItemString, 
	const TDesC& aSearchText, HBufC*& aNextChars )
	{
    if ( aItemString.Length() == 0 )
        {
        return EFalse;
        }
    if ( aSearchText.Length() == 0 )
        {        
        UpdateNextCharsFromString( aNextChars, aItemString );
        return ETrue;
        }
        
    if( iDigraphChars == NULL )
        {
        iDigraphChars = StringLoader::LoadL( R_QTN_ADS_DIGRAPH );
        TPtr digraph = iDigraphChars->Des();
        digraph.UpperCase();
        }
        
    TBuf<KAknStringBufferSize> itemString(aItemString);
    itemString.UpperCase();

    //AS does not show tone marks and diacritics when language is Thai.
    TLanguage lang = User::Language();  
    if ( lang == ELangThai )
        {
        for(TInt i=0; i < itemString.Length(); i++)
            {
            if(IsThaiSpecialCharacter( itemString[i] ))
                {
                itemString.Delete(i,1);
                }
            }
        }

    if ( IsIndicWord(aItemString) )
    	{
    	// itemString contains Devanagari letters
    	return IsIndicAdaptiveFindMatch( itemString, aSearchText, aNextChars, iInputLanguage );		
    	}
    else 
    	{
    	return IsAdaptiveFindMatch( itemString, aSearchText, aNextChars, iInputLanguage, iDigraphChars->Des() );				
    	}    
	}
// ---------------------------------------------------------------------------
// CAknMemorySelectionModelMultiDrive::AddRemoteItemToLbxL
// ---------------------------------------------------------------------------
//
void CAknMemorySelectionModelMultiDrive::AddRemoteItemToLbxL( const TCFDDriveInfo& aDriveInfo )
    {
    HBufC* lbxItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
    TPtr itemString( lbxItemBuf->Des() );

    // Item text is affected by layout
    switch( iLayout )
        {
        case ELayoutPopupMenu:
            {
            // A-column icon:
            itemString.Format( KImageHeader, EIconRemoteDrive );
            itemString.Append( KTabChar );

            // 1st row text:
            if( aDriveInfo.iVolumeLabel.Length() > 0 )
                {
                // Append drive name if it has one
                itemString.Append( aDriveInfo.iVolumeLabel );
                }
            else
                {
                // Use default drive description
                itemString.Append( *iLocStringArray[ ETextRemoteDrive ] );
                }
            break;
            }
        case ELayoutSettingPage:
            {
            // 1st row text:
            if( aDriveInfo.iVolumeLabel.Length() > 0 )
                {
                // Append drive name if it has one
                itemString.Append( aDriveInfo.iVolumeLabel );
                }
            else
                {
                // Use default drive description
                itemString.Append( *iLocStringArray[ ETextRemoteDrive ] );
                }
            break;
            }
        case ELayoutDoublePopup:
            {
            // A-column icon:
            itemString.Format( KImageHeader, EIconRemoteDrive );
            itemString.Append( KTabChar );

            // 1st row text:
            if( aDriveInfo.iVolumeLabel.Length() > 0 )
                {
                // Append drive name if it has one
                itemString.Append( aDriveInfo.iVolumeLabel );
                itemString.Append( KTabChar );
                }
            else
                {
                // Use default drive description
                itemString.Append( *iLocStringArray[ ETextRemoteDrive ] );
                itemString.Append( KTabChar );
                }

            if( aDriveInfo.iDriveStatus == EDriveOK )
                {
                // 2nd row text:
                // Currently Remote drive does not support query for available
                // disk space, so just return " "
                _LIT( KEmptySpace, " ");
                itemString.Append( KEmptySpace ); 

                //if( aDriveInfo.iConnectionState == KMountStronglyConnected )
                //    {
                // D-column icon: Show active icon if drive has no error
                //    itemString.Append( KTabChar );
                //    itemString.AppendFormat(
                //      KImageHeader, EIconRemoteDriveActive );
                //    }
                //else // KMountNotConnected
                //    {
                    // D-column icon: Show active icon if drive has no error
                itemString.Append( KTabChar );
                //    }
                }
            else
                {
                // 2nd row text:
                itemString.Append( *iLocStringArray[ ETextMMCUnavailable ] );
                // D-column is empty if error.
                }
            break;
            }
        }

    // Finally!: append the formatted string to listbox
    User::LeaveIfError( iListBoxArray.Append( lbxItemBuf ) );
    CleanupStack::Pop( lbxItemBuf );
    _LOG1( "[CAknMemorySelectionModelMultiDrive] Item string added to lbx array: %S", &itemString );
    _LOG1( "itemString length=%d", itemString.Length() );
    }
// ---------------------------------------------------------------------------
// CAknMemorySelectionModelMultiDrive::AddMMCItemToLbxL
// ---------------------------------------------------------------------------
//
void CAknMemorySelectionModelMultiDrive::AddMMCItemToLbxL(
    const TCFDDriveInfo& aDriveInfo )
    {
    HBufC* lbxItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
    TPtr itemString( lbxItemBuf->Des() );
    HBufC* textItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
    TPtr textString( textItemBuf->Des() );
    HBufC* textItemBuf2 = HBufC::NewLC( KListBoxEntryMaxLength );
    TPtr textString2( textItemBuf2->Des() );
    TDriveUnit driveUnit( aDriveInfo.iDriveNumber );

    // Item text is affected by layout
    switch( iLayout )
        {
        case ELayoutPopupMenu:
            {
            // A-column icon:
            switch ( aDriveInfo.iDriveStatus )
                {
                case EDriveNotReady:
                    {
                    itemString.Format( KImageHeader, EIconMMCUnavailable );
                    break;
                    }
                case EDriveLocked:
                    {
                    itemString.Format( KImageHeader, EIconMMCLocked );
                    break;
                    }
                 default: // Normal condition
                    {
                    itemString.Format( KImageHeader, EIconMMC );
                    break;
                    }
                }
            itemString.Append( KTabChar );

            // 1st row text:
            if( ( aDriveInfo.iDriveStatus == EDriveOK ) &&
                ( aDriveInfo.iVolumeLabel.Length() > 0 ) )
                {
                StringLoader::Format(
                    textString2,
                    *iLocStringArray[ ETextMMCNamed ],
                    KIndexFirst,
                    driveUnit.Name()
                    );
                StringLoader::Format(
                    textString,
                    textString2,
                    KIndexSecond,
                    aDriveInfo.iVolumeLabel
                    );
                }
            else if ( aDriveInfo.iDriveStatus == EDriveNotReady )
                {
                //textString.Format(
                //    *iLocStringArray[ ETextMMCUnavailable ],
                //    driveUnit.Name() );
                StringLoader::Format(
                    textString,
                    *iLocStringArray[ ETextMMCUnavailable ],
                    KNoIndex,
                    driveUnit.Name()
                    );
                }
            else if( aDriveInfo.iDriveStatus == EDriveLocked )
                {
                //textString.Format(
                //    *iLocStringArray[ ETextMMCLocked ],
                //    driveUnit.Name() );
                StringLoader::Format(
                    textString,
                    *iLocStringArray[ ETextMMCLocked ],
                    KNoIndex,
                    driveUnit.Name()
                    );
                }
            else
                {
                // Use default drive description
                //textString.Format(
                //    *iLocStringArray[ ETextMMCDefaultName ],
                //    driveUnit.Name() );
                StringLoader::Format(
                    textString,
                    *iLocStringArray[ ETextMMCDefaultName ],
                    KNoIndex,
                    driveUnit.Name()
                    );
                }
            itemString.Append( textString );

            break;
            }
        case ELayoutSettingPage:
            {
            // 1st row text:
            if( aDriveInfo.iVolumeLabel.Length() > 0 )
                {
                // Append drive name if it has one
                //itemString.Format(
                //    *iLocStringArray[ ETextMMCNamed ],
                //    driveUnit.Name(),
                //    aDriveInfo.iVolumeLabel
                //    );
                StringLoader::Format(
                    textString,
                    *iLocStringArray[ ETextMMCNamed ],
                    KIndexFirst,
                    driveUnit.Name()
                    );
                StringLoader::Format(
                    itemString,
                    textString,
                    KIndexSecond,
                    aDriveInfo.iVolumeLabel
                    );
                }
            else
                {
                //itemString.Format(
                //    *iLocStringArray[ ETextMMCDefaultName ],
                //    driveUnit.Name()
                //    );
                StringLoader::Format(
                    itemString,
                    *iLocStringArray[ ETextMMCDefaultName ],
                    KNoIndex,
                    driveUnit.Name()
                    );
                }
            break;
            }
        case ELayoutDoublePopup:
            {
            // A-column icon:
            if( aDriveInfo.iDriveStatus == EDriveNotReady )
                {
                itemString.Format( KImageHeader, EIconMMCUnavailable );
                }
            else
                {
                itemString.Format( KImageHeader, EIconMMC );
                }
            itemString.Append( KTabChar );

            // 1st row text:
            if( aDriveInfo.iVolumeLabel.Length() > 0 )
                {
                StringLoader::Format(
                    textString2,
                    *iLocStringArray[ ETextMMCNamed ],
                    KIndexFirst,
                    driveUnit.Name()
                    );
                StringLoader::Format(
                    textString,
                    textString2,
                    KIndexSecond,
                    aDriveInfo.iVolumeLabel
                    );
                }
            else
                {
                // Use default drive description
                //textString.Format(
                //    *iLocStringArray[ ETextMMCDefaultName ],
                //    driveUnit.Name()
                //   );
                StringLoader::Format(
                    textString,
                    *iLocStringArray[ ETextMMCDefaultName ],
                    KNoIndex,
                    driveUnit.Name()
                    );
                }
            itemString.Append( textString );
            itemString.Append( KTabChar );

            // 2nd row text:
            switch( aDriveInfo.iDriveStatus )
                {
                case EDriveNotReady:
                    {
                    itemString.Append(
                        *iLocStringArray[ ETextMMCUnavailable ] );
                    break;
                    }
                case EDriveLocked:
                    {
                    itemString.Append( *iLocStringArray[ ETextMMCLocked ] );
                    break;
                    }
                case EDriveOK:
                default:
                    {
                    HBufC* buffer;
                    TInt64 freeSpace = aDriveInfo.iDiskSpace;
                    if ( freeSpace >= 0 )
                        {
                        buffer = HBufC::NewLC( KListBoxEntryMaxLength );  
                        TPtr unitStr( buffer->Des() );
                        AknCFDUtility::SetSecondRowTextL( freeSpace, unitStr );
                        }
                    else
                        {
                        // Disk space is unavailable
                        buffer = StringLoader::LoadLC(
                                    R_CFD_QTN_MEMC_SPACE_NOT_AVAILABLE,
                                    iCoeEnv);
                        }
                    itemString.Append( *buffer );//Free mem text
                    CleanupStack::PopAndDestroy( buffer );
                    break;
                    }
                }
            break;
            }
        }

    // Finally!: append the formatted string to listbox
    User::LeaveIfError( iListBoxArray.Append( lbxItemBuf ) );
    CleanupStack::PopAndDestroy( 2 ); // textItemBuf2, textItemBuf
    CleanupStack::Pop( lbxItemBuf );
    _LOG1( "[CAknMemorySelectionModelMultiDrive] Item string added to lbx array: %S", &itemString );
    _LOG1( "itemString length=%d", itemString.Length() );
    }
// --------------------------------------------------------------------------
// CAknMemorySelectionModelMultiDrive::AddInternalStorageItemToLbxL
//
//
// --------------------------------------------------------------------------
//
void CAknMemorySelectionModelMultiDrive::AddInternalStorageItemToLbxL(
    const TCFDDriveInfo& aDriveInfo )
    {
    HBufC* lbxItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
    TPtr itemString( lbxItemBuf->Des() );
    HBufC* textItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
    TPtr textString( textItemBuf->Des() );
    TDriveUnit driveUnit( aDriveInfo.iDriveNumber );

    // Item text is affected by layout
    switch( iLayout )
        {
        case ELayoutPopupMenu:
            {
            // A-column icon:
            if( aDriveInfo.iDriveStatus == EDriveOK )
                {
                itemString.Format( KImageHeader, EIconInternalMassStorage );
                }
            else
                {
                itemString.Format( KImageHeader,
                                   EIconInternalMassStorageUnavailable );
                }
            itemString.Append( KTabChar );

            // 1st row text:
            if( aDriveInfo.iDriveStatus == EDriveOK )
                {
                StringLoader::Format(
                    textString,
                    *iLocStringArray[ ETextInternalMassStorage ],
                    KNoIndex,
                    driveUnit.Name()
                    );
                }
            else
                {
                StringLoader::Format(
                    textString,
                    *iLocStringArray[ ETextInternalMassStorageUnavailable ],
                    KNoIndex,
                    driveUnit.Name()
                    );
                }
            itemString.Append( textString );
            break;
            }
        case ELayoutSettingPage:
            {
            // 1st row text:
            StringLoader::Format(
                    itemString,
                    *iLocStringArray[ ETextInternalMassStorage ],
                    KNoIndex,
                    driveUnit.Name()
                    );
            break;
            }
        case ELayoutDoublePopup:
            {
            // A-column icon:
            itemString.Format( KImageHeader, EIconInternalMassStorage );
            itemString.Append( KTabChar );

            // 1st row text:
            StringLoader::Format(
                    textString,
                    *iLocStringArray[ ETextInternalMassStorage ],
                    KNoIndex,
                    driveUnit.Name()
                    );
            itemString.Append( textString );
            itemString.Append( KTabChar );

            // 2nd row text:
            if ( aDriveInfo.iDriveStatus == EDriveOK )
                {
                HBufC* buffer;
                TInt64 freeSpace = aDriveInfo.iDiskSpace;
                if ( freeSpace >= 0 )
                    {
                    buffer = HBufC::NewLC( KListBoxEntryMaxLength );  
                    TPtr unitStr( buffer->Des() );
                    AknCFDUtility::SetSecondRowTextL( freeSpace, unitStr );
                    }
                else
                    {
                    // Disk space is unavailable
                    buffer = StringLoader::LoadLC(
                                R_CFD_QTN_MEMC_SPACE_NOT_AVAILABLE,
                                iCoeEnv);
                    }
                itemString.Append( *buffer );//Free mem text
                CleanupStack::PopAndDestroy( buffer );
                }
            else
                {
                itemString.Append(
                    *iLocStringArray[
                        ETextInternalMassStorageUnavailable ] );
                }
            break;
            }
        }

    // Finally!: append the formatted string to listbox
    User::LeaveIfError( iListBoxArray.Append( lbxItemBuf ) );
    CleanupStack::PopAndDestroy( textItemBuf );
    CleanupStack::Pop( lbxItemBuf );
    _LOG1( "[CAknMemorySelectionModelMultiDrive] Item string added to lbx array: %S", &itemString );
    _LOG1( "itemString length=%d", itemString.Length() );
    }