9#ifndef __STATE_CLASS_H__
10#define __STATE_CLASS_H__
Wraps a private implementation of the state machine. The implementation maintains the context in whic...
std::string RemoveComments(std::string text)
Entry point for callers to filter text. Removes C++-style line and block comments from the text.
std::unique_ptr< IStateContext > _stateContextimpl
Pointer to the actual implementation.
StateContext_Class()
Default constructor.
The namespace containing all Design Pattern Examples implemented in C++.
const char EOF_CHAR
Indicates End-of-file (no more data available).
CurrentState
Represents the current state of the state machine.
@ SingleQuotedText
‘’` transitions to EscapedSingleQuoteText, \ transitions to NormalText, EOF_CHAR transitions to Done
@ DoubleQuotedText
\ transitions to EscapedDoubleQuoteText, " transitions to NormalText, EOF_CHAR transitions to Done
@ BlockComment
* transitions to EndBlockComment, EOF_CHAR transitions to Done
@ Initial
State before the state machine actually starts. transitions to NormalText.
@ EndBlockComment
/ transitions to NormalText, EOF_CHAR transitions to Done, all else transitions to BlockComment
@ LineComment
\\n transitions to NormalText, EOF_CHAR transitions to Done
@ Done
Indicates processing is done.
@ StartComment
/ transitions to LineComment, * transitions to BlockComment, EOF_CHAR transitions to Done,...
@ NormalText
" transitions to QuotedText, / transitions to StartComment, EOF_CHAR transitions to Done
@ EscapedDoubleQuoteText
\ transitions to QuotedText, EOF_CHAR transitions to Done
@ EscapedSingleQuoteText
\ transitions to SingleQuotedText, EOF_CHAR transitions to Done
Represents a class that implements one state of the state machine.
std::shared_ptr< IStateBehavior > shared_ptr_t
Alias to make using a shared pointer easier.
virtual ~IStateBehavior()
Virtual destructor as required for interfaces.
virtual CurrentState GoNext(IStateContext *context)=0
Represents the context as passed to each state class.
std::shared_ptr< IStateContext > shared_ptr_t
Alias to make using a shared pointer easier.
virtual void OutputCharacter(char character)=0
Write the character to the context-> This is how the parser accumulates the filtered text.
virtual char GetNextCharacter()=0
Get the next character from the input.
virtual ~IStateContext()
Virtual destructor as required for interfaces.