已合并
add clang-format #146
sinat_31531339创建于 3月31日
add clang-format #146
已合并
从已删除 :dev_master_format合入到cann/oam-toolsmaster
共 1 个文件变更+635-0
| @@ -0,0 +1,635 @@ | |||
| 1 | +# Language, this format style is targeted at. | ||
| 2 | +# LK_Cpp(in configuration: Cpp) Should be used for C, C++, ObjectiveC, ObjectiveC++. | ||
| 3 | +# 参数可取值 | ||
| 4 | +# None, Cpp, Java, JavaScript, Proto | ||
| 5 | +Language: Cpp | ||
| 6 | + | ||
| 7 | +# The style used for all options not specifically set in the configuration | ||
| 8 | +# 该配置文件没有指定的,将使用该配置的 Coding Style 进行格式化。 | ||
| 9 | +# 参数可取值 | ||
| 10 | +# None, LLVM, Google, Chromium, Mozilla, WebKit | ||
| 11 | +BasedOnStyle: Google | ||
| 12 | + | ||
| 13 | +# The extra indent or outdent of access modifiers, e.g. public:. | ||
| 14 | +# 访问限制关键字缩进,如 public、private 等。-4 即顶行首。 | ||
| 15 | +AccessModifierOffset: -4 | ||
| 16 | + | ||
| 17 | +# If true, horizontally aligns arguments after an open an open bracket. | ||
| 18 | +# 水平对齐跨行括号内参数。适用于用圆括号、尖括号和方括号。 | ||
| 19 | +# Align: someLongFunction(argument1, | ||
| 20 | +# argument2); | ||
| 21 | +# DontAlign: someLongFunction(argument1, | ||
| 22 | +# argument2); | ||
| 23 | +# AlwaysBreak: someLongFunction( | ||
| 24 | +# argument1, argument2); | ||
| 25 | +# BlockIndent: someLongFunction( | ||
| 26 | +# argument1, argument2 | ||
| 27 | +# ); | ||
| 28 | +AlignAfterOpenBracket: DontAlign | ||
| 29 | + | ||
| 30 | +# If true, aligns consecutive C/C++ preprocessor macros. | ||
| 31 | +# This will align C/C++ preprocessor macros of consecutive lines. | ||
| 32 | +# 对齐预处理宏定义 | ||
| 33 | +AlignConsecutiveMacros: false | ||
| 34 | + | ||
| 35 | +# 对齐连续行的位域分隔符 | ||
| 36 | +# int aaaa : 1; | ||
| 37 | +# int b : 12; | ||
| 38 | +# int ccc : 8; | ||
| 39 | +AlignConsecutiveBitFields: Consecutive | ||
| 40 | + | ||
| 41 | +# If true, aligns consecutive assignments. | ||
| 42 | +# 对齐连续行的赋值运算符。 | ||
| 43 | +# int aaaa = 12; | ||
| 44 | +# int b = 23; | ||
| 45 | +# int ccc = 23; | ||
| 46 | +AlignConsecutiveAssignments: false | ||
| 47 | + | ||
| 48 | +# If true, aligns consecutive declarations. | ||
| 49 | +# This will align the declaration names of consecutive lines. This will result in formattings like | ||
| 50 | +# int aaaa = 12; | ||
| 51 | +# float b = 23; | ||
| 52 | +# std::string ccc = 23; | ||
| 53 | +# 对齐声明的变量名 | ||
| 54 | +AlignConsecutiveDeclarations: false | ||
| 55 | + | ||
| 56 | +# Options for aligning backslashes in escaped newlines. | ||
| 57 | +# DontAlign: Don’t align escaped newlines. | ||
| 58 | +# Left: Align escaped newlines as far left as possible. | ||
| 59 | +# Right: Align escaped newlines in the right-most column. | ||
| 60 | +# 在转义的换行符中反斜杠对齐的选项。 | ||
| 61 | +# DontAlign: 不对齐 | ||
| 62 | +# Left: 左对齐 | ||
| 63 | +# Right: 右对齐 | ||
| 64 | +AlignEscapedNewlines: Left | ||
| 65 | + | ||
| 66 | +# If true, horizontally align operands of binary and ternary expressions. | ||
| 67 | +# 水平对齐二元表达式和三元表达式的操作数。 | ||
| 68 | +AlignOperands: true | ||
| 69 | + | ||
| 70 | +# If true, aligns trailing comments. | ||
| 71 | +# 对齐行尾注释 | ||
| 72 | +AlignTrailingComments: true | ||
| 73 | + | ||
| 74 | +# 对齐数组列 | ||
| 75 | +# struct test demo[] = | ||
| 76 | +# { | ||
| 77 | +# {56, 23, "hello"}, | ||
| 78 | +# {-1, 93463, "world"}, | ||
| 79 | +# { 7, 5, "!!"} | ||
| 80 | +# }; | ||
| 81 | +AlignArrayOfStructures: Right | ||
| 82 | + | ||
| 83 | +# If a function call or braced initializer list doesn’t fit on a line, allow putting all arguments onto the next line, even if BinPackArguments is false. | ||
| 84 | +# 如果一个函数的参数一行放不下, 即使BinPackArguments设置为false,也允许把所有的参数放在下一行 | ||
| 85 | +# true: | ||
| 86 | +# callFunction( | ||
| 87 | +# a, b, c, d); | ||
| 88 | + | ||
| 89 | +# false: | ||
| 90 | +# callFunction(a, | ||
| 91 | +# b, | ||
| 92 | +# c, | ||
| 93 | +# d); | ||
| 94 | +AllowAllArgumentsOnNextLine: true | ||
| 95 | + | ||
| 96 | +# If a constructor definition with a member initializer list doesn’t fit on a single line, | ||
| 97 | +# allow putting all member initializers onto the next line, if `ConstructorInitializerAllOnOneLineOrOnePerLine` is true. Note that this parameter has no effect if `ConstructorInitializerAllOnOneLineOrOnePerLine` is false. | ||
| 98 | +# true: | ||
| 99 | +# MyClass::MyClass() : | ||
| 100 | +# member0(0), member1(2) {} | ||
| 101 | + | ||
| 102 | +# false: | ||
| 103 | +# MyClass::MyClass() : | ||
| 104 | +# member0(0), | ||
| 105 | +# member1(2) {} | ||
| 106 | +AllowAllConstructorInitializersOnNextLine: true | ||
| 107 | + | ||
| 108 | +# Allow putting all parameters of a function declaration onto the next line even if BinPackParameters is false. | ||
| 109 | +# 即使 BinPackParameters 设置为 false,也允许把函数声明的所有参数放到下一行。 | ||
| 110 | +AllowAllParametersOfDeclarationOnNextLine: false | ||
| 111 | + | ||
| 112 | +# Allows contracting simple braced statements to a single line. | ||
| 113 | +# E.g., this allows if (a) { return; } to be put on a single line. | ||
| 114 | +# 允许短的代码块在一行内。如:if (a) { return; } | ||
| 115 | +AllowShortBlocksOnASingleLine: Never | ||
| 116 | + | ||
| 117 | +# If true, short case labels will be contracted to a single line. | ||
| 118 | +# 允许短的 case 分支在一行内。 | ||
| 119 | +AllowShortCaseLabelsOnASingleLine: true | ||
| 120 | + | ||
| 121 | +# 允许在单行上使用短枚举。 | ||
| 122 | +# true: | ||
| 123 | +# enum { A, B } myEnum; | ||
| 124 | +# | ||
| 125 | +# false: | ||
| 126 | +# enum { | ||
| 127 | +# A, | ||
| 128 | +# B | ||
| 129 | +# } myEnum; | ||
| 130 | +AllowShortEnumsOnASingleLine: true | ||
| 131 | + | ||
| 132 | +# Dependent on the value, int f() { return 0; } can be put on a single line. | ||
| 133 | +# 允许如 int f() { return 0; } 这样的短函数放在一行内。 | ||
| 134 | +# 参数可取值 | ||
| 135 | +# None: 从不 | ||
| 136 | +# Empty: 只适用于空函数 | ||
| 137 | +# Inline: 适用于定义在 class 内部的函数。包括 Empty。 | ||
| 138 | +# All: 适用于所有可以放在一行内的函数 | ||
| 139 | +AllowShortFunctionsOnASingleLine: Inline | ||
| 140 | + | ||
| 141 | +# Dependent on the value, auto lambda []() { return 0; } can be put on a single line. | ||
| 142 | +AllowShortLambdasOnASingleLine: All | ||
| 143 | + | ||
| 144 | +# If true, if (a) return; can be put on a single line. | ||
| 145 | +# Never: Never put short ifs on the same line. | ||
| 146 | +# WithoutElse: Without else put short ifs on the same line only if the else is not a compound statement. | ||
| 147 | +# Always: Always put short ifs on the same line if the else is not a compound statement or not. | ||
| 148 | +# 允许如 if (a) return; 这样短的 if 语句在一行内。 | ||
| 149 | +AllowShortIfStatementsOnASingleLine: Never | ||
| 150 | + | ||
| 151 | +# If true, while (true) continue; can be put on a single line. | ||
| 152 | +# 允许如 while (true) continue; 这样短的循环语句在一行内。 | ||
| 153 | +AllowShortLoopsOnASingleLine: false | ||
| 154 | + | ||
| 155 | +# The function definition return type breaking style to use. | ||
| 156 | +# 函数返回类型换行风格。 | ||
| 157 | +# 参数可取值 | ||
| 158 | +# None: 返回类型之后自动换行。PenaltyReturnTypeOnItsOwnLine 考虑在内。 | ||
| 159 | +# All: 返回类型之后总是断开。 | ||
| 160 | +# TopLevel: 只是在 Top Level 函数的返回类型之后断开 | ||
| 161 | +# 实测参数可取值为 true 和 false。 | ||
| 162 | +AlwaysBreakAfterDefinitionReturnType: None | ||
| 163 | + | ||
| 164 | +# The function declaration return type breaking style to use. | ||
| 165 | +# None: Break after return type automatically | ||
| 166 | +# All: Always break after the return type. | ||
| 167 | +# TopLevel: Always break after the return types of top-level functions. without class method | ||
| 168 | +# AllDefinitions: Always break after the return type of function definitions. with class method | ||
| 169 | +# TopLevelDefinitions: Always break after the return type of top-level definitions. | ||
| 170 | +# 总是在返回类型后换行: | ||
| 171 | +# None, All, TopLevel(顶级函数,不包括在类中的函数), | ||
| 172 | +# AllDefinitions(所有的定义,不包括声明), | ||
| 173 | +# TopLevelDefinitions(所有的顶级函数的定义) | ||
| 174 | +AlwaysBreakAfterReturnType: None | ||
| 175 | + | ||
| 176 | +# If true, always break before multiline string literals. | ||
| 177 | +# This flag is mean to make cases where there are multiple multiline strings in a file look more consistent. | ||
| 178 | +# Thus, it will only take effect if wrapping the string at that point leads to it being indented ContinuationIndentWidth spaces from the start of the line. | ||
| 179 | + | ||
| 180 | +# 如果为true,则始终在多行字符串文字之前断行。 | ||
| 181 | +# 此标志的意思是使文件中有多个多行字符串的情况看起来更一致。 | ||
| 182 | +# 因此,只有在该点处将字符串换行导致其从行首开始缩进ContinuationIndentWidth空格时,此选项才会生效。 | ||
| 183 | +# true: false: | ||
| 184 | +# aaaa = vs. aaaa = "bbbb" | ||
| 185 | +# "bbbb" "cccc"; | ||
| 186 | +# "cccc"; | ||
| 187 | +AlwaysBreakBeforeMultilineStrings: false | ||
| 188 | + | ||
| 189 | +# If true, always break after the template<...> of a template declaration. | ||
| 190 | +# 允许模板声明 template<...>之后总是断行 | ||
| 191 | +# No: Do not force break before declaration. PenaltyBreakTemplateDeclaration is taken into account. | ||
| 192 | +# 在声明前不强制换行。 PenaltyBreakTemplateDeclaration 被考虑在内。 | ||
| 193 | +# MultiLine: Force break after template declaration only when the following declaration spans multiple lines. | ||
| 194 | +# 仅当以下声明跨越多行时,才在模板声明后强制换行。 | ||
| 195 | +# Yes: Always break after template declaration. 总是在模板声明后换行 | ||
| 196 | +AlwaysBreakTemplateDeclarations: Yes | ||
| 197 | + | ||
| 198 | +# If false, a function call’s arguments will either be all on the same line or will have one line each. | ||
| 199 | +# 如果设置为 false,函数调用的参数要么所有都在同一行,要么每个独自占一行。各家都是 true。 | ||
| 200 | +BinPackArguments: true | ||
| 201 | + | ||
| 202 | +# If false, a function declaration’s or function definition’s parameters will either all be on the same line or will have one line each. | ||
| 203 | +# 如果设置为 false,函数声明或函数声明的参数要么都在同一行,要么每个独占一行。 | ||
| 204 | +BinPackParameters: true | ||
| 205 | + | ||
| 206 | +# AfterFunction true 规则【3.3.1】 | ||
| 207 | +BraceWrapping: | ||
| 208 | + AfterCaseLabel: false | ||
| 209 | + AfterClass: false | ||
| 210 | + AfterControlStatement: Never | ||
| 211 | + AfterEnum: false | ||
| 212 | + AfterFunction: false | ||
| 213 | + AfterNamespace: false | ||
| 214 | + AfterObjCDeclaration: false | ||
| 215 | + AfterStruct: false | ||
| 216 | + AfterUnion: false | ||
| 217 | + AfterExternBlock: false | ||
| 218 | + BeforeCatch: false | ||
| 219 | + BeforeElse: false | ||
| 220 | + IndentBraces: false | ||
| 221 | + SplitEmptyFunction: true | ||
| 222 | + SplitEmptyRecord: true | ||
| 223 | + SplitEmptyNamespace: true | ||
| 224 | + | ||
| 225 | +# The way to wrap binary operators. | ||
| 226 | +# 二元表达式操作数之前换行。 | ||
| 227 | +# 参数可取值 None, NonAssignment, All | ||
| 228 | +# WebKit 设置为 All,其他家设置为 None | ||
| 229 | +BreakBeforeBinaryOperators: None | ||
| 230 | + | ||
| 231 | +# The brace breaking style to use. | ||
| 232 | +# 大括号断行方式。 | ||
| 233 | +# 参数可取值 | ||
| 234 | +# Attach: Always attach braces to surrounding context. 总是连接括号,使其包围上下文。 | ||
| 235 | +# Linux: Like Attach, but break before braces on function, namespace and class definitions. 类似 Attach,但是在函数、命名空间和类定义的大括号前断行。 | ||
| 236 | +# Stroustrup: Like Attach, but break before function definitions, and ‘else’.类似 Attach,但是在函数和 else 的大括号前断行。 | ||
| 237 | +# Allman: Always break before braces. 总是在大括号前断行。 | ||
| 238 | +# GNU: Always break before braces and add an extra level of indentation to braces of control statements, not to those of class, function or other definitions. 总是在大括号前断行,并额外加一级缩进以控制语句(类和函数等的定义除外)。 | ||
| 239 | +# WebKit 是 Stroustrup,其他家都是 Attach。 | ||
| 240 | +BreakBeforeBraces: Custom | ||
| 241 | + | ||
| 242 | +# If true, in the class inheritance expression clang-format will break before : and , if there is multiple inheritance. | ||
| 243 | +# true: false: | ||
| 244 | +# class MyClass vs. class MyClass : public X, public Y { | ||
| 245 | +# : public X }; | ||
| 246 | +# , public Y { | ||
| 247 | +# }; | ||
| 248 | +# 如果有多重继承,继承类表达式会换行 ":" "," | ||
| 249 | +BreakBeforeInheritanceComma: false | ||
| 250 | + | ||
| 251 | +#The inheritance list style to use. | ||
| 252 | +# BeforeColon: Break inheritance list before the colon and after the commas. | ||
| 253 | +# class Foo | ||
| 254 | +# : Base1, | ||
| 255 | +# Base2 | ||
| 256 | +# {}; | ||
| 257 | +# BeforeComma: Break inheritance list before the colon and commas, and align the commas with the colon. | ||
| 258 | +# class Foo | ||
| 259 | +# : Base1 | ||
| 260 | +# , Base2 | ||
| 261 | +# {}; | ||
| 262 | +# AfterColon: Break inheritance list after the colon and commas. | ||
| 263 | +# class Foo : | ||
| 264 | +# Base1, | ||
| 265 | +# Base2 | ||
| 266 | +# {}; | ||
| 267 | +# AfterComma: Break inheritance list only after the commas. | ||
| 268 | +# class Foo : Base1, | ||
| 269 | +# Base2 | ||
| 270 | +# {}; | ||
| 271 | +BreakInheritanceList: BeforeColon | ||
| 272 | + | ||
| 273 | +# If true, ternary operators will be placed after line breaks. | ||
| 274 | +# 三元表达式操作数之前换行 | ||
| 275 | +# 各家都是 true。 | ||
| 276 | +BreakBeforeTernaryOperators: false | ||
| 277 | + | ||
| 278 | +# Always break constructor initializers before commas and align the commas with the colon. | ||
| 279 | +# 总是在构造函数初始化之前的逗号断行,并将逗号和冒号对齐。 | ||
| 280 | +BreakConstructorInitializersBeforeComma: false | ||
| 281 | + | ||
| 282 | +# The constructor initializers style to use. | ||
| 283 | +# BeforeColon: Break constructor initializers before the colon and after the commas. | ||
| 284 | +# BeforeComma: Break constructor initializers before the colon and commas, and align the commas with the colon. | ||
| 285 | +# AfterColon: Break constructor initializers after the colon and commas. | ||
| 286 | +# 构造函数初始化列表风格 | ||
| 287 | +# BeforeColon:在冒号在前,逗号在后换行 | ||
| 288 | +# BeforeComma: 在冒号、逗号前换行,用冒号对齐逗号 | ||
| 289 | +# AfterColon:在冒号后,逗号前换行 | ||
| 290 | +BreakConstructorInitializers: BeforeColon | ||
| 291 | + | ||
| 292 | +# Break after each annotation on a field in Java files. | ||
| 293 | +BreakAfterJavaFieldAnnotations: false | ||
| 294 | + | ||
| 295 | +# Allow breaking string literals when formatting. | ||
| 296 | +# 逐字符串换行 | ||
| 297 | +BreakStringLiterals: true | ||
| 298 | + | ||
| 299 | +# The column limit. | ||
| 300 | +# A column limit of 0 means that there is no column limit. In this case, clang-format will respect the input’s line breaking decisions within statements unless they contradict other rules. | ||
| 301 | +# 设置为 0,表示无限制。这种情况下,clang-format 保留用户输入时的换行,除非和其他规则冲突。 | ||
| 302 | +ColumnLimit: 120 | ||
| 303 | + | ||
| 304 | +# A regular expression that describes comments with special meaning, which should not be split into lines or otherwise changed. | ||
| 305 | +# 表示具有特殊含义的注释内容,该注释内容不允许分成多行或者以其他方式改变。各家设置都是这样的。 | ||
| 306 | +CommentPragmas: '^lint' | ||
| 307 | + | ||
| 308 | +# If true, consecutive namespace declarations will be on the same line. If false, each namespace is declared on a new line. | ||
| 309 | +# false: 每个命名空间一行 | ||
| 310 | +CompactNamespaces: false | ||
| 311 | + | ||
| 312 | +# If the constructor initializers don’t fit on a line, put each initializer on its own line. | ||
| 313 | +# 如果构造函数初始化一行内放不下,就把每个初始化值独立放在一行。 | ||
| 314 | +ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
| 315 | + | ||
| 316 | +# The number of characters to use for indentation of constructor initializer lists. | ||
| 317 | +# 构造函数初始值列表缩进值。各家都是4. | ||
| 318 | +ConstructorInitializerIndentWidth: 4 | ||
| 319 | + | ||
| 320 | +# Indent width for line continuations. | ||
| 321 | +# 行延续的缩进宽度。各家都是4. | ||
| 322 | +ContinuationIndentWidth: 4 | ||
| 323 | + | ||
| 324 | +# If true, format braced lists as best suited for C++11 braced lists. | ||
| 325 | +# Important differences: - No spaces inside the braced list. - No line break before the closing brace. - Indentation with the continuation indent, not with the block indent. | ||
| 326 | +# Fundamentally, C++11 braced lists are formatted exactly like function calls would be formatted in their place. If the braced list follows a name (e.g. a type or variable name), clang-format formats as if the {} were the parentheses of a function call with that name. If there is no name, a zero-length name is assumed. | ||
| 327 | +# 如果设置为 true,格式化大括号为 C++11 的大括号风格 | ||
| 328 | +# 重要差异:大括号中没有空格,右括号之前没有断行。根据续行的缩进而不是块缩进来缩进。 | ||
| 329 | +# 从根本上说,C++11 的大括号格式化和函数调用在自己的位置被格式化完全一致。如果大括号后面有一个类型名或变量名,clang-format 将把 {} 当做这个变量名或类型名的函数调用的括号。如果没有类型名或变量名,将假设这儿有一个 0 长度的类型名或变量名(来进行格式化)。 | ||
| 330 | +# Mozilla 和 WebKit 是 false,其余是 true。 | ||
| 331 | +Cpp11BracedListStyle: true | ||
| 332 | + | ||
| 333 | +# If true, analyze the formatted file for the most common alignment of & and *. PointerAlignment is then used only as fallback. | ||
| 334 | +# 分析将要格式化的文件中最通用的 & 和 * 的对齐方式。PointerAlignment 参数的设置仅作为一种后备方案。仅 Google 和 Mozilla 设置为 true。 | ||
| 335 | +DerivePointerAlignment: false | ||
| 336 | + | ||
| 337 | +# Disables formatting completely. | ||
| 338 | +# 完全禁用代码格式化 | ||
| 339 | +DisableFormat: false | ||
| 340 | + | ||
| 341 | +# If true, clang-format detects whether function calls and definitions are formatted with one parameter per line. | ||
| 342 | +# Each call can be bin-packed, one-per-line or inconclusive. If it is inconclusive, e.g. completely on one line, but a decision needs to be made, clang-format analyzes whether there are other bin-packed cases in the input file and act accordingly. | ||
| 343 | +# NOTE: This is an experimental flag, that might go away or be renamed. Do not use this in config files, etc. Use at your own risk. | ||
| 344 | +# 如果设置为 true,clang-format 将会检测函数调用和声明时是否格式化为了每个参数独占一行。 | ||
| 345 | +# 每个函数调用都可以格式化为 bin-packed(集装优化,见 Wikipedia 词条 Bin packing problem),也可以格式化为每个参数独占一行,或者二者均可。如果不确定,假如完全在一行,clang-format 将分析欲格式化的文件中类似场景的格式化方式并作相同的处理。 | ||
| 346 | +# 注意:这是一个实验性的设置项。该设置项可能会去掉或者重命名,除非你愿意自担风险,否则不要使用该设置项。 | ||
| 347 | +ExperimentalAutoDetectBinPacking: false | ||
| 348 | + | ||
| 349 | +# If true, clang-format adds missing namespace end comments and fixes invalid existing ones. | ||
| 350 | +# 增加或修复命名空间注释 | ||
| 351 | +FixNamespaceComments: true | ||
| 352 | + | ||
| 353 | +# A vector of macros that should be interpreted as foreach loops instead of as function calls. | ||
| 354 | +# These are expected to be macros of the form: FOREACH(<variable-declaration>, ...) <loop-body> | ||
| 355 | +# For example: BOOST_FOREACH. | ||
| 356 | +# 应该被解释为 foreach 循环而不是函数调用的宏 | ||
| 357 | +# 形式如 FOREACH(<variable-declaration>, ...) <loop-body> 的宏 | ||
| 358 | +# 例如:BOOST_FOREACH。各家都是这样设置的。 | ||
| 359 | +ForEachMacros: | ||
| 360 | + - foreach | ||
| 361 | + - Q_FOREACH | ||
| 362 | + - BOOST_FOREACH | ||
| 363 | + | ||
| 364 | +IncludeBlocks: Regroup | ||
| 365 | + | ||
| 366 | +IncludeCategories: | ||
| 367 | + - Regex: '^<ext/.*\.h>' | ||
| 368 | + Priority: 2 | ||
| 369 | + - Regex: '^<.*\.h>' | ||
| 370 | + Priority: 1 | ||
| 371 | + - Regex: '^<.*' | ||
| 372 | + Priority: 2 | ||
| 373 | + - Regex: '.*' | ||
| 374 | + Priority: 3 | ||
| 375 | + | ||
| 376 | +IncludeIsMainRegex: '(Test)?$' | ||
| 377 | + | ||
| 378 | +# Indent case labels one level from the switch statement. | ||
| 379 | +# When false, use the same indentation level as for the switch statement. Switch statement body is always indented one level more than case labels. | ||
| 380 | +# 相比 switch,对 case 缩进一级。 | ||
| 381 | +# 当设置为 false 是,对 case 和 switch 使用相同的缩进级别。Switch 语句的内容总是比 case 多缩进一个级别。 | ||
| 382 | +IndentCaseLabels: true | ||
| 383 | + | ||
| 384 | +IndentPPDirectives: None | ||
| 385 | + | ||
| 386 | +# The number of columns to use for indentation. | ||
| 387 | +# 缩进宽度 | ||
| 388 | +IndentWidth: 4 | ||
| 389 | + | ||
| 390 | +# Indent if a function definition or declaration is wrapped after the type. | ||
| 391 | +# 对在返回类型之后换行的函数定义或声明进行缩进。各家都是 false。 | ||
| 392 | +IndentWrappedFunctionNames: false | ||
| 393 | + | ||
| 394 | +JavaScriptQuotes: Leave | ||
| 395 | +JavaScriptWrapImports: true | ||
| 396 | + | ||
| 397 | +# If true, empty lines at the start of blocks are kept. | ||
| 398 | +# 保留代码块之前的空行。只有 Google 家的是false。 | ||
| 399 | +KeepEmptyLinesAtTheStartOfBlocks: false | ||
| 400 | + | ||
| 401 | +MacroBlockBegin: "\ | ||
| 402 | +^ *PROG *$|\ | ||
| 403 | +^ *PROC *$|\ | ||
| 404 | +CATCH_ALL_ERROR.*$" | ||
| 405 | +MacroBlockEnd: "\ | ||
| 406 | +^ *END_PROG *$|\ | ||
| 407 | +^ *END_PROC *$|\ | ||
| 408 | +END_CATCH_ERROR$" | ||
| 409 | + | ||
| 410 | +# The maximum number of consecutive empty lines to keep. | ||
| 411 | +# 保留的最大连续空行数 | ||
| 412 | +MaxEmptyLinesToKeep: 1 | ||
| 413 | + | ||
| 414 | +# The indentation used for namespaces. | ||
| 415 | +# 命名空间缩进 | ||
| 416 | +# 参数可取值 | ||
| 417 | +# None: 不缩进 | ||
| 418 | +# Inner: 只对内部命名空间 | ||
| 419 | +# All | ||
| 420 | +# 只有 WebKit 设置为 Inner,其他家都是 None。 | ||
| 421 | +NamespaceIndentation: None | ||
| 422 | + | ||
| 423 | +# Controls bin-packing Objective-C protocol conformance list items into as few lines as possible when they go over ColumnLimit. | ||
| 424 | +# BPS_Auto (in configuration: Auto) Automatically determine parameter bin-packing behavior. | ||
| 425 | +# BPS_Always (in configuration: Always) Always bin-pack parameters. | ||
| 426 | +# BPS_Never (in configuration: Never) Never bin-pack parameters. | ||
| 427 | +ObjCBinPackProtocolList: Never | ||
| 428 | + | ||
| 429 | +# The number of characters to use for indentation of ObjC blocks. | ||
| 430 | +# Objc blocks 缩进。 | ||
| 431 | +ObjCBlockIndentWidth: 4 | ||
| 432 | + | ||
| 433 | +# Add a space after @property in Objective-C, i.e. use @property (readonly) instead of @property(readonly). | ||
| 434 | +# Objective-C 语言 @property 后面加一个空格。形如 @property (readonly) 而非 @property(readonly)。 | ||
| 435 | +ObjCSpaceAfterProperty: false | ||
| 436 | + | ||
| 437 | +# Add a space in front of an Objective-C protocol list, i.e. use Foo <Protocol> instead of Foo<Protocol>. | ||
| 438 | +# 为 Objective-C 语言 protocol 列表之前加一个空格。形如 Foo <Protocol> 而非 Foo<Protocol>。 | ||
| 439 | +ObjCSpaceBeforeProtocolList: true | ||
| 440 | + | ||
| 441 | +# The penalty for breaking around an assignment operator. | ||
| 442 | +PenaltyBreakAssignment: 2 | ||
| 443 | + | ||
| 444 | +# The penalty for breaking a function call after “call(”. | ||
| 445 | +# 函数调用 call( 断行之后的惩罚(补偿?啥意思不明白)。Google家是 1,其他家都是 19。 | ||
| 446 | +PenaltyBreakBeforeFirstCallParameter: 1 | ||
| 447 | + | ||
| 448 | +# The penalty for each line break introduced inside a comment. | ||
| 449 | +# 注释内部断行之后的惩罚。各家都是 300。 | ||
| 450 | +PenaltyBreakComment: 300 | ||
| 451 | + | ||
| 452 | +# The penalty for breaking before the first <<. | ||
| 453 | +# << 断行之前的惩罚。各家都是 120。 | ||
| 454 | +PenaltyBreakFirstLessLess: 120 | ||
| 455 | + | ||
| 456 | +# The penalty for each line break introduced inside a string literal. | ||
| 457 | +# 字符串内部断行之后的惩罚。各家都是 1000。 | ||
| 458 | +PenaltyBreakString: 1000 | ||
| 459 | + | ||
| 460 | +# The penalty for breaking after template declaration. | ||
| 461 | +PenaltyBreakTemplateDeclaration: 10 | ||
| 462 | + | ||
| 463 | +# The penalty for each character outside of the column limit. | ||
| 464 | +# 对每个超出行限制的字符的惩罚。各家都是 1,000,000。 | ||
| 465 | +PenaltyExcessCharacter: 1000000 | ||
| 466 | + | ||
| 467 | +# Penalty for putting the return type of a function onto its own line. | ||
| 468 | +# 对把返回类型放置在自己行内惩罚。WebKit 和 LLVM 是 60,其他家都是 200。 | ||
| 469 | +PenaltyReturnTypeOnItsOwnLine: 200 | ||
| 470 | + | ||
| 471 | +# Pointer and reference alignment style. | ||
| 472 | +# 指针和引用的对齐方式。 | ||
| 473 | +# 参数可取值 Left, Right, Middle。火狐和 Google 家都在左边。 | ||
| 474 | +PointerAlignment: Right | ||
| 475 | + | ||
| 476 | +# Defines hints for detecting supported languages code blocks in raw strings. | ||
| 477 | +# Defines hints for detecting supported languages code blocks in raw strings. | ||
| 478 | +# A raw string with a matching delimiter or a matching enclosing function name will be reformatted assuming the specified | ||
| 479 | +# language based on the style for that language defined in the .clang-format file. If no style has been defined in the | ||
| 480 | +# .clang-format file for the specific language, a predefined style given by ‘BasedOnStyle’ is used. | ||
| 481 | +# If ‘BasedOnStyle’ is not found, the formatting is based on llvm style. A matching delimiter takes precedence over a matching | ||
| 482 | +# enclosing function name for determining the language of the raw string contents. | ||
| 483 | +# If a canonical delimiter is specified, occurrences of other delimiters for the same language will be updated to the canonical if possible. | ||
| 484 | +# There should be at most one specification per language and each delimiter and enclosing function should not occur in multiple specifications. | ||
| 485 | +# To configure this in the .clang-format file, use: | ||
| 486 | + | ||
| 487 | +# 定义用于检测原始字符串中支持的语言代码块的提示。 | ||
| 488 | +# 将根据.clang格式文件中定义的指定语言,使用指定的语言重新格式化具有匹配的定界符或包含的封闭函数名称的原始字符串。 | ||
| 489 | +# 如果在.clang格式的文件中未为特定语言定义任何样式,则使用“ BasedOnStyle”给出的预定义样式。如果未找到“ BasedOnStyle”, | ||
| 490 | +# 则格式基于llvm样式。匹配的定界符优先于匹配的包围函数名称,用于确定原始字符串内容的语言。 | ||
| 491 | +# 如果指定了规范定界符,则在可能的情况下,针对相同语言的其他定界符的出现将更新为规范。 | ||
| 492 | +# 每种语言最多应有一个规范,并且每个分隔符和封闭函数不应出现在多个规范中。 | ||
| 493 | +# 要在.clang格式的文件中进行配置,请使用: | ||
| 494 | + | ||
| 495 | +RawStringFormats: | ||
| 496 | + - Language: Cpp | ||
| 497 | + Delimiters: | ||
| 498 | + - cc | ||
| 499 | + - CC | ||
| 500 | + - cpp | ||
| 501 | + - Cpp | ||
| 502 | + - CPP | ||
| 503 | + - 'c++' | ||
| 504 | + - 'C++' | ||
| 505 | + CanonicalDelimiter: '' | ||
| 506 | + BasedOnStyle: google | ||
| 507 | + - Language: TextProto | ||
| 508 | + Delimiters: | ||
| 509 | + - pb | ||
| 510 | + - PB | ||
| 511 | + - proto | ||
| 512 | + - PROTO | ||
| 513 | + EnclosingFunctions: | ||
| 514 | + - EqualsProto | ||
| 515 | + - EquivToProto | ||
| 516 | + - PARSE_PARTIAL_TEXT_PROTO | ||
| 517 | + - PARSE_TEST_PROTO | ||
| 518 | + - PARSE_TEXT_PROTO | ||
| 519 | + - ParseTextOrDie | ||
| 520 | + - ParseTextProtoOrDie | ||
| 521 | + CanonicalDelimiter: '' | ||
| 522 | + BasedOnStyle: google | ||
| 523 | + | ||
| 524 | +# If true, clang-format will attempt to re-flow comments. | ||
| 525 | +# 允许重新排版注释 | ||
| 526 | +ReflowComments: true | ||
| 527 | + | ||
| 528 | +# If true, clang-format will sort #includes. | ||
| 529 | +# 允许排序#include | ||
| 530 | +SortIncludes: Never | ||
| 531 | + | ||
| 532 | +# If true, clang-format will sort using declarations. | ||
| 533 | +# 允许排序using声明 | ||
| 534 | +SortUsingDeclarations: true | ||
| 535 | + | ||
| 536 | +# If true, a space may be inserted after C style casts. | ||
| 537 | +# C 风格的类型转换后面插入一个空格。 | ||
| 538 | +# 各家都是 false。 | ||
| 539 | +SpaceAfterCStyleCast: false | ||
| 540 | + | ||
| 541 | +# If true, a space is inserted after the logical not operator (!). | ||
| 542 | +# true: 在逻辑非前面插入一个空格 | ||
| 543 | +SpaceAfterLogicalNot: false | ||
| 544 | + | ||
| 545 | +# If true, a space will be inserted after the ‘template’ keyword. | ||
| 546 | +# true: 在template关键字后面插入一个空格 | ||
| 547 | +SpaceAfterTemplateKeyword: true | ||
| 548 | + | ||
| 549 | +# If false, spaces will be removed before assignment operators. | ||
| 550 | +# 如果设置为 false,赋值运算符前面的空格将会被删除。 | ||
| 551 | +SpaceBeforeAssignmentOperators: true | ||
| 552 | + | ||
| 553 | +# If true, a space will be inserted before a C++11 braced list used to initialize an object (after the preceding identifier or type). | ||
| 554 | +# 如果为true,将在用于初始化对象的C ++ 11括号列表之前(前面的标识符或类型之后)插入一个空格。 | ||
| 555 | +SpaceBeforeCpp11BracedList: false | ||
| 556 | + | ||
| 557 | +# If false, spaces will be removed before constructor initializer colon. | ||
| 558 | +# 如果为false,则将在构造函数初始化程序冒号之前删除空格。 | ||
| 559 | +SpaceBeforeCtorInitializerColon: true | ||
| 560 | + | ||
| 561 | +# If false, spaces will be removed before inheritance colon. | ||
| 562 | +# 如果为false,则在继承冒号之前将删除空格。 | ||
| 563 | +SpaceBeforeInheritanceColon: true | ||
| 564 | + | ||
| 565 | +# Defines in which cases to put a space before opening parentheses. | ||
| 566 | +# 定义开括号前加空格的风格。 | ||
| 567 | +# 可取参数值 | ||
| 568 | +# Never 从不 | ||
| 569 | +# ControlStatements 只对 for, if, while 这样的控制语句的关键字后加。 | ||
| 570 | +# Always 除非语法规则禁止或者其他 clang-format 归档已经定义了,不然总是在开括号前加空格。 | ||
| 571 | +# 这个没啥好争议的,各家都设置为 ControlStatements。 | ||
| 572 | +SpaceBeforeParens: ControlStatements | ||
| 573 | + | ||
| 574 | +# If false, spaces will be removed before range-based for loop colon. | ||
| 575 | +# 如果为false,则会在基于范围的循环冒号之前删除空格。 | ||
| 576 | +SpaceBeforeRangeBasedForLoopColon: true | ||
| 577 | + | ||
| 578 | +# If true, spaces may be inserted into ‘()’. | ||
| 579 | +# 空括号 () 中插入一个空格。 | ||
| 580 | +# 各家都没开。 | ||
| 581 | +SpaceInEmptyParentheses: false | ||
| 582 | + | ||
| 583 | +# The number of spaces before trailing line comments (// - comments). | ||
| 584 | +# This does not affect trailing block comments (/**/ - comments) as those commonly have different usage patterns and a number of special cases. | ||
| 585 | +# 行尾注释前的空格数。 | ||
| 586 | +# 仅对 // 生效,对行尾的注释块 /**/ 以及那些常用的具有不同使用模式和一系列特殊场景不生效。 | ||
| 587 | +SpacesBeforeTrailingComments: 1 | ||
| 588 | + | ||
| 589 | +# If true, spaces will be inserted after ‘<’ and before ‘>’ in template argument lists | ||
| 590 | +# 尖括号内部列表前加空格。 | ||
| 591 | +SpacesInAngles: false | ||
| 592 | + | ||
| 593 | +# If true, spaces are inserted inside container literals (e.g. ObjC and Javascript array and dict literals). | ||
| 594 | +# 容器内的文字插入空格。如 Objc 和 Javascript 的数组和字典。形如 @[ @"a", @"b" ] | ||
| 595 | +# true: false: | ||
| 596 | +# var arr = [ 1, 2, 3 ]; vs. var arr = [1, 2, 3]; | ||
| 597 | +# f({a : 1, b : 2, c : 3}); f({a: 1, b: 2, c: 3}); | ||
| 598 | +SpacesInContainerLiterals: false | ||
| 599 | + | ||
| 600 | +# If true, spaces may be inserted into C style casts. | ||
| 601 | +# C 风格类型转换括号内插入空格。形如float fffff = ( float )aaa; | ||
| 602 | +SpacesInCStyleCastParentheses: false | ||
| 603 | + | ||
| 604 | + | ||
| 605 | +# If true, spaces will be inserted after ‘(‘ and before ‘)’. | ||
| 606 | +# 圆括号内加空格。 | ||
| 607 | +SpacesInParentheses: false | ||
| 608 | + | ||
| 609 | +# If true, spaces will be inserted after ‘[‘ and before ‘]’. | ||
| 610 | +# 方括号内加空格。 | ||
| 611 | +SpacesInSquareBrackets: false | ||
| 612 | + | ||
| 613 | +# Format compatible with this standard, e.g. use A<A<int> > instead of A<A<int>> for LS_Cpp03. | ||
| 614 | +# 代码格式化兼容标准。如 Cpp03 中 A<A<int> > 而不是 A<A<int>>。 | ||
| 615 | +# 参数可取值 | ||
| 616 | +# LS_Cpp03 (in configuration: c++03) Parse and format as C++03. Cpp03 is a deprecated alias for c++03 | ||
| 617 | +# LS_Cpp11 (in configuration: c++11) Parse and format as C++11. | ||
| 618 | +# LS_Cpp14 (in configuration: c++14) Parse and format as C++14. | ||
| 619 | +# LS_Cpp17 (in configuration: c++17) Parse and format as C++17. | ||
| 620 | +# LS_Cpp20 (in configuration: c++20) Parse and format as C++20. | ||
| 621 | +# LS_Latest (in configuration: Latest) Parse and format using the latest supported language version. Cpp11 is a deprecated alias for Latest | ||
| 622 | +# LS_Auto (in configuration: Auto) Automatic detection based on the input. | ||
| 623 | +Standard: Latest | ||
| 624 | + | ||
| 625 | +# The number of columns used for tab stops. | ||
| 626 | +# Tab 宽度。各家都是 8,但是各家都 Never UseTab。 | ||
| 627 | +TabWidth: 4 | ||
| 628 | + | ||
| 629 | +# The way to use tab characters in the resulting file. | ||
| 630 | +# tab 字符使用情况。 | ||
| 631 | +# 参数可取值 | ||
| 632 | +# Never, ForIndentation, Always | ||
| 633 | +UseTab: Never | ||
| 634 | +... | ||
| 635 | + | ||