-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.clang-format
More file actions
297 lines (289 loc) · 10.8 KB
/
.clang-format
File metadata and controls
297 lines (289 loc) · 10.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
---
Language: Cpp
# BasedOnStyle: Google # 基于Google样式指南
# 访问修饰符(public, private, protected)相对于基本缩进的偏移量
AccessModifierOffset: -1
# 对齐括号后的参数列表
AlignAfterOpenBracket: Align
# 不对齐连续的宏定义
AlignConsecutiveMacros: false
# 不对齐连续的赋值语句
AlignConsecutiveAssignments: false
# 不对齐连续的声明语句
AlignConsecutiveDeclarations: false
# 对齐反斜杠换行的连续行
AlignEscapedNewlines: Left
# 对齐运算符两侧的操作数
AlignOperands: true
# 对齐尾随注释
AlignTrailingComments: true
# 允许所有参数在下一行
AllowAllArgumentsOnNextLine: true
# 允许所有构造函数初始化列表在下一行
AllowAllConstructorInitializersOnNextLine: true
# 允许所有声明的参数在下一行
AllowAllParametersOfDeclarationOnNextLine: true
# 不允许将短的代码块放在单行
AllowShortBlocksOnASingleLine: Never
# 不允许将短的case标签放在单行
AllowShortCaseLabelsOnASingleLine: false
# 允许将所有短函数放在单行
AllowShortFunctionsOnASingleLine: All
# 允许将所有短Lambda表达式放在单行
AllowShortLambdasOnASingleLine: All
# 允许将没有else的短if语句放在单行
AllowShortIfStatementsOnASingleLine: WithoutElse
# 允许将短循环放在单行
AllowShortLoopsOnASingleLine: true
# 在定义返回类型后不强制换行
AlwaysBreakAfterDefinitionReturnType: None
# 在返回类型后不强制换行
AlwaysBreakAfterReturnType: None
# 在多行字符串之前始终换行
AlwaysBreakBeforeMultilineStrings: true
# 总是在模板声明处换行
AlwaysBreakTemplateDeclarations: Yes
# 将函数调用的参数尽可能多地放在同一行
BinPackArguments: true
# 将函数声明的参数尽可能多地放在同一行
BinPackParameters: true
# 大括号换行设置
BraceWrapping:
# case标签后的大括号不另起一行
AfterCaseLabel: true
# 类声明后的大括号不另起一行
AfterClass: true
# 控制语句后的大括号不另起一行
AfterControlStatement: true
# 枚举声明后的大括号不另起一行
AfterEnum: true
# 函数声明后的大括号不另起一行
AfterFunction: true
# 命名空间声明后的大括号不另起一行
AfterNamespace: true
# Objective-C声明后的大括号不另起一行
AfterObjCDeclaration: true
# 结构体声明后的大括号不另起一行
AfterStruct: true
# union声明后的大括号不另起一行
AfterUnion: true
# 外部块声明后的大括号不另起一行
AfterExternBlock: true
# catch关键字前的大括号不另起一行
BeforeCatch: true
# else关键字前的大括号不另起一行
BeforeElse: true
# 不对大括号进行缩进
IndentBraces: false
# 空函数的大括号分开
SplitEmptyFunction: true
# 空记录(类、结构体、联合体)的大括号分开
SplitEmptyRecord: true
# 空命名空间的大括号分开
SplitEmptyNamespace: true
# 二元操作符前不换行
BreakBeforeBinaryOperators: None
# 大括号附加在控制语句、函数等同一行
# 在大括号前换行: Attach(始终将大括号附加到周围的上下文), Linux(除函数、命名空间和类定义,与Attach类似),
# Mozilla(除枚举、函数、记录定义,与Attach类似), Stroustrup(除函数定义、catch、else,与Attach类似),
# Allman(总是在大括号前换行), GNU(总是在大括号前换行,并对于控制语句的大括号增加额外的缩进), WebKit(在函数前换行), Custom
# 注:这里认为语句块也属于函数
BreakBeforeBraces: Custom
# 继承列表中的逗号前不换行
BreakBeforeInheritanceComma: false
# 继承列表在冒号前换行
BreakInheritanceList: BeforeColon
# 三元操作符前换行
BreakBeforeTernaryOperators: true
# 构造函数初始化列表中的逗号前不换行
BreakConstructorInitializersBeforeComma: false
# 构造函数初始化列表在冒号前换行
BreakConstructorInitializers: BeforeColon
# Java字段注解后不换行
BreakAfterJavaFieldAnnotations: false
# 字符串字面量在需要时换行
BreakStringLiterals: true
# 每行最大字符数限制为80
ColumnLimit: 80
# 特定注释格式的正则表达式匹配
CommentPragmas: '^ IWYU pragma:'
# 命名空间内容不紧凑排列
CompactNamespaces: false
# 构造函数初始化列表要么全部在一行,要么每个成员一行
ConstructorInitializerAllOnOneLineOrOnePerLine: true
# 构造函数初始化列表的缩进宽度为4个空格
ConstructorInitializerIndentWidth: 4
# 换行后的续行缩进宽度为4个
ContinuationIndentWidth: 4
# 使用C++11风格的花括号列表格式,即在初始化列表中,每个元素后都跟一个逗号
Cpp11BracedListStyle: true
# 自动推断换行符风格,如Windows(\r\n)或Unix(\n)等
DeriveLineEnding: true
# 自动推断指针对齐风格,如左对齐(Type *var)或右对齐(Type* var)等
DerivePointerAlignment: true
# 不禁用格式化,即允许格式化操作
DisableFormat: false
# 不使用实验性的自动检测二进制打包功能。这个选项仅用于尝试自动检测是否启用二进制参数包装
ExperimentalAutoDetectBinPacking: false
# 修复命名空间注释,使其与命名空间对齐并以一致的风格显示
FixNamespaceComments: true
# 自定义支持的foreach宏,这些宏将被识别为循环并进行适当的缩进
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
# 将#include指令按分类重新组织。在这种模式下,相同类别的#include指令将聚集在一起,并用空行分隔
IncludeBlocks: Regroup
# 指定#include指令的分类和排序优先级,使用正则表达式匹配。
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
SortPriority: 0
- Regex: '^<.*\.h>'
Priority: 1
SortPriority: 0
- Regex: '^<.*'
Priority: 2
SortPriority: 0
- Regex: '.*'
Priority: 3
SortPriority: 0
# 指定main文件的正则表达式,用于确定文件中是否包含主要的#include指令
IncludeIsMainRegex: '([-_](test|unittest))?$'
# 指定main源文件的正则表达式。当未指定时,使用IncludeIsMainRegex匹配
IncludeIsMainSourceRegex: ''
# 缩进case标签,使其与所属的switch语句内部代码对齐
IndentCaseLabels: true
# 缩进goto标签,使其与所属的控制流程代码对齐
IndentGotoLabels: true
# 预处理器指令不缩进
IndentPPDirectives: None
# 缩进宽度为2个空格
IndentWidth: 2
# 不缩进换行后的函数名
IndentWrappedFunctionNames: false
# 保留JavaScript中的引号风格(单引号或双引号)
JavaScriptQuotes: Leave
# 将JavaScript导入语句换行
JavaScriptWrapImports: true
# 在块的开始处不保留空行
KeepEmptyLinesAtTheStartOfBlocks: false
# 定义用于标记宏块开始的字符串。为空时,不使用宏块特性
MacroBlockBegin: ''
# 定义用于标记宏块结束的字符串。为空时,不使用宏块特性
MacroBlockEnd: ''
# 保留的最大连续空行数为1
MaxEmptyLinesToKeep: 1
# 命名空间内部的内容不进行缩进
NamespaceIndentation: None
# Objective-C协议列表不进行二进制打包
ObjCBinPackProtocolList: Never
# Objective-C块的缩进宽度为2个空格
ObjCBlockIndentWidth: 2
# Objective-C属性后不添加空格
ObjCSpaceAfterProperty: false
# Objective-C协议列表前添加空格
ObjCSpaceBeforeProtocolList: true
# 赋值操作符换行的惩罚值为2
PenaltyBreakAssignment: 2
# 函数调用参数列表的第一个参数前换行的惩罚值为1
PenaltyBreakBeforeFirstCallParameter: 1
# 注释换行的惩罚值为300
PenaltyBreakComment: 300
# 在C++的左移操作符(<<)前换行的惩罚值为120
PenaltyBreakFirstLessLess: 120
# 字符串换行的惩罚值为1000
PenaltyBreakString: 1000
# 模板声明换行的惩罚值为10
PenaltyBreakTemplateDeclaration: 10
# 每个超出列限制的字符的惩罚值为1000000
PenaltyExcessCharacter: 1000000
# 返回类型独占一行的惩罚值为200
PenaltyReturnTypeOnItsOwnLine: 200
# 指针对齐方式为左对齐,即“Type *var”
PointerAlignment: Left
# 原始字符串格式设置,用于不同语言和定界符
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: '' # 规范定界符为空字符串。
BasedOnStyle: google # 基于Google样式指南。
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions: # 包含原始字符串的函数列表。
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: '' # 规范定界符为空字符串。
BasedOnStyle: google # 基于Google样式指南。
# 重新排列注释以适应列限制
ReflowComments: true
# 对#include指令进行排序
SortIncludes: true
# 对using声明进行排序
SortUsingDeclarations: true
# C风格类型转换后不添加空格
SpaceAfterCStyleCast: false
# 逻辑非操作符后不添加空格
SpaceAfterLogicalNot: false
# 模板关键字后添加空格
SpaceAfterTemplateKeyword: true
# 赋值操作符前添加空格
SpaceBeforeAssignmentOperators: true
# C++11花括号列表前不添加空格
SpaceBeforeCpp11BracedList: false
# 构造函数初始化列表的冒号前添加空格
SpaceBeforeCtorInitializerColon: true
# 继承列表的冒号前添加空格
SpaceBeforeInheritanceColon: true
# 控制语句的圆括号前添加空格
SpaceBeforeParens: ControlStatements
# 基于范围的for循环的冒号前添加空格
SpaceBeforeRangeBasedForLoopColon: true
# 空块中不添加空格
SpaceInEmptyBlock: false
# 空圆括号中不添加空格
SpaceInEmptyParentheses: false
# 尾部注释前添加2个空格
SpacesBeforeTrailingComments: 2
# 尖括号中不添加空格
SpacesInAngles: false
# 条件语句中不添加空格
SpacesInConditionalStatement: false
# 容器字面量中添加空格
SpacesInContainerLiterals: true
# C风格类型转换的圆括号中不添加空格
SpacesInCStyleCastParentheses: false
# 圆括号中不添加空格
SpacesInParentheses: false
# 方括号中不添加空格
SpacesInSquareBrackets: false
# 方括号前不添加空格
SpaceBeforeSquareBrackets: false
# 自动检测使用的C++标准(如C++11、C++14等)
Standard: Cpp17
# 语句宏列表,这些宏将被视为单个语句并进行适当的缩进
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
# 制表符宽度为4个空格
TabWidth: 4
# 使用Unix风格的换行符(\n),而非Windows风格的换行符(\r\n)
UseCRLF: false
# 永远不使用制表符进行缩进
UseTab: Never