@@ -13,6 +13,8 @@ This style-guide is intended for developers writing code for AMDiS, is not compl
Parts of this convention are taken from well established style guides, like the *Google C++ Style Guide*.
In general, the code should follow the [C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines).
## File naming conventions
Filenames should be mixed lower and upper case, starting with an uppercase letter. They should not include underscores or dashed. Use an uppercase letter to indicate a new subword. Sourcefiles should end in `.cpp` and header files should end in `.hpp`. In case you move the code of a template class to a separate file, included textually at the end of the corresponding header file, use the extensions `.inc.hpp`.
...
...
@@ -26,19 +28,19 @@ Examples of valid filenames:
*`DOFVector.cpp`
*`DOFVector.inc.hpp` (the implementation of the methods of the template class `DOFVector<T>`)
Do not use filenames that already exist in /usr/include or are stdandard C/C++ include files, such as `math.h` (remember that windows files-systems are case insensitive and thus, there is not difference between `math.h` and `Math.H`.)
Do not use filenames that already exist in /usr/include or are stdandard C/C++ include files, such as `math.h` (remember that windows files-systems are case insensitive and thus, there is no difference between `math.h` and `Math.H`.)
## Generale file structure
Every header file should start with a copyright notice and an include guard `#pragma once`, where the text of the copyright notice is given in the file `tools/license.templ.txt` and can automatically by added, using the script files in the `tools` directory:
``` c++
// Software License for AMDiS2
// Software License for dune-amdis
//
// Copyright (c) 2015 Institute for Scientific Computing, TU-Dresden
// Copyright (c) 2015 Institute for Scientific Computing, Technische Universitaet Dresden
// All rights reserved.
// Authors: Simon Praetorius
//
// This file is part of the AMDiS2 Library
// This file is part of the dune-amdis Library
// see also the LICENSE file in the distribution.
#pragma once
...
...
@@ -55,7 +57,7 @@ All of a project's header files should be listed as descendants of the project's
* Other external libraries' header files.
* Your project's header files.
For better readability a comment above each group can be added. Within each section the includes should be ordered alphabetically. Project's header files should be surrounded by `"`, while external header files hould be surrounded by `<...>`.
For better readability a comment above each group can be added. Within each section the includes should be ordered alphabetically. Project's header files should be surrounded by `"`, while external header files should be surrounded by `<...>`.
For example, the includes in `io/VtkWriter.cpp` might look like this:
...
...
@@ -93,15 +95,15 @@ namespace AMDiS
}// end namespace AMDiS
```
Implementation details are put into a subnamespace `Impl`.
Implementation details are put into a subnamespace `Impl`. A few more subnamespaces of `AMDiS` are allowed, e.g., `Concepts`. If onw of these subnamespaces need another subsubnamespace for implementation details, it should be names `_Impl`.
## Line length
Each line of text in your code should be at most 80 characters long.
Each line of text in your code should be at most 100 characters long.
**Exceptions:**
* An #include statement with a long path may exceed 80 columns.
* A raw-string literal may have content that exceeds 80 characters.
* An #include statement with a long path may exceed 100 columns.
* A raw-string literal may have content that exceeds 100 characters.