| 1 |
librevenge coding style |
| 2 |
----------------------- |
| 3 |
|
| 4 |
Indentation/spacing: We indent with tabs. Not spaces. This decision is, of |
| 5 |
course, rather contentious, but it does have the force of inertia going for |
| 6 |
it. Try to keep lines less than 120 columns wide. Please run |
| 7 |
|
| 8 |
make astyle |
| 9 |
|
| 10 |
before committing. |
| 11 |
|
| 12 |
API: By agreement, public API does use neither C++ standard library nor Boost. |
| 13 |
If a function takes or returns a dynamically allocated data buffer, it must be |
| 14 |
documented who is responsible for freeing the memory. |
| 15 |
|
| 16 |
Naming: All public classes, enumerations, and defines should be prefixed with |
| 17 |
RVNG. |
| 18 |
|
| 19 |
For better worse, we have decided on using the camel caps convention for naming |
| 20 |
variables (i.e.: tempJustification). Use of hungarian notation (i.e.: iNum) is |
| 21 |
forbidden, with one exception: use the 'm_' prefix for naming class and struct |
| 22 |
variables (i.e.: my_class->m_var). Short-hand for variable names is allowed, |
| 23 |
but don't overdo it (m_var->len() instead of m_variable->length() is ok, |
| 24 |
m_nam instead of m_name is stupid). |
| 25 |
|
| 26 |
Memory allocation: Use C++ smart pointers, i.e., std::shared_ptr and |
| 27 |
std::unique_ptr. Direct memory management using plain pointers and new/delete is |
| 28 |
strongly discouraged. The only exeption to that is public API, where only plain |
| 29 |
pointers are allowed. |
| 30 |
|
| 31 |
Data structures: Use the C++ standard library wherever appropriate and |
| 32 |
convenient. It should almost never be necessary to roll your own data |
| 33 |
structure. |
| 34 |
|
| 35 |
Strings: You may use either the C++ standard strings or our very own |
| 36 |
UTF8-compliant RVNGString. Hand-allocated char *'s are discouraged. |
| 37 |
|
| 38 |
Further information: The OpenOffice.org (http://tools.openoffice.org/coding.html) |
| 39 |
and AbiWord (cvs://cvs.abisource.com/abi/docs/AbiSourceCodeGuidelines.abw) |
| 40 |
contain lots of useful information that will make you a better C++ coder. |
| 41 |
Follow their advice religiously, except when they contradict something in this |
| 42 |
document. |
| 43 |
|
| 44 |
Fun: Remember, the important thing is to have fun. :-) These rules are a means, |
| 45 |
not an end. Happy hacking! |