官方文檔:http://clang.llvm.org/docs/ClangFormatStyleOptions.htmlhtml
中文c++
在代碼中配置樣式 當使用 clang::format::reformat(...) 方法, 格式將被clang::format::FormatStyle 框架指定。 配置格式化樣式選項 這一部分列出了被支持的選項。 每一個操做都有指定類型。 枚舉類型的可能的值,被C++枚舉(一個預編譯,例如:LS_Auto)和配置中的一個值(沒有預編譯:Auto)指定。 BasedOnStyle (string) 這個樣式用於全部沒有特殊指定配置的選項。 這個選項僅在clang-format配置中支持(在-style='{...}' 和 .clang-format 文件裏). 可能的值有: LLVM:符合LLVM代碼標準的樣式 Google:符合谷歌的c++樣式指南的樣式 Chromium:符合Chromium樣式指南的樣式 Mozilla:符合Mozilla樣式指南的樣式 WebKit:符合WebKit的樣式指南的樣式 AccessModifierOffset (int) 訪問修飾符的縮進或者向外伸展,例如 public:。 AlignAfterOpenBracket (BracketAlignmentStyle) 若是爲真(true),在一個左圓括號後水平對齊參數 這會應用在圓括號,尖括號和中(方)括號。 可能的值有: BAS_Align (在配置中: Align) 在左圓括號後調整參數, 例如: someLongFunction(argument1, argument2); BAS_DontAlign (在配置中: DontAlign) 不調整, 換用 ContinuationIndentWidth, 例如: someLongFunction(argument1, argument2); BAS_AlwaysBreak (在配置中: AlwaysBreak) 在左圓括號後老是換行, 若是參數不能適應單行, 例如: someLongFunction( argument1, argument2); AlignConsecutiveAssignments (bool) 若是爲真(true),連續調整多行 這將會調整連續行中的分配操做符。這將會致使像下面這樣的格式: int aaaa = 12; int b = 23; int ccc = 23; AlignConsecutiveDeclarations (bool) 若是爲真(true), 校準連續的聲明。 這將會校準連續多行的聲明的名字。這將會致使像下面這樣的格式: int aaaa = 12; float b = 23; std::string ccc = 23; AlignEscapedNewlinesLeft (bool) 若是爲真(true), 校準被忽略的新行距左邊儘量遠。或者把它們放到列的最右邊 AlignOperands (bool) 若是爲真(true), 水平對齊二進制和三元表達式的操做數。 具體來講,這將一個表達式的操做數對準一個須要被分割的多行的操做數, 例如: int aaa = bbbbbbbbbbbbbbb + ccccccccccccccc; AlignTrailingComments (bool) 若是爲真(true), 對齊註釋。 AllowAllParametersOfDeclarationOnNextLine (bool) 即便BinPackParameters是假的,也容許將一個函數聲明的全部參數移到下一行. AllowShortBlocksOnASingleLine (bool) 容許將簡單的語句塊放到一個單行. 例如, 這容許 將 語句 「if (a) { return; }」 放到一個單行. AllowShortCaseLabelsOnASingleLine (bool) 若是爲真(true), 很短的狀況下的標籤將會被放到單獨的行。 AllowShortFunctionsOnASingleLine (ShortFunctionStyle) 取決於值, 語句「int f() { return 0; }」能夠被放到一個單行。 可能的值有: SFS_None (在配置中: None) 從不合並方法或函數到單獨的一行。 SFS_Empty (在配置中: Empty) 僅合併空的函數。 SFS_Inline (在配置中: Inline) 僅合併類中定義的方法或函數. 意味着 「empty」. SFS_All (在配置中: All) 合併全部的方法適應單行. AllowShortIfStatementsOnASingleLine (bool) 若是爲真(true), 語句「if (a) return;」 能被放到單行。 AllowShortLoopsOnASingleLine (bool) 若是爲真(true), 語句「while (true) continue;」 能被放到單行。 AlwaysBreakAfterDefinitionReturnType (DefinitionReturnTypeBreakingStyle) 用於函數定義返回類型換行樣式。這個選項是過期的而且被保留向後兼容。 可能的值有: DRTBS_None (在配置中: None) 再返回類型後自動換行。PenaltyReturnTypeOnItsOwnLine 會被考慮到. DRTBS_All (在配置中: All) 老是在返回類型後換行。 DRTBS_TopLevel (在配置中: TopLevel) 老是在返回類型的頂級函數後換行。 AlwaysBreakAfterReturnType (ReturnTypeBreakingStyle) 用於函數聲明返回類型換行樣式。 可能的值有: RTBS_None (在配置中: None) 在返回類型後自動換行。「PenaltyReturnTypeOnItsOwnLine」會被考慮. RTBS_All (在配置中: All) 再返回類型後老是換行。 RTBS_TopLevel (在配置中: TopLevel) 在方法的頂層的返回類型後老是換行。 RTBS_AllDefinitions (在配置中: AllDefinitions) 在方法定義中的返回類型後老是換行。 RTBS_TopLevelDefinitions (在配置中: TopLevelDefinitions) 在頂層定義的返回類型後老是換行。 AlwaysBreakBeforeMultilineStrings (bool) 若是爲真(true), 在多行字面量字符串前老是換行。 這個標誌意味着使在文件中有多行字符串的狀況看起來更一致。所以,若是字符串被「ContinuationIndentWidth」空格致使換行,它將會在行首生效。 AlwaysBreakTemplateDeclarations (bool) 若是爲真(true), 在模板聲明「template<...>」後老是換行 BinPackArguments (bool) 若是爲假(false), 函數調用的參數要麼是在同一行上,要麼將在同一行上有一行。 BinPackParameters (bool) 若是爲假(false), 函數聲明或函數定義的參數將都在同一行上,或各有一行。 BraceWrapping (BraceWrappingFlags) 控制單獨的大括號換行事件。 若是「BreakBeforeBraces」設置爲「BS_Custom」, 使用這個指定如何處理每一個單獨的括號的狀況。不然,這是被忽略的。 嵌套結構的標誌: bool AfterClass 使類定義換行. bool AfterControlStatement 使控制語句(if/for/while/switch/..)換行。 bool AfterEnum 使枚舉定義換行。 bool AfterFunction 使方法定義換行。 bool AfterNamespace 使命名空間定義換行。 bool AfterObjCDeclaration 使OC定義(@autoreleasepool, interfaces, ..)換行。 bool AfterStruct 使結構定義換行。 bool AfterUnion 使共同體定義換行。 bool BeforeCatch 在catch以前換行。 bool BeforeElse 在else以前換行。 bool IndentBraces 縮進換行的大括號。 BreakAfterJavaFieldAnnotations (bool) 在JAVA文件中每一個註釋後換行。 BreakBeforeBinaryOperators (BinaryOperatorStyle) 使二進制操做符換行的方法。 可能的值有: BOS_None (在配置中: None) 在操做符後換行。 BOS_NonAssignment (在配置中: NonAssignment) 在操做符沒有被指定前換行。 BOS_All (在配置中: All) 在操做符前換行。 BreakBeforeBraces (BraceBreakingStyle) 用於大括號換行樣式。 可能的值有: BS_Attach (在配置中: Attach) 老是將大括號與上下文連在一塊兒。 BS_Linux (在配置中: Linux) 像Attach同樣, 可是在一個方法、命名空間或一個類定義的大括號以前換行 BS_Mozilla (在配置中: Mozilla) 像Attach同樣, 可是在一個枚舉、方法或記錄定義前換行。 BS_Stroustrup (在配置中: Stroustrup) 像Attach同樣,可是在方法定義、catch、和else前換行 BS_Allman (在配置中: Allman) 老是在大括號以前換行。 BS_GNU (在配置中: GNU) 老是在括號前中斷,並添加一個額外的級別的縮進到控件語句的括號中,而不是類、函數或其餘定義的括號中。 BS_WebKit (在配置中: WebKit) 像Attach同樣, 可是在方法前換行。 BS_Custom (在配置中: Custom) 在「BraceWrapping」裏配置每個單獨的大括號。 BreakBeforeTernaryOperators (bool) 若是爲真(true), 三元運算符將被放置在換行後。 BreakConstructorInitializersBeforeComma (bool) 老是在逗號和對齊逗號跟冒號前把構造函數初始化式換行。 BreakStringLiterals (bool) 當格式化時,老是對字面量字符串換行。 ColumnLimit (unsigned) 限制列。 列的限制爲0意味着沒有列限制。在這種狀況下,clang-format將謹慎對待在聲明中輸入行的換行決定,除非與其餘規則矛盾。 CommentPragmas (std::string) 一個固定的表達式,它描述了具備特殊意義的註釋,不該該被分裂成行或以其餘方式改變。 ConstructorInitializerAllOnOneLineOrOnePerLine (bool) 若是構造函數初始化器不適合在一行,把每一個初始化放到單獨的行。 ConstructorInitializerIndentWidth (unsigned) 使用構造函數初始化列表縮進的字符數。 ContinuationIndentWidth (unsigned) 新行縮進寬度。 Cpp11BracedListStyle (bool) 若是爲真(true),格式化大括號列表達到最適合c++11列表。 重要區別:-沒有空格內的大括號列表。-大括號關閉前沒有換行。與延續縮進縮進,不與塊縮進。 從根本上講,C++ 11大括號列表與函數調用格式化是如出一轍的。若是大括號列表跟着一個名字(例如類型或變量名),clang-format的格式像是一個調用那個名字的函數的圓括號的「{}」。若是沒有名稱,則假定一個零長度的名稱。 DerivePointerAlignment (bool) 若是爲真(true), 分析最多見的格式化文件中「&」和「\*」的對齊方式。pointeralignment則僅做爲後備。 DisableFormat (bool) 徹底禁止格式化。 ExperimentalAutoDetectBinPacking (bool) 若是爲真(true), clang-format檢測函數調用和定義格式化爲每行一個參數。 每一個調用均可以被包裝,每行一個或不肯定的。若是是不肯定的,例如徹底在一行,但須要作出一個決定,clang-format分析文件中是否有其餘被包裝的事例和相應的行動。 注意:這是一個實驗標誌,可能會消失或被重命名。不要在配置文件中使用。你本身要爲你的使用負責。 ForEachMacros (std::vector<std::string>) 一個宏,應解釋爲foreach循環而不是做爲函數調用矢量。 這些都是預期形式的宏: FOREACH(<variable-declaration>, ...) <loop-body> 在.clang-format 配置文件中, 這能夠被設定爲: ForEachMacros: ['RANGES_FOR', 'FOREACH'] 例如: BOOST_FOREACH. IncludeCategories (std::vector<IncludeCategory>) 正則表達式表示不一樣的#include類別被用於#includes命令。 這些正則表達式與一個包含(包括< >或「)的文件的文件名相匹配。屬於第一匹配正則表達式的值被分配,而且#include首先根據增長類別數而後在每一個類別按字母的順序排序。 若是正則表達式都不匹配,int_max分配類別。源文件的主要頭引用自動獲取類別0。所以,它一般是保持在#include開頭(http://llvm.org/docs/CodingStandards.html#include-style)。然而,若是你有老是須要排在首位的頭引用,你也能夠分配負面的優先事項。 爲了在.clang-format文件中配置這個, 請使用: IncludeCategories: - Regex: '^"(llvm|llvm-c|clang|clang-c)/' Priority: 2 - Regex: '^(<|"(gtest|isl|json)/)' Priority: 3 - Regex: '.\*' Priority: 1 IncludeIsMainRegex (std::string) 指定一個經常使用的能夠在文件主要包括映射的正則表達式的表達式。 在猜想是否#include是「main」include(指定類別0,見上文),使用這個正則表達式容許後綴的頭引用源。部分匹配完成,因此說:-「」意思是任意後綴,-「$」的意思是沒有後綴 例如,若是配置」(_test)?$」,而後.h將被視爲包括在a.cc和a_test.ccde中的「main」。 IndentCaseLabels (bool) 從switch語句縮進case標籤一級。 當錯誤時,使用相同的縮進級別做爲切換語句。switch語句的語句體老是縮進一級以上的case標籤。 IndentWidth (unsigned) 用於縮進的列數。 IndentWrappedFunctionNames (bool) 縮進若是函數定義或聲明後包的類型。 JavaScriptQuotes (JavaScriptQuoteStyle) JavaScriptQuoteStyle 使用JavaScript字符串。 可能的值有: JSQS_Leave (在配置中: Leave) 留下字符串本來的括號 JSQS_Single (在配置中: Single) 老是使用單括號 JSQS_Double (在配置中: Double) 老是使用雙括號. KeepEmptyLinesAtTheStartOfBlocks (bool) 若是爲真(true), 保持塊的起始空行。 Language (LanguageKind) 這種格式針對的是語言。 可能的值有: LK_None (在配置中: None) 不使用 LK_Cpp (在配置中: Cpp) 應該被用於C, C++, ObjectiveC, ObjectiveC++. LK_Java (在配置中: Java) 應該被用於Java. LK_JavaScript (在配置中: JavaScript) 應該被用於 JavaScript. LK_Proto (在配置中: Proto) 應該被用於 Protocol 緩衝 (https://developers.google.com/protocol-buffers/). LK_TableGen (在配置中: TableGen) 應該被用於 TableGen 代碼. MacroBlockBegin (std::string) 匹配宏指令的一個經常使用於開始一個塊的表達式。 MacroBlockEnd (std::string) 匹配宏指令的一個經常使用於結束一個塊的表達式。 MaxEmptyLinesToKeep (unsigned) 連續空行的最大數。 NamespaceIndentation (NamespaceIndentationKind) 用於命名空間的縮排。 可能的值有: NI_None (在配置中: None) 在命名空間中不縮進。 NI_Inner (在配置中: Inner) 僅在內部命名空間縮進(嵌套在其餘命名空間)。 NI_All (在配置中: All) 在全部的命名空間中縮進。 ObjCBlockIndentWidth (unsigned) OC塊中所拍的字符數。 ObjCSpaceAfterProperty (bool) 在OC中的@property後面添加一個空格。例如:使用「@property (readonly)」而不是「@property(readonly)」。 ObjCSpaceBeforeProtocolList (bool) 在OC協議列表前添加一個空格, 例如: 使用<Protocol>而不是<Protocol>。 PenaltyBreakBeforeFirstCallParameter (unsigned) 在調用小括號「(」後給一個方法調用換行的處罰。 PenaltyBreakComment (unsigned) 包含在一個註釋中的每個換行的處罰。 PenaltyBreakFirstLessLess (unsigned) 在第一個「<<」前的換行的處罰。 PenaltyBreakString (unsigned) 包含一個字面量的字符串中的每個換行的處罰。 PenaltyExcessCharacter (unsigned) 每個字符的列限制外的處罰。 PenaltyReturnTypeOnItsOwnLine (unsigned) 把一個方法返回類型放到函數的同一行。 PointerAlignment (PointerAlignmentStyle) 指針和引用的對其方式。 可能的值有: PAS_Left (在配置中: Left) 指針左對齊。 PAS_Right (在配置中: Right) 指針右對齊。 PAS_Middle (在配置中: Middle) 指針中間對齊。 ReflowComments (bool) 若是爲真(true), clang-format 將會嘗試將註釋從新流佈局。 SortIncludes (bool) 若是爲真(true), clang-format 將會分類#includes. SpaceAfterCStyleCast (bool) 若是爲真(true), 可能在一個C樣式描述後插入一個空格。 SpaceAfterTemplateKeyword (bool) 若是爲真(true), 在「template」關鍵字後插入一個空格。 SpaceBeforeAssignmentOperators (bool) 若是爲假(false),移除分配操做符(=)前空格。 SpaceBeforeParens (SpaceBeforeParensOptions) 大括號以前定義空格的狀況。 可能的值有: SBPO_Never (在配置中: Never) 從不在圓括號以前加空格。 SBPO_ControlStatements (在配置中: ControlStatements) 僅在控制聲明關鍵詞(for/if/while···)的圓括號前面加空格。 SBPO_Always (在配置中: Always) 總在圓括號前面加空格, 除了語法規則禁止的(在方法中-像宏定義)或者 當其餘樣式規則定義過的(在一元運算符後,圓括號, 等等) SpaceInEmptyParentheses (bool) 若是爲真(true), 可能會在「()」中插入空格。 SpacesBeforeTrailingComments (unsigned) 單行註釋前的空格數(// - comments)。 這不會影響塊註釋(/* - comments),由於它們一般會有不一樣的使用模式和一些特殊狀況。 SpacesInAngles (bool) 若是爲真(true), 將會在模板對齊列的「<>」中間插入空格。 SpacesInCStyleCastParentheses (bool) 若是爲真(true), 將會在C樣式描述中插入空格。 SpacesInContainerLiterals (bool) 若是爲真(true), 將會在字面量容器中插入空格(例如 OC和Javascript的數組和字典字面量)。 SpacesInParentheses (bool) 若是爲真(true), 將會在「(」以後和「)」以前插入空格。 SpacesInSquareBrackets (bool) 若是爲真(true),將會在「[」以後和「]」以前插入空格。 Standard (LanguageStandard) 用這個標準格式化:例如:在LS_Cpp03中使用 A<A<int> > 而不是 A<A<int>> 可能的值有: LS_Cpp03 (在配置中: Cpp03) 使用Use C++03統一語法。 LS_Cpp11 (在配置中: Cpp11) 使用C++11的特徵(例如 A<A<int>>而不是A<A<int> >). LS_Auto (在配置中: Auto) 基於輸入自動檢查。 TabWidth (unsigned) 用於製表符中止的列數。 UseTab (UseTabStyle) 在結果文件中使用製表符字符的方式。 可能的值有: UT_Never (在配置中: Never) 從不使用製表符。 UT_ForIndentation (在配置中: ForIndentation) 僅縮排時使用製表符。 UT_Always (在配置中: Always) 使用標籤時,咱們須要填補的空白,至少從一個製表位到下一個。
英文正則表達式
Configuring Style in Code When using clang::format::reformat(...) functions, the format is specified by supplying the clang::format::FormatStyle structure. Configurable Format Style Options This section lists the supported style options. Value type is specified for each option. For enumeration types possible values are specified both as a C++ enumeration member (with a prefix, e.g. LS_Auto), and as a value usable in the configuration (without a prefix: Auto). BasedOnStyle (string) The style used for all options not specifically set in the configuration. This option is supported only in the clang-format configuration (both within -style='{...}' and the .clang-format file). Possible values: LLVM A style complying with the LLVM coding standards Google A style complying with Google’s C++ style guide Chromium A style complying with Chromium’s style guide Mozilla A style complying with Mozilla’s style guide WebKit A style complying with WebKit’s style guide AccessModifierOffset (int) The extra indent or outdent of access modifiers, e.g. public:. AlignAfterOpenBracket (BracketAlignmentStyle) If true, horizontally aligns arguments after an open bracket. This applies to round brackets (parentheses), angle brackets and square brackets. Possible values: BAS_Align (in configuration: Align) Align parameters on the open bracket, e.g.: someLongFunction(argument1, argument2); BAS_DontAlign (in configuration: DontAlign) Don’t align, instead use ContinuationIndentWidth, e.g.: someLongFunction(argument1, argument2); BAS_AlwaysBreak (in configuration: AlwaysBreak) Always break after an open bracket, if the parameters don’t fit on a single line, e.g.: someLongFunction( argument1, argument2); AlignConsecutiveAssignments (bool) If true, aligns consecutive assignments. This will align the assignment operators of consecutive lines. This will result in formattings like int aaaa = 12; int b = 23; int ccc = 23; AlignConsecutiveDeclarations (bool) If true, aligns consecutive declarations. This will align the declaration names of consecutive lines. This will result in formattings like int aaaa = 12; float b = 23; std::string ccc = 23; AlignEscapedNewlinesLeft (bool) If true, aligns escaped newlines as far left as possible. Otherwise puts them into the right-most column. AlignOperands (bool) If true, horizontally align operands of binary and ternary expressions. Specifically, this aligns operands of a single expression that needs to be split over multiple lines, e.g.: int aaa = bbbbbbbbbbbbbbb + ccccccccccccccc; AlignTrailingComments (bool) If true, aligns trailing comments. AllowAllParametersOfDeclarationOnNextLine (bool) Allow putting all parameters of a function declaration onto the next line even if BinPackParameters is false. AllowShortBlocksOnASingleLine (bool) Allows contracting simple braced statements to a single line. E.g., this allows if (a) { return; } to be put on a single line. AllowShortCaseLabelsOnASingleLine (bool) If true, short case labels will be contracted to a single line. AllowShortFunctionsOnASingleLine (ShortFunctionStyle) Dependent on the value, int f() { return 0; } can be put on a single line. Possible values: SFS_None (in configuration: None) Never merge functions into a single line. SFS_Empty (in configuration: Empty) Only merge empty functions. SFS_Inline (in configuration: Inline) Only merge functions defined inside a class. Implies 「empty」. SFS_All (in configuration: All) Merge all functions fitting on a single line. AllowShortIfStatementsOnASingleLine (bool) If true, if (a) return; can be put on a single line. AllowShortLoopsOnASingleLine (bool) If true, while (true) continue; can be put on a single line. AlwaysBreakAfterDefinitionReturnType (DefinitionReturnTypeBreakingStyle) The function definition return type breaking style to use. This option is deprecated and is retained for backwards compatibility. Possible values: DRTBS_None (in configuration: None) Break after return type automatically. PenaltyReturnTypeOnItsOwnLine is taken into account. DRTBS_All (in configuration: All) Always break after the return type. DRTBS_TopLevel (in configuration: TopLevel) Always break after the return types of top-level functions. AlwaysBreakAfterReturnType (ReturnTypeBreakingStyle) The function declaration return type breaking style to use. Possible values: RTBS_None (in configuration: None) Break after return type automatically. PenaltyReturnTypeOnItsOwnLine is taken into account. RTBS_All (in configuration: All) Always break after the return type. RTBS_TopLevel (in configuration: TopLevel) Always break after the return types of top-level functions. RTBS_AllDefinitions (in configuration: AllDefinitions) Always break after the return type of function definitions. RTBS_TopLevelDefinitions (in configuration: TopLevelDefinitions) Always break after the return type of top-level definitions. AlwaysBreakBeforeMultilineStrings (bool) If true, always break before multiline string literals. This flag is mean to make cases where there are multiple multiline strings in a file look more consistent. 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. AlwaysBreakTemplateDeclarations (bool) If true, always break after the template<...> of a template declaration. BinPackArguments (bool) If false, a function call’s arguments will either be all on the same line or will have one line each. BinPackParameters (bool) 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. BraceWrapping (BraceWrappingFlags) Control of individual brace wrapping cases. If BreakBeforeBraces is set to BS_Custom, use this to specify how each individual brace case should be handled. Otherwise, this is ignored. Nested configuration flags: bool AfterClass Wrap class definitions. bool AfterControlStatement Wrap control statements (if/for/while/switch/..). bool AfterEnum Wrap enum definitions. bool AfterFunction Wrap function definitions. bool AfterNamespace Wrap namespace definitions. bool AfterObjCDeclaration Wrap ObjC definitions (@autoreleasepool, interfaces, ..). bool AfterStruct Wrap struct definitions. bool AfterUnion Wrap union definitions. bool BeforeCatch Wrap before catch. bool BeforeElse Wrap before else. bool IndentBraces Indent the wrapped braces themselves. BreakAfterJavaFieldAnnotations (bool) Break after each annotation on a field in Java files. BreakBeforeBinaryOperators (BinaryOperatorStyle) The way to wrap binary operators. Possible values: BOS_None (in configuration: None) Break after operators. BOS_NonAssignment (in configuration: NonAssignment) Break before operators that aren’t assignments. BOS_All (in configuration: All) Break before operators. BreakBeforeBraces (BraceBreakingStyle) The brace breaking style to use. Possible values: BS_Attach (in configuration: Attach) Always attach braces to surrounding context. BS_Linux (in configuration: Linux) Like Attach, but break before braces on function, namespace and class definitions. BS_Mozilla (in configuration: Mozilla) Like Attach, but break before braces on enum, function, and record definitions. BS_Stroustrup (in configuration: Stroustrup) Like Attach, but break before function definitions, catch, and else. BS_Allman (in configuration: Allman) Always break before braces. BS_GNU (in configuration: 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. BS_WebKit (in configuration: WebKit) Like Attach, but break before functions. BS_Custom (in configuration: Custom) Configure each individual brace in BraceWrapping. BreakBeforeTernaryOperators (bool) If true, ternary operators will be placed after line breaks. BreakConstructorInitializersBeforeComma (bool) Always break constructor initializers before commas and align the commas with the colon. BreakStringLiterals (bool) Allow breaking string literals when formatting. ColumnLimit (unsigned) The column limit. 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. CommentPragmas (std::string) A regular expression that describes comments with special meaning, which should not be split into lines or otherwise changed. ConstructorInitializerAllOnOneLineOrOnePerLine (bool) If the constructor initializers don’t fit on a line, put each initializer on its own line. ConstructorInitializerIndentWidth (unsigned) The number of characters to use for indentation of constructor initializer lists. ContinuationIndentWidth (unsigned) Indent width for line continuations. Cpp11BracedListStyle (bool) If true, format braced lists as best suited for C++11 braced lists. 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. 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. DerivePointerAlignment (bool) If true, analyze the formatted file for the most common alignment of & and \*. PointerAlignment is then used only as fallback. DisableFormat (bool) Disables formatting completely. ExperimentalAutoDetectBinPacking (bool) If true, clang-format detects whether function calls and definitions are formatted with one parameter per line. 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. 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. ForEachMacros (std::vector<std::string>) A vector of macros that should be interpreted as foreach loops instead of as function calls. These are expected to be macros of the form: FOREACH(<variable-declaration>, ...) <loop-body> In the .clang-format configuration file, this can be configured like: ForEachMacros: ['RANGES_FOR', 'FOREACH'] For example: BOOST_FOREACH. IncludeCategories (std::vector<IncludeCategory>) Regular expressions denoting the different #include categories used for ordering #includes. These regular expressions are matched against the filename of an include (including the <> or 「」) in order. The value belonging to the first matching regular expression is assigned and #includes are sorted first according to increasing category number and then alphabetically within each category. If none of the regular expressions match, INT_MAX is assigned as category. The main header for a source file automatically gets category 0. so that it is generally kept at the beginning of the #includes (http://llvm.org/docs/CodingStandards.html#include-style). However, you can also assign negative priorities if you have certain headers that always need to be first. To configure this in the .clang-format file, use: IncludeCategories: - Regex: '^"(llvm|llvm-c|clang|clang-c)/' Priority: 2 - Regex: '^(<|"(gtest|isl|json)/)' Priority: 3 - Regex: '.\*' Priority: 1 IncludeIsMainRegex (std::string) Specify a regular expression of suffixes that are allowed in the file-to-main-include mapping. When guessing whether a #include is the 「main」 include (to assign category 0, see above), use this regex of allowed suffixes to the header stem. A partial match is done, so that: - 「」 means 「arbitrary suffix」 - 「$」 means 「no suffix」 For example, if configured to 「(_test)?$」, then a header a.h would be seen as the 「main」 include in both a.cc and a_test.cc. IndentCaseLabels (bool) Indent case labels one level from the switch statement. When false, use the same indentation level as for the switch statement. Switch statement body is always indented one level more than case labels. IndentWidth (unsigned) The number of columns to use for indentation. IndentWrappedFunctionNames (bool) Indent if a function definition or declaration is wrapped after the type. JavaScriptQuotes (JavaScriptQuoteStyle) The JavaScriptQuoteStyle to use for JavaScript strings. Possible values: JSQS_Leave (in configuration: Leave) Leave string quotes as they are. JSQS_Single (in configuration: Single) Always use single quotes. JSQS_Double (in configuration: Double) Always use double quotes. KeepEmptyLinesAtTheStartOfBlocks (bool) If true, empty lines at the start of blocks are kept. Language (LanguageKind) Language, this format style is targeted at. Possible values: LK_None (in configuration: None) Do not use. LK_Cpp (in configuration: Cpp) Should be used for C, C++, ObjectiveC, ObjectiveC++. LK_Java (in configuration: Java) Should be used for Java. LK_JavaScript (in configuration: JavaScript) Should be used for JavaScript. LK_Proto (in configuration: Proto) Should be used for Protocol Buffers (https://developers.google.com/protocol-buffers/). LK_TableGen (in configuration: TableGen) Should be used for TableGen code. MacroBlockBegin (std::string) A regular expression matching macros that start a block. MacroBlockEnd (std::string) A regular expression matching macros that end a block. MaxEmptyLinesToKeep (unsigned) The maximum number of consecutive empty lines to keep. NamespaceIndentation (NamespaceIndentationKind) The indentation used for namespaces. Possible values: NI_None (in configuration: None) Don’t indent in namespaces. NI_Inner (in configuration: Inner) Indent only in inner namespaces (nested in other namespaces). NI_All (in configuration: All) Indent in all namespaces. ObjCBlockIndentWidth (unsigned) The number of characters to use for indentation of ObjC blocks. ObjCSpaceAfterProperty (bool) Add a space after @property in Objective-C, i.e. use @property (readonly) instead of @property(readonly). ObjCSpaceBeforeProtocolList (bool) Add a space in front of an Objective-C protocol list, i.e. use Foo <Protocol> instead of Foo<Protocol>. PenaltyBreakBeforeFirstCallParameter (unsigned) The penalty for breaking a function call after call(. PenaltyBreakComment (unsigned) The penalty for each line break introduced inside a comment. PenaltyBreakFirstLessLess (unsigned) The penalty for breaking before the first <<. PenaltyBreakString (unsigned) The penalty for each line break introduced inside a string literal. PenaltyExcessCharacter (unsigned) The penalty for each character outside of the column limit. PenaltyReturnTypeOnItsOwnLine (unsigned) Penalty for putting the return type of a function onto its own line. PointerAlignment (PointerAlignmentStyle) Pointer and reference alignment style. Possible values: PAS_Left (in configuration: Left) Align pointer to the left. PAS_Right (in configuration: Right) Align pointer to the right. PAS_Middle (in configuration: Middle) Align pointer in the middle. ReflowComments (bool) If true, clang-format will attempt to re-flow comments. SortIncludes (bool) If true, clang-format will sort #includes. SpaceAfterCStyleCast (bool) If true, a space may be inserted after C style casts. SpaceAfterTemplateKeyword (bool) If true, a space will be inserted after the ‘template’ keyword. SpaceBeforeAssignmentOperators (bool) If false, spaces will be removed before assignment operators. SpaceBeforeParens (SpaceBeforeParensOptions) Defines in which cases to put a space before opening parentheses. Possible values: SBPO_Never (in configuration: Never) Never put a space before opening parentheses. SBPO_ControlStatements (in configuration: ControlStatements) Put a space before opening parentheses only after control statement keywords (for/if/while...). SBPO_Always (in configuration: Always) Always put a space before opening parentheses, except when it’s prohibited by the syntax rules (in function-like macro definitions) or when determined by other style rules (after unary operators, opening parentheses, etc.) SpaceInEmptyParentheses (bool) If true, spaces may be inserted into (). SpacesBeforeTrailingComments (unsigned) The number of spaces before trailing line comments (// - comments). This does not affect trailing block comments (/* - comments) as those commonly have different usage patterns and a number of special cases. SpacesInAngles (bool) If true, spaces will be inserted after < and before > in template argument lists. SpacesInCStyleCastParentheses (bool) If true, spaces may be inserted into C style casts. SpacesInContainerLiterals (bool) If true, spaces are inserted inside container literals (e.g. ObjC and Javascript array and dict literals). SpacesInParentheses (bool) If true, spaces will be inserted after ( and before ). SpacesInSquareBrackets (bool) If true, spaces will be inserted after [ and before ]. Standard (LanguageStandard) Format compatible with this standard, e.g. use A<A<int> > instead of A<A<int>> for LS_Cpp03. Possible values: LS_Cpp03 (in configuration: Cpp03) Use C++03-compatible syntax. LS_Cpp11 (in configuration: Cpp11) Use features of C++11 (e.g. A<A<int>> instead of A<A<int> >). LS_Auto (in configuration: Auto) Automatic detection based on the input. TabWidth (unsigned) The number of columns used for tab stops. UseTab (UseTabStyle) The way to use tab characters in the resulting file. Possible values: UT_Never (in configuration: Never) Never use tab. UT_ForIndentation (in configuration: ForIndentation) Use tabs only for indentation. UT_Always (in configuration: Always) Use tabs whenever we need to fill whitespace that spans at least from one tab stop to the next one.
******express
後面的內容與標題無關 推廣下我的開發的APP 以爲還不錯的 本身本身偷偷用就好了json
密碼口袋數組