Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: Add .gitattributes to allow running ITK clang-formatting scripts
``` git filter-branch -f \ --tree-filter "~/ITK/Utilities/Maintenance/clang-format.bash --clang-format ~/Dashboard/src/ITK-clang11/clang-format-Linux --tracked" \ master.. ```
- Loading branch information
1 parent
97847db
commit 705f384
Showing
4 changed files
with
255 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
## This config file is only relevant for clang-format version 8.0.0 | ||
## | ||
## Examples of each format style can be found on the in the clang-format documentation | ||
## See: https://clang.llvm.org/docs/ClangFormatStyleOptions.html for details of each option | ||
## | ||
## The clang-format binaries can be downloaded as part of the clang binary distributions | ||
## from http://releases.llvm.org/download.html | ||
## | ||
## Use the script Utilities/Maintenance/clang-format.bash to faciliate | ||
## maintaining a consistent code style. | ||
## | ||
## EXAMPLE apply code style enforcement before commit: | ||
# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_8.0.0} --modified | ||
## EXAMPLE apply code style enforcement after commit: | ||
# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_8.0.0} --last | ||
--- | ||
# This configuration requires clang-format version 8.0.0 exactly. | ||
BasedOnStyle: Mozilla | ||
Language: Cpp | ||
AccessModifierOffset: -2 | ||
AlignAfterOpenBracket: Align | ||
AlignConsecutiveAssignments: false | ||
AlignConsecutiveDeclarations: true | ||
AlignEscapedNewlines: Right | ||
AlignOperands: true | ||
AlignTrailingComments: true | ||
# clang 9.0 AllowAllArgumentsOnNextLine: true | ||
# clang 9.0 AllowAllConstructorInitializersOnNextLine: true | ||
AllowAllParametersOfDeclarationOnNextLine: false | ||
AllowShortBlocksOnASingleLine: false | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: Inline | ||
# clang 9.0 AllowShortLambdasOnASingleLine: All | ||
# clang 9.0 features AllowShortIfStatementsOnASingleLine: Never | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterDefinitionReturnType: None | ||
AlwaysBreakAfterReturnType: All | ||
AlwaysBreakBeforeMultilineStrings: false | ||
AlwaysBreakTemplateDeclarations: Yes | ||
BinPackArguments: false | ||
BinPackParameters: false | ||
BreakBeforeBraces: Custom | ||
BraceWrapping: | ||
# clang 9.0 feature AfterCaseLabel: false | ||
AfterClass: true | ||
AfterControlStatement: true | ||
AfterEnum: true | ||
AfterFunction: true | ||
AfterNamespace: true | ||
AfterObjCDeclaration: true | ||
AfterStruct: true | ||
AfterUnion: true | ||
AfterExternBlock: true | ||
BeforeCatch: true | ||
BeforeElse: true | ||
## This is the big change from historical ITK formatting! | ||
# Historically ITK used a style similar to https://en.wikipedia.org/wiki/Indentation_style#Whitesmiths_style | ||
# with indented braces, and not indented code. This style is very difficult to automatically | ||
# maintain with code beautification tools. Not indenting braces is more common among | ||
# formatting tools. | ||
IndentBraces: false | ||
SplitEmptyFunction: false | ||
SplitEmptyRecord: false | ||
SplitEmptyNamespace: false | ||
BreakBeforeBinaryOperators: None | ||
#clang 6.0 BreakBeforeInheritanceComma: true | ||
BreakInheritanceList: BeforeComma | ||
BreakBeforeTernaryOperators: true | ||
#clang 6.0 BreakConstructorInitializersBeforeComma: true | ||
BreakConstructorInitializers: BeforeComma | ||
BreakAfterJavaFieldAnnotations: false | ||
BreakStringLiterals: true | ||
## The following line allows larger lines in non-documentation code | ||
ColumnLimit: 120 | ||
CommentPragmas: '^ IWYU pragma:' | ||
CompactNamespaces: false | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||
ConstructorInitializerIndentWidth: 2 | ||
ContinuationIndentWidth: 2 | ||
Cpp11BracedListStyle: false | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
ExperimentalAutoDetectBinPacking: false | ||
FixNamespaceComments: true | ||
ForEachMacros: | ||
- foreach | ||
- Q_FOREACH | ||
- BOOST_FOREACH | ||
IncludeBlocks: Preserve | ||
IncludeCategories: | ||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/' | ||
Priority: 2 | ||
- Regex: '^(<|"(gtest|gmock|isl|json)/)' | ||
Priority: 3 | ||
- Regex: '.*' | ||
Priority: 1 | ||
IncludeIsMainRegex: '(Test)?$' | ||
IndentCaseLabels: true | ||
IndentPPDirectives: AfterHash | ||
IndentWidth: 2 | ||
IndentWrappedFunctionNames: false | ||
JavaScriptQuotes: Leave | ||
JavaScriptWrapImports: true | ||
KeepEmptyLinesAtTheStartOfBlocks: true | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
MaxEmptyLinesToKeep: 2 | ||
NamespaceIndentation: None | ||
ObjCBinPackProtocolList: Auto | ||
ObjCBlockIndentWidth: 2 | ||
ObjCSpaceAfterProperty: true | ||
ObjCSpaceBeforeProtocolList: false | ||
PenaltyBreakAssignment: 2 | ||
PenaltyBreakBeforeFirstCallParameter: 19 | ||
PenaltyBreakComment: 300 | ||
## The following line allows larger lines in non-documentation code | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakString: 1000 | ||
PenaltyBreakTemplateDeclaration: 10 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 200 | ||
PointerAlignment: Middle | ||
ReflowComments: true | ||
# We may want to sort the includes as a separate pass | ||
SortIncludes: false | ||
# We may want to revisit this later | ||
SortUsingDeclarations: false | ||
SpaceAfterCStyleCast: false | ||
# SpaceAfterLogicalNot: false | ||
SpaceAfterTemplateKeyword: true | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeCpp11BracedList: false | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceBeforeRangeBasedForLoopColon: true | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 1 | ||
SpacesInAngles: false | ||
SpacesInContainerLiterals: false | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
Standard: Cpp11 | ||
StatementMacros: | ||
- Q_UNUSED | ||
- QT_REQUIRE_VERSION | ||
TabWidth: 2 | ||
UseTab: Never | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Custom attribute to mark sources as using our C++/C code style. | ||
[attr]our-c-style whitespace=tab-in-indent,no-lf-at-eof hooks.style=KWStyle,clangformat | ||
|
||
*.c our-c-style | ||
*.h our-c-style | ||
*.cxx our-c-style | ||
*.hxx our-c-style | ||
*.txx our-c-style | ||
*.txt whitespace=tab-in-indent,no-lf-at-eof | ||
*.cmake whitespace=tab-in-indent,no-lf-at-eof | ||
|
||
# ExternalData content links must have LF newlines | ||
*.md5 crlf=input | ||
*.sha512 crlf=input |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,94 @@ | ||
/*========================================================================= | ||
* | ||
* Copyright Insight Software Consortium | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0.txt | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*=========================================================================*/ | ||
* | ||
* Copyright Insight Software Consortium | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0.txt | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*=========================================================================*/ | ||
|
||
#ifndef itkMultipleImageIterator_h | ||
#define itkMultipleImageIterator_h | ||
#include <vector> | ||
#include <itkImageRegionIterator.h> | ||
|
||
|
||
namespace itk { | ||
/** \class MultipleImageIterator | ||
* \brief An wrapper around image iterators to iterate over several images simultaneously | ||
* All iterators must | ||
* - point to images of the same type | ||
* - be of the same size (number of values from begin to end) | ||
* \ingroup MultipleImageIterator */ | ||
template<typename TIterator> | ||
class MultipleImageIterator { | ||
namespace itk | ||
{ | ||
/** \class MultipleImageIterator | ||
* \brief An wrapper around image iterators to iterate over several images simultaneously | ||
* All iterators must | ||
* - point to images of the same type | ||
* - be of the same size (number of values from begin to end) | ||
* \ingroup MultipleImageIterator */ | ||
template <typename TIterator> | ||
class MultipleImageIterator | ||
{ | ||
public: | ||
using Self = MultipleImageIterator; | ||
using IteratorType = TIterator; | ||
using ImageType = typename IteratorType::ImageType; | ||
/// Access one of the iterators | ||
IteratorType& operator[](const int i) {return m_Iterators[i];} | ||
IteratorType & operator[](const int i) { return m_Iterators[i]; } | ||
/// Add a new iterator | ||
void AddIterator(const IteratorType& it) {m_Iterators.push_back(it);} | ||
void | ||
AddIterator(const IteratorType & it) | ||
{ | ||
m_Iterators.push_back(it); | ||
} | ||
/// Advance all iterators | ||
Self& operator++() { | ||
for (auto it = m_Iterators.begin(); | ||
it != m_Iterators.end(); ++it) { | ||
Self & | ||
operator++() | ||
{ | ||
for (auto it = m_Iterators.begin(); it != m_Iterators.end(); ++it) | ||
{ | ||
++(*it); | ||
} | ||
return *this; | ||
} | ||
/// Rewind all iterators | ||
void GoToBegin() { | ||
for (auto it = m_Iterators.begin(); | ||
it != m_Iterators.end(); ++it) { | ||
void | ||
GoToBegin() | ||
{ | ||
for (auto it = m_Iterators.begin(); it != m_Iterators.end(); ++it) | ||
{ | ||
it->GoToBegin(); | ||
} | ||
} | ||
/** Check if the first iterator is at end. In debug mode, additionally check | ||
* that at least one iterator is present and that all iterators' IsAtEnd() | ||
* that at least one iterator is present and that all iterators' IsAtEnd() | ||
* methods return the same thing */ | ||
bool IsAtEnd() { | ||
bool | ||
IsAtEnd() | ||
{ | ||
#ifdef NDEBUG | ||
return m_Iterators[0].IsAtEnd(); | ||
#else | ||
assert(m_Iterators.size()); | ||
bool retval = m_Iterators[0].IsAtEnd(); | ||
for (unsigned int i=0; i<m_Iterators.size();++i) | ||
for (unsigned int i = 0; i < m_Iterators.size(); ++i) | ||
assert(m_Iterators[i].IsAtEnd() == retval); | ||
return retval; | ||
#endif | ||
} | ||
/// Returns the number of iterators | ||
unsigned int Size () const { return m_Iterators.size(); } | ||
unsigned int | ||
Size() const | ||
{ | ||
return m_Iterators.size(); | ||
} | ||
|
||
protected: | ||
std::vector<IteratorType> m_Iterators; | ||
|
||
}; | ||
} | ||
#endif //itkMultipleImageIterator_h | ||
} // namespace itk | ||
#endif // itkMultipleImageIterator_h |
Oops, something went wrong.