clang 24.0.0git
FormatStyle::AlignConsecutiveStyle Struct Reference

Alignment options. More...

#include "clang/Format/Format.h"

Public Member Functions

bool operator== (const AlignConsecutiveStyle &R) const
bool operator!= (const AlignConsecutiveStyle &R) const

Public Attributes

bool Enabled
 Whether aligning is enabled.
bool AcrossEmptyLines
 Whether to align across empty lines.
bool AcrossComments
 Whether to align across comments.
bool AlignCompound
 Only for AlignConsecutiveAssignments.
bool AlignFunctionDeclarations
 Only for AlignConsecutiveDeclarations.
bool AlignFunctionPointers
 Only for AlignConsecutiveDeclarations.
bool EnumAssignments
 Only for AlignConsecutiveAssignments.
bool PadOperators
 Only for AlignConsecutiveAssignments.

Detailed Description

Alignment options.

They can also be read as a whole for compatibility. The choices are:

  • None
  • Consecutive
  • AcrossEmptyLines
  • AcrossComments
  • AcrossEmptyLinesAndComments

For example, to align across empty lines and not across comments, either of these work.

<option-name>: AcrossEmptyLines
<option-name>:
Enabled: true
bool AcrossEmptyLines
Whether to align across empty lines.
Definition Format.h:183
bool Enabled
Whether aligning is enabled.
Definition Format.h:166
bool AcrossComments
Whether to align across comments.
Definition Format.h:196

Definition at line 145 of file Format.h.

Member Function Documentation

◆ operator!=()

bool clang::format::FormatStyle::AlignConsecutiveStyle::operator!= ( const AlignConsecutiveStyle & R) const
inline

Definition at line 272 of file Format.h.

◆ operator==()

bool clang::format::FormatStyle::AlignConsecutiveStyle::operator== ( const AlignConsecutiveStyle & R) const
inline

Definition at line 263 of file Format.h.

Member Data Documentation

◆ AcrossComments

bool clang::format::FormatStyle::AlignConsecutiveStyle::AcrossComments

Whether to align across comments.

true:
int d = 3;
/* A comment. */
double e = 4;
false:
int d = 3;
/* A comment. */
double e = 4;

Definition at line 196 of file Format.h.

◆ AcrossEmptyLines

bool clang::format::FormatStyle::AlignConsecutiveStyle::AcrossEmptyLines

Whether to align across empty lines.

true:
int a = 1;
int somelongname = 2;
double c = 3;
int d = 3;
false:
int a = 1;
int somelongname = 2;
double c = 3;
int d = 3;

Definition at line 183 of file Format.h.

◆ AlignCompound

bool clang::format::FormatStyle::AlignConsecutiveStyle::AlignCompound

Only for AlignConsecutiveAssignments.

Whether compound assignments like += are aligned along with =.

true:
a &= 2;
bbb = 2;
false:
a &= 2;
bbb = 2;

Definition at line 208 of file Format.h.

◆ AlignFunctionDeclarations

bool clang::format::FormatStyle::AlignConsecutiveStyle::AlignFunctionDeclarations

Only for AlignConsecutiveDeclarations.

Whether function declarations are aligned.

true:
unsigned int f1(void);
void f2(void);
size_t f3(void);
false:
unsigned int f1(void);
void f2(void);
size_t f3(void);

Definition at line 222 of file Format.h.

◆ AlignFunctionPointers

bool clang::format::FormatStyle::AlignConsecutiveStyle::AlignFunctionPointers

Only for AlignConsecutiveDeclarations.

Whether function pointers are aligned.

true:
unsigned i;
int &r;
int *p;
int (*f)();
false:
unsigned i;
int &r;
int *p;
int (*f)();

Definition at line 238 of file Format.h.

◆ Enabled

bool clang::format::FormatStyle::AlignConsecutiveStyle::Enabled

Whether aligning is enabled.

#define SHORT_NAME 42
#define LONGER_NAME 0x007f
#define EVEN_LONGER_NAME (2)
#define foo(x) (x * x)
#define bar(y, z) (y + z)
int a = 1;
int somelongname = 2;
double c = 3;
int aaaa : 1;
int b : 12;
int ccc : 8;
int aaaa = 12;
float b = 23;
std::string ccc;

Definition at line 166 of file Format.h.

◆ EnumAssignments

bool clang::format::FormatStyle::AlignConsecutiveStyle::EnumAssignments

Only for AlignConsecutiveAssignments.

Whether enum assignments are aligned. If Enabled is false, setting this to true forces alignment for enum assignments only. If Enabled is true, enum assignments are always aligned.

Definition at line 243 of file Format.h.

◆ PadOperators

bool clang::format::FormatStyle::AlignConsecutiveStyle::PadOperators

Only for AlignConsecutiveAssignments.

Whether short assignment operators are left-padded to the same length as long ones in order to put all assignment operators to the right of the left hand side.

true:
a >>= 2;
bbb = 2;
a = 2;
bbb >>= 2;
false:
a >>= 2;
bbb = 2;
a = 2;
bbb >>= 2;

Definition at line 262 of file Format.h.


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