mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-08-06 11:27:27 +00:00
style: Update style to include some C++ element
This style is used by other SPICE projects like spice-streaming-agent. See discussion "Coding style and naming conventions for C++" at https://lists.freedesktop.org/archives/spice-devel/2018-January/041562.html. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Lukáš Hrázký <lhrazky@redhat.com>
This commit is contained in:
parent
c2faefc2e1
commit
5088afb05a
@ -380,3 +380,55 @@ Also in source (no header) files you must include `config.h` at the beginning so
|
||||
|
||||
#include "spice_server.h"
|
||||
----
|
||||
|
||||
C++
|
||||
---
|
||||
C\++ style follows C style if not specified otherwise.
|
||||
The C+\+11 dialect is assumed by default. No attempts will be made to
|
||||
restrict the code to older variants of C+\+.
|
||||
For compatibility reasons don't use more recent C++ dialects.
|
||||
|
||||
Method names
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Method names should use lower case and separate words with
|
||||
underscores.
|
||||
|
||||
|
||||
Namespaces
|
||||
~~~~~~~~~~
|
||||
|
||||
Namespaces should use lower case and separate words with underscores.
|
||||
Namespace blocks should not increase indentation.
|
||||
Namespaces can be nested. Namespace closing brackets for nested
|
||||
namespaces can be placed together on the same line, but for
|
||||
readability reasons the closure should specify the namespace with a
|
||||
comment.
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
namespace spice {
|
||||
namespace streaming_agent {
|
||||
|
||||
class ClassInsideNamespace {
|
||||
...
|
||||
};
|
||||
|
||||
}} // namespace spice::streaming_agent
|
||||
----
|
||||
|
||||
The `using namespace` construct should never be used in headers. It should
|
||||
be used sparingly in source files, and only within the body of short
|
||||
functions.
|
||||
|
||||
Preferred alternatives to `using namespace` include:
|
||||
|
||||
* using declarations
|
||||
+
|
||||
[source,cpp]
|
||||
using spice::streaming_agent::some_class;
|
||||
+
|
||||
* namespace aliases
|
||||
+
|
||||
[source,cpp]
|
||||
namespace ssa = spice::streaming_agent;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user