Hacking:Code style conventions

General
Use space instead real tabs that equal 4 spaces.

Max length of source code line equal 120 characters. Put "//---" cars in front of function definitions with maximum length (120) :

Use typically trailing braces everywhere (if, else, functions, structures, typedefs, class definitions, etc.)

The else statement starts on new line after the last closing brace.

Function names start with an upper case:

In multi-word function names each word starts with an upper case:

Variable names start with a lower case character.

In multi-word variable names the first word starts with a lower case character and each successive word starts with an upper case.

Names of recursive functions end with "_r"

Defined names use all upper case characters. Multiple words are separated with an underscore.

Use ‘const’ as much as possible. Use:

Same true for variables that will not be changed after initialization.

Don’t use:

Negation operator should not be used in its short form :

Put spaces between function arguments in definition or call :

Don't use

C++ namespaces and the using namespace  statement can confuse lupdate. It will interpret  like. Runtime translation of these strings will fail because of that.

Classes
Class names start with "V" and each successive word starts with an upper case.

Class variables have the same naming convention as variables.

Class methods have the same naming convention as functions.

Indent the names of class variables and class methods to make nice columns. The variable type or method return type is in the first column and the variable name or method name is in the second column.

The * of the pointer is in the first column because it improves readability when considered part of the type.

Ordering of class variables and methods should be as follows:
 * 1) list of friend classes
 * 2) public variables
 * 3) public methods
 * 4) protected variables
 * 5) protected methods
 * 6) private variables
 * 7) private methods

This allows the public interface to be easily found at the beginning of the class.

Always make class methods ‘const’ when they do not modify any class variables.

Avoid use of ‘const_cast’. When object is needed to be modified, but only const versions are accessible, create a function that clearly gives an editable version of the object. This keeps the control of the ‘const-ness’ in the hands of the object and not the user.

Function overloading should be avoided in most cases. For example, instead of:

Use:

Inline member functions define outside the class:

Note. Don't make virtual methods inline. See Clang warning -Wweak-vtables. Discusion on StackOverflow.

File names
Each class should be in a separate source file unless it makes sense to group several smaller classes. The file name should be the same as the name of the class with the "V" prefix.

files: