Skip to content

Commit

Permalink
update clang-format and source to clp config
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlion committed Jun 3, 2024
1 parent 4d3ca8a commit 8896f4b
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 100 deletions.
137 changes: 72 additions & 65 deletions cpp/.clang-format
Original file line number Diff line number Diff line change
@@ -1,37 +1,42 @@
# yamllint disable-line rule:document-start
---
ColumnLimit: 100
IndentWidth: 4
# yamllint disable-line rule:document-start
---
Language: Cpp
Language: "Cpp"
AccessModifierOffset: -4
AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: None
AlignEscapedNewlines: DontAlign
AlignOperands: Align
AlignTrailingComments: Never
AlignAfterOpenBracket: "BlockIndent"
AlignArrayOfStructures: "None"
AlignConsecutiveAssignments: "None"
AlignConsecutiveBitFields: "None"
AlignConsecutiveDeclarations: "None"
AlignConsecutiveMacros: "None"
AlignEscapedNewlines: "DontAlign"
AlignOperands: "Align"
AlignTrailingComments:
Kind: "Never"
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowBreakBeforeNoexceptSpecifier: "OnlyWithParen"
AllowShortBlocksOnASingleLine: "Always"
AllowShortCaseLabelsOnASingleLine: false
AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortFunctionsOnASingleLine: "Inline"
AllowShortIfStatementsOnASingleLine: "Never"
AllowShortLambdasOnASingleLine: "All"
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakAfterReturnType: "None"
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
AlwaysBreakTemplateDeclarations: "Yes"
BinPackArguments: false
BinPackParameters: false
BitFieldColonSpacing: Both
BitFieldColonSpacing: "Both"
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: MultiLine
AfterControlStatement: "MultiLine"
AfterEnum: false
AfterFunction: false
AfterNamespace: false
Expand All @@ -46,45 +51,46 @@ BraceWrapping:
SplitEmptyFunction: false
SplitEmptyNamespace: false
SplitEmptyRecord: false
BreakAfterAttributes: Never
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Custom
BreakBeforeConceptDeclarations: Always
BreakBeforeInlineASMColon: OnlyMultiline
BreakAfterAttributes: "Never"
BreakBeforeBinaryOperators: "All"
BreakBeforeBraces: "Custom"
BreakBeforeConceptDeclarations: "Always"
BreakBeforeInlineASMColon: "OnlyMultiline"
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakConstructorInitializers: "BeforeColon"
BreakInheritanceList: "BeforeColon"
BreakStringLiterals: true
CompactNamespaces: true
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 8
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
EmptyLineAfterAccessModifier: "Never"
EmptyLineBeforeAccessModifier: "LogicalBlock"
FixNamespaceComments: true
IncludeBlocks: Regroup
IncludeBlocks: "Regroup"
IncludeCategories:
# NOTE: A header is grouped by first matching regex
# Project headers
- Regex: '^<ffi_go'
Priority: 4
# Third-party headers. Update when adding new third-party library
# Library headers. Update when adding new libraries.
# NOTE: clang-format retains leading white-space on a line in violation of the YAML spec.
- Regex: '^<(clp)'
Priority: 3
# C headers
- Regex: '^<.*\.h>$'
# C system headers
- Regex: "^<.+\\.h>"
Priority: 1
# C++ standard libraries
- Regex: '^<.*>$'
- Regex: "^<.+>"
Priority: 2
# Project headers
- Regex: "^\".+\""
Priority: 4
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: Indent
IndentExternBlock: "Indent"
IndentGotoLabels: false
IndentPPDirectives: None
IndentPPDirectives: "BeforeHash"
IndentRequiresClause: false
IndentWrappedFunctionNames: false
InsertBraces: true
Expand All @@ -97,61 +103,62 @@ IntegerLiteralSeparator:
Hex: 4
HexMinDigits: 4
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
LineEnding: LF
LambdaBodyIndentation: "Signature"
LineEnding: "LF"
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
NamespaceIndentation: "None"
PPIndentWidth: -1
PackConstructorInitializers: CurrentLine
PenaltyBreakAssignment: 50
PackConstructorInitializers: "CurrentLine"
PenaltyBreakOpenParenthesis: 25
PenaltyBreakBeforeFirstCallParameter: 25
PenaltyReturnTypeOnItsOwnLine: 100
PointerAlignment: Left
QualifierAlignment: Custom
PointerAlignment: "Left"
QualifierAlignment: "Custom"
QualifierOrder:
- static
- friend
- inline
- "static"
- "friend"
- "inline"
# constexpr west as explained in https://www.youtube.com/watch?v=z6s6bacI424
- constexpr
- type
- const
- volatile
ReferenceAlignment: Pointer
- "constexpr"
- "type"
- "const"
- "volatile"
ReferenceAlignment: "Pointer"
ReflowComments: true
RemoveBracesLLVM: false
RemoveSemicolon: true
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Always
RequiresClausePosition: "OwnLine"
RequiresExpressionIndentation: "OuterScope"
SeparateDefinitionBlocks: "Always"
ShortNamespaceLines: 0
SortIncludes: CaseInsensitive
SortUsingDeclarations: Lexicographic
SortIncludes: "CaseInsensitive"
SortUsingDeclarations: "Lexicographic"
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceAroundPointerQualifiers: "Default"
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeParens: "ControlStatements"
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInParens: "Custom"
SpacesInParensOptions:
InConditionalStatements: false
InCStyleCasts: false
InEmptyParentheses: false
Other: false
SpacesInSquareBrackets: false
Standard: Latest
Standard: "Latest"
TabWidth: 4
UseTab: Never
UseTab: "Never"
4 changes: 2 additions & 2 deletions cpp/src/ffi_go/api_decoration.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* ensure C linkage.
*/
#ifdef __cplusplus
#define CLP_FFI_GO_EXTERN_C extern "C"
#define CLP_FFI_GO_EXTERN_C extern "C"
#else
#define CLP_FFI_GO_EXTERN_C
#define CLP_FFI_GO_EXTERN_C
#endif

