|
Panini 1.4.0
Header-only library for generating C++, written in C++17
|
Command for outputting opening and closing (curly) braces. More...
#include <Braces.hpp>
Public Types | |
| using | TCallback = std::function< void(Writer &)> |
Public Member Functions | |
| Braces (TCallback &&callback, BraceBreakingStyle breakingStyle=BraceBreakingStyle::Inherit) noexcept | |
| Braces (TCallback &&callback, const BracesOptions &options) noexcept | |
| void | Visit (Writer &writer) override |
Public Member Functions inherited from panini::Command | |
| virtual | ~Command ()=default |
Command for outputting opening and closing (curly) braces.
This command tracks the current indentation level and takes the brace breaking style into account when outputting braces. You can change both the brace breaking style and the brace chunks it outputs with the BracesOptions parameter.
After outputting the opening brace, the Braces command calls a callback with the current Writer instance as a parameter.
If you want to prefix the opening brace with a chunk, it may be more convenient to use a Scope instead.
Example:
Output:
| using panini::Braces::TCallback = std::function<void(Writer&)> |
|
inlineexplicitnoexcept |
Create a Braces command with a callback that is moved into the instance.
The callback is called when the command is visited by a Writer.
Setting the breakingStyle parameter to BraceBreakingStyle::Inherit copies the brace breaking style from the writer, otherwise it will be overridden for this command only.
|
inlineexplicitnoexcept |
Create a Braces command a callback that is moved into the instance.
The callback is called when the command is visited by a Writer.
Setting the breakingStyle parameter in the options to BraceBreakingStyle::Inherit copies the brace breaking style from the writer, otherwise it will be overridden for this command only.
|
inlineoverridevirtual |
Accepts a Writer to write chunks to the output.
Implements panini::Command.