File: HACKING

package info (click to toggle)
cervisia 4:17.08.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 7,548 kB
  • sloc: cpp: 14,364; xml: 393; makefile: 3; sh: 3
file content (101 lines) | stat: -rw-r--r-- 1,987 bytes parent folder | download | duplicates (5)
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
Coding Style
============

Formatting
----------

- No tabs.
- Indent is 4 spaces.
- A line should be 80 chars in length, with a maximum length of 90 chars
- Brackets are always on separate lines.
- Put spaces between brackets of if, while and
  similar statements.
- Follow the style of the rest of the file if it is different from these
  guidelines
  
Example:

void MyClass::myFunction(const QString& arg)
{
    if ( blah == "halb" )
    {
        doSometing();
    }
    else
    {
        varA = varB;
    }
}



Header Formatting
-----------------

- Access modifiers are not indented.
- Double inclusion guard defines are all upper case
  letters and are composed of the namespace (if available),
  the classname and a H suffix separated by underscores.
- Inside a namespace there is no indentation.

  
Example:

#ifndef NAMESPACE_MYCLASS_H
#define NAMESPACE_MYCLASS_H

namespace Namespace 
{

class MyClass
{
public:
    MyClass();
    
private:
    int m_intVar;
    QProcess* m_proc;
};

}

#endif



Class and File Names
--------------------

- Use .h and .cpp for the header and source files, respectively
- Do not abbreviate words in filenames
- Use the classname without the namespace as the name of the file

Example:

class FooDialog : public QDialog
{
public:
    FooDialog( QWidget* parent );
};

has files foodialog.h and foodialog.cpp instead of foodialog.h and foodlg.cpp


Class and Variable Names
------------------------

- For class, variable and function names separate multiple
  words by uppercasing the words preceded by other words.
- Class names start with an uppercase letter.
- Function names start with a lowercase letter.
- Variable names start with a lowercase letter.
- Member Variables of a class start with a 'm_' prefix
  followed by an lowercase letter.
- Use descriptive names where possible. Write "job" instead of "j", for
  example.

Member Functions
----------------

- Do not write inline accessors. All code should be in the .cpp files