Public Member Functions | List of all members
clang::insights::OutputFormatHelper Class Reference

The C++ Insights formatter. More...

#include "OutputFormatHelper.h"

Public Member Functions

 OutputFormatHelper ()=default
 
 OutputFormatHelper (const unsigned indent)
 
 operator std::string_view () const &
 
auto size () const
 
size_t CurrentPos () const
 Returns the current position in the output buffer. More...
 
void InsertAt (const size_t atPos, std::string_view data)
 Insert a string before the position atPos. More...
 
 STRONG_BOOL (SkipIndenting)
 
auto GetIndent () const
 
void SetIndent (const unsigned indent, const SkipIndenting skipIndenting=SkipIndenting::No)
 Set the indent level of this class to indent. More...
 
void SetIndent (const OutputFormatHelper &rhs, const SkipIndenting skipIndenting=SkipIndenting::No)
 Set the indent level of this class to that of rhs. More...
 
bool empty () const
 Check whether the buffer is empty. More...
 
std::string & GetString ()
 Returns a reference to the underlying string buffer. More...
 
void Append (const char c)
 Append a single character. More...
 
void Append (const std::string_view &arg)
 
void Append (const auto &... args)
 Append a variable number of data. More...
 
void AppendNewLine (const char c)
 Same as Append but adds a newline after the last argument. More...
 
void AppendNewLine (const std::string_view &arg)
 
void AppendNewLine (const auto &... args)
 Same as Append but adds a newline after the last argument. More...
 
void AppendComment (const std::string_view &arg)
 
void AppendCommentNewLine (const std::string_view &arg)
 
void AppendCommentNewLine (const auto &... args)
 
 STRONG_BOOL (NameOnly)
 
 STRONG_BOOL (GenMissingParamName)
 
void AppendParameterList (const ArrayRef< ParmVarDecl * > parameters, const NameOnly nameOnly=NameOnly::No, const GenMissingParamName genMissingParamName=GenMissingParamName::No)
 Append a ParamVarDecl array. More...
 
void IncreaseIndent ()
 Increase the current indention by SCOPE_INDENT. More...
 
void DecreaseIndent ()
 Decrease the current indention by SCOPE_INDENT. More...
 
void OpenScope ()
 Open a scope by inserting a '{' followed by an indented newline. More...
 
 STRONG_BOOL (NoNewLineBefore)
 
void CloseScope (const NoNewLineBefore newLineBefore=NoNewLineBefore::No)
 Close a scope by inserting a '}'. More...
 
void CloseScopeWithSemi (const NoNewLineBefore newLineBefore=NoNewLineBefore::No)
 Similiar to CloseScope only this time a ';' is inserted after the brace. More...
 
void AppendComma (OnceFalse &needsComma)
 Append a comma if needed. More...
 
void AppendSemiNewLine ()
 Append a semicolon and a newline. More...
 
template<typename... Args>
void AppendSemiNewLine (const Args &... args)
 Append a semicolon and a newline. More...
 
void AppendSemiNewLine (const std::string_view &arg)
 
void ForEachArg (const auto &arguments, auto &&lambda)
 Append a argument list to the buffer. More...
 
void InsertIfDefTemplateGuard ()
 
void InsertEndIfTemplateGuard ()
 

Detailed Description

The C++ Insights formatter.

Most of the code is handed to OutputFormatHelper for easy code formatting.

Definition at line 27 of file OutputFormatHelper.h.

Constructor & Destructor Documentation

◆ OutputFormatHelper() [1/2]

clang::insights::OutputFormatHelper::OutputFormatHelper ( )
default

◆ OutputFormatHelper() [2/2]

clang::insights::OutputFormatHelper::OutputFormatHelper ( const unsigned  indent)
inlineexplicit

Definition at line 32 of file OutputFormatHelper.h.

Member Function Documentation

◆ Append() [1/3]

void clang::insights::OutputFormatHelper::Append ( const auto &...  args)
inline

Append a variable number of data.

