misc formatting fixes
This commit is contained in:
parent
377995f495
commit
76b49f9ee6
4 changed files with 199 additions and 52 deletions
137
.clang-format
Normal file
137
.clang-format
Normal file
|
@ -0,0 +1,137 @@
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
# BasedOnStyle: Mozilla
|
||||||
|
AccessModifierOffset: -2
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveMacros: false
|
||||||
|
AlignConsecutiveAssignments: false
|
||||||
|
AlignConsecutiveDeclarations: false
|
||||||
|
AlignEscapedNewlines: Right
|
||||||
|
AlignOperands: true
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowAllArgumentsOnNextLine: true
|
||||||
|
AllowAllConstructorInitializersOnNextLine: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: TopLevel
|
||||||
|
AlwaysBreakAfterReturnType: TopLevel
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: true
|
||||||
|
AfterClass: true
|
||||||
|
AfterControlStatement: true
|
||||||
|
AfterEnum: true
|
||||||
|
AfterFunction: true
|
||||||
|
AfterNamespace: true
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: true
|
||||||
|
AfterUnion: true
|
||||||
|
AfterExternBlock: true
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: true
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
SplitEmptyRecord: false
|
||||||
|
SplitEmptyNamespace: true
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
BreakBeforeInheritanceComma: false
|
||||||
|
BreakInheritanceList: BeforeComma
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializersBeforeComma: false
|
||||||
|
BreakConstructorInitializers: BeforeComma
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakStringLiterals: false
|
||||||
|
ColumnLimit: 180
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DeriveLineEnding: true
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: false
|
||||||
|
ForEachMacros:
|
||||||
|
- foreach
|
||||||
|
- Q_FOREACH
|
||||||
|
- BOOST_FOREACH
|
||||||
|
IncludeBlocks: Preserve
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||||
|
Priority: 2
|
||||||
|
SortPriority: 0
|
||||||
|
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||||
|
Priority: 3
|
||||||
|
SortPriority: 0
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 1
|
||||||
|
SortPriority: 0
|
||||||
|
IncludeIsMainRegex: '(Test)?$'
|
||||||
|
IncludeIsMainSourceRegex: ''
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentGotoLabels: false
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: None
|
||||||
|
ObjCBinPackProtocolList: Auto
|
||||||
|
ObjCBlockIndentWidth: 2
|
||||||
|
ObjCSpaceAfterProperty: true
|
||||||
|
ObjCSpaceBeforeProtocolList: false
|
||||||
|
PenaltyBreakAssignment: 2
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 19
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 200
|
||||||
|
PointerAlignment: Left
|
||||||
|
ReflowComments: true
|
||||||
|
SortIncludes: false
|
||||||
|
SortUsingDeclarations: true
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: false
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCpp11BracedList: true
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceInEmptyBlock: false
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInConditionalStatement: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
SpaceBeforeSquareBrackets: false
|
||||||
|
Standard: Latest
|
||||||
|
StatementMacros:
|
||||||
|
- Q_UNUSED
|
||||||
|
- QT_REQUIRE_VERSION
|
||||||
|
TabWidth: 8
|
||||||
|
UseCRLF: false
|
||||||
|
UseTab: Never
|
||||||
|
...
|
||||||
|
|
|
@ -104,7 +104,7 @@ class input_stream_adapter
|
||||||
{
|
{
|
||||||
auto res = sb->sbumpc();
|
auto res = sb->sbumpc();
|
||||||
// set eof manually, as we don't use the istream interface.
|
// set eof manually, as we don't use the istream interface.
|
||||||
if (res == EOF)
|
if (JSON_HEDLEY_UNLIKELY(res == EOF))
|
||||||
{
|
{
|
||||||
is->clear(is->rdstate() | std::ios::eofbit);
|
is->clear(is->rdstate() | std::ios::eofbit);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ class iterator_input_adapter
|
||||||
|
|
||||||
typename std::char_traits<char_type>::int_type get_character()
|
typename std::char_traits<char_type>::int_type get_character()
|
||||||
{
|
{
|
||||||
if (current != end)
|
if (JSON_HEDLEY_LIKELY(current != end))
|
||||||
{
|
{
|
||||||
auto result = std::char_traits<char_type>::to_int_type(*current);
|
auto result = std::char_traits<char_type>::to_int_type(*current);
|
||||||
std::advance(current, 1);
|
std::advance(current, 1);
|
||||||
|
@ -171,7 +171,7 @@ struct wide_string_input_helper<BaseInputAdapter, 4>
|
||||||
{
|
{
|
||||||
utf8_bytes_index = 0;
|
utf8_bytes_index = 0;
|
||||||
|
|
||||||
if (input.empty())
|
if (JSON_HEDLEY_UNLIKELY(input.empty()))
|
||||||
{
|
{
|
||||||
utf8_bytes[0] = std::char_traits<char>::eof();
|
utf8_bytes[0] = std::char_traits<char>::eof();
|
||||||
utf8_bytes_filled = 1;
|
utf8_bytes_filled = 1;
|
||||||
|
@ -229,7 +229,7 @@ struct wide_string_input_helper<BaseInputAdapter, 2>
|
||||||
{
|
{
|
||||||
utf8_bytes_index = 0;
|
utf8_bytes_index = 0;
|
||||||
|
|
||||||
if (input.empty())
|
if (JSON_HEDLEY_UNLIKELY(input.empty()))
|
||||||
{
|
{
|
||||||
utf8_bytes[0] = std::char_traits<char>::eof();
|
utf8_bytes[0] = std::char_traits<char>::eof();
|
||||||
utf8_bytes_filled = 1;
|
utf8_bytes_filled = 1;
|
||||||
|
@ -331,34 +331,39 @@ struct iterator_input_adapter_factory
|
||||||
using char_type = typename std::iterator_traits<iterator_type>::value_type;
|
using char_type = typename std::iterator_traits<iterator_type>::value_type;
|
||||||
using adapter_type = iterator_input_adapter<iterator_type>;
|
using adapter_type = iterator_input_adapter<iterator_type>;
|
||||||
|
|
||||||
static adapter_type create(IteratorType begin, IteratorType end)
|
static adapter_type create(IteratorType first, IteratorType last)
|
||||||
{
|
{
|
||||||
return adapter_type(std::move(begin), std::move(end));
|
return adapter_type(std::move(first), std::move(last));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename IteratorType>
|
// This test breaks astyle formatting when inlined in a template specialization.
|
||||||
struct iterator_input_adapter_factory<IteratorType,
|
template<typename T>
|
||||||
typename std::enable_if<(sizeof(typename std::iterator_traits<IteratorType>::value_type)>1)>::type >
|
inline constexpr bool is_iterator_of_multibyte()
|
||||||
{
|
|
||||||
|
|
||||||
using iterator_type = IteratorType;
|
|
||||||
using char_type = typename std::iterator_traits<iterator_type>::value_type;
|
|
||||||
using base_adapter_type = iterator_input_adapter<iterator_type>;
|
|
||||||
using adapter_type = wide_string_input_adapter<base_adapter_type, char_type>;
|
|
||||||
|
|
||||||
static adapter_type create(IteratorType begin, IteratorType end)
|
|
||||||
{
|
{
|
||||||
return adapter_type(base_adapter_type(std::move(begin), std::move(end)));
|
return sizeof(typename std::iterator_traits<T>::value_type) > 1;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
template<typename IteratorType>
|
||||||
|
struct iterator_input_adapter_factory<IteratorType, enable_if_t<is_iterator_of_multibyte<IteratorType>()>>
|
||||||
|
{
|
||||||
|
using iterator_type = IteratorType;
|
||||||
|
using char_type = typename std::iterator_traits<iterator_type>::value_type;
|
||||||
|
using base_adapter_type = iterator_input_adapter<iterator_type>;
|
||||||
|
using adapter_type = wide_string_input_adapter<base_adapter_type, char_type>;
|
||||||
|
|
||||||
|
static adapter_type create(IteratorType first, IteratorType last)
|
||||||
|
{
|
||||||
|
return adapter_type(base_adapter_type(std::move(first), std::move(last)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// General purpose iterator-based input
|
// General purpose iterator-based input
|
||||||
template<typename IteratorType>
|
template<typename IteratorType>
|
||||||
typename iterator_input_adapter_factory<IteratorType>::adapter_type input_adapter(IteratorType begin, IteratorType end)
|
typename iterator_input_adapter_factory<IteratorType>::adapter_type input_adapter(IteratorType first, IteratorType last)
|
||||||
{
|
{
|
||||||
using factory_type = iterator_input_adapter_factory<IteratorType>;
|
using factory_type = iterator_input_adapter_factory<IteratorType>;
|
||||||
return factory_type::create(begin, end);
|
return factory_type::create(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convenience shorthand from container to iterator
|
// Convenience shorthand from container to iterator
|
||||||
|
|
|
@ -6623,13 +6623,13 @@ class basic_json
|
||||||
|
|
||||||
template<typename IteratorType>
|
template<typename IteratorType>
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
static basic_json parse(IteratorType begin,
|
static basic_json parse(IteratorType first,
|
||||||
IteratorType end,
|
IteratorType last,
|
||||||
const parser_callback_t cb = nullptr,
|
const parser_callback_t cb = nullptr,
|
||||||
const bool allow_exceptions = true)
|
const bool allow_exceptions = true)
|
||||||
{
|
{
|
||||||
basic_json result;
|
basic_json result;
|
||||||
parser(detail::input_adapter(std::move(begin), std::move(end)), cb, allow_exceptions).parse(true, result);
|
parser(detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions).parse(true, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6650,9 +6650,9 @@ class basic_json
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename IteratorType>
|
template<typename IteratorType>
|
||||||
static bool accept(IteratorType begin, IteratorType end)
|
static bool accept(IteratorType first, IteratorType last)
|
||||||
{
|
{
|
||||||
return parser(detail::input_adapter(std::move(begin), std::move(end))).accept(true);
|
return parser(detail::input_adapter(std::move(first), std::move(last))).accept(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool accept(detail::span_input_adapter&& i)
|
static bool accept(detail::span_input_adapter&& i)
|
||||||
|
|
|
@ -4526,7 +4526,7 @@ class input_stream_adapter
|
||||||
{
|
{
|
||||||
auto res = sb->sbumpc();
|
auto res = sb->sbumpc();
|
||||||
// set eof manually, as we don't use the istream interface.
|
// set eof manually, as we don't use the istream interface.
|
||||||
if (res == EOF)
|
if (JSON_HEDLEY_UNLIKELY(res == EOF))
|
||||||
{
|
{
|
||||||
is->clear(is->rdstate() | std::ios::eofbit);
|
is->clear(is->rdstate() | std::ios::eofbit);
|
||||||
}
|
}
|
||||||
|
@ -4552,7 +4552,7 @@ class iterator_input_adapter
|
||||||
|
|
||||||
typename std::char_traits<char_type>::int_type get_character()
|
typename std::char_traits<char_type>::int_type get_character()
|
||||||
{
|
{
|
||||||
if (current != end)
|
if (JSON_HEDLEY_LIKELY(current != end))
|
||||||
{
|
{
|
||||||
auto result = std::char_traits<char_type>::to_int_type(*current);
|
auto result = std::char_traits<char_type>::to_int_type(*current);
|
||||||
std::advance(current, 1);
|
std::advance(current, 1);
|
||||||
|
@ -4593,7 +4593,7 @@ struct wide_string_input_helper<BaseInputAdapter, 4>
|
||||||
{
|
{
|
||||||
utf8_bytes_index = 0;
|
utf8_bytes_index = 0;
|
||||||
|
|
||||||
if (input.empty())
|
if (JSON_HEDLEY_UNLIKELY(input.empty()))
|
||||||
{
|
{
|
||||||
utf8_bytes[0] = std::char_traits<char>::eof();
|
utf8_bytes[0] = std::char_traits<char>::eof();
|
||||||
utf8_bytes_filled = 1;
|
utf8_bytes_filled = 1;
|
||||||
|
@ -4651,7 +4651,7 @@ struct wide_string_input_helper<BaseInputAdapter, 2>
|
||||||
{
|
{
|
||||||
utf8_bytes_index = 0;
|
utf8_bytes_index = 0;
|
||||||
|
|
||||||
if (input.empty())
|
if (JSON_HEDLEY_UNLIKELY(input.empty()))
|
||||||
{
|
{
|
||||||
utf8_bytes[0] = std::char_traits<char>::eof();
|
utf8_bytes[0] = std::char_traits<char>::eof();
|
||||||
utf8_bytes_filled = 1;
|
utf8_bytes_filled = 1;
|
||||||
|
@ -4753,34 +4753,39 @@ struct iterator_input_adapter_factory
|
||||||
using char_type = typename std::iterator_traits<iterator_type>::value_type;
|
using char_type = typename std::iterator_traits<iterator_type>::value_type;
|
||||||
using adapter_type = iterator_input_adapter<iterator_type>;
|
using adapter_type = iterator_input_adapter<iterator_type>;
|
||||||
|
|
||||||
static adapter_type create(IteratorType begin, IteratorType end)
|
static adapter_type create(IteratorType first, IteratorType last)
|
||||||
{
|
{
|
||||||
return adapter_type(std::move(begin), std::move(end));
|
return adapter_type(std::move(first), std::move(last));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename IteratorType>
|
// This test breaks astyle formatting when inlined in a template specialization.
|
||||||
struct iterator_input_adapter_factory<IteratorType,
|
template<typename T>
|
||||||
typename std::enable_if<(sizeof(typename std::iterator_traits<IteratorType>::value_type)>1)>::type >
|
inline constexpr bool is_iterator_of_multibyte()
|
||||||
{
|
|
||||||
|
|
||||||
using iterator_type = IteratorType;
|
|
||||||
using char_type = typename std::iterator_traits<iterator_type>::value_type;
|
|
||||||
using base_adapter_type = iterator_input_adapter<iterator_type>;
|
|
||||||
using adapter_type = wide_string_input_adapter<base_adapter_type, char_type>;
|
|
||||||
|
|
||||||
static adapter_type create(IteratorType begin, IteratorType end)
|
|
||||||
{
|
{
|
||||||
return adapter_type(base_adapter_type(std::move(begin), std::move(end)));
|
return sizeof(typename std::iterator_traits<T>::value_type) > 1;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
template<typename IteratorType>
|
||||||
|
struct iterator_input_adapter_factory<IteratorType, enable_if_t<is_iterator_of_multibyte<IteratorType>()>>
|
||||||
|
{
|
||||||
|
using iterator_type = IteratorType;
|
||||||
|
using char_type = typename std::iterator_traits<iterator_type>::value_type;
|
||||||
|
using base_adapter_type = iterator_input_adapter<iterator_type>;
|
||||||
|
using adapter_type = wide_string_input_adapter<base_adapter_type, char_type>;
|
||||||
|
|
||||||
|
static adapter_type create(IteratorType first, IteratorType last)
|
||||||
|
{
|
||||||
|
return adapter_type(base_adapter_type(std::move(first), std::move(last)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// General purpose iterator-based input
|
// General purpose iterator-based input
|
||||||
template<typename IteratorType>
|
template<typename IteratorType>
|
||||||
typename iterator_input_adapter_factory<IteratorType>::adapter_type input_adapter(IteratorType begin, IteratorType end)
|
typename iterator_input_adapter_factory<IteratorType>::adapter_type input_adapter(IteratorType first, IteratorType last)
|
||||||
{
|
{
|
||||||
using factory_type = iterator_input_adapter_factory<IteratorType>;
|
using factory_type = iterator_input_adapter_factory<IteratorType>;
|
||||||
return factory_type::create(begin, end);
|
return factory_type::create(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convenience shorthand from container to iterator
|
// Convenience shorthand from container to iterator
|
||||||
|
@ -22381,13 +22386,13 @@ class basic_json
|
||||||
|
|
||||||
template<typename IteratorType>
|
template<typename IteratorType>
|
||||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||||
static basic_json parse(IteratorType begin,
|
static basic_json parse(IteratorType first,
|
||||||
IteratorType end,
|
IteratorType last,
|
||||||
const parser_callback_t cb = nullptr,
|
const parser_callback_t cb = nullptr,
|
||||||
const bool allow_exceptions = true)
|
const bool allow_exceptions = true)
|
||||||
{
|
{
|
||||||
basic_json result;
|
basic_json result;
|
||||||
parser(detail::input_adapter(std::move(begin), std::move(end)), cb, allow_exceptions).parse(true, result);
|
parser(detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions).parse(true, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22408,9 +22413,9 @@ class basic_json
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename IteratorType>
|
template<typename IteratorType>
|
||||||
static bool accept(IteratorType begin, IteratorType end)
|
static bool accept(IteratorType first, IteratorType last)
|
||||||
{
|
{
|
||||||
return parser(detail::input_adapter(std::move(begin), std::move(end))).accept(true);
|
return parser(detail::input_adapter(std::move(first), std::move(last))).accept(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool accept(detail::span_input_adapter&& i)
|
static bool accept(detail::span_input_adapter&& i)
|
||||||
|
|
Loading…
Reference in a new issue