9#include "helpers/formatstring.h"
10#include "helpers/split.h"
11#include "helpers/stringlist.h"
30 for (std::string line : lines)
59 std::cout << std::endl;
60 std::cout <<
"State Exercise" << std::endl;
64 "/*#################### Block Comment #################################*/\n"
65 "//#################### Line Comment ####################################\n"
66 "// A comment. /* A nested comment */\n"
68 "void State_Exercise() // An exercise in state machines\n"
70 " char character = '\\\"';\n"
71 " std::cout << std::endl;\n"
72 " std::cout << \"\\\"State\\\" /*Exercise*/\" << std::endl;\n"
74 " StateContext_Class filterContext;\n"
76 " std::cout << \"\\t\\tDone. //(No, really)//\" << std::endl;\n"
79 std::cout <<
" Text to filter:" << std::endl;
82 std::cout <<
" Filtering text..." << std::endl;
85 std::cout <<
" Filtered text:" << std::endl;
88 std::cout <<
" Done." << std::endl;
Declaration of the IStateContext and IStateBehavior interfaces, as well as the StateContext_Class cla...
static const char * textToFilter
static void _State_DisplayText(const char *textToDisplay)
Helper function to display text from the State exercise. Text is displayed with line numbers.
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.
Declaration of the State_Exercise() function as used in the State Pattern.
std::vector< std::string > StringList
Typedef for a vector of std::string.
The namespace containing all Design Pattern Examples implemented in C++.
void State_Exercise()
Example of using the State design pattern.
std::string formatstring(const char *fmt,...)
Use the given string and arguments to return a buffer containing the formatted string....
std::vector< std::string > split(const char *pszString, const char *splitChars)
Split the given string into a list of strings given the character on which to split....