Panini 1.4.0
Header-only library for generating C++, written in C++17
panini::Label Class Reference

Command for outputting a label statement. More...

#include <Label.hpp>

Inheritance diagram for panini::Label:
panini::Command

Public Member Functions

 Label (const std::string &name)
 
 Label (std::string &&name) noexcept
 
void Visit (Writer &writer) override
 
- Public Member Functions inherited from panini::Command
virtual ~Command ()=default
 

Detailed Description

Command for outputting a label statement.

A label is a name and a ":" chunk. The command pops the indentation before writing the label and restores it afterwards.

Labels are useful when you don't want to modify the current indentation level, e.g. when writing an access identifier for a class or a switch..case statement.

Example:

writer << Scope("class Vehicle", [](Writer& writer) {
writer << Label("public") << NextLine();
writer << "Vehicle(const std::string& maker);" << NextLine();
writer << Label("private") << NextLine();
writer << "std::string m_maker;" << NextLine();
}) << ";";
Label(const std::string &name)
Definition: Label.hpp:76

Output:

class Vehicle
{
public:
Vehicle(const std::string& maker);
private:
std::string m_maker;
};
See also
Scope

Constructor & Destructor Documentation

◆ Label() [1/2]

panini::Label::Label ( const std::string &  name)
inlineexplicit

Create a Label command with a name that is copied to the instance.

◆ Label() [2/2]

panini::Label::Label ( std::string &&  name)
inlineexplicitnoexcept

Create a Label command with a name that is moved into the instance.

Member Function Documentation

◆ Visit()

void panini::Label::Visit ( Writer writer)
inlineoverridevirtual

Accepts a Writer to write chunks to the output.

Implements panini::Command.


The documentation for this class was generated from the following file: