doc: update enum naming in developer notes

- Update the enumerator examples to snake_case per CPP Core Guidelines
  https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Renum-caps

- Clarify that in this project enumerators may be snake_case, PascalCase, or
  ALL_CAPS, and to use what is seems appropriate.
This commit is contained in:
Jon Atack 2021-05-12 16:28:46 +02:00
parent d8f1e1327f
commit 77f37f58ad
No known key found for this signature in database
GPG key ID: 4F5721B3D0E3921D

View file

@ -89,6 +89,10 @@ code.
- Class member variables have a `m_` prefix. - Class member variables have a `m_` prefix.
- Global variables have a `g_` prefix. - Global variables have a `g_` prefix.
- Constant names are all uppercase, and use `_` to separate words. - Constant names are all uppercase, and use `_` to separate words.
- Enumerator constants may be `snake_case`, `PascalCase` or `ALL_CAPS`.
This is a more tolerant policy than the [C++ Core
Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Renum-caps),
which recommend using `snake_case`. Please use what seems appropriate.
- Class names, function names, and method names are UpperCamelCase - Class names, function names, and method names are UpperCamelCase
(PascalCase). Do not prefix class names with `C`. (PascalCase). Do not prefix class names with `C`.
- Test suite naming convention: The Boost test suite in file - Test suite naming convention: The Boost test suite in file
@ -669,19 +673,19 @@ Foo(vec);
```cpp ```cpp
enum class Tabs { enum class Tabs {
INFO, info,
CONSOLE, console,
GRAPH, network_graph,
PEERS peers
}; };
int GetInt(Tabs tab) int GetInt(Tabs tab)
{ {
switch (tab) { switch (tab) {
case Tabs::INFO: return 0; case Tabs::info: return 0;
case Tabs::CONSOLE: return 1; case Tabs::console: return 1;
case Tabs::GRAPH: return 2; case Tabs::network_graph: return 2;
case Tabs::PEERS: return 3; case Tabs::peers: return 3;
} // no default case, so the compiler can warn about missing cases } // no default case, so the compiler can warn about missing cases
assert(false); assert(false);
} }