mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-07 19:48:58 +02:00
Merge bitcoin/bitcoin#21930: doc: update enumerator naming in developer notes
77f37f58ad2f349cecb2eda28b415267d3d7d76e doc: update enum naming in developer notes (Jon Atack) Pull request description: Per our current doc, the general rule is we follow the C++ Core Guidelines, which for enumerator naming stipulate: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Renum-caps ``` Don’t use ALL_CAPS for enumerators Reason: Avoid clashes with macros. ``` but our examples (and often, codebase) are contradictory to it (and perhaps to common usage), which can be confusing when a contributor needs to choose a style to use. This patch: - updates the enumerator examples to snake_case per CPP Core Guidelines - clarifies for contributors that in this project enumerators may be snake_case, PascalCase or ALL_CAPS, and to use what seems appropriate. ACKs for top commit: practicalswift: cr ACK 77f37f58ad2f349cecb2eda28b415267d3d7d76e ryanofsky: ACK 77f37f58ad2f349cecb2eda28b415267d3d7d76e. I think this is good because it modernizes the example and clarifies current conventions. promag: ACK 77f37f58ad2f349cecb2eda28b415267d3d7d76e. Tree-SHA512: 7facc607fe5e1abab0f635864340143f13c2e4bb074eb17eac7d829dcd0cf244c5c617fc49d35e8774e8af1fa1205eeebe0cca81f538a2a61f6a7ba200878bc6
This commit is contained in:
commit
92aad5303b
@ -89,6 +89,10 @@ code.
|
||||
- Class member variables have a `m_` prefix.
|
||||
- Global variables have a `g_` prefix.
|
||||
- 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
|
||||
(PascalCase). Do not prefix class names with `C`.
|
||||
- Test suite naming convention: The Boost test suite in file
|
||||
@ -669,19 +673,19 @@ Foo(vec);
|
||||
|
||||
```cpp
|
||||
enum class Tabs {
|
||||
INFO,
|
||||
CONSOLE,
|
||||
GRAPH,
|
||||
PEERS
|
||||
info,
|
||||
console,
|
||||
network_graph,
|
||||
peers
|
||||
};
|
||||
|
||||
int GetInt(Tabs tab)
|
||||
{
|
||||
switch (tab) {
|
||||
case Tabs::INFO: return 0;
|
||||
case Tabs::CONSOLE: return 1;
|
||||
case Tabs::GRAPH: return 2;
|
||||
case Tabs::PEERS: return 3;
|
||||
case Tabs::info: return 0;
|
||||
case Tabs::console: return 1;
|
||||
case Tabs::network_graph: return 2;
|
||||
case Tabs::peers: return 3;
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
assert(false);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user