-
Notifications
You must be signed in to change notification settings - Fork 4
/
CODING
63 lines (46 loc) · 1.84 KB
/
CODING
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
C++ coding style
================
The Ubuntu UI Toolkit follows the Qt conventions, see:
- https://wiki.qt.io/Coding_Conventions
- https://wiki.qt.io/Qt_Coding_Style
On top of it we add the few clarifications listed below.
Header inclusion
----------------
1/ When including Qt or UITK headers, always prefix with the project name. Use:
#include <QtCore/QMap>
#include <UbuntuMetrics/applicationmonitor.h>
not
#include <QMap>
#include <applicationmonitor.h>
2/ For readability reasons and to avoid hidden dependencies, headers should be
included in ordered sections, separated by an empty line, as follows:
// The project's related header (for instance here for foo.cpp).
#include "foo.h"
// C standard library headers.
#include <sys/types.h>
#include <unistd.h>
// C++ standard library headers.
#include <functional>
#include <hash_map>
#include <vector>
// Qt and UITK headers. Try to first list QtCore and QtGui headers. Private
// headers come right after public headers of the same project.
#include <QtCore/QDebug>
#include <QtCore/QHash>
#include <QtCore/private/qobject_p.h>
#include <QtGui/QWindow>
#include <QtGui/private/qcolor_p.h>
#include <UbuntuMetrics/applicationmonitor.h>
// Other libraries headers.
#include <gst/gst.h>
#include <boost/call_traits.hpp>
// The project's headers.
#include "bar.h"
#include "baz_p.h"
3/ For libraries, the "foo" inclusion variant must be used in C++
source files for the project's headers. The <Project/foo.h> and
<Project/private/foo_p.h> inclusion variant must be used for the
project's headers in private and public headers, wherever the
header is located in the source tree. That ensures the inclusion of
private headers by external projects (or by our unit tests) won't
break.