textandlocutils/numbergrouping/inc/StateMachine.h
changeset 40 91ef7621b7fc
parent 16 56cd22a7a1cb
equal deleted inserted replaced
21:f2f7b3284356 40:91ef7621b7fc
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *    
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef C_STATE_MACHINE_H
       
    22 #define C_STATE_MACHINE_H
       
    23 
       
    24 #include "NumberGroupingStd.h"
       
    25 
       
    26 NONSHARABLE_CLASS(CStateMachine) : public CBase
       
    27 {
       
    28 public:
       
    29 	static CStateMachine*	NewL(TInt aMaxNumberChars, TInt aMaxNumberStates);
       
    30 	static CStateMachine*	NewLC(TInt aMaxNumberChars, TInt aMaxNumberStates);
       
    31 
       
    32 	virtual ~CStateMachine();
       
    33 
       
    34 	void			AddStateTransistionL(TChar aChar, TInt aState, TInt aNextState);
       
    35 	void			AddStateTransistionL(TInt aDigit, TInt aState, TInt aNextState);
       
    36 
       
    37 	TBool			Matches(const TDesC& aString);
       
    38     
       
    39     /**
       
    40     * This routine writes into a client supplied descriptor a string that is a wildcard version
       
    41     * of the pattern match for this state machine.  It writes characters into the supplied descriptor
       
    42     * to a length of the maximum number of characters to match. 
       
    43     * For each character index, if there is only one possible valid character, it puts in that 
       
    44     * character.  If there are more than one, then the supplied aWildcardChar is written in.
       
    45     * The character '.' in the state machine is not treated as a single character, but as a range,
       
    46     * and so the wildcard character is written in for the '.'.
       
    47     * 
       
    48     * aWildcardPattern must have MaxLength which is equal or greater than iMaxNumberStates
       
    49     * 
       
    50     * @param    aWildcardChar   The character to put in aExamplePattern if there is no single 
       
    51     *                           valid character at that point
       
    52     * @param    aWildcardedPattern Descriptor to write the wildcarded number pattern into
       
    53     */
       
    54     void            GetWildcardVersionOfPattern( 
       
    55         TText aWildcardChar, 
       
    56         TDes& aWildcardedPattern ) const;
       
    57 
       
    58 private:
       
    59 	CStateMachine(TInt aMaxNumberChars, TInt aMaxNumberStates);
       
    60 
       
    61 	void			ConstructL();
       
    62 	virtual TInt	MapIndex(TChar aChar, RArray<TInt>& aIndices);
       
    63 	
       
    64 	TInt**			iStateTable;
       
    65 	TInt			iMaxNumberChars;
       
    66 	TInt			iMaxNumberStates;
       
    67 };
       
    68 
       
    69 #endif // C_STATE_MACHINE_H
       
    70 // End of File