diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..a02f024 --- /dev/null +++ b/.clang-format @@ -0,0 +1,88 @@ +--- +# SPDX-License-Identifier: MIT +# +# Copyright (C) 2019 Christoph Cullmann +# Copyright (C) 2019 Gernot Gebhard +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +# Style for C++ +Language: Cpp + +# base is WebKit coding style: http://www.webkit.org/coding/coding-style.html +# below are only things set that diverge from this style! +BasedOnStyle: WebKit + +# enforce C++11 (e.g. for std::vector> +Standard: Cpp11 + +# 4 spaces indent +TabWidth: 4 + +# 3 * 80 wide lines +ColumnLimit: 240 + +# sematics shall be grouped via empty lines +SortIncludes: true + +# break before braces on function, namespace and class definitions. +BreakBeforeBraces: Linux + +# CrlInstruction *a; +PointerAlignment: Right + +# horizontally aligns arguments after an open bracket. +AlignAfterOpenBracket: Align + +# align trailing comments +AlignTrailingComments: true + +# don't move all parameters to new line +AllowAllParametersOfDeclarationOnNextLine: false + +# no single line functions +AllowShortFunctionsOnASingleLine: None + +# always break before you encounter multi line strings +AlwaysBreakBeforeMultilineStrings: true + +# don't move arguments to own lines if they are not all on the same +BinPackArguments: false + +# don't move parameters to own lines if they are not all on the same +BinPackParameters: false + +# don't break binary ops +BreakBeforeBinaryOperators: None + +# don't break tenary ops +BreakBeforeTernaryOperators: false + +# format C++11 braced lists like function calls +Cpp11BracedListStyle: true + +# indent case labels one level +IndentCaseLabels: true + +# remove empty lines +KeepEmptyLinesAtTheStartOfBlocks: false + +# no namespace indentation to keep indent level low +NamespaceIndentation: None diff --git a/reformat.sh b/reformat.sh new file mode 100755 index 0000000..b58ea83 --- /dev/null +++ b/reformat.sh @@ -0,0 +1,6 @@ +# reformat the code +# no operator is implicit -a with higher precedence than -o +find . \( -name "*.cpp" -or -name "*.h" \) -exec clang-format -i {} \; + +# check in the result +git commit -a -m "GIT_SILENT: application of coding style"