To the extent possible and reasonable, we value consistency of source code formatting, class and variable naming, and so forth.
This Note lists some such conventions that we would like to follow, where it makes sense to do so.
We use astyle (http://astyle.sourceforge.net) as a tool to reformat C++ source code files in a consistent fashion. The file astylerc, at the top of the github repo, contains the default settings we use.
Our conventions are:
LF endings (unix style), not CRLF (windows style)
spaces, not tabs
indent to four (4) spaces (“Four shalt be the number thou shalt count, and the number of the counting shall be four. Three shalt thou not count, neither count thou five...”)
braces shall be on their own lines, like this:
if (p)
{
foo();
}
copyright header, license, and author(s) on every file
two spaces between major units, e.g. function bodies
For public headers from the ./include/pdal directory, use angle brackets: #include <pdal/Stage.h>
For private headers (from somehwere in ./src), use quotes: #include “support.hpp”
#include lines should be grouped and arranged in this order: C++/std headers, 3rd-party headers (e.g. gdal), pdal headers, local headers. The pdal headers may be further grouped by subdirectory, e.g. drivers/liblas, filters, etc.
Exception to the above: source files (.cpp) should #include their corresponding .hpp file first. This assures that the header is including all the files it needs to.
Don’t #include a file where a simple forward declaration will do. (Note: this only applies to pdal files; don’t forward declare from system or 3rd party headers.)
Don’t include a file unless it actually is required to compile the source unit.
Don’t use manual include guards. All reasonable compilers support the once pragma:
#pragma once