Coding style

From Yate Documentation
(Difference between revisions)
Jump to: navigation, search
(Created page with "These coding style rules should be followed to preserve uniformity of the source code. Nonconforming code will not be included to Yate as such and would have to be rewritten. ...")

Revision as of 17:01, 15 November 2012

These coding style rules should be followed to preserve uniformity of the source code. Nonconforming code will not be included to Yate as such and would have to be rewritten.

Contents

C++ code

File name conventions

  • File names must have .cpp extension, include files must have .h
  • All header file names must be lower case
  • Module file name is always lower case
  • Engine file names are mixed case just like class names

Comments

  • Use exclusively C++ style comments in code definition
  • Use C style comments in declarations only to provide documentation to kdoc or Doxygen
  • Don't use comments to temporarily disable more than one line of code, use #if 0 ... #endif instead
  • At the end of source code files please add settings for those that use vi or vim as editor: /* vi: set ts=8 sw=4 sts=4 noet: */

Templates

  • Avoid templates if at all possible, even those from standard template library (STL)
  • Only use fully inline template classes and functions

PHP code

The style for writing external PHP modules and IVRs is very similar to the one for C++ code.

  • Always require_once("libyate.php") towards the start of any module or library
  • Never put anything outside the <? ... ?> tags
  • Properly declare static methods with the static keyword as required by PHP5 or higher
  • Use Yate::Output to send output to console or log file
  • Use Yate::Debug to send debugging output to console or log file, this can be turned on or off by providing a boolean argument
Personal tools
Namespaces

Variants
Actions
Preface
Configuration
Administrators
Developers