rapidyaml  0.16.0
parseandemitYAML,anddoitfast
Event Handlers

Policy classes to use with the ParseEngine, to create side-effects from YAML events. More...

Modules

 Tree Event Handler
 An event handler used by ParseEngine to create the Tree (see Parser).
 
 Ints Event Handler
 An event handler used by ParseEngine to creates an integer buffer with a very compact representation of the YAML tree in a source buffer.
 

Classes

struct  c4::yml::EventHandlerStack< HandlerImpl, HandlerState >
 Use this class a base of implementations of event handler to simplify the stack logic. More...
 

Detailed Description

Policy classes to use with the ParseEngine, to create side-effects from YAML events.

rapidyaml implements its parsing logic with a two-level model, where a ParseEngine object reads through the YAML source, and dispatches events to an EventHandler bound to the ParseEngine.

Because ParseEngine is templated on the event handler, the binding uses static polymorphism, without any virtual functions. The actual handler object can be changed at run time, (but of course needs to be the type of the template parameter). This is thus a very efficient architecture, and further enables the user to provide his own custom handler if he wishes to bypass the rapidyaml Tree.

The following handlers are implemented in this project:

Event model

The event model used by the parse engine and event handlers follows very closely the event model in the YAML test suite.

Consider for example this YAML,

Special events

Most of the parsing events adopted by rapidyaml in its event model are fairly obvious, but there are two less-obvious events requiring some explanation.

These events exist to make it easier to parse some special YAML cases. They are called by the parser when a just-handled value/container is actually the first key of a new map:

For example, consider an implicit map inside a seq: [a: b, c: d] which is parsed as [{a: b}, {c: d}]. The standard event sequence for this YAML would be the following:

| | |

(2) (1) (3) <- event sequence