Trace: » piqsl » release_cycle » pgregory » todo » shortwave » tcolgate » libraries » beaker » tip » code_guidelines
Coding Style Guidelines
File Naming Convention
To avoid any problems with non-case sensitive filesystems, such as Windows, all filenames should follow the following rules where possible. The only allowable exception is for files sourced from a third-party that are not under the direct control of the project, such as header files for a third-party library.
- All filenames should be completely lowercase
- All C/C++ header files will use the extension .h
- All C source files will use the extension .c
- All C++ source files will use the extension .cpp
Style guidelines
The following sections are a brief rundown of some parts of the aqsis coding conventions. It's important to also inspect the example code which contains extra information missing here.
Naming Conventions
All code written specifically for the Aqsis project should use the following common naming convention for code elements.
Name prefixes
Reading the aqsis codebase, you will notice the common occurrence of the prefixes, Cq, Sq, Eq, Tq, Iq, Xq, and m_. These prefixes are applied to:
- Cq All classes, unless otherwise specified
- Sq All structs
- Eq All enumerations
- Tq All typedefs
- Iq All interfaces (pure virtual base classes)
- Xq All exceptions
- m_ All private class member data (note: classes should not have public member data!)
Naming of types, member data etc
Apart from the prefixes described above, the remainders of names should adhere to the following policies:
- All types (classes, enums, etc) should be named with
CamelCase. - All functions, including member functions should be named with
lowerCamelCase. - All variables (including member data) should be named with
lowerCamelCase - Individual enumerations elements should be named with a common
CamelCaseprefix, followed by a single underscore, and the enumeration name usingCamelCase
Examples
Here are some examples adhering to the above conventions:
class CqSurfacePointsPolygonsstruct SqSamplePointenum EqPlaneSide- Enumeration element:
Side_Outside
- typedef:
TqFloat - Class member data:
m_pointerToData - Member function:
pointerToData()
Indenting, bracket placement
Please read the example code linked above for a fairly complete guide to the accepted bracket placement and indenting style.
The Aqsis code base uses a custom Artistic Style settings file in an attempt to ensure that the coding style remains constant throughout. Please use this program to adapt your personal coding style (in particular, indenting type/style and bracket placement) to the accepted Aqsis style before committing changes to the svn repository.
The style file for the Aqsis project may be found under [http://aqsis.svn.sourceforge.net/viewvc/*checkout*/aqsis/trunk/aqsis/coding_standard/astylerc|astylerc]] in the svn repository, and basically encapsulates the following rules…
- Break block brackets to separate lines, i.e. ANSI C/C++ style
- Indent using 'tab' characters equivalent to 4 spaces
- Indent classes so that the keywords 'public', 'protected' and 'private' are indented
- Indent switches so that the 'case' statements are indented
- Indent cases so that the code block is indented from the case statement
Style guildlines as example code
Example code following the style guidelines is included in the aqsis SVN repository. For convenience it is listed inline:
- there's clearly something wrong here, since these aren't appearing inline. Perhaps https clashes with the repo plugin?