| 1 |
libstaroffice 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 |
astyle -HU -A3 -k3 -y -n -s2 -r \*.cpp \*.h \*.?xx |
| 9 |
|
| 10 |
Naming: Version-specific classes, enumerations, and defines should be prefixed |
| 11 |
with a clear abreviation of the format 'ClarisWks', 'MacWrt', ... |
| 12 |
Generic classes (this includes utility abstractions like streams and strings) |
| 13 |
should be prefixed with STOFF. |
| 14 |
|
| 15 |
For better worse, we have decided on using the 'm_' prefix for naming class and struct |
| 16 |
variables (i.e.: my_class->m_var). Short-hand for variable names is allowed, |
| 17 |
but don't overdo it (m_var->len() instead of m_variable->length() is ok, |
| 18 |
m_nam instead of m_name is stupid). |
| 19 |
|
| 20 |
Memory allocation: Use the C++ standard operations for this (new, delete) and shared_ptr (boost, c++11, ...). |
| 21 |
|
| 22 |
Data structures: Use the C++ standard library wherever appropriate and |
| 23 |
convenient. It should almost never be necessary to roll your own data |
| 24 |
structure. |
| 25 |
|
| 26 |
Strings: You may use either the C++ standard strings or our very own |
| 27 |
UTF8-compliant RVNGString. Hand-allocated char *'s are discouraged. |
| 28 |
|
| 29 |
Further information: The OpenOffice.org (http://tools.openoffice.org/coding.html) |
| 30 |
and AbiWord (cvs://cvs.abisource.com/abi/docs/AbiSourceCodeGuidelines.abw) |
| 31 |
contain lots of useful information that will make you a better C++ coder. |
| 32 |
Follow their advice religiously, except when they contradict something in this |
| 33 |
document. |
| 34 |
|
| 35 |
Fun: Remember, the important thing is to have fun. :-) These rules are a means, |
| 36 |
not an end. Happy hacking! |