Skip to content

Commit 3e02d0c

Browse files
committed
format code base in Mozilla style
1 parent d690908 commit 3e02d0c

File tree

106 files changed

+15665
-13100
lines changed

Some content is hidden

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

106 files changed

+15665
-13100
lines changed

.clang-format

+192
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
---
2+
Language: Cpp
3+
# BasedOnStyle: Mozilla
4+
AccessModifierOffset: -2
5+
AlignAfterOpenBracket: Align
6+
AlignArrayOfStructures: None
7+
AlignConsecutiveMacros: None
8+
AlignConsecutiveAssignments: None
9+
AlignConsecutiveBitFields: None
10+
AlignConsecutiveDeclarations: None
11+
AlignEscapedNewlines: Right
12+
AlignOperands: Align
13+
AlignTrailingComments: true
14+
AllowAllArgumentsOnNextLine: 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+
QualifierAlignment: Leave
63+
CompactNamespaces: 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+
PackConstructorInitializers: BinPack
74+
BasedOnStyle: ''
75+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
76+
AllowAllConstructorInitializersOnNextLine: true
77+
FixNamespaceComments: false
78+
ForEachMacros:
79+
- foreach
80+
- Q_FOREACH
81+
- BOOST_FOREACH
82+
IfMacros:
83+
- KJ_IF_MAYBE
84+
IncludeBlocks: Preserve
85+
IncludeCategories:
86+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
87+
Priority: 2
88+
SortPriority: 0
89+
CaseSensitive: false
90+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
91+
Priority: 3
92+
SortPriority: 0
93+
CaseSensitive: false
94+
- Regex: '.*'
95+
Priority: 1
96+
SortPriority: 0
97+
CaseSensitive: false
98+
IncludeIsMainRegex: '(Test)?$'
99+
IncludeIsMainSourceRegex: ''
100+
IndentAccessModifiers: false
101+
IndentCaseLabels: true
102+
IndentCaseBlocks: false
103+
IndentGotoLabels: true
104+
IndentPPDirectives: None
105+
IndentExternBlock: AfterExternBlock
106+
IndentRequires: false
107+
IndentWidth: 2
108+
IndentWrappedFunctionNames: false
109+
InsertTrailingCommas: None
110+
JavaScriptQuotes: Leave
111+
JavaScriptWrapImports: true
112+
KeepEmptyLinesAtTheStartOfBlocks: true
113+
LambdaBodyIndentation: Signature
114+
MacroBlockBegin: ''
115+
MacroBlockEnd: ''
116+
MaxEmptyLinesToKeep: 1
117+
NamespaceIndentation: None
118+
ObjCBinPackProtocolList: Auto
119+
ObjCBlockIndentWidth: 2
120+
ObjCBreakBeforeNestedBlockParam: true
121+
ObjCSpaceAfterProperty: true
122+
ObjCSpaceBeforeProtocolList: false
123+
PenaltyBreakAssignment: 2
124+
PenaltyBreakBeforeFirstCallParameter: 19
125+
PenaltyBreakComment: 300
126+
PenaltyBreakFirstLessLess: 120
127+
PenaltyBreakOpenParenthesis: 0
128+
PenaltyBreakString: 1000
129+
PenaltyBreakTemplateDeclaration: 10
130+
PenaltyExcessCharacter: 1000000
131+
PenaltyReturnTypeOnItsOwnLine: 200
132+
PenaltyIndentedWhitespace: 0
133+
PointerAlignment: Left
134+
PPIndentWidth: -1
135+
ReferenceAlignment: Pointer
136+
ReflowComments: true
137+
RemoveBracesLLVM: false
138+
SeparateDefinitionBlocks: Leave
139+
ShortNamespaceLines: 1
140+
SortIncludes: CaseSensitive
141+
SortJavaStaticImport: Before
142+
SortUsingDeclarations: true
143+
SpaceAfterCStyleCast: false
144+
SpaceAfterLogicalNot: false
145+
SpaceAfterTemplateKeyword: false
146+
SpaceBeforeAssignmentOperators: true
147+
SpaceBeforeCaseColon: false
148+
SpaceBeforeCpp11BracedList: false
149+
SpaceBeforeCtorInitializerColon: true
150+
SpaceBeforeInheritanceColon: true
151+
SpaceBeforeParens: ControlStatements
152+
SpaceBeforeParensOptions:
153+
AfterControlStatements: true
154+
AfterForeachMacros: true
155+
AfterFunctionDefinitionName: false
156+
AfterFunctionDeclarationName: false
157+
AfterIfMacros: true
158+
AfterOverloadedOperator: false
159+
BeforeNonEmptyParentheses: false
160+
SpaceAroundPointerQualifiers: Default
161+
SpaceBeforeRangeBasedForLoopColon: true
162+
SpaceInEmptyBlock: false
163+
SpaceInEmptyParentheses: false
164+
SpacesBeforeTrailingComments: 1
165+
SpacesInAngles: Never
166+
SpacesInConditionalStatement: false
167+
SpacesInContainerLiterals: true
168+
SpacesInCStyleCastParentheses: false
169+
SpacesInLineCommentPrefix:
170+
Minimum: 1
171+
Maximum: -1
172+
SpacesInParentheses: false
173+
SpacesInSquareBrackets: false
174+
SpaceBeforeSquareBrackets: false
175+
BitFieldColonSpacing: Both
176+
Standard: Latest
177+
StatementAttributeLikeMacros:
178+
- Q_EMIT
179+
StatementMacros:
180+
- Q_UNUSED
181+
- QT_REQUIRE_VERSION
182+
TabWidth: 8
183+
UseCRLF: false
184+
UseTab: Never
185+
WhitespaceSensitiveMacros:
186+
- STRINGIZE
187+
- PP_STRINGIZE
188+
- BOOST_PP_STRINGIZE
189+
- NS_SWIFT_NAME
190+
- CF_SWIFT_NAME
191+
...
192+

