|
Packit Service |
f5eea5 |
librevenge coding style
|
|
Packit Service |
f5eea5 |
-----------------------
|
|
Packit Service |
f5eea5 |
|
|
Packit Service |
f5eea5 |
Indentation/spacing: We indent with tabs. Not spaces. This decision is, of
|
|
Packit Service |
f5eea5 |
course, rather contentious, but it does have the force of inertia going for
|
|
Packit Service |
f5eea5 |
it. Try to keep lines less than 120 columns wide. Please run
|
|
Packit Service |
f5eea5 |
|
|
Packit Service |
f5eea5 |
astyle --options=astyle.options \*.h \*.cpp
|
|
Packit Service |
f5eea5 |
|
|
Packit Service |
f5eea5 |
before committing.
|
|
Packit Service |
f5eea5 |
|
|
Packit Service |
f5eea5 |
API: By agreement, public API does use neither C++ standard library nor Boost.
|
|
Packit Service |
f5eea5 |
If a function takes or returns a dynamically allocated data buffer, it must be
|
|
Packit Service |
f5eea5 |
documented who is responsible for freeing the memory.
|
|
Packit Service |
f5eea5 |
|
|
Packit Service |
f5eea5 |
Naming: All public classes, enumerations, and defines should be prefixed with
|
|
Packit Service |
f5eea5 |
RVNG.
|
|
Packit Service |
f5eea5 |
|
|
Packit Service |
f5eea5 |
For better worse, we have decided on using the camel caps convention for naming
|
|
Packit Service |
f5eea5 |
variables (i.e.: tempJustification). Use of hungarian notation (i.e.: iNum) is
|
|
Packit Service |
f5eea5 |
forbidden, with one exception: use the 'm_' prefix for naming class and struct
|
|
Packit Service |
f5eea5 |
variables (i.e.: my_class->m_var). Short-hand for variable names is allowed,
|
|
Packit Service |
f5eea5 |
but don't overdo it (m_var->len() instead of m_variable->length() is ok,
|
|
Packit Service |
f5eea5 |
m_nam instead of m_name is stupid).
|
|
Packit Service |
f5eea5 |
|
|
Packit Service |
f5eea5 |
Memory allocation: Use the C++ standard operations for this (new, delete).
|
|
Packit Service |
f5eea5 |
Use of smart pointers, e.g., boost::shared_ptr and boost::scoped_ptr, is
|
|
Packit Service |
f5eea5 |
strongly encouraged. The only exeption to that is public API, where only plain
|
|
Packit Service |
f5eea5 |
pointers are allowed.
|
|
Packit Service |
f5eea5 |
|
|
Packit Service |
f5eea5 |
Data structures: Use the C++ standard library wherever appropriate and
|
|
Packit Service |
f5eea5 |
convenient. It should almost never be necessary to roll your own data
|
|
Packit Service |
f5eea5 |
structure.
|
|
Packit Service |
f5eea5 |
|
|
Packit Service |
f5eea5 |
Strings: You may use either the C++ standard strings or our very own
|
|
Packit Service |
f5eea5 |
UTF8-compliant RVNGString. Hand-allocated char *'s are discouraged.
|
|
Packit Service |
f5eea5 |
|
|
Packit Service |
f5eea5 |
Further information: The OpenOffice.org (http://tools.openoffice.org/coding.html)
|
|
Packit Service |
f5eea5 |
and AbiWord (cvs://cvs.abisource.com/abi/docs/AbiSourceCodeGuidelines.abw)
|
|
Packit Service |
f5eea5 |
contain lots of useful information that will make you a better C++ coder.
|
|
Packit Service |
f5eea5 |
Follow their advice religiously, except when they contradict something in this
|
|
Packit Service |
f5eea5 |
document.
|
|
Packit Service |
f5eea5 |
|
|
Packit Service |
f5eea5 |
Fun: Remember, the important thing is to have fun. :-) These rules are a means,
|
|
Packit Service |
f5eea5 |
not an end. Happy hacking!
|