mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
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:
parent
d8f1e1327f
commit
77f37f58ad
1 changed files with 12 additions and 8 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue