File: coding-style.md

package info (click to toggle)
seafile-client 6.1.8-1~bpo9+1
  • links: PTS, VCS
  • area: main
  • in suites: stretch-backports
  • size: 9,408 kB
  • sloc: cpp: 41,401; ansic: 3,876; python: 253; sh: 206; xml: 17; makefile: 10
file content (43 lines) | stat: -rw-r--r-- 1,046 bytes parent folder | download | duplicates (3)
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
## C++ Coding Style

Mainly borrowed from [google c++ style coding style](http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml)

### Naming Conventions

#### Member Vairables

Lower case words seprated by underscores, and ends with an underscore, e.g. `repos_list_`, `context_menu_`

#### Variables in Qt Ui Files

Camel case starts with a "m", e.g. `mUserNameText`, `mServerAddr`

#### Functions

Camel case, e.g. `showRepos`

#### Setter and Getter

- setter: `setRepoName()`
- getter: `repoName()`

#### Constants

Camel case starts with "k", e.g. :

    const int kRepoRefreshInterval = 1000;
    const char *kDefaultName = "seafile";

Use constants variables instead of macros to define constants.

### Invoking functions

- constant function parameter must be passed by object reference
- No `this->` when invoking member functions.

### Others

- no source file scope static variable/function, use anonymous namespace
- use forward declaration when possible, instead of including unnecessary header files
- Never use exceptions