CELUI Coding Standards
This file represents an extension and an integration of the Celestia standard coding convention and is used in the CELUI library.

Files

The names of CELUI source files and data files are always lower case.
The extension .cpp is used for all C++ sources files.
The extension .h is used for all the header files.
The prefix "ui" is used fo all the CELUI files. Some examples are:
uimanager.h, uimanager.cpp, uiwidget.h, uiwidget.cpp.

"Guard defines" around include files are used to prevent multiple inclusion of headers. Guard macros must be unique. The scheme for Guard macros is _<subdirectory>_<filename>_H_ Here's an example:

// This header file is uicommon.h in the celui subdirectory.

#ifndef _CELUI_UICOMMON_H_
#define _CELUI_UICOMMON_H_

enum uiWidgetStyle
{
...
};

#endif // _CELUI_UICOMMON_H_


Language
Celui is exlusively C++. All the structure is based upon a unique global object of the class uiManager. C++ features are used wherever possible except in some cases where it is necessary to call functions from external libraries like OpenGL and GLUT.

STL
CELUI uses extensively the Standard Template Library. Reference to an STL class or function in a header, is made using the "std" namespace prefix. Implementation modules aren't forced to import the entire std namespace just because they include a particular header. The right way:

#include <string>

extern std::string foo;

Strings
CELUI uses C++'s string class rather than C-style zero terminated strings. A call to string::c_str() for a pointer to a zero terminated string is used to pass to external API functions that require C-style zero terminated strings.
 

Casts
Type casting is avoided as much as possible. However,  C++ style casts (reinterpret_cast, static_cast, and const_cast) are occasionally used.
 

Const
Const declaration is the preferred way for method declaration.
All reference parameters to a function are declared const unless they are intended to be modified by the function.
All the methods which does not modify class members are declared as const.
Const iterators are used to browse containers unless they are intended to allow the modify of the elements of the container.

Reference Parameters
Wherever possible function and method parameters are passed as reference or as pointers.

I/O
C++ I/O is the standard system used by CELUI. Sometimes, printf is used.


Indentation and Spacing

Naming