Browse Source

Update coding style. Closes #2091.

adaptive-webui-19844
sledgehammer999 10 years ago
parent
commit
17f56a7744
  1. 63
      CODING_GUIDELINES.md

63
CODING_GUIDELINES.md

@ -7,52 +7,53 @@ If you make changes in a file that still uses another coding style, make sure th
```c++ ```c++
int myFunction(int a) int myFunction(int a)
{ {
//code //code
} }
myClass::myClass(int *parent) : m_parent(parent) myClass::myClass(int *parent)
: m_parent(parent)
{ {
//initialiaze //initialiaze
} }
int myClass::myMethod(int a) int myClass::myMethod(int a)
{ {
//code //code
} }
class myOtherClass class myOtherClass
{ {
public: public:
//code //code
protected: protected:
//code //code
private: private:
//code //code
}; };
namespace id namespace id
{ {
//code //code
} }
``` ```
#### b. Other code blocks #### #### b. Other code blocks ####
```c++ ```c++
if (condition) { if (condition) {
//code //code
} }
for(int a=0; a<b; ++b) { for(int a=0; a<b; ++b) {
//code //code
} }
switch(a) { switch(a) {
case 1: case 1:
//blah //blah
case 2: case 2:
//blah //blah
default: default:
//blah //blah
} }
``` ```
@ -64,9 +65,9 @@ case 1: {
//code //code
} }
case 2: case 2:
//code //code
default: default:
//code //code
} }
``` ```
@ -116,7 +117,35 @@ Generally it will depend on the particular piece of code and would be determined
UTF-8 and Unix-like line ending (LF). Unless some platform speficic files need other encodings/line endings. UTF-8 and Unix-like line ending (LF). Unless some platform speficic files need other encodings/line endings.
### 5. Misc.### ### 5. Initialization lists.###
Initialization lists should be vertical. This will allow for more easily readable diffs. The inilization colon should be indented and in its own line along with first argument. The rest of the arguments should be indented too and have the comma prepended.
```c++
myClass::myClass(int a, int b, int c, int d)
: priv_a(a)
, priv_b(b)
, priv_c(c)
, priv_d(d)
{
//code
}
```
### 6. Enums.###
Enums should be vertical. This will allow for more easily readable diffs. The members should be indented.
```c++
enum days
{
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday
};
```
### 7. Misc.###
* Line breaks for long lines with operation: * Line breaks for long lines with operation:
@ -140,5 +169,5 @@ for(int a=0; a<b; ++b) {
* Method definitions aren't allowed in header files * Method definitions aren't allowed in header files
###6. Not covered above### ###8. Not covered above###
If something isn't covered above, just follow the same style the file you are editing has. If that particular detail isn't present in the file you are editing, then use whatever the rest of the project uses. If something isn't covered above, just follow the same style the file you are editing has. If that particular detail isn't present in the file you are editing, then use whatever the rest of the project uses.
Loading…
Cancel
Save