The StrCat function which is used ensures, that a StringRef or a char are converted appropriately.

Definition at line 91 of file OutputFormatHelper.h.

References clang::insights::details::StrCat().

◆ Append() [2/3]

void clang::insights::OutputFormatHelper::Append ( const char  c)
inline

◆ Append() [3/3]

void clang::insights::OutputFormatHelper::Append ( const std::string_view &  arg)
inline

Definition at line 86 of file OutputFormatHelper.h.

◆ AppendComma()

void clang::insights::OutputFormatHelper::AppendComma ( OnceFalse needsComma)
inline

Append a comma if needed.

Definition at line 182 of file OutputFormatHelper.h.

Referenced by clang::insights::CodeGenerator::InsertTemplateParameters().

◆ AppendComment()

void clang::insights::OutputFormatHelper::AppendComment ( const std::string_view &  arg)
inline

◆ AppendCommentNewLine() [1/2]

void clang::insights::OutputFormatHelper::AppendCommentNewLine ( const auto &...  args)
inline

Definition at line 131 of file OutputFormatHelper.h.

References clang::insights::details::StrCat().

◆ AppendCommentNewLine() [2/2]

void clang::insights::OutputFormatHelper::AppendCommentNewLine ( const std::string_view &  arg)
inline

◆ AppendNewLine() [1/3]

void clang::insights::OutputFormatHelper::AppendNewLine ( const auto &...  args)
inline

Same as Append but adds a newline after the last argument.

Definition at line 109 of file OutputFormatHelper.h.

References clang::insights::details::StrCat().

◆ AppendNewLine() [2/3]

void clang::insights::OutputFormatHelper::AppendNewLine ( const char  c)
inline

◆ AppendNewLine() [3/3]

void clang::insights::OutputFormatHelper::AppendNewLine ( const std::string_view &  arg)
inline

Definition at line 102 of file OutputFormatHelper.h.

◆ AppendParameterList()

void clang::insights::OutputFormatHelper::AppendParameterList ( const ArrayRef< ParmVarDecl * >  parameters,
const NameOnly  nameOnly = NameOnly::No,
const GenMissingParamName  genMissingParamName = GenMissingParamName::No 
)

◆ AppendSemiNewLine() [1/3]

void clang::insights::OutputFormatHelper::AppendSemiNewLine ( )
inline

◆ AppendSemiNewLine() [2/3]

template<typename... Args>
void clang::insights::OutputFormatHelper::AppendSemiNewLine ( const Args &...  args)
inline

Append a semicolon and a newline.

Definition at line 194 of file OutputFormatHelper.h.

References clang::insights::details::StrCat().

◆ AppendSemiNewLine() [3/3]

void clang::insights::OutputFormatHelper::AppendSemiNewLine ( const std::string_view &  arg)
inline

Definition at line 203 of file OutputFormatHelper.h.

◆ CloseScope()

void clang::insights::OutputFormatHelper::CloseScope ( const NoNewLineBefore  newLineBefore = NoNewLineBefore::No)

Close a scope by inserting a '}'.

With the parameter newLineBefore a newline after the brace can be inserted.

Definition at line 58 of file OutputFormatHelper.cpp.

References Append(), and DecreaseIndent().

Referenced by clang::insights::CodeGenerator::InsertLambdaStaticInvoker().

◆ CloseScopeWithSemi()

void clang::insights::OutputFormatHelper::CloseScopeWithSemi ( const NoNewLineBefore  newLineBefore = NoNewLineBefore::No)
inline

Similiar to CloseScope only this time a ';' is inserted after the brace.

Definition at line 175 of file OutputFormatHelper.h.

◆ CurrentPos()

size_t clang::insights::OutputFormatHelper::CurrentPos ( ) const
inline

Returns the current position in the output buffer.

Definition at line 42 of file OutputFormatHelper.h.

Referenced by clang::insights::CodeGenerator::UpdateCurrentPos().

◆ DecreaseIndent()