examples/basic_usage.cpp

+46-32
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,62 @@
1-
//include bitsery.h to get serialization and deserialization classes
1+
// include bitsery.h to get serialization and deserialization classes
22
#include <bitsery/bitsery.h>
3-
//in ordered to serialize/deserialize data to buffer, include buffer adapter
3+
// in ordered to serialize/deserialize data to buffer, include buffer adapter
44
#include <bitsery/adapter/buffer.h>
5-
//bitsery itself doesn't is lightweight, and doesnt include any unnessessary files,
6-
//traits helps library to know how to use types correctly,
7-
//in this case we'll be using vector both, to serialize/deserialize data and to store use as a buffer.
5+
// bitsery itself doesn't is lightweight, and doesnt include any unnessessary
6+
// files, traits helps library to know how to use types correctly, in this case
7+
// we'll be using vector both, to serialize/deserialize data and to store use as
8+
// a buffer.
89
#include <bitsery/traits/vector.h>
910

10-
enum class MyEnum:uint16_t { V1,V2,V3 };
11-
struct MyStruct {
12-
uint32_t i;
13-
MyEnum e;
14-
std::vector<float> fs;
11+
enum class MyEnum : uint16_t
12+
{
13+
V1,
14+
V2,
15+
V3
16+
};
17+
struct MyStruct
18+
{
19+
uint32_t i;
20+
MyEnum e;
21+
std::vector<float> fs;
1522
};
1623

17-
//define how object should be serialized/deserialized
18-
template <typename S>
19-
void serialize(S& s, MyStruct& o) {
20-
s.value4b(o.i);//fundamental types (ints, floats, enums) of size 4b
21-
s.value2b(o.e);
22-
s.container4b(o.fs, 10);//resizable containers also requires maxSize, to make it safe from buffer-overflow attacks
24+
// define how object should be serialized/deserialized
25+
template<typename S>
26+
void
27+
serialize(S& s, MyStruct& o)
28+
{
29+
s.value4b(o.i); // fundamental types (ints, floats, enums) of size 4b
30+
s.value2b(o.e);
31+
s.container4b(o.fs, 10); // resizable containers also requires maxSize, to
32+
// make it safe from buffer-overflow attacks
2333
}
2434

25-
//some helper types
35+
// some helper types
2636
using Buffer = std::vector<uint8_t>;
2737
using OutputAdapter = bitsery::OutputBufferAdapter<Buffer>;
2838
using InputAdapter = bitsery::InputBufferAdapter<Buffer>;
2939

30-
int main() {
31-
//set some random data
32-
MyStruct data{8941, MyEnum::V2, {15.0f, -8.5f, 0.045f}};
33-
MyStruct res{};
40+
int
41+
main()
42+
{
43+
// set some random data
44+
MyStruct data{ 8941, MyEnum::V2, { 15.0f, -8.5f, 0.045f } };
45+
MyStruct res{};
3446

35-
//create buffer to store data
36-
Buffer buffer;
37-
//use quick serialization function,
38-
//it will use default configuration to setup all the nesessary steps
39-
//and serialize data to container
40-
auto writtenSize = bitsery::quickSerialization<OutputAdapter>(buffer, data);
47+
// create buffer to store data
48+
Buffer buffer;
49+
// use quick serialization function,
50+
// it will use default configuration to setup all the nesessary steps
51+
// and serialize data to container
52+
auto writtenSize = bitsery::quickSerialization<OutputAdapter>(buffer, data);
4153

42-
//same as serialization, but returns deserialization state as a pair
43-
//first = error code, second = is buffer was successfully read from begin to the end.
44-
auto state = bitsery::quickDeserialization<InputAdapter>({buffer.begin(), writtenSize}, res);
54+
// same as serialization, but returns deserialization state as a pair
55+
// first = error code, second = is buffer was successfully read from begin to
56+
// the end.
57+
auto state = bitsery::quickDeserialization<InputAdapter>(
58+
{ buffer.begin(), writtenSize }, res);
4559

46-
assert(state.first == bitsery::ReaderError::NoError && state.second);
47-
assert(data.fs == res.fs && data.i == res.i && data.e == res.e);
60+
assert(state.first == bitsery::ReaderError::NoError && state.second);
61+
assert(data.fs == res.fs && data.i == res.i && data.e == res.e);
4862
}

0 commit comments

Comments
 (0)