summaryrefslogtreecommitdiffstats
path: root/doc/CodingStyle
blob: 3a254b7fa70496b5bd4c24406f8268f4dd63113e (plain)
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
Coding style used in abrt
=================================

1. Class
--------
1.1 Class has to start with 'C'

1.2 Method
-----------
1.2.1 method starts witch a capital letter
1.2.2 method name can contain only letters
1.2.3 parameter of a method has to start with the letter 'p'

1.3 Attribute
-------------
1.3.1 non-float attribute has to start with "m_n"
1.3.2 float attribute has to start with "m_f"
1.3.3 double attribute has to start with "m_d"
1.3.4 bool attribute has to start with "m_b"
1.3.5 string/char attribute has to start with "m_s"
1.3.6 pointer attribute has to start with "m_p"
1.3.7 template attribute has to start with a template name "m_map"
1.3.8 otherwise "m_"

2. Type
-------
2.1 every type has to end with "_t"
2.2 types created from templates has to start with a template name
2.3 words in a type has to be separated with "_"

3. Statement
------------
3.1 "if", "while" and "for" has to have {} every time.
3.2 { is on the new line every time

4. Example
----------

typedef std::map<int, int> map_new_type_t;

class CAwesomeClass
{
	private:
		map_new_type_t m_NewType;
		std::string m_sName;
		COtherClass* m_pOtherClass;
		void PrivateFunction(int pParameter);
	public:
		CAwesomeClass(std::string pName) :
		    m_sName(pName), m_pOtherClass(NULL)
		{}
};

void CAwesomeClass::PrivateFunction(int pParameter)
{
	if (pParameter != "")
	{
		// do something
	}
	else
	{
		// do something else
	}
}