void clang::insights::OutputFormatHelper::DecreaseIndent ( )
inline

Decrease the current indention by SCOPE_INDENT.

Definition at line 153 of file OutputFormatHelper.h.

Referenced by CloseScope().

◆ empty()

bool clang::insights::OutputFormatHelper::empty ( ) const
inline

Check whether the buffer is empty.

This also treats a string of just whitespaces as empty.

Definition at line 76 of file OutputFormatHelper.h.

Referenced by clang::insights::CodeGenerator::LambdaHelper::finish().

◆ ForEachArg()

void clang::insights::OutputFormatHelper::ForEachArg ( const auto &  arguments,
auto &&  lambda 
)
inline

Append a argument list to the buffer.

This function takes care of the delimiting ',' between the parameters. The lambda lambda is called to each argument after the comma was inserted. Usage:

ForEachArg(parameters, [&](const auto& p) {
// do something with p
});
void ForEachArg(const auto &arguments, auto &&lambda)
Append a argument list to the buffer.

Definition at line 219 of file OutputFormatHelper.h.

Referenced by AppendParameterList(), and clang::insights::CodeGenerator::ForEachArg().

◆ GetIndent()

auto clang::insights::OutputFormatHelper::GetIndent ( ) const
inline

Definition at line 49 of file OutputFormatHelper.h.

◆ GetString()

std::string& clang::insights::OutputFormatHelper::GetString ( )
inline

◆ IncreaseIndent()

void clang::insights::OutputFormatHelper::IncreaseIndent ( )
inline

Increase the current indention by SCOPE_INDENT.

Definition at line 151 of file OutputFormatHelper.h.

◆ InsertAt()

void clang::insights::OutputFormatHelper::InsertAt ( const size_t  atPos,
std::string_view  data 
)
inline

Insert a string before the position atPos.

Definition at line 45 of file OutputFormatHelper.h.

Referenced by clang::insights::CodeGenerator::LambdaHelper::finish().

◆ InsertEndIfTemplateGuard()

void clang::insights::OutputFormatHelper::InsertEndIfTemplateGuard ( )
inline

◆ InsertIfDefTemplateGuard()

void clang::insights::OutputFormatHelper::InsertIfDefTemplateGuard ( )
inline

◆ OpenScope()

void clang::insights::OutputFormatHelper::OpenScope ( )
inline

Open a scope by inserting a '{' followed by an indented newline.

Definition at line 161 of file OutputFormatHelper.h.

Referenced by clang::insights::CodeGenerator::InsertLambdaStaticInvoker().

◆ operator std::string_view()

clang::insights::OutputFormatHelper::operator std::string_view ( ) const &
inline

Definition at line 37 of file OutputFormatHelper.h.

◆ SetIndent() [1/2]

void clang::insights::OutputFormatHelper::SetIndent ( const OutputFormatHelper rhs,
const SkipIndenting  skipIndenting = SkipIndenting::No 
)
inline

Set the indent level of this class to that of rhs.

Definition at line 62 of file OutputFormatHelper.h.

◆ SetIndent() [2/2]

void clang::insights::OutputFormatHelper::SetIndent ( const unsigned  indent,
const SkipIndenting  skipIndenting = SkipIndenting::No 
)
inline

◆ size()

auto clang::insights::OutputFormatHelper::size ( ) const
inline

Definition at line 39 of file OutputFormatHelper.h.

◆ STRONG_BOOL() [1/4]

clang::insights::OutputFormatHelper::STRONG_BOOL ( GenMissingParamName  )

◆ STRONG_BOOL() [2/4]

clang::insights::OutputFormatHelper::STRONG_BOOL ( NameOnly  )

◆ STRONG_BOOL() [3/4]

clang::insights::OutputFormatHelper::STRONG_BOOL ( NoNewLineBefore  )

◆ STRONG_BOOL() [4/4]

clang::insights::OutputFormatHelper::STRONG_BOOL ( SkipIndenting  )

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