/**
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/ffi_go/ir/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include <clp/components/core/src/ffi/encoding_methods.hpp>
#include <clp/components/core/src/ffi/ir_stream/decoding_methods.hpp>

#include <ffi_go/api_decoration.h>
#include <ffi_go/defs.h>
#include <ffi_go/ir/types.hpp>
#include "ffi_go/api_decoration.h"
#include "ffi_go/defs.h"
#include "ffi_go/ir/types.hpp"

namespace ffi_go::ir {
using namespace ffi::ir_stream;
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/ffi_go/ir/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <stdint.h>
#include <stdlib.h>

#include <ffi_go/api_decoration.h>
#include <ffi_go/defs.h>
#include "ffi_go/api_decoration.h"
#include "ffi_go/defs.h"

/**
* Create a ir::Decoder used as the underlying data storage for a Go ir.Decoder.
Expand Down
23 changes: 13 additions & 10 deletions cpp/src/ffi_go/ir/deserializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
#include <clp/components/core/src/ffi/ir_stream/decoding_methods.hpp>
#include <clp/components/core/src/string_utils.hpp>

#include <ffi_go/api_decoration.h>
#include <ffi_go/defs.h>
#include <ffi_go/ir/types.hpp>
#include <ffi_go/search/wildcard_query.h>
#include <ffi_go/types.hpp>
#include "ffi_go/api_decoration.h"
#include "ffi_go/defs.h"
#include "ffi_go/ir/types.hpp"
#include "ffi_go/search/wildcard_query.h"
#include "ffi_go/types.hpp"

namespace ffi_go::ir {
using namespace ffi;
Expand Down Expand Up @@ -120,10 +120,12 @@ auto deserialize_wildcard_match(
std::string_view const query_view{merged_query.m_queries.m_data, merged_query.m_queries.m_size};
std::span<size_t> const end_offsets{
merged_query.m_end_offsets.m_data,
merged_query.m_end_offsets.m_size};
merged_query.m_end_offsets.m_size
};
std::span<bool> const case_sensitivity{
merged_query.m_case_sensitivity.m_data,
merged_query.m_case_sensitivity.m_size};
merged_query.m_case_sensitivity.m_size
};

std::vector<std::pair<std::string_view, bool>> queries(merged_query.m_end_offsets.m_size);
size_t pos{0};
Expand Down Expand Up @@ -185,7 +187,8 @@ auto deserialize_wildcard_match(
continue;
}
auto const [has_matching_query, matching_query_idx]{
query_fn(deserializer->m_log_event.m_log_message)};
query_fn(deserializer->m_log_event.m_log_message)
};
if (false == has_matching_query) {
continue;
}
Expand Down Expand Up @@ -234,8 +237,8 @@ CLP_FFI_GO_METHOD auto ir_deserializer_new_deserializer_with_preamble(
}
*ir_encoding = four_byte_encoding ? 1 : 0;

if (IRErrorCode const err{
decode_preamble(ir_buf, *metadata_type, *metadata_pos, *metadata_size)};
if (IRErrorCode const err{decode_preamble(ir_buf, *metadata_type, *metadata_pos, *metadata_size)
};
IRErrorCode_Success != err)
{
return static_cast<int>(err);
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/ffi_go/ir/deserializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include <stdint.h>
#include <stdlib.h>

#include <ffi_go/api_decoration.h>
#include <ffi_go/defs.h>
#include <ffi_go/search/wildcard_query.h>
#include "ffi_go/api_decoration.h"
#include "ffi_go/defs.h"
#include "ffi_go/search/wildcard_query.h"

/**
* Clean up the underlying ir::Deserializer of a Go ir.Deserializer.
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/ffi_go/ir/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#include <clp/components/core/src/ffi/encoding_methods.hpp>
#include <clp/components/core/src/ffi/ir_stream/decoding_methods.hpp>

#include <ffi_go/api_decoration.h>
#include <ffi_go/defs.h>
#include <ffi_go/ir/types.hpp>
#include "ffi_go/api_decoration.h"
#include "ffi_go/defs.h"
#include "ffi_go/ir/types.hpp"

namespace ffi_go::ir {
using namespace ffi::ir_stream;
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/ffi_go/ir/encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <stdint.h>
#include <stdlib.h>

#include <ffi_go/api_decoration.h>
#include <ffi_go/defs.h>
#include "ffi_go/api_decoration.h"
#include "ffi_go/defs.h"

/**
* Create a ir::Encoder used as the underlying data storage for a Go ir.Encoder.
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/ffi_go/ir/serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include <clp/components/core/src/ffi/ir_stream/decoding_methods.hpp>
#include <clp/components/core/src/ffi/ir_stream/encoding_methods.hpp>

#include <ffi_go/api_decoration.h>
#include <ffi_go/defs.h>
#include <ffi_go/ir/types.hpp>
#include "ffi_go/api_decoration.h"
#include "ffi_go/defs.h"
#include "ffi_go/ir/types.hpp"

namespace ffi_go::ir {
using namespace ffi;
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/ffi_go/ir/serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <stdint.h>
#include <stdlib.h>

#include <ffi_go/api_decoration.h>
#include <ffi_go/defs.h>
#include "ffi_go/api_decoration.h"
#include "ffi_go/defs.h"

/**
* Clean up the underlying ir::Serializer of a Go ir.Serializer.
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/ffi_go/ir/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <clp/components/core/src/ffi/encoding_methods.hpp>

#include <ffi_go/types.hpp>
#include "ffi_go/types.hpp"

namespace ffi_go::ir {

Expand Down
4 changes: 2 additions & 2 deletions cpp/src/ffi_go/search/wildcard_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include <clp/components/core/src/string_utils.hpp>

#include <ffi_go/api_decoration.h>
#include <ffi_go/defs.h>
#include "ffi_go/api_decoration.h"
#include "ffi_go/defs.h"

namespace ffi_go::search {
CLP_FFI_GO_METHOD auto wildcard_query_new(StringView query, void** ptr) -> StringView {
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/ffi_go/search/wildcard_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#include <stdbool.h>

#include <ffi_go/api_decoration.h>
#include <ffi_go/defs.h>
#include "ffi_go/api_decoration.h"
#include "ffi_go/defs.h"

/**
* A timestamp interval of [m_lower, m_upper).
Expand Down

0 comments on commit 8896f4b

Please sign in to comment.