added c++ coding style

This commit is contained in:
lins05 2013-11-06 14:30:04 +08:00
parent 80f10a086e
commit be88340c45
2 changed files with 49 additions and 6 deletions

43
coding-style.md Normal file
View file

@ -0,0 +1,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

View file

@ -1,20 +1,20 @@
## C++ Coding Style
TO DO
Refer to `coding-style.md`
## I18N
### update the .ts files
make update-ts
### Add a new language
1. add the language to the LANGUAGES variable in `CMakeLists.txt`
SET(LANGUAGES zh_CN xx_YY)
2. make update-ts
3. add a line to `seafile-client.qrc`
@ -26,8 +26,8 @@ TO DO
1. add the language to the LANGUAGES variable in `CMakeLists.txt`
SET(LANGUAGES zh_CN xx_YY)
2. add a line to `seafile-client.qrc`
<file>i18n/seafile_xx_YY.qm</file>