Differences
This shows you the differences between two versions of the page.
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/ |
- | * Use single blank lines | + | |
- | * Use doxygen | + | |
- | * 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: | ||
+ | Language: Cpp | ||
+ | PointerAlignment: | ||
+ | ColumnLimit: | ||
+ | AllowShortFunctionsOnASingleLine: | ||
+ | AlwaysBreakTemplateDeclarations: | ||
+ | BreakBeforeBraces: | ||
+ | BraceWrapping: | ||
+ | AfterClass: | ||
+ | AfterFunction: | ||
+ | AfterStruct: | ||
+ | AfterUnion: | ||
+ | BreakConstructorInitializersBeforeComma: | ||
+ | ... | ||
- | <code> | + | </file> |
- | namespace metno { | + | This style configuration should be saved in the diana top-level source-directory as '' |
- | const int DEFAULT_NUMBER = 1; | + | We suggest using [[https:// |
- | /** | + | * save [[https:// |
- | | + | * if '' |
- | */ | + | * preview reformatted modifications with < |
- | class Point { | + | * reformat modifications with < |
- | 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:: | ||
- | double dx = x - other.x; | ||
- | LOG4CXX_DEBUG(logger,"" | ||
- | double dy = y - other.y; // comment | ||
- | return sqrt(dx * dx + dy * dy); | ||
- | } | ||
- | |||
- | } // end namespace metno | ||
- | |||
- | </ |