Represents the state machine. This maintains the context in which the state machine runs. More...
Public Member Functions | |
string | RemoveComments (string text) |
Entry point for callers to filter text. Removes C++-style line and block comments from the text. | |
char | GetNextCharacter () |
Get the next character from the input. | |
void | OutputCharacter (char character) |
Write the character to the context. This is how the parser accumulates the filtered text. | |
Private Member Functions | |
void | _SetNextState (CurrentState newState) |
Helper method to transition the state machine to the specified state. Does nothing if the new state is the same as the old state. Instantiates the state class the first time the state class is needed. | |
char IStateContext. | GetNextCharacter () |
Retrieve the next character from the input. | |
void IStateContext. | OutputCharacter (char character) |
Save the character to the accumulation of the filtered text. | |
Private Attributes | |
string | _inputText = string.Empty |
The text to be filtered. | |
int | _textIndex = 0 |
Index into the text to be filtered. | |
StringBuilder | _outputText = new StringBuilder() |
The results of the filtering. | |
Dictionary< CurrentState, IStateBehavior > | _stateBehaviors = new Dictionary<CurrentState, IStateBehavior>() |
Maps values from the CurrentState enumeration to instances of the IStateBehavior representing the behavior for that state. | |
CurrentState | _currentState |
The current state of the machine. | |
IStateBehavior | _currentStateBehavior = new State_NormalText() |
The current behavior (that is, a reference to the state behavior class) for the current state. | |
Represents the state machine. This maintains the context in which the state machine runs.
To use:
Definition at line 695 of file State_Class.cs.
|
inlineprivate |
Helper method to transition the state machine to the specified state. Does nothing if the new state is the same as the old state. Instantiates the state class the first time the state class is needed.
newState | A value from the CurrentState enumeration indicating the state to which to transition. |
Definition at line 742 of file State_Class.cs.
References StateContext_Class._currentState, StateContext_Class._currentStateBehavior, StateContext_Class._stateBehaviors, and State_Factory.CreateState().
Referenced by StateContext_ClassImpl.RemoveComments(), and StateContext_Class.RemoveComments().
|
inlineprivate |
Retrieve the next character from the input.
Implements IStateContext.
Definition at line 799 of file State_Class.cs.
References StateContext_Class._inputText, StateContext_Class._textIndex, and State_Constants.EOF.
|
inlineprivate |
Save the character to the accumulation of the filtered text.
character | The character to save. |
Implements IStateContext.
Definition at line 815 of file State_Class.cs.
References StateContext_Class._outputText, and State_Constants.EOF.
|
inline |
Entry point for callers to filter text. Removes C++-style line and block comments from the text.
text | The text to filter. |
Definition at line 769 of file State_Class.cs.
References StateContext_Class._currentState, StateContext_Class._currentStateBehavior, StateContext_Class._inputText, StateContext_Class._outputText, StateContext_Class._SetNextState(), StateContext_Class._textIndex, and IStateBehavior.GoNext().
Referenced by State_Exercise.Run().
|
private |
The current state of the machine.
Definition at line 721 of file State_Class.cs.
Referenced by StateContext_Class._SetNextState(), StateContext_ClassImpl._SetNextState(), StateContext_ClassImpl.RemoveComments(), and StateContext_Class.RemoveComments().
|
private |
The current behavior (that is, a reference to the state behavior class) for the current state.
Definition at line 727 of file State_Class.cs.
Referenced by StateContext_Class._SetNextState(), StateContext_ClassImpl.RemoveComments(), and StateContext_Class.RemoveComments().
|
private |
The text to be filtered.
Definition at line 700 of file State_Class.cs.
Referenced by StateContext_Class.GetNextCharacter(), StateContext_ClassImpl.GetNextCharacter(), StateContext_ClassImpl.RemoveComments(), and StateContext_Class.RemoveComments().
|
private |
The results of the filtering.
Definition at line 710 of file State_Class.cs.
Referenced by StateContext_Class.OutputCharacter(), StateContext_ClassImpl.OutputCharacter(), StateContext_ClassImpl.RemoveComments(), and StateContext_Class.RemoveComments().
|
private |
Maps values from the CurrentState enumeration to instances of the IStateBehavior representing the behavior for that state.
Definition at line 716 of file State_Class.cs.
Referenced by StateContext_Class._SetNextState(), and StateContext_ClassImpl._SetNextState().
|
private |
Index into the text to be filtered.
Definition at line 705 of file State_Class.cs.
Referenced by StateContext_Class.GetNextCharacter(), StateContext_ClassImpl.GetNextCharacter(), StateContext_ClassImpl.RemoveComments(), and StateContext_Class.RemoveComments().