Parsing and State Machines

This section daily deals with state machines and the use of visitors as events.

We'll cover the following

Parsing a Config File

The idea comes from the previous example of a command line. In the case of a configuration file, we usually work with pairs of <Name, Value>. Where Value might be a different type: string, int, array, bool, float, etc.

For such a use case, even void* could be used to hold such an unknown type. However, this pattern is extremely error-prone. We could improve the design by using std::variant if we know all the possible types, or leverage std::any.

State Machines

How about modelling a state machine? For example, a door’s state:

Get hands-on with 1400+ tech skills courses.