Design Pattern Examples
Overview of object-oriented design patterns
State_RemoveComments.h File Reference

Declaration of the State_RemoveComments() function that uses a state machine to filter out comments out of a piece of source code, as used in the State Pattern. More...

#include <stdbool.h>
#include "helpers/dynamicstring.h"
Include dependency graph for State_RemoveComments.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define __STATE_REMOVECOMMENTS_H__
 

Functions

bool State_RemoveComments (const char *text, DynamicString *filteredText)
 Entry point for callers to filter text. Removes C++-style line and block comments from the text.
 

Detailed Description

Declaration of the State_RemoveComments() function that uses a state machine to filter out comments out of a piece of source code, as used in the State Pattern.

Definition in file State_RemoveComments.h.

Macro Definition Documentation

◆ __STATE_REMOVECOMMENTS_H__

#define __STATE_REMOVECOMMENTS_H__

Definition at line 9 of file State_RemoveComments.h.

Function Documentation

◆ State_RemoveComments()

bool State_RemoveComments ( const char *  text,
DynamicString filteredText 
)

Entry point for callers to filter text. Removes C++-style line and block comments from the text.

Parameters
textThe text to filter.
filteredTextA DynamicString that returns the filtered text.
Returns
Returns true if the text was filtered successfully, otherwise, returns false if an out of memory condition occurs (or a NULL argument).

Definition at line 745 of file State_RemoveComments.c.

References _SetNextState(), StateContext::currentState, StateContext::currentStateBehavior, DynamicString_Set(), StateContext::inputText, StateContext::outputText, StateContext::outputTextIndex, State_Done, State_Error, State_Initial, State_NormalText, and StateContext::textIndex.

Referenced by State_Exercise().