.clang-format 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # Copyright (C) 2016 Olivier Goffart <ogoffart@woboq.com>
  2. #
  3. # You may use this file under the terms of the 3-clause BSD license.
  4. # See the file LICENSE from this package for details.
  5. # This is the clang-format configuration style to be used by Qt,
  6. # based on the rules from https://wiki.qt.io/Qt_Coding_Style and
  7. # https://wiki.qt.io/Coding_Conventions
  8. ---
  9. # Webkit style was loosely based on the Qt style
  10. BasedOnStyle: WebKit
  11. Standard: Cpp11
  12. # Column width is limited to 100 in accordance with Qt Coding Style.
  13. # https://wiki.qt.io/Qt_Coding_Style
  14. # Note that this may be changed at some point in the future.
  15. ColumnLimit: 120
  16. # How much weight do extra characters after the line length limit have.
  17. # PenaltyExcessCharacter: 4
  18. # Disable reflow of qdoc comments: indentation rules are different.
  19. # Translation comments are also excluded.
  20. CommentPragmas: "^!|^:"
  21. # We want a space between the type and the star for pointer types.
  22. PointerBindsToType: false
  23. #指针的*的挨着哪边
  24. #PointerAlignment: Right
  25. # We use template< without space.
  26. SpaceAfterTemplateKeyword: false
  27. # We want to break before the operators, but not before a '='.
  28. BreakBeforeBinaryOperators: NonAssignment
  29. # Braces are usually attached, but not after functions or class declarations.
  30. BreakBeforeBraces: Custom
  31. BraceWrapping:
  32. AfterClass: true
  33. AfterControlStatement: false
  34. AfterEnum: true
  35. AfterFunction: true
  36. AfterNamespace: false
  37. AfterObjCDeclaration: false
  38. AfterStruct: true
  39. AfterUnion: false
  40. BeforeCatch: false
  41. BeforeElse: false
  42. IndentBraces: false
  43. # When constructor initializers do not fit on one line, put them each on a new line.
  44. ConstructorInitializerAllOnOneLineOrOnePerLine: true
  45. # Indent initializers by 4 spaces
  46. ConstructorInitializerIndentWidth: 4
  47. # Indent width for line continuations.
  48. ContinuationIndentWidth: 8
  49. # No indentation for namespaces.
  50. NamespaceIndentation: None
  51. # Allow indentation for preprocessing directives (if/ifdef/endif). https://reviews.llvm.org/rL312125
  52. IndentPPDirectives: AfterHash
  53. # Horizontally align arguments after an open bracket.
  54. # The coding style does not specify the following, but this is what gives
  55. # results closest to the existing code.
  56. AlignAfterOpenBracket: true
  57. AlwaysBreakTemplateDeclarations: true
  58. # Ideally we should also allow less short function in a single line, but
  59. # clang-format does not handle that.
  60. AllowShortFunctionsOnASingleLine: Inline
  61. # The coding style specifies some include order categories, but also tells to
  62. # separate categories with an empty line. It does not specify the order within
  63. # the categories. Since the SortInclude feature of clang-format does not
  64. # re-order includes separated by empty lines, the feature is not used.
  65. SortIncludes: false
  66. # macros for which the opening brace stays attached.
  67. ForEachMacros: [ for, foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE ]
  68. # Break constructor initializers before the colon and after the commas.
  69. BreakConstructorInitializers: BeforeColon
  70. # 连续赋值时,对齐所有等号
  71. AlignConsecutiveAssignments: true
  72. # 连续声明时,对齐所有声明的变量名
  73. AlignConsecutiveDeclarations: false
  74. # 支持一行的if
  75. #AllowShortIfStatementsOnASingleLine: true
  76. # 注释对齐
  77. AlignTrailingComments: true
  78. FixNamespaceComments: true
  79. # 在尾随的注释前添加的空格数(只适用于//)
  80. SpacesBeforeTrailingComments: 2
  81. # false表示函数实参要么都在同一行,要么都各自一行
  82. #BinPackArguments: true
  83. # false表示所有形参要么都在同一行,要么都各自一行
  84. #BinPackParameters: true