Implementation of the main() entry point and the machinery to call all the design pattern example functions. See Main Overview. More...
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <version.h>
#include "helpers/enablevtmode.h"
#include "helpers/stringlist.h"
#include "Adapter_Exercise.h"
#include "Bridge_Exercise.h"
#include "Command_Exercise.h"
#include "Composite_Exercise.h"
#include "Decorator_Exercise.h"
#include "Facade_Exercise.h"
#include "Flyweight_Exercise.h"
#include "HandlerChain_Exercise.h"
#include "Interpreter_Exercise.h"
#include "Iterator_Exercise.h"
#include "Mediator_Exercise.h"
#include "Memento_Exercise.h"
#include "NullObject_Exercise.h"
#include "Observer_Exercise.h"
#include "Proxy_Exercise.h"
#include "State_Exercise.h"
#include "Strategy_Exercise.h"
#include "Visitor_Exercise.h"
Go to the source code of this file.
Classes | |
struct | _Exercise |
Represents a single exercise or example for a design pattern. More... | |
struct | _Options |
Represents the command line options provided to the program, if any. More... | |
Typedefs | |
typedef void(* | Action) (void) |
Alias for a function pointer, using C# as inspiration for the name. | |
typedef struct _Exercise | Exercise |
Represents a single exercise or example for a design pattern. | |
typedef Exercise | ExerciseList[] |
Alias for an array of Exercise objects. | |
typedef struct _Options | Options |
Represents the command line options provided to the program, if any. | |
Functions | |
static void | Help (ExerciseList exercises) |
Helper function to show usage information for this program. | |
static void | ShowVersion (void) |
Helper function to show just the version of the application. | |
static bool | ParseOptions (int argc, char **argv, Options *options, ExerciseList exercises) |
Helper function to parse the given options and store the results in the given Options structure. Displays help if requested and returns false. | |
int | main (int argc, char **argv) |
Main entry point into this example program. | |
Variables | |
ExerciseList | exercises |
Implementation of the main() entry point and the machinery to call all the design pattern example functions. See Main Overview.
Definition in file program.c.
typedef void(* Action) (void) |
typedef Exercise ExerciseList[] |
Represents the command line options provided to the program, if any.
|
static |
Helper function to show usage information for this program.
exercises | List of Exercise objects to display if help is needed. The list is expected to be terminated by a NULL pointer for the exercise name. |
Definition at line 82 of file program.c.
References exercises.
Referenced by ParseOptions().
int main | ( | int | argc, |
char ** | argv | ||
) |
Main entry point into this example program.
argc | Number of command line arguments + 1 (the first argument is the name of the program). |
argv | Pointer to a list of zero-terminated strings containing the command line arguments. |
Definition at line 206 of file program.c.
References enableVTMode(), _Options::exercise_names, exercises, main(), ParseOptions(), StringList_Clear(), StringList_Find(), and StringList_Initialize().
|
static |
Helper function to parse the given options and store the results in the given Options structure. Displays help if requested and returns false.
argc | Number of command line arguments + 1 (the first argument is the name of the program). |
argv | Pointer to a list of zero-terminated strings containing the command line arguments. |
options | An Options structure to be filled in by command line parameters. |
exercises | List of Exercise objects to display if help is needed. The list is expected to be terminated by a NULL pointer for the exercise name. |
Definition at line 134 of file program.c.
References _Options::exercise_names, exercises, Help(), ShowVersion(), and StringList_AddString().
Referenced by main().
|
static |
Helper function to show just the version of the application.
Definition at line 111 of file program.c.
Referenced by ParseOptions().
ExerciseList exercises |
Definition at line 177 of file program.c.
Referenced by Help(), Program::Help(), main(), ParseOptions(), Program::ParseOptions(), and Program::Run().