diana:diana_codestyle

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
diana:diana_codestyle [2008-12-03 13:49:24]
lisbethb created
diana:diana_codestyle [2022-05-31 09:29:31] (current)
Line 1: Line 1:
 ====== Code style ====== ====== Code style ======
  
-  * Code style for Eclipse:[[http://diana.met.no/pu_codestyle.xml|code style]] +To gradually improve the code style in diana, we ask to format all changesets using [[http://releases.llvm.org/4.0.0/tools/clang/docs/ClangFormat.html|clang-format]] (4.0) with these style options:
-  * Use single blank lines +
-  * Use doxygen (java or c++) +
-  * Always use downcase in namespace +
-  * Space after semicolon in for-loops etc. +
-  * Space before and after assignment operators+
  
-... and follow the example below ...+<file - .clang-format> 
 +--- 
 +BasedOnStyle: LLVM 
 +Language: Cpp 
 +PointerAlignment: Left 
 +ColumnLimit: 160 
 +AllowShortFunctionsOnASingleLine: Inline 
 +AlwaysBreakTemplateDeclarations: true 
 +BreakBeforeBraces: Custom 
 +BraceWrapping: 
 +  AfterClass:      true 
 +  AfterFunction:   true 
 +  AfterStruct:     true 
 +  AfterUnion:      true 
 +BreakConstructorInitializersBeforeComma: true 
 +...
  
-<code>+</file>
  
-namespace metno {+This style configuration should be saved in the diana top-level source-directory as ''.clang-format''.
  
-const int DEFAULT_NUMBER = 1;+We suggest using [[https://gist.github.com/spott/98e25623ebc1d923dce4|git-clang-format]] to reformat modified lines:
  
-/** +  * save [[https://gist.github.com/spott/98e25623ebc1d923dce4|git-clang-format]] in your ''PATH'' and make it executable 
- A sample source file for the code formatter preview +  if ''clang-format'' is not version 4.0, it might necessary to configure git with <code>git config  clangFormat.binary clang-format-4.0</code> 
- */ +  preview reformatted modifications with <code>git clang-format --diff</code> 
-class Point { +  * reformat modifications with <code>git clang-format -f</code>
-public: +
-  /** +
-   * @param xc bla bla +
-   */ +
-  Point(double xc, double yc) : x(xc), y(yc) { }+
  
-  Point(double yc) : y(yc)  
-  { 
-    if (true) { 
-       
-    } else if (false) { 
-       
-    } 
-    for (int i = 0; i < yc; ++i) { ///< space etter ; 
-      int j = 0; 
-    } 
- 
-  } 
-   
-  /** 
-   * Description of distance 
-   */ 
-  double distance(const Point& other) const; 
-  int minParam; 
-  double x; ///< a doxygen comment on dx 
-  double y; 
-  char *hello; 
-  Point& p; 
- 
-  /// Enum description 
-  enum MyEnum {ONE, TWO, THREE}; 
- 
-}; 
- 
-double Point::distance(const Point& other) const { 
-  double dx = x - other.x; 
-  LOG4CXX_DEBUG(logger,""); 
-  double dy = y - other.y; // comment 
-  return sqrt(dx * dx + dy * dy); 
-} 
- 
-} // end namespace metno 
- 
-</code> 
  • diana/diana_codestyle.1228312164.txt.gz
  • Last modified: 2022-05-31 09:23:14
  • (external edit)