File: coding_style_cpp.rst

package info (click to toggle)
dnf5 5.4.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,960 kB
  • sloc: cpp: 94,312; python: 3,370; xml: 1,073; ruby: 600; sql: 250; ansic: 232; sh: 104; perl: 62; makefile: 30
file content (51 lines) | stat: -rw-r--r-- 1,127 bytes parent folder | download
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
C++ coding style
================

* C++20
* Indent by 4 spaces
* Up to 120 characters per line
* Comments start with two forward slashes: ``//``
* Docstrings start with three forward slashes: ``///``
* See .clang-format for more details and examples


Character case
--------------

* Types: CamelCase
* Classes: CamelCase
* Functions: snake_case
* Variables: snake_case
* Arguments: snake_case
* Constants: UPPER_CASE


Includes
--------
* Includes grouped and alphabetically ordered within each group::

    #include "current-dir-include.hpp"

    #include <libdnf5-cli/.../*.hpp>

    #include <libdnf5/.../*.hpp>

    #include <3rd party>

    #include <standard library>

* Includes within the same directory should use relative paths::

     #include "current-dir-include.hpp"

* Other includes should use absolute paths::

    #include <libdnf5/.../*.hpp>

* Includes within the same component should use the double-quote form. E.g. in dnf5::

    #include "commands/.../*.hpp"

* Includes from a different component in the repository should use the angle-bracket form. E.g. in dnf5::

    #include <libdnf5/.../*.hpp>