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 () |
The C++ Insights formatter.
Most of the code is handed to OutputFormatHelper for easy code formatting.
Definition at line 27 of file OutputFormatHelper.h.
|
default |
|
inlineexplicit |
Definition at line 32 of file OutputFormatHelper.h.
|
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().
|
inline |
Append a single character.
Append a single character to the buffer
Definition at line 84 of file OutputFormatHelper.h.
Referenced by AppendParameterList(), clang::insights::AppendTemplateTypeParamName(), CloseScope(), clang::insights::CfrontCodeGenerator::FormatCast(), clang::insights::GetDeclContext(), clang::insights::details::SimpleTypePrinter::GetTypeString(), clang::insights::CfrontCodeGenerator::InsertArg(), clang::insights::CodeGenerator::InsertCXXMethodHeader(), clang::insights::CodeGenerator::InsertFunctionNameWithReturnType(), clang::insights::CodeGenerator::LambdaHelper::insertInits(), clang::insights::CodeGenerator::InsertLambdaStaticInvoker(), clang::insights::CodeGenerator::InsertNamespace(), clang::insights::CodeGenerator::InsertQualifierAndName(), clang::insights::CodeGenerator::InsertQualifierAndNameWithTemplateArgs(), clang::insights::CodeGenerator::InsertTemplateArgs(), clang::insights::CodeGenerator::InsertTemplateParameters(), clang::insights::ToDo(), and clang::insights::MultiStmtDeclCodeGenerator::~MultiStmtDeclCodeGenerator().
|
inline |
Definition at line 86 of file OutputFormatHelper.h.
|
inline |
Append a comma if needed.
Definition at line 182 of file OutputFormatHelper.h.
Referenced by clang::insights::CodeGenerator::InsertTemplateParameters().
|
inline |
Definition at line 118 of file OutputFormatHelper.h.
Referenced by clang::insights::CoroutinesCodeGenerator::InsertArg().
|
inline |
Definition at line 131 of file OutputFormatHelper.h.
References clang::insights::details::StrCat().
|
inline |
Definition at line 125 of file OutputFormatHelper.h.
Referenced by clang::insights::CodeGenerator::InsertInstantiationPoint().
|
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().
|
inline |
Same as Append but adds a newline after the last argument.
Append a single character to the buffer
Definition at line 96 of file OutputFormatHelper.h.
Referenced by clang::insights::EmitGlobalVariableCtors(), clang::insights::CodeGenerator::HandleLambdaExpr(), clang::insights::CfrontCodeGenerator::InsertArg(), clang::insights::CfrontCodeGenerator::InsertCXXMethodDecl(), clang::insights::CodeGenerator::InsertCXXMethodHeader(), clang::insights::CodeGenerator::InsertLambdaStaticInvoker(), clang::insights::CodeGenerator::InsertMethodBody(), clang::insights::CodeGenerator::InsertTemplateParameters(), and clang::insights::CodeGenerator::InsertTemplateSpecializationHeader().
|
inline |
Definition at line 102 of file OutputFormatHelper.h.
void clang::insights::OutputFormatHelper::AppendParameterList | ( | const ArrayRef< ParmVarDecl * > | parameters, |
const NameOnly | nameOnly = NameOnly::No , |
||
const GenMissingParamName | genMissingParamName = GenMissingParamName::No |
||
) |
Append a ParamVarDecl
array.
The parameter name is always added as well.
Definition at line 24 of file OutputFormatHelper.cpp.
References Append(), clang::insights::BuildInternalVarName(), ForEachArg(), clang::insights::GetName(), clang::insights::GetType(), clang::insights::GetTypeNameAsParameter(), clang::insights::CodeGenerator::InsertAttributes(), kwElipsis, and clang::insights::StrCat().
Referenced by clang::insights::CodeGenerator::InsertFunctionNameWithReturnType(), and clang::insights::CodeGenerator::InsertLambdaStaticInvoker().
|
inline |
Append a semicolon and a newline.
Definition at line 190 of file OutputFormatHelper.h.
Referenced by clang::insights::CfrontCodeGenerator::InsertArg(), clang::insights::CodeGenerator::InsertLambdaStaticInvoker(), clang::insights::CodeGenerator::InsertMethodBody(), and clang::insights::CodeGenerator::InsertTemplateArgsObjectParam().
|
inline |
Append a semicolon and a newline.
Definition at line 194 of file OutputFormatHelper.h.
References clang::insights::details::StrCat().
|
inline |
Definition at line 203 of file OutputFormatHelper.h.
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().
|
inline |
Similiar to CloseScope only this time a ';' is inserted after the brace.
Definition at line 175 of file OutputFormatHelper.h.
|
inline |
Returns the current position in the output buffer.
Definition at line 42 of file OutputFormatHelper.h.
Referenced by clang::insights::CodeGenerator::UpdateCurrentPos().
|
inline |
Decrease the current indention by SCOPE_INDENT
.
Definition at line 153 of file OutputFormatHelper.h.
Referenced by CloseScope().
|
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().
|
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:
Definition at line 219 of file OutputFormatHelper.h.
Referenced by AppendParameterList(), and clang::insights::CodeGenerator::ForEachArg().
|
inline |
Definition at line 49 of file OutputFormatHelper.h.
|
inline |
Returns a reference to the underlying string buffer.
Definition at line 79 of file OutputFormatHelper.h.
Referenced by clang::insights::details::SimpleTypePrinter::GetString(), clang::insights::CodeGenerator::InsertFunctionNameWithReturnType(), and clang::insights::CodeGenerator::InsertTemplateArgs().
|
inline |
Increase the current indention by SCOPE_INDENT
.
Definition at line 151 of file OutputFormatHelper.h.
|
inline |
Insert a string before the position atPos
.
Definition at line 45 of file OutputFormatHelper.h.
Referenced by clang::insights::CodeGenerator::LambdaHelper::finish().
|
inline |
Definition at line 235 of file OutputFormatHelper.h.
Referenced by clang::insights::CodeGenerator::InsertTemplateGuardEnd().
|
inline |
Definition at line 234 of file OutputFormatHelper.h.
Referenced by clang::insights::CodeGenerator::InsertTemplateGuardBegin().
|
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().
|
inline |
Definition at line 37 of file OutputFormatHelper.h.
|
inline |
Set the indent level of this class to that of rhs
.
Definition at line 62 of file OutputFormatHelper.h.
|
inline |
Set the indent level of this class to indent
.
Definition at line 52 of file OutputFormatHelper.h.
Referenced by clang::insights::CfrontCodeGenerator::InsertCXXMethodDecl(), clang::insights::CodeGenerator::InsertCXXMethodDecl(), and clang::insights::CodeGenerator::LambdaHelper::LambdaHelper().
|
inline |
Definition at line 39 of file OutputFormatHelper.h.
clang::insights::OutputFormatHelper::STRONG_BOOL | ( | GenMissingParamName | ) |
clang::insights::OutputFormatHelper::STRONG_BOOL | ( | NameOnly | ) |
clang::insights::OutputFormatHelper::STRONG_BOOL | ( | NoNewLineBefore | ) |
clang::insights::OutputFormatHelper::STRONG_BOOL | ( | SkipIndenting | ) |