-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodingStyle.cpp
More file actions
131 lines (108 loc) · 1.6 KB
/
CodingStyle.cpp
File metadata and controls
131 lines (108 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// Includes:
// .hpp if it's an implementation
#include "Common/SomeHeader.hpp"
// System/STL
#include <algorithm>
#include <iostream>
// Third-party
#include <QtCore>
// Our includes
#include "Mind/Mind.hpp"
// Indentation
#define foobar(A)\
{Foo();Bar();}
#define anotherFoo(B)\
return Bar()
// Empty lines:
// Use whatever feels most readable inside compound statements ({}).
// Use either 1 or 2 empty lines between top-level code blocks (function definitions, class/variable declarations etc.).
// Line length: Please try not to exceed the limit of 120 characters per single line.
class BarBar {
public:
BarBar(int a, float x);
private:
int f;
float z;
};
BarBar::BarBar(int a, float x)
: f{a}, z{2.0f * x}
{}
namespace Bar
{
class Foo {
public:
Foo();
virtual ~Foo();
};
switch (foo) {
case 1:
a += 1;
break;
case 2: {
a += 2;
break;
}
}
if (isFoo) {
bar();
} else {
anotherBar();
}
int foo()
while (isFoo) {
...
goto error;
....
error:
...
}
}
fooArray[] = {
red,
green,
darkblue
};
fooFunction(
barArg1,
barArg2,
barArg3);
struct foo { int bar() {} };
// Formatting
void func()
{
if (isFoo(a, b))
bar(a, b);
if (isFoo)
a = bar((b - c) * a, *d--);
if (isFoo(a, b))
bar(a, b);
if (isFoo) {
isFoo = false;
cat << isFoo << endl;
}
if (isFoo)
DoBar();
if (isFoo)
bar();
else if (isBar())
anotherBar();
int var = 1;
int *ptr = &var;
int &ref = i;
QList<int>::const_iterator it = list.begin();
}
namespace A
{
namespace B
{
class someClass {
void foo()
{
if (true)
func();
else
// bla
}
};
}
}