Panini 1.4.0
Header-only library for generating C++, written in C++17
panini::ConfiguredWriter< TConfig > Class Template Reference

Base class implementation for writers. More...

#include <Writer.hpp>

Inheritance diagram for panini::ConfiguredWriter< TConfig >:
panini::Writer

Public Member Functions

 ConfiguredWriter (const TConfig &config=TConfig{})
 
virtual ~ConfiguredWriter ()=default
 
const WriterConfigGetConfig () const override
 
BraceBreakingStyle GetBraceBreakingStyle () const override
 
IncludeStyle GetIncludeStyle () const override
 
bool IsOnNewLine () const override
 
Writeroperator<< (const std::string &chunk) override
 
Writeroperator<< (const char *chunkString) override
 
Writeroperator<< (const NextLine &command) override
 
Writeroperator<< (const IndentPush &command) override
 
Writeroperator<< (const IndentPop &command) override
 
Writeroperator<< (Command &&command) override
 
void SetIsInCommentBlock (bool value) override
 
virtual bool IsChanged () const override
 
bool Commit (bool force=false) override
 
- Public Member Functions inherited from panini::Writer
virtual ~Writer ()=default
 

Protected Member Functions

void WriteNewLine () override
 
- Protected Member Functions inherited from panini::Writer
virtual void Write (const std::string &chunk)=0
 
virtual bool OnCommit (bool force=false)=0
 

Protected Attributes

TConfig m_config
 

Detailed Description

template<typename TConfig>
class panini::ConfiguredWriter< TConfig >

Base class implementation for writers.

When making your own writer, you should inherit from this class and supply a config struct that inherits from WriterConfig.

Constructor & Destructor Documentation

◆ ConfiguredWriter()

template<typename TConfig >
panini::ConfiguredWriter< TConfig >::ConfiguredWriter ( const TConfig &  config = TConfig{})
inlineexplicit

Constructs a writer with an optional configuration instance.

◆ ~ConfiguredWriter()

template<typename TConfig >
virtual panini::ConfiguredWriter< TConfig >::~ConfiguredWriter ( )
virtualdefault

Member Function Documentation

◆ Commit()

template<typename TConfig >
bool panini::ConfiguredWriter< TConfig >::Commit ( bool  force = false)
inlineoverridevirtual

Commits the generated output to the target of a writer if the output was changed.

Parameters
forceForce writing the file even if the output was not changed.
Returns
Returns true if the commit was successful.

Implements panini::Writer.

◆ GetBraceBreakingStyle()

template<typename TConfig >
BraceBreakingStyle panini::ConfiguredWriter< TConfig >::GetBraceBreakingStyle ( ) const
inlineoverridevirtual

Get the default brace breaking style.

Deprecated:
Will be removed in the next major release in favor of GetConfig()
Returns
Brace breaking style.

Implements panini::Writer.

◆ GetConfig()

template<typename TConfig >
const WriterConfig & panini::ConfiguredWriter< TConfig >::GetConfig ( ) const
inlineoverridevirtual

Get a reference to the active WriterConfig for this writer.

Returns
Configuration instance.

Implements panini::Writer.

◆ GetIncludeStyle()

template<typename TConfig >
IncludeStyle panini::ConfiguredWriter< TConfig >::GetIncludeStyle ( ) const
inlineoverridevirtual

Get the default include style.

Deprecated:
Will be removed in the next major release in favor of GetConfig()
Returns
Include style.

Implements panini::Writer.

◆ IsChanged()

template<typename TConfig >
virtual bool panini::ConfiguredWriter< TConfig >::IsChanged ( ) const
inlineoverridevirtual

Check if the output was changed compared to what the implementation has seen before.

Implements panini::Writer.

Reimplemented in panini::CompareWriter, panini::DebugWriter, and panini::FileWriter.

◆ IsOnNewLine()

template<typename TConfig >
bool panini::ConfiguredWriter< TConfig >::IsOnNewLine ( ) const
inlineoverridevirtual

Check whether the writer is on a new line and waiting for new chunks.

Returns
True if the writer is on a new line

Implements panini::Writer.

◆ operator<<() [1/6]

template<typename TConfig >
Writer & panini::ConfiguredWriter< TConfig >::operator<< ( Command &&  command)
inlineoverridevirtual

Visit a command.

Warning
Commands are moved instead of copied!

Commands are used to output chunks and modify the writer's state.

Returns
Reference to itself to allow for chaining

Implements panini::Writer.

◆ operator<<() [2/6]

template<typename TConfig >
Writer & panini::ConfiguredWriter< TConfig >::operator<< ( const char *  chunkString)
inlineoverridevirtual

Write a C-style string chunk to the output.

Will add indentation if the writer is on a new line.

Returns
Reference to itself to allow for chaining.

Implements panini::Writer.

◆ operator<<() [3/6]

template<typename TConfig >
Writer & panini::ConfiguredWriter< TConfig >::operator<< ( const IndentPop command)
inlineoverridevirtual

Decrement the level of indentation.

Indentation is applied when the writer is on a new line. The level of indentation cannot go negative.

Returns
Reference to itself to allow for chaining.

Implements panini::Writer.

◆ operator<<() [4/6]

template<typename TConfig >
Writer & panini::ConfiguredWriter< TConfig >::operator<< ( const IndentPush command)
inlineoverridevirtual

Increment the level of indentation.

Indentation is applied only when the writer is on a new line.

Returns
Reference to itself to allow for chaining.

Implements panini::Writer.

◆ operator<<() [5/6]

template<typename TConfig >
Writer & panini::ConfiguredWriter< TConfig >::operator<< ( const NextLine command)
inlineoverridevirtual

Write a new line chunk to the output.

New line chunks can be configured with the Config.

Returns
Reference to itself to allow for chaining.

Implements panini::Writer.

◆ operator<<() [6/6]

template<typename TConfig >
Writer & panini::ConfiguredWriter< TConfig >::operator<< ( const std::string &  chunk)
inlineoverridevirtual

Write an std::string chunk to the output.

Will add indentation if the writer is on a new line.

Returns
Reference to itself to allow for chaining.

Implements panini::Writer.

◆ SetIsInCommentBlock()

template<typename TConfig >
void panini::ConfiguredWriter< TConfig >::SetIsInCommentBlock ( bool  value)
inlineoverridevirtual

Set the writer to be inside a comment block, which will add " * " after the indentation of a new line.

Implements panini::Writer.

◆ WriteNewLine()

template<typename TConfig >
void panini::ConfiguredWriter< TConfig >::WriteNewLine ( )
inlineoverrideprotectedvirtual

Writes a new line chunk to the output.

Implements panini::Writer.

Member Data Documentation

◆ m_config

template<typename TConfig >
TConfig panini::ConfiguredWriter< TConfig >::m_config
protected

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