Reconcile style of include directives across all source files.

This commit is contained in:
Jim Evins
2017-01-06 19:00:59 -05:00
parent 602e3f9ab6
commit 9cba0d4a43
134 changed files with 408 additions and 455 deletions
+54
View File
@@ -1,6 +1,10 @@
Glabels Coding Style
====================
This file describes the coding style used in all glabels source code. Any patches or pull requests should
adhere to this style.
Tabs vs. Spaces
---------------
@@ -40,3 +44,53 @@ else
Also applies to class and namespace declaration statements.
See https://en.wikipedia.org/wiki/Indent_style#Allman_style for more information.
File Organization
-----------------
Generally code is organized into modules. Usually a module defines a single class or a small namespace of
functions/constants/etc. A module is defined by two files: a header file (its specification) and an
implementation file. Header filenames have a ".h" extension and implementation filenames have a ".cpp"
extension.
### Self-contained Headers
Header files should be self-contained. I.e. they should not require any prerequisite includes. To enforce
this requirement, an implementation file shall include its header file before any other includes.
### Multiple Inclusion Guards
All header files should have an ifndef guard to prevent multiple inclusion.
```
#ifndef ns_Module_h
#define ns_Module_h
...
#endif // ns_Module_h
```
### Include Directives
Header files should be included in the following order.
1. header file for this module (e.g. this would be "Foo.h" in "Foo.cpp").
2. C system header files (preference is for the C++ version if available, e.g. <cmath> instead of <math.h>.
3. C++ system header files (e.g. STL files)
4. Qt header files
5. Other libraries' header files
6. Other glabels header files.
Paths used in include directives should always be relative to either the glabels source directory or an
appropriate base directory for each library. They should NEVER include UNIX directory shortcuts such as "."
(the current directory) or ".." (the parent directory).
Angle brackets ("<>") should be used for inclusion of all external header files (such as C/C++ and Qt
header files). Double quotes should be used for all glabels header files.
Do not use forward declarations to any external entities. Use the appropriate include directive instead.