Design Pattern Examples
Overview of object-oriented design patterns
c/State_Exercise.h File Reference

Declaration of the State_Exercise() function as used in the State Pattern. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define __STATE_EXERCISE_H__
 

Functions

void State_Exercise (void)
 Example of using the State Pattern.
 

Detailed Description

Declaration of the State_Exercise() function as used in the State Pattern.

Definition in file c/State_Exercise.h.

Macro Definition Documentation

◆ __STATE_EXERCISE_H__

#define __STATE_EXERCISE_H__

Definition at line 9 of file c/State_Exercise.h.

Function Documentation

◆ State_Exercise()

void State_Exercise ( void  )

Example of using the State Pattern.

The State pattern alters the behavior of the class hierarchy based on some state. This is the basis of a Finite State Machine.

In this exercise, the State class is a filter that parses text to remove C++-style line and block comments. It needs to be smart enough to ignore comment characters inside quotes.

The filtering process starts with creating the context that drives the state machine. Internal classes are provided for each state.

Definition at line 83 of file State_Exercise.c.

References _State_DisplayText(), DynamicString_Clear(), State_RemoveComments(), DynamicString::string, and textToFilter.