Skip to content

Commit e8abe51

Browse files
authored
Add .clang-format, Format files (#946)
* add .clang-format * add format-all script * format all
1 parent beae0f6 commit e8abe51

File tree

407 files changed

+82855
-66451
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

407 files changed

+82855
-66451
lines changed

.clang-format

+177
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
---
2+
Language: Cpp
3+
AccessModifierOffset: -4
4+
AlignAfterOpenBracket: Align
5+
AlignArrayOfStructures: None
6+
AlignConsecutiveMacros: None
7+
AlignConsecutiveAssignments: None
8+
AlignConsecutiveBitFields: None
9+
AlignConsecutiveDeclarations: None
10+
AlignEscapedNewlines: Right
11+
AlignOperands: Align
12+
AlignTrailingComments: true
13+
AllowAllArgumentsOnNextLine: true
14+
AllowAllConstructorInitializersOnNextLine: true
15+
AllowAllParametersOfDeclarationOnNextLine: false
16+
AllowShortEnumsOnASingleLine: true
17+
AllowShortBlocksOnASingleLine: Never
18+
AllowShortCaseLabelsOnASingleLine: false
19+
AllowShortFunctionsOnASingleLine: Inline
20+
AllowShortLambdasOnASingleLine: All
21+
AllowShortIfStatementsOnASingleLine: Never
22+
AllowShortLoopsOnASingleLine: false
23+
AlwaysBreakAfterDefinitionReturnType: TopLevel
24+
AlwaysBreakAfterReturnType: TopLevel
25+
AlwaysBreakBeforeMultilineStrings: false
26+
AlwaysBreakTemplateDeclarations: Yes
27+
AttributeMacros:
28+
- __capability
29+
BinPackArguments: false
30+
BinPackParameters: false
31+
BraceWrapping:
32+
AfterCaseLabel: false
33+
AfterClass: true
34+
AfterControlStatement: Never
35+
AfterEnum: true
36+
AfterFunction: true
37+
AfterNamespace: false
38+
AfterObjCDeclaration: false
39+
AfterStruct: true
40+
AfterUnion: true
41+
AfterExternBlock: true
42+
BeforeCatch: false
43+
BeforeElse: false
44+
BeforeLambdaBody: false
45+
BeforeWhile: false
46+
IndentBraces: false
47+
SplitEmptyFunction: true
48+
SplitEmptyRecord: false
49+
SplitEmptyNamespace: true
50+
BreakBeforeBinaryOperators: None
51+
BreakBeforeConceptDeclarations: true
52+
BreakBeforeBraces: Mozilla
53+
BreakBeforeInheritanceComma: false
54+
BreakInheritanceList: BeforeComma
55+
BreakBeforeTernaryOperators: true
56+
BreakConstructorInitializersBeforeComma: false
57+
BreakConstructorInitializers: BeforeComma
58+
BreakAfterJavaFieldAnnotations: false
59+
BreakStringLiterals: true
60+
ColumnLimit: 80
61+
CommentPragmas: '^ IWYU pragma:'
62+
CompactNamespaces: false
63+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
64+
ConstructorInitializerIndentWidth: 2
65+
ContinuationIndentWidth: 2
66+
Cpp11BracedListStyle: false
67+
DeriveLineEnding: true
68+
DerivePointerAlignment: false
69+
DisableFormat: false
70+
EmptyLineAfterAccessModifier: Never
71+
EmptyLineBeforeAccessModifier: LogicalBlock
72+
ExperimentalAutoDetectBinPacking: false
73+
FixNamespaceComments: true
74+
ForEachMacros:
75+
- foreach
76+
- Q_FOREACH
77+
- BOOST_FOREACH
78+
IfMacros:
79+
- KJ_IF_MAYBE
80+
IncludeBlocks: Preserve
81+
IncludeCategories:
82+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
83+
Priority: 2
84+
SortPriority: 0
85+
CaseSensitive: false
86+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
87+
Priority: 3
88+
SortPriority: 0
89+
CaseSensitive: false
90+
- Regex: '.*'
91+
Priority: 1
92+
SortPriority: 0
93+
CaseSensitive: false
94+
IncludeIsMainRegex: '(Test)?$'
95+
IncludeIsMainSourceRegex: ''
96+
IndentAccessModifiers: false
97+
IndentCaseLabels: true
98+
IndentCaseBlocks: false
99+
IndentGotoLabels: true
100+
IndentPPDirectives: None
101+
IndentExternBlock: AfterExternBlock
102+
IndentRequires: false
103+
IndentWidth: 4
104+
IndentWrappedFunctionNames: false
105+
InsertTrailingCommas: None
106+
JavaScriptQuotes: Leave
107+
JavaScriptWrapImports: true
108+
KeepEmptyLinesAtTheStartOfBlocks: true
109+
LambdaBodyIndentation: Signature
110+
MacroBlockBegin: ''
111+
MacroBlockEnd: ''
112+
MaxEmptyLinesToKeep: 1
113+
NamespaceIndentation: None
114+
ObjCBinPackProtocolList: Auto
115+
ObjCBlockIndentWidth: 2
116+
ObjCBreakBeforeNestedBlockParam: true
117+
ObjCSpaceAfterProperty: true
118+
ObjCSpaceBeforeProtocolList: false
119+
PenaltyBreakAssignment: 2
120+
PenaltyBreakBeforeFirstCallParameter: 19
121+
PenaltyBreakComment: 300
122+
PenaltyBreakFirstLessLess: 120
123+
PenaltyBreakString: 1000
124+
PenaltyBreakTemplateDeclaration: 10
125+
PenaltyExcessCharacter: 1000000
126+
PenaltyReturnTypeOnItsOwnLine: 200
127+
PenaltyIndentedWhitespace: 0
128+
PointerAlignment: Left
129+
PPIndentWidth: -1
130+
ReferenceAlignment: Pointer
131+
ReflowComments: true
132+
ShortNamespaceLines: 1
133+
SortIncludes: Never
134+
SortJavaStaticImport: Before
135+
SortUsingDeclarations: true
136+
SpaceAfterCStyleCast: false
137+
SpaceAfterLogicalNot: false
138+
SpaceAfterTemplateKeyword: false
139+
SpaceBeforeAssignmentOperators: true
140+
SpaceBeforeCaseColon: false
141+
SpaceBeforeCpp11BracedList: false
142+
SpaceBeforeCtorInitializerColon: true
143+
SpaceBeforeInheritanceColon: true
144+
SpaceBeforeParens: ControlStatements
145+
SpaceAroundPointerQualifiers: Default
146+
SpaceBeforeRangeBasedForLoopColon: true
147+
SpaceInEmptyBlock: false
148+
SpaceInEmptyParentheses: false
149+
SpacesBeforeTrailingComments: 1
150+
SpacesInAngles: Never
151+
SpacesInConditionalStatement: false
152+
SpacesInContainerLiterals: true
153+
SpacesInCStyleCastParentheses: false
154+
SpacesInLineCommentPrefix:
155+
Minimum: 1
156+
Maximum: -1
157+
SpacesInParentheses: false
158+
SpacesInSquareBrackets: false
159+
SpaceBeforeSquareBrackets: false
160+
BitFieldColonSpacing: Both
161+
Standard: Latest
162+
StatementAttributeLikeMacros:
163+
- Q_EMIT
164+
StatementMacros:
165+
- Q_UNUSED
166+
- QT_REQUIRE_VERSION
167+
TabWidth: 8
168+
UseCRLF: false
169+
UseTab: Never
170+
WhitespaceSensitiveMacros:
171+
- STRINGIZE
172+
- PP_STRINGIZE
173+
- BOOST_PP_STRINGIZE
174+
- NS_SWIFT_NAME
175+
- CF_SWIFT_NAME
176+
...
177+

examples/Org.Website.Samples/CustomSerializerSample.cpp

+36-26
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,57 @@
1717

1818
using namespace hazelcast::client;
1919

20-
struct Person {
21-
friend std::ostream &operator<<(std::ostream &os, const Person &person);
20+
struct Person
21+
{
22+
friend std::ostream& operator<<(std::ostream& os, const Person& person);
2223

2324
std::string name;
2425
bool male;
2526
int32_t age;
2627
};
2728

28-
std::ostream &operator<<(std::ostream &os, const Person &person) {
29-
os << "name: " << person.name << " male: " << person.male << " age: " << person.age;
29+
std::ostream&
30+
operator<<(std::ostream& os, const Person& person)
31+
{
32+
os << "name: " << person.name << " male: " << person.male
33+
<< " age: " << person.age;
3034
return os;
3135
}
3236

3337
namespace hazelcast {
34-
namespace client {
35-
namespace serialization {
36-
template<>
37-
struct hz_serializer<Person> : custom_serializer {
38-
static constexpr int32_t get_type_id() noexcept {
39-
return 3;
40-
}
41-
42-
static void write(const Person &object, hazelcast::client::serialization::object_data_output &out) {
43-
out.write(object.name);
44-
out.write(object.male);
45-
out.write(object.age);
46-
}
47-
48-
static Person read(hazelcast::client::serialization::object_data_input &in) {
49-
return Person{in.read<std::string>(), in.read<bool>(), in.read<int32_t>()};
50-
}
51-
};
52-
}
38+
namespace client {
39+
namespace serialization {
40+
template<>
41+
struct hz_serializer<Person> : custom_serializer
42+
{
43+
static constexpr int32_t get_type_id() noexcept { return 3; }
44+
45+
static void write(const Person& object,
46+
hazelcast::client::serialization::object_data_output& out)
47+
{
48+
out.write(object.name);
49+
out.write(object.male);
50+
out.write(object.age);
5351
}
54-
}
5552

56-
int main() {
53+
static Person read(hazelcast::client::serialization::object_data_input& in)
54+
{
55+
return Person{ in.read<std::string>(),
56+
in.read<bool>(),
57+
in.read<int32_t>() };
58+
}
59+
};
60+
} // namespace serialization
61+
} // namespace client
62+
} // namespace hazelcast
63+
64+
int
65+
main()
66+
{
5767
auto hz = hazelcast::new_client().get();
5868

5969
auto map = hz.get_map("customMap").get();
60-
map->put(1L, Person{"My Person", false, 57}).get();
70+
map->put(1L, Person{ "My Person", false, 57 }).get();
6171

6272
return 0;
6373
}

examples/Org.Website.Samples/EntryProcessorSample.cpp

+38-30
Original file line numberDiff line numberDiff line change
@@ -17,51 +17,59 @@
1717

1818
using namespace hazelcast::client;
1919

20-
struct IdentifiedEntryProcessor {
20+
struct IdentifiedEntryProcessor
21+
{
2122
std::string name;
2223
};
2324

2425
namespace hazelcast {
25-
namespace client {
26-
namespace serialization {
27-
template<>
28-
struct hz_serializer<IdentifiedEntryProcessor> : identified_data_serializer {
29-
static int32_t get_factory_id() noexcept {
30-
return 66;
31-
}
26+
namespace client {
27+
namespace serialization {
28+
template<>
29+
struct hz_serializer<IdentifiedEntryProcessor> : identified_data_serializer
30+
{
31+
static int32_t get_factory_id() noexcept { return 66; }
3232

33-
static int32_t get_class_id() noexcept {
34-
return 1;
35-
}
33+
static int32_t get_class_id() noexcept { return 1; }
3634

37-
static void
38-
write_data(const IdentifiedEntryProcessor &object, hazelcast::client::serialization::object_data_output &out) {
39-
out.write(object.name);
40-
}
35+
static void write_data(
36+
const IdentifiedEntryProcessor& object,
37+
hazelcast::client::serialization::object_data_output& out)
38+
{
39+
out.write(object.name);
40+
}
4141

42-
static IdentifiedEntryProcessor read_data(hazelcast::client::serialization::object_data_input &in) {
43-
// no-need to implement here, since we do not expect to receive this object but we only send it to server
44-
assert(0);
45-
return IdentifiedEntryProcessor{};
46-
}
47-
};
48-
}
42+
static IdentifiedEntryProcessor read_data(
43+
hazelcast::client::serialization::object_data_input& in)
44+
{
45+
// no-need to implement here, since we do not expect to receive this
46+
// object but we only send it to server
47+
assert(0);
48+
return IdentifiedEntryProcessor{};
4949
}
50-
}
50+
};
51+
} // namespace serialization
52+
} // namespace client
53+
} // namespace hazelcast
5154

52-
int main() {
53-
// Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
55+
int
56+
main()
57+
{
58+
// Start the Hazelcast Client and connect to an already running Hazelcast
59+
// Cluster on 127.0.0.1
5460
auto hz = hazelcast::new_client().get();
5561
// Get the Distributed Map from Cluster.
5662
auto map = hz.get_map("my-distributed-map").get();
5763
// Put the integer value of 0 into the Distributed Map
5864
map->put("key", 0).get();
59-
// Run the IncEntryProcessor class on the Hazelcast Cluster Member holding the key called "key",
60-
// The entry processor returns in32_t.
61-
auto returnValueFromIncEntryProcessor = map->execute_on_key<std::string, int32_t, IdentifiedEntryProcessor>(
62-
"key", IdentifiedEntryProcessor{"my_name"});
65+
// Run the IncEntryProcessor class on the Hazelcast Cluster Member holding
66+
// the key called "key", The entry processor returns in32_t.
67+
auto returnValueFromIncEntryProcessor =
68+
map->execute_on_key<std::string, int32_t, IdentifiedEntryProcessor>(
69+
"key", IdentifiedEntryProcessor{ "my_name" });
6370
// Show that the IncEntryProcessor updated the value.
64-
std::cout << "new value:" << *map->get<std::string, std::string>("key").get();
71+
std::cout << "new value:"
72+
<< *map->get<std::string, std::string>("key").get();
6573
// Shutdown this Hazelcast Client
6674
hz.shutdown().get();
6775

0 commit comments

Comments
 